Accessing and marking imported boundaries

Hey,

I am trying to create a meshfile in gmsh, import it into fenics and access the boundaries to set Dirichlet boundary conditions and weakly implemented boundary conditions for a Penalty/Nitsche method.

I am exporting the gmsh file in the Version 2 ASCII format. It starts with the following code:

$MeshFormat
2.2 0 8
$EndMeshFormat
$PhysicalNames
4
1 1 "Inlet"
1 2 "Outlet"
1 3 "Top"
1 4 "Bottom"
$EndPhysicalNames
  1. Let’s say I wanted to set some Dirichlet boundary conditions on the boundary labeled “Inlet”.
    Setting bc1 = DirichletBC(V, Constant((2, 0)), mf, 1) returns:
*** Warning: Found no facets matching domain for boundary condition.

Does the “1” here not stand for the boundary labeled as 1?
If I set it to 0 in DirichletBC I get no error, but the boundary condition is applied to all boundaries.

  1. I also want to set some boundary conditions using a Penalty method. Let’s say I wanted to do this on the boundary “Top” labeled as “3”. I know how to mark boundaries defined by a class for domain edge boundaries:
boundaries = MeshFunction("size_t", mesh, dim=1)
boundaries.set_all(0)
example.mark(boundaries, 1)

What is the correct way of marking already labeled boundaries?
Just using

 ... ds("label")

doesn’t seem to give what I want.

Thank you very much.

See for instance: Transitioning from mesh.xml to mesh.xdmf, from dolfin-convert to meshio - #3 by dokken

Hi, thank you for your reply.

Unfortunately I still don’t understand, how to solve my problem.

Looking at the post you linked I could figure out, how to set the weakly implemented boundary condition using

ds_2 = Measure('ds', domain=mesh, subdomain_id=0, subdomain_data=mf)

I am importing the mesh using

msh = meshio.read(filepath)
#print(msh)
triangle_mesh = create_mesh(msh, "triangle", True)
line_mesh = create_mesh(msh, "line", True)

meshio.write("mesh.xdmf", triangle_mesh)
meshio.write("mf.xdmf", line_mesh)

mesh = Mesh()

mvc = MeshValueCollection("size_t", mesh, mesh.topology().dim())
with XDMFFile("mesh.xdmf") as infile:
    infile.read(mesh)
    infile.read(mvc, "name_to_read")
cf = cpp.mesh.MeshFunctionSizet(mesh, mvc)  # boundary_parts

mvc = MeshValueCollection("size_t", mesh, mesh.topology().dim() - 1)  # subdomains

with XDMFFile("mf.xdmf") as infile:
    infile.read(mvc, "name_to_read")
mf = cpp.mesh.MeshFunctionSizet(mesh, mvc)

How does subdomain_id=0 relate to the PhysicalNames in the gmsh file I posted above?

I also still don’t have any idea how to use

bc = DirichletBC(V, Constant((1, 0)), mf, ???)

instead of the combination of

def force_on_rhs_boundary(x, on_boundary):
    return on_boundary and near(x[0], 60.0, tol) of the combination of

bc = DirichletBC(V, Constant((1, 0)), force_on_rhs_boundary)

Thank You very much.

Dolfin does not support string tags, and you need to use integers to mark your boundaries in GMSH

1 Like

I changed the tags in my .geo file to only integer tags instead of integer and string tags. This makes the section $PhysicalNames in my .msh file disappear. Choosing the given integer tags in fenics still results in

 *** Warning: Found no facets matching domain for boundary condition.

The answer to my problem is exactly what you posted as the accepted solution in:
https://fenicsproject.discourse.group/t/extracting-mesh-regions-for-gmsh-mesh/1125

(In the original post in this thread, however, string and integer tags are used at the same time)

For my problem this would mean setting

bc1 = DirichletBC(V, Constant((1, 0)), mf, 2)

ds_2 = Measure('ds', domain=mesh, subdomain_id=(3, 4), subdomain_data=mf)

This still gives the same error.

For anyone to be able to help you, you need to share the geo file.

My geo file is:

