<div dir="ltr">Incidentally, swiss cheese is one of the examples for pygmsh [1]. It produces the geo-file, too.<div><br></div><div>Cheers,</div><div>Nico<div><br></div><div>[1] <a href="https://github.com/nschloe/pygmsh/blob/master/test/examples/swiss_cheese.py">https://github.com/nschloe/pygmsh/blob/master/test/examples/swiss_cheese.py</a></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Mar 31, 2017 at 12:54 AM Achille Pluplu <<a href="mailto:mail.plutus@gmail.com">mail.plutus@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear all,<br class="gmail_msg">
<br class="gmail_msg">
I'm quite new to GMSH so, please, be patient.<br class="gmail_msg">
I need to create a 3D mesh of a cube that include some inclusions<br class="gmail_msg">
(spheres) of a different material.<br class="gmail_msg">
<br class="gmail_msg">
I could find the following script that generates a cube with 5<br class="gmail_msg">
cavities, but how can I mesh also the inclusions? In particular I need<br class="gmail_msg">
two well separated meshes, one for the "cheese" the other for the<br class="gmail_msg">
inclusions<br class="gmail_msg">
<br class="gmail_msg">
Thanks a lot for helping!<br class="gmail_msg">
<br class="gmail_msg">
Function CheeseHole<br class="gmail_msg">
<br class="gmail_msg">
// In the following commands we use the reserved variable name<br class="gmail_msg">
// `newp', which automatically selects a new point number. This<br class="gmail_msg">
// number is chosen as the highest current point number, plus<br class="gmail_msg">
// one. (Note that, analogously to `newp', the variables `newc',<br class="gmail_msg">
// `news', `newv' and `newreg' select the highest number amongst<br class="gmail_msg">
// currently defined curves, surfaces, volumes and `any entities<br class="gmail_msg">
// other than points', respectively.)<br class="gmail_msg">
<br class="gmail_msg">
p1 = newp; Point(p1) = {x, y, z, lcar3} ;<br class="gmail_msg">
p2 = newp; Point(p2) = {x+r,y, z, lcar3} ;<br class="gmail_msg">
p3 = newp; Point(p3) = {x, y+r,z, lcar3} ;<br class="gmail_msg">
p4 = newp; Point(p4) = {x, y, z+r,lcar3} ;<br class="gmail_msg">
p5 = newp; Point(p5) = {x-r,y, z, lcar3} ;<br class="gmail_msg">
p6 = newp; Point(p6) = {x, y-r,z, lcar3} ;<br class="gmail_msg">
p7 = newp; Point(p7) = {x, y, z-r,lcar3} ;<br class="gmail_msg">
<br class="gmail_msg">
c1 = newreg; Circle(c1) = {p2,p1,p7};<br class="gmail_msg">
c2 = newreg; Circle(c2) = {p7,p1,p5};<br class="gmail_msg">
c3 = newreg; Circle(c3) = {p5,p1,p4};<br class="gmail_msg">
c4 = newreg; Circle(c4) = {p4,p1,p2};<br class="gmail_msg">
c5 = newreg; Circle(c5) = {p2,p1,p3};<br class="gmail_msg">
c6 = newreg; Circle(c6) = {p3,p1,p5};<br class="gmail_msg">
c7 = newreg; Circle(c7) = {p5,p1,p6};<br class="gmail_msg">
c8 = newreg; Circle(c8) = {p6,p1,p2};<br class="gmail_msg">
c9 = newreg; Circle(c9) = {p7,p1,p3};<br class="gmail_msg">
c10 = newreg; Circle(c10) = {p3,p1,p4};<br class="gmail_msg">
c11 = newreg; Circle(c11) = {p4,p1,p6};<br class="gmail_msg">
c12 = newreg; Circle(c12) = {p6,p1,p7};<br class="gmail_msg">
<br class="gmail_msg">
// We need non-plane surfaces to define the spherical holes. Here we<br class="gmail_msg">
// use ruled surfaces, which can have 3 or 4 sides:<br class="gmail_msg">
<br class="gmail_msg">
l1 = newreg; Line Loop(l1) = {c5,c10,c4}; Ruled Surface(newreg) = {l1};<br class="gmail_msg">
l2 = newreg; Line Loop(l2) = {c9,-c5,c1}; Ruled Surface(newreg) = {l2};<br class="gmail_msg">
l3 = newreg; Line Loop(l3) = {c12,-c8,-c1}; Ruled Surface(newreg) = {l3};<br class="gmail_msg">
l4 = newreg; Line Loop(l4) = {c8,-c4,c11}; Ruled Surface(newreg) = {l4};<br class="gmail_msg">
l5 = newreg; Line Loop(l5) = {-c10,c6,c3}; Ruled Surface(newreg) = {l5};<br class="gmail_msg">
l6 = newreg; Line Loop(l6) = {-c11,-c3,c7}; Ruled Surface(newreg) = {l6};<br class="gmail_msg">
l7 = newreg; Line Loop(l7) = {-c2,-c7,-c12};Ruled Surface(newreg) = {l7};<br class="gmail_msg">
l8 = newreg; Line Loop(l8) = {-c6,-c9,c2}; Ruled Surface(newreg) = {l8};<br class="gmail_msg">
<br class="gmail_msg">
// We then store the surface loops identification numbers in a list<br class="gmail_msg">
// for later reference (we will need these to define the final<br class="gmail_msg">
// volume):<br class="gmail_msg">
<br class="gmail_msg">
theloops[t] = newreg ;<br class="gmail_msg">
<br class="gmail_msg">
Surface Loop(theloops[t]) = {l8+1,l5+1,l1+1,l2+1,l3+1,l7+1,l6+1,l4+1};<br class="gmail_msg">
<br class="gmail_msg">
thehole = newreg ;<br class="gmail_msg">
Volume(thehole) = theloops[t] ;<br class="gmail_msg">
<br class="gmail_msg">
Return<br class="gmail_msg">
<br class="gmail_msg">
lcar3 = .055;<br class="gmail_msg">
<br class="gmail_msg">
hloc = 0.1;<br class="gmail_msg">
Point(1) = {0, 0, 0, hloc};<br class="gmail_msg">
Point(2) = {1, 0, 0, hloc};<br class="gmail_msg">
Point(3) = {1, 1, 0, hloc};<br class="gmail_msg">
Point(4) = {0, 1, 0, hloc};<br class="gmail_msg">
<br class="gmail_msg">
Point(5) = {0, 0, 1, hloc};<br class="gmail_msg">
Point(6) = {1, 0, 1, hloc};<br class="gmail_msg">
Point(7) = {1, 1, 1, hloc};<br class="gmail_msg">
Point(8) = {0, 1, 1, hloc};<br class="gmail_msg">
<br class="gmail_msg">
Line(1) = {1,2};<br class="gmail_msg">
Line(2) = {2,3};<br class="gmail_msg">
Line(3) = {3,4};<br class="gmail_msg">
Line(4) = {4,1};<br class="gmail_msg">
<br class="gmail_msg">
Line(5) = {5,6};<br class="gmail_msg">
Line(6) = {6,7};<br class="gmail_msg">
Line(7) = {7,8};<br class="gmail_msg">
Line(8) = {8,5};<br class="gmail_msg">
<br class="gmail_msg">
Line(9) = {1,5};<br class="gmail_msg">
Line(10) = {2,6};<br class="gmail_msg">
Line(11) = {3,7};<br class="gmail_msg">
Line(12) = {4,8};<br class="gmail_msg">
<br class="gmail_msg">
// bottom<br class="gmail_msg">
Line Loop(21) = {-1,-4,-3,-2};<br class="gmail_msg">
Plane Surface(31) = {21} ;<br class="gmail_msg">
<br class="gmail_msg">
// top<br class="gmail_msg">
Line Loop(22) = {5,6,7,8};<br class="gmail_msg">
Plane Surface(32) = {22} ;<br class="gmail_msg">
<br class="gmail_msg">
// left<br class="gmail_msg">
Line Loop(23) = {1,10,-5,-9};<br class="gmail_msg">
Plane Surface(33) = {23} ;<br class="gmail_msg">
<br class="gmail_msg">
// right<br class="gmail_msg">
Line Loop(24) = {12,-7,-11,3};<br class="gmail_msg">
Plane Surface(34) = {24} ;<br class="gmail_msg">
<br class="gmail_msg">
// front<br class="gmail_msg">
Line Loop(25) = {2,11,-6,-10};<br class="gmail_msg">
Plane Surface(35) = {25} ;<br class="gmail_msg">
<br class="gmail_msg">
// back<br class="gmail_msg">
Line Loop(26) = {9,-8,-12,4};<br class="gmail_msg">
Plane Surface(36) = {26} ;<br class="gmail_msg">
<br class="gmail_msg">
// We can use a `For' loop to generate five holes in the cube:<br class="gmail_msg">
<br class="gmail_msg">
x = 0 ; y = 0.75 ; z = 0 ; r = 0.09 ;<br class="gmail_msg">
<br class="gmail_msg">
For t In {1:5}<br class="gmail_msg">
<br class="gmail_msg">
x += 0.166 ;<br class="gmail_msg">
z += 0.166 ;<br class="gmail_msg">
<br class="gmail_msg">
// We call the `CheeseHole' function:<br class="gmail_msg">
<br class="gmail_msg">
Call CheeseHole ;<br class="gmail_msg">
<br class="gmail_msg">
// We define a physical volume for each hole:<br class="gmail_msg">
<br class="gmail_msg">
Physical Volume (t) = thehole ;<br class="gmail_msg">
<br class="gmail_msg">
// We also print some variables on the terminal (note that, since<br class="gmail_msg">
// all variables are treated internally as floating point numbers,<br class="gmail_msg">
// the format string should only contain valid floating point format<br class="gmail_msg">
// specifiers like `%g', `%f', '%e', etc.):<br class="gmail_msg">
<br class="gmail_msg">
Printf("Hole %g (center = {%g,%g,%g}, radius = %g) has number %g!",<br class="gmail_msg">
t, x, y, z, r, thehole) ;<br class="gmail_msg">
<br class="gmail_msg">
EndFor<br class="gmail_msg">
<br class="gmail_msg">
theloops[0] = newreg ;<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
Surface Loop(theloops[0]) = {31,32,33,34,35,36};<br class="gmail_msg">
<br class="gmail_msg">
Volume(100) = {theloops[]};<br class="gmail_msg">
<br class="gmail_msg">
Physical Volume (10) = 100 ;<br class="gmail_msg">
<br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
gmsh mailing list<br class="gmail_msg">
<a href="mailto:gmsh@onelab.info" class="gmail_msg" target="_blank">gmsh@onelab.info</a><br class="gmail_msg">
<a href="http://onelab.info/mailman/listinfo/gmsh" rel="noreferrer" class="gmail_msg" target="_blank">http://onelab.info/mailman/listinfo/gmsh</a><br class="gmail_msg">
</blockquote></div>