In an attempt to create three-dimensional volumes with inclusions in Gmsh I stumble upon a problem which was non-existent in the two-dimensional case.

I'm using the OpenCASCADE geometry kernel because this facilitates convenient boolean operations to remove parts of the inclusions outside my considered domain box.

In a nutshell the problem boils down to:

  • whenever I incorporate inclusions I perform a unite step, such that the different geometrical features are recognized but the interfaces are joined in the mesh. This works like a charm in 2D, however, when I do the equivalent in 3D, my volumetric geometrical information is lost and volumes are actually united completely removing the interface.

I can graphically depict this by performing the 2D mesh step, in both 2D and 3D:

2D united mesh 3D united mesh

What the above showcases is the intended behaviour in 2D where (continuous) interfaces are retained, but although in 3D the sphere locations are still visible from the outside, the internal surface is no longer existent, i.e. the sphere outside is not meshed, only the cut section. I should note that I believe I need the unite step to tie the different geometrical features together, that I've tried many different minor variations to produce 3D results like the one depicted above but none resulted in the intended mesh and that my web search was unhelpful.

I hope someone has a concrete idea or even a hunch on where to find the solution for the issue.


For completeness I'm adding the simplified .geo examples used to obtain the above graphs.

For 2D:

SetFactory("OpenCASCADE");

Point(1) = {0, 0, 0};
Point(2) = {2, 0, 0};
Point(3) = {2, 2, 0};
Point(4) = {0, 2, 0};

Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 4};
Line(4) = {4, 1};

Line Loop(1) = {1, 2, 3, 4};

Plane Surface(1) = {1};

Periodic Line{1} = {-3};
Periodic Line{2} = {-4};

Disk(2) = {0, 0, 0, 0.5};
Disk(3) = {2, 0, 0, 0.5};
Disk(4) = {0, 2, 0, 0.5};
Disk(5) = {2, 2, 0, 0.5};
Disk(6) = {1, 1, 0, 0.5};

f1() = BooleanDifference{ Surface{1}; }{ Surface{2:6}; };
f2() = BooleanIntersection{ Surface{1}; Delete; }{ Surface{2:6}; Delete; };
BooleanUnion{ Surface{ f1() }; Delete; }{ Surface{ f2() }; Delete; }

For 3D:

SetFactory("OpenCASCADE");

incRadi = 0.5;
boxSize = 1.5;

Box(1) = {0,0,0, boxSize,boxSize,boxSize};

Periodic Surface{2} = {1} Translate{boxSize,0,0};
Periodic Surface{4} = {3} Translate{0,boxSize,0};
Periodic Surface{6} = {5} Translate{0,0,boxSize};

Sphere(2) = {0, 0.5*boxSize, 0.5*boxSize, incRadi, -Pi/2, Pi/2, 2*Pi};
Sphere(3) = {boxSize, 0.5*boxSize, 0.5*boxSize, incRadi, -Pi/2, Pi/2, 2*Pi};

f1() = BooleanDifference{ Volume{1}; }{ Volume{2:3}; };
f2() = BooleanIntersection{ Volume{1}; Delete; }{ Volume{2:3}; Delete; };
BooleanUnion{ Volume{ f1() }; Delete; }{ Volume{ f2() }; Delete; }

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.