// Gmsh project created on Fri Apr 23 12:46:44 2021
SetFactory("OpenCASCADE");
//+
v() = ShapeFromFile("test1.stp");
//+
MeshSize {19, 20, 18, 16, 17, 1, 3, 2, 15, 4, 14, 5, 6, 13, 7, 12, 11, 8, 10, 9} = 1;
//+
Physical Curve(3) = {10, 11, 12, 13, 14, 15, 16, 17, 18};
//+
Physical Curve(2) = {9};
//+
Physical Curve(4) = {19};
//+
Physical Curve(1) = {8, 2, 3, 4, 5, 6, 7, 1, 20};

As you are using a stp file I do not have access to, I cannot really do much more than showing you a minimal working example.
Here is a minimal geo file (taken from the gmsh tutorial, called tutorial_t1.geo

lc = 1e-1;
Point(1) = {0, 0, 0, lc};
Point(2) = {.1, 0,  0, lc};
Point(3) = {.1, .3, 0, lc};
Point(4) = {0,  .3, 0, lc};
Line(1) = {1, 2};
Line(2) = {3, 2};
Line(3) = {3, 4};
Line(4) = {4, 1};
Curve Loop(1) = {4, 1, -2, 3};
Plane Surface(1) = {1};
Physical Curve(666) = {1, 2, 4};
Physical Surface(555) = {1};

using gmsh -2 tutorial_gmsh.geo
and converting it using:

import meshio

def create_mesh(mesh, cell_type, prune_z=False):
    cells = mesh.get_cells_type(cell_type)
    cell_data = mesh.get_cell_data("gmsh:physical", cell_type)
    out_mesh = meshio.Mesh(points=mesh.points, cells={
                           cell_type: cells}, cell_data={"name_to_read": [cell_data]})
    if prune_z:
        out_mesh.prune_z_0()
    return out_mesh

mesh_from_file = meshio.read("tutorial_t1.msh")
triangle_mesh = create_mesh(mesh_from_file, "triangle", prune_z=True)
line_mesh = create_mesh(mesh_from_file, "line", prune_z=True)
meshio.write("mesh_2d.xdmf", triangle_mesh)
meshio.write("mesh_1d.xdmf", line_mesh)

You can visualize the corresponding xdmf files in paraview, and observe that the boundary data is written to the files.
Corresponding msh file (observe that the physical marker data is stored inside entities):

$MeshFormat
4.1 0 8
$EndMeshFormat
$Entities
4 4 1 0
1 0 0 0 0 
2 0.1 0 0 0 
3 0.1 0.3 0 0 
4 0 0.3 0 0 
1 0 0 0 0.1 0 0 1 666 2 1 -2 
2 0.1 0 0 0.1 0.3 0 1 666 2 3 -2 
3 0 0.3 0 0.1 0.3 0 0 2 3 -4 
4 0 0 0 0 0.3 0 1 666 2 4 -1 
1 0 0 0 0.1 0.3 0 1 555 4 4 1 -2 3 
$EndEntities
$Nodes
8 11 1 11
0 1 0 1
1
0 0 0
0 2 0 1
2
0.1 0 0
0 3 0 1
3
0.1 0.3 0
0 4 0 1
4
0 0.3 0
1 1 0 0
1 2 0 2
5
6
0.1 0.2000000000002564 0
0.1 0.1000000000002544 0
1 4 0 2
7
8
0 0.2000000000002564 0
0 0.1000000000002544 0
2 1 0 3
9
10
11
0.05000000000000001 0.1500000000002553 0
0.05 0.2500000000001282 0
0.05 0.05000000000012717 0
$EndNodes
$Elements
4 19 1 19
1 1 1 1
1 1 2 
1 2 1 3
2 3 5 
3 5 6 
4 6 2 
1 4 1 3
5 4 7 
6 7 8 
7 8 1 
2 1 2 12
8 3 4 10 
9 8 1 11 
10 2 6 11 
11 6 5 9 
12 7 8 9 
13 9 5 10 
14 7 9 10 
15 8 6 9 
16 6 8 11 
17 1 2 11 
18 5 3 10 
19 4 7 10 
$EndElements

Thank you. I will have a closer look at your minimal working example later on. The .stp file I am using is posted below:

ISO-10303-21;
HEADER;
/* Generated by software containing ST-Developer
 * from STEP Tools, Inc. (www.steptools.com) 
 */
/* OPTION: using custom schema-name function */

FILE_DESCRIPTION(
/* description */ (''),
/* implementation_level */ '2;1');

FILE_NAME(
/* name */ 'Umriss_Blech_Sicke-6mm_2021-03-29.stp',
/* time_stamp */ '2021-03-29T10:44:51+02:00',
/* author */ (''),
/* organization */ (''),
/* preprocessor_version */ 'ST-DEVELOPER v16.7',
/* originating_system */ 'SIEMENS PLM Software NX 12.0',
/* authorisation */ '');

FILE_SCHEMA (('AUTOMOTIVE_DESIGN { 1 0 10303 214 3 1 1 1 }'));
ENDSEC;

DATA;
#10=PROPERTY_DEFINITION_REPRESENTATION(#14,#12);
#11=PROPERTY_DEFINITION_REPRESENTATION(#15,#13);
#12=REPRESENTATION('',(#16),#228);
#13=REPRESENTATION('',(#17),#228);
#14=PROPERTY_DEFINITION('pmi validation property','',#21);
#15=PROPERTY_DEFINITION('pmi validation property','',#21);
#16=VALUE_REPRESENTATION_ITEM('number of annotations',COUNT_MEASURE(0.));
#17=VALUE_REPRESENTATION_ITEM('number of views',COUNT_MEASURE(0.));
#18=SHAPE_REPRESENTATION_RELATIONSHIP('None',
'relationship between PEin068CE362pvpz-None and PEin068CE362pvpz-None',
#30,#19);
#19=MANIFOLD_SURFACE_SHAPE_REPRESENTATION('PEin068CE362pvpz-None',(#40),
#228);
#20=SHAPE_DEFINITION_REPRESENTATION(#21,#30);
#21=PRODUCT_DEFINITION_SHAPE('','',#22);
#22=PRODUCT_DEFINITION(' ','',#24,#23);
#23=PRODUCT_DEFINITION_CONTEXT('part definition',#29,'design');
#24=PRODUCT_DEFINITION_FORMATION_WITH_SPECIFIED_SOURCE(' ',' ',#26,
 .NOT_KNOWN.);
