This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Problem with loading mesh to Fenics generated by Gmsh

0 votes

Hi everybody,

I am trying to load to Fenics a 3D mesh generated with Gmsh. My domain is cube 10x10x10 and sphere or radius 1 in the middle. Gmsh generates the geometry and the mesh fine, see attached image. Dolfin-convert works with no errors converting the .geo file to .xml. However when I load the .xml file with the Mesh command in Fenics, the plot shows only the sphere, see second attached image.

So does anyone have any idea about what goes wrong and where?

Thank you

Gmsh
Fenics

asked Mar 20, 2015 by Katianefs FEniCS Novice (200 points)

Hi, can you post the .geo file?

It's kind of messy but here it is:

Point(1) = {0, 0, 0, 1};
Point(2) = {10, 0, 0, 1};
Point(3) = {10, 10, 0, 1};
Point(4) = {0, 10, 0, 1};
Point(5) = {0, 0, 10, 1};
Point(6) = {0, 10, 10, 1};
Point(7) = {10, 10, 10, 1};
Point(8) = {10, 0, 10, 1};
Point(41) = {5, 5, 5, 0.3};
Point(42) = {4, 5, 5, 0.3};
Point(43) = {5, 6, 5, 0.3};
Point(46) = {5, 5, 6, 0.3};
Point(47) = {5, 4, 5, 0.3};
Point(48) = {6, 5, 5, 0.3};
Point(49) = {5, 5, 4, 0.3};
Line(1) = {2, 1};
Line(2) = {1, 4};
Line(3) = {4, 3};
Line(4) = {2, 3};
Line(5) = {5, 8};
Line(6) = {7, 8};
Line(7) = {5, 6};
Line(8) = {6, 7};
Line(9) = {5, 1};
Line(10) = {8, 2};
Line(11) = {3, 7};
Line(12) = {6, 4};
Circle(21) = {42, 41, 43};
Circle(25) = {46, 41, 42};
Circle(26) = {46, 41, 43};
Circle(62) = {47, 41, 42};
Circle(64) = {46, 41, 47};
Circle(66) = {48, 41, 47};
Circle(68) = {46, 41, 48};
Circle(70) = {43, 41, 48};
Circle(72) = {49, 41, 43};
Circle(74) = {42, 41, 49};
Circle(78) = {47, 41, 49};
Circle(82) = {48, 41, 49};
Line Loop(60) = {21, -26, 25};
Ruled Surface(60) = {60};
Line Loop(61) = {62, -25, 64};
Ruled Surface(61) = {61};
Line Loop(65) = {66, -64, 68};
Ruled Surface(65) = {65};
Line Loop(69) = {70, -68, 26};
Ruled Surface(69) = {69};
Line Loop(71) = {72, -21, 74};
Ruled Surface(71) = {71};
Line Loop(75) = {-74, -62, 78};
Ruled Surface(75) = {75};
Line Loop(79) = {-78, -66, 82};
Ruled Surface(79) = {79};
Line Loop(83) = {-82, -70, -72};
Ruled Surface(83) = {83};
Line Loop(102) = {8, 6, -5, 7};
Plane Surface(102) = {102};
Line Loop(104) = {12, 3, 11, -8};
Plane Surface(104) = {104};
Line Loop(106) = {10, 1, -9, 5};
Plane Surface(106) = {106};
Line Loop(108) = {12, -2, -9, 7};
Plane Surface(108) = {108};
Line Loop(110) = {4, -3, -2, -1};
Plane Surface(110) = {110};
Line Loop(112) = {10, 4, 11, 6};
Plane Surface(112) = {112};
Surface Loop(114) = {102, 104, 106, 108, 110, 112};
Volume(114) = {114};
Surface Loop(115) = {60, 61, 65, 69, 71, 75, 79, 83, 102, 104, 106, 108, 110, 112};
Volume(115) = {115};

1 Answer

+1 vote

Hi, adding

Physical Volume(1) = {115};

to the .geo file should fix the problem.

answered Mar 20, 2015 by MiroK FEniCS Expert (80,920 points)

Well now I am getting the error when loading the new .xml file

Not a DOLFIN XML Mesh file.

Could you please tell me what is the Physical Volume command doing ?

OK I found the mistake. For completeness, what I did to create the two separate volumes is

Surface Loop(114) = {102, 104, 106, 108, 110, 112};
Volume(114) = {114};
Surface Loop(115) = {60, 61, 65, 69, 71, 75, 79, 83};
Volume(115) = {115};

Thanks for you reply.

With dolfin 1.5.0 and gmsh 2.8.5 a mesh generated for .geo file which is your + the extra line

# ...
Surface Loop(115) = {60, 61, 65, 69, 71, 75, 79, 83, 102, 104, 106, 108, 110, 112};
Volume(115) = {115};
Physical Volume(1) = {115};

running dolfin-convert and finaly running python -c 'from dolfin import Mesh, plot; mesh = plot(Mesh("foo.xml"), interactive=True)' produced this plot.

...