#25=PRODUCT_RELATED_PRODUCT_CATEGORY('part','',(#26));
#26=PRODUCT('PEin068CE362pvpz','PEin068CE362pvpz',' ',(#27));
#27=PRODUCT_CONTEXT(' ',#29,'mechanical');
#28=APPLICATION_PROTOCOL_DEFINITION('international standard',
'automotive_design',2010,#29);
#29=APPLICATION_CONTEXT(
'core data for automotive mechanical design processes');
#30=SHAPE_REPRESENTATION('PEin068CE362pvpz-None',(#137),#228);
#31=PRESENTATION_LAYER_ASSIGNMENT('1','Layer 1',(#40));
#32=STYLED_ITEM('',(#33),#40);
#33=PRESENTATION_STYLE_ASSIGNMENT((#34));
#34=SURFACE_STYLE_USAGE(.BOTH.,#35);
#35=SURFACE_SIDE_STYLE('',(#36));
#36=SURFACE_STYLE_FILL_AREA(#37);
#37=FILL_AREA_STYLE('',(#38));
#38=FILL_AREA_STYLE_COLOUR('',#39);
#39=COLOUR_RGB('Strong Lemon',1.,0.949004348821241,0.513725490196078);
#40=SHELL_BASED_SURFACE_MODEL('',(#41));
#41=OPEN_SHELL('',(#42));
#42=ADVANCED_FACE('',(#44),#43,.T.);
#43=PLANE('',#142);
#44=FACE_OUTER_BOUND('',#45,.T.);
#45=EDGE_LOOP('',(#73,#74,#75,#76,#77,#78,#79,#80,#81,#82,#83,#84,#85,#86,
#87,#88,#89,#90,#91,#92));
#46=B_SPLINE_CURVE_WITH_KNOTS('',3,(#198,#199,#200,#201,#202,#203),
 .UNSPECIFIED.,.F.,.F.,(4,1,1,4),(0.,0.0893194689232157,0.544659734461608,
1.),.UNSPECIFIED.);
#47=B_SPLINE_CURVE_WITH_KNOTS('',3,(#210,#211,#212,#213,#214,#215),
 .UNSPECIFIED.,.F.,.F.,(4,1,1,4),(0.,0.456254379747083,0.912508759494166,
1.),.UNSPECIFIED.);
#48=(
BOUNDED_CURVE()
B_SPLINE_CURVE(3,(#172,#173,#174,#175),.UNSPECIFIED.,.F.,.F.)
B_SPLINE_CURVE_WITH_KNOTS((4,4),(0.,1.),.UNSPECIFIED.)
CURVE()
GEOMETRIC_REPRESENTATION_ITEM()
RATIONAL_B_SPLINE_CURVE((1.10819418755439,0.891805812445611,0.891805812445611,
1.10819418755439))
REPRESENTATION_ITEM('')
);
#49=(
BOUNDED_CURVE()
B_SPLINE_CURVE(3,(#179,#180,#181,#182),.UNSPECIFIED.,.F.,.F.)
B_SPLINE_CURVE_WITH_KNOTS((4,4),(0.,1.),.UNSPECIFIED.)
CURVE()
GEOMETRIC_REPRESENTATION_ITEM()
RATIONAL_B_SPLINE_CURVE((1.10819418755439,0.891805812445613,0.891805812445613,
1.10819418755439))
REPRESENTATION_ITEM('')
);
#50=(
BOUNDED_CURVE()
B_SPLINE_CURVE(3,(#205,#206,#207,#208),.UNSPECIFIED.,.F.,.F.)
B_SPLINE_CURVE_WITH_KNOTS((4,4),(0.,1.),.UNSPECIFIED.)
CURVE()
GEOMETRIC_REPRESENTATION_ITEM()
RATIONAL_B_SPLINE_CURVE((0.500003470905647,0.499998843031451,0.499998843031451,
0.500003470905647))
REPRESENTATION_ITEM('')
);
#51=LINE('',#170,#62);
#52=LINE('',#177,#63);
#53=LINE('',#184,#64);
#54=LINE('',#188,#65);
#55=LINE('',#190,#66);
#56=LINE('',#192,#67);
#57=LINE('',#196,#68);
#58=LINE('',#217,#69);
#59=LINE('',#221,#70);
#60=LINE('',#223,#71);
#61=LINE('',#225,#72);
#62=VECTOR('',#147,1.);
#63=VECTOR('',#148,1.);
#64=VECTOR('',#149,1.);
#65=VECTOR('',#152,1.);
#66=VECTOR('',#153,1.);
#67=VECTOR('',#154,1.);
#68=VECTOR('',#157,1.);
#69=VECTOR('',#158,1.);
#70=VECTOR('',#161,1.);
#71=VECTOR('',#162,1.);
#72=VECTOR('',#163,1.);
#73=ORIENTED_EDGE('',*,*,#113,.T.);
#74=ORIENTED_EDGE('',*,*,#114,.T.);
#75=ORIENTED_EDGE('',*,*,#115,.T.);
#76=ORIENTED_EDGE('',*,*,#116,.T.);
#77=ORIENTED_EDGE('',*,*,#117,.T.);
#78=ORIENTED_EDGE('',*,*,#118,.T.);
#79=ORIENTED_EDGE('',*,*,#119,.T.);
#80=ORIENTED_EDGE('',*,*,#120,.T.);
#81=ORIENTED_EDGE('',*,*,#121,.T.);
#82=ORIENTED_EDGE('',*,*,#122,.T.);
#83=ORIENTED_EDGE('',*,*,#123,.T.);
#84=ORIENTED_EDGE('',*,*,#124,.T.);
#85=ORIENTED_EDGE('',*,*,#125,.T.);
#86=ORIENTED_EDGE('',*,*,#126,.T.);
#87=ORIENTED_EDGE('',*,*,#127,.T.);
#88=ORIENTED_EDGE('',*,*,#128,.T.);
#89=ORIENTED_EDGE('',*,*,#129,.T.);
#90=ORIENTED_EDGE('',*,*,#130,.T.);
#91=ORIENTED_EDGE('',*,*,#131,.T.);
#92=ORIENTED_EDGE('',*,*,#132,.T.);
#93=VERTEX_POINT('',#168);
#94=VERTEX_POINT('',#169);
#95=VERTEX_POINT('',#171);
#96=VERTEX_POINT('',#176);
#97=VERTEX_POINT('',#178);
#98=VERTEX_POINT('',#183);
#99=VERTEX_POINT('',#185);
#100=VERTEX_POINT('',#187);
#101=VERTEX_POINT('',#189);
#102=VERTEX_POINT('',#191);
#103=VERTEX_POINT('',#193);
#104=VERTEX_POINT('',#195);
#105=VERTEX_POINT('',#197);
#106=VERTEX_POINT('',#204);
#107=VERTEX_POINT('',#209);
#108=VERTEX_POINT('',#216);
#109=VERTEX_POINT('',#218);
#110=VERTEX_POINT('',#220);
#111=VERTEX_POINT('',#222);
#112=VERTEX_POINT('',#224);
#113=EDGE_CURVE('',#93,#94,#133,.T.);
#114=EDGE_CURVE('',#94,#95,#51,.T.);
#115=EDGE_CURVE('',#95,#96,#48,.T.);
#116=EDGE_CURVE('',#96,#97,#52,.T.);
#117=EDGE_CURVE('',#97,#98,#49,.T.);
#118=EDGE_CURVE('',#98,#99,#53,.T.);
#119=EDGE_CURVE('',#99,#100,#134,.T.);
#120=EDGE_CURVE('',#100,#101,#54,.T.);
#121=EDGE_CURVE('',#101,#102,#55,.T.);
#122=EDGE_CURVE('',#102,#103,#56,.T.);
#123=EDGE_CURVE('',#103,#104,#135,.T.);
#124=EDGE_CURVE('',#104,#105,#57,.T.);
#125=EDGE_CURVE('',#105,#106,#46,.T.);
#126=EDGE_CURVE('',#106,#107,#50,.T.);
#127=EDGE_CURVE('',#107,#108,#47,.T.);
#128=EDGE_CURVE('',#108,#109,#58,.T.);
#129=EDGE_CURVE('',#109,#110,#136,.T.);
#130=EDGE_CURVE('',#110,#111,#59,.T.);
#131=EDGE_CURVE('',#111,#112,#60,.T.);
#132=EDGE_CURVE('',#112,#93,#61,.T.);
#133=CIRCLE('',#138,3.);
#134=CIRCLE('',#139,3.);
#135=CIRCLE('',#140,2.);
#136=CIRCLE('',#141,2.);
#137=AXIS2_PLACEMENT_3D('',#166,#143,#144);
#138=AXIS2_PLACEMENT_3D('',#167,#145,#146);
#139=AXIS2_PLACEMENT_3D('',#186,#150,#151);
#140=AXIS2_PLACEMENT_3D('',#194,#155,#156);
#141=AXIS2_PLACEMENT_3D('',#219,#159,#160);
#142=AXIS2_PLACEMENT_3D('',#226,#164,#165);
#143=DIRECTION('',(0.,0.,1.));
#144=DIRECTION('',(1.,0.,0.));
#145=DIRECTION('',(3.64474856532125E-15,-3.64474856532124E-15,1.));
#146=DIRECTION('',(-1.,0.,3.64474856532125E-15));
#147=DIRECTION('',(-0.650134905906068,-0.759818796899963,0.));
#148=DIRECTION('',(-1.,0.,0.));
#149=DIRECTION('',(-0.650134905906174,0.759818796899873,0.));
#150=DIRECTION('',(0.,0.,1.));
#151=DIRECTION('',(1.,0.,0.));
#152=DIRECTION('',(-1.,0.,0.));
#153=DIRECTION('',(0.,-1.,0.));
#154=DIRECTION('',(1.,0.,0.));
#155=DIRECTION('',(0.,0.,-1.));
#156=DIRECTION('',(0.999999999999999,0.,0.));
#157=DIRECTION('',(0.649704180854046,-0.760187133132871,0.));
#158=DIRECTION('',(0.649719425641452,0.760174103705291,0.));
#159=DIRECTION('',(-3.64474856532125E-15,3.64474856532124E-15,-1.));
#160=DIRECTION('',(-1.,0.,3.64474856532125E-15));
#161=DIRECTION('',(1.,0.,0.));
#162=DIRECTION('',(0.,1.,0.));
#163=DIRECTION('',(-1.,0.,0.));
#164=DIRECTION('',(0.,0.,1.));
#165=DIRECTION('',(1.,0.,0.));
#166=CARTESIAN_POINT('',(0.,0.,0.));
#167=CARTESIAN_POINT('',(39.7779953734287,10.0000000000004,-1.08533305915446E-13));
#168=CARTESIAN_POINT('',(39.7779953734291,13.,0.));
#169=CARTESIAN_POINT('',(37.49853898273,11.95040471772,-9.31165257090302E-14));
#170=CARTESIAN_POINT('',(37.4985389827288,11.9504047177186,0.));
#171=CARTESIAN_POINT('',(35.0589127813998,9.09919056456357,0.));
#172=CARTESIAN_POINT('',(36.5,13.,0.));
#173=CARTESIAN_POINT('',(36.5,9.48528137423858,0.));
#174=CARTESIAN_POINT('',(34.0147186257614,7.,0.));
#175=CARTESIAN_POINT('',(30.5,7.,0.));
#176=CARTESIAN_POINT('',(30.5,7.,0.));
#177=CARTESIAN_POINT('',(30.5,7.,0.));
#178=CARTESIAN_POINT('',(29.5,7.,0.));
#179=CARTESIAN_POINT('',(29.5,7.,0.));
#180=CARTESIAN_POINT('',(25.9852813742386,7.,0.));
#181=CARTESIAN_POINT('',(23.5,9.48528137423857,0.));
#182=CARTESIAN_POINT('',(23.5,13.,0.));
#183=CARTESIAN_POINT('',(24.9410872186008,9.09919056456297,0.));
#184=CARTESIAN_POINT('',(24.9410872186008,9.09919056456295,0.));
#185=CARTESIAN_POINT('',(22.5014610172705,11.9504047177185,0.));
#186=CARTESIAN_POINT('',(20.2220046265709,10.,0.));
#187=CARTESIAN_POINT('',(20.2220046265709,13.,0.));
#188=CARTESIAN_POINT('',(23.5,13.,0.));
#189=CARTESIAN_POINT('',(0.,13.,0.));
#190=CARTESIAN_POINT('',(0.,13.,0.));
#191=CARTESIAN_POINT('',(0.,12.,0.));
#192=CARTESIAN_POINT('',(0.,12.,0.));
#193=CARTESIAN_POINT('',(20.2220046265709,12.,0.));
#194=CARTESIAN_POINT('',(20.2220046265709,10.,0.));
#195=CARTESIAN_POINT('',(21.7423788928367,11.2994083617081,0.));
#196=CARTESIAN_POINT('',(24.1863245011887,8.43986695764384,0.));
#197=CARTESIAN_POINT('',(24.1863245011857,8.4398669576473,0.));
#198=CARTESIAN_POINT('',(24.1863245011857,8.4398669576473,0.));
#199=CARTESIAN_POINT('',(24.3029466545987,8.30341307128576,0.));
#200=CARTESIAN_POINT('',(25.0464262450855,7.49933748163699,0.));
#201=CARTESIAN_POINT('',(26.7571179035045,6.36977322856096,0.));
#202=CARTESIAN_POINT('',(28.5838226383132,5.99371229560287,0.));
#203=CARTESIAN_POINT('',(29.5000083358491,5.99834338299765,0.));
#204=CARTESIAN_POINT('',(29.5000083358491,5.99834338299766,0.));
#205=CARTESIAN_POINT('',(29.5000083358491,5.99834338299766,0.));
#206=CARTESIAN_POINT('',(29.8333343370831,6.00002826178022,0.));
#207=CARTESIAN_POINT('',(30.1666645933719,5.99997739873893,0.));
#208=CARTESIAN_POINT('',(30.4999898630693,5.99815348790884,0.));
#209=CARTESIAN_POINT('',(30.4999898630693,5.99815348790884,0.));
#210=CARTESIAN_POINT('',(30.4999898630693,5.99815348790884,0.));
#211=CARTESIAN_POINT('',(31.4180818644462,5.9931298125486,0.));
#212=CARTESIAN_POINT('',(33.2483404280824,6.37065755044799,0.));
#213=CARTESIAN_POINT('',(34.9574020122579,7.50248146668021,0.));
#214=CARTESIAN_POINT('',(35.6986361720629,8.305386631309,0.));
#215=CARTESIAN_POINT('',(35.812814487254,8.43897567757707,0.));
#216=CARTESIAN_POINT('',(35.8128144872471,8.43897567756898,0.));
#217=CARTESIAN_POINT('',(38.2576471660181,11.2994388512833,0.));
#218=CARTESIAN_POINT('',(38.2576471660181,11.2994388512833,-3.60037297112999E-15));
#219=CARTESIAN_POINT('',(39.7779953734287,10.0000000000004,-1.38777878078145E-14));
#220=CARTESIAN_POINT('',(39.7779953734287,12.,-6.58829067717334E-15));
#221=CARTESIAN_POINT('',(39.7779953734291,12.,0.));
#222=CARTESIAN_POINT('',(60.,12.,0.));
#223=CARTESIAN_POINT('',(60.,12.,0.));
#224=CARTESIAN_POINT('',(60.,13.,0.));
#225=CARTESIAN_POINT('',(60.,13.,0.));
#226=CARTESIAN_POINT('',(29.9918918918919,9.52103061195586,0.));
#227=MECHANICAL_DESIGN_GEOMETRIC_PRESENTATION_REPRESENTATION('',(#32),#228);
#228=(
GEOMETRIC_REPRESENTATION_CONTEXT(3)
GLOBAL_UNCERTAINTY_ASSIGNED_CONTEXT((#229))
GLOBAL_UNIT_ASSIGNED_CONTEXT((#235,#231,#230))
REPRESENTATION_CONTEXT('Umriss_Blech_Sicke-6mm_2021-03-29',
'TOP_LEVEL_ASSEMBLY_PART')
);
#229=UNCERTAINTY_MEASURE_WITH_UNIT(LENGTH_MEASURE(2.E-5),#235,
'DISTANCE_ACCURACY_VALUE','Maximum Tolerance applied to model');
#230=(
NAMED_UNIT(*)
SI_UNIT($,.STERADIAN.)
SOLID_ANGLE_UNIT()
);
#231=(
CONVERSION_BASED_UNIT('DEGREE',#233)
NAMED_UNIT(#232)
PLANE_ANGLE_UNIT()
);
#232=DIMENSIONAL_EXPONENTS(0.,0.,0.,0.,0.,0.,0.);
#233=PLANE_ANGLE_MEASURE_WITH_UNIT(PLANE_ANGLE_MEASURE(0.0174532925),#234);
#234=(
NAMED_UNIT(*)
PLANE_ANGLE_UNIT()
SI_UNIT($,.RADIAN.)
);
#235=(
LENGTH_UNIT()
NAMED_UNIT(*)
SI_UNIT(.MILLI.,.METRE.)
);
ENDSEC;
END-ISO-10303-21;

As this topic appears numerous times in the forum:

You can easily convert and import meshes from Gmsh to fenics with the functionalities implemented in my package cashocs (GitHub - sblauth/cashocs: computational adjoint-based shape optimization and optimal control software for python)

All you need is a working Gmsh mesh file where the physical regions are labelled by integers, which we call “mesh.msh” for convenience. You can then convert the mesh to .xdmf by calling

cashocs-convert mesh.msh mesh.xdmf

from the command line, which will generate the the corresponding .xdmf files.
In your python script, you then just have to do

import cashocs

mesh, subdomains, boundaries, dx, ds, dS = cashocs.import_mesh('mesh.xdmf')

which will read the mesh and let you work directly with it. I find it very easy to use and would be glad if this can help you, too.

1 Like