[Gmsh] torus in larger volume

Nico Schlömer nico.schloemer at gmail.com
Tue Oct 2 21:23:48 CEST 2012


Hi,

I would like to embed a torus into a larger entity such that I have a
fine mesh on the torus and a coarser one around (while staying
conform).
>From ancient mailing list entries, I put together a torus function

==================== *snip* ====================
Function Torus
  // Given a zshift and two radii rad and orad, and a zshift, this
  // creates a torus parallel to the x-y-plane.
  // The points:
  tp1 = newp;
  Point(tp1) = {0,orad,zshift,lcar2};
  tp2 = newp;
  Point(tp2) = {0,rad+orad,zshift,lcar2};
  tp3 = newp;
  Point(tp3) = {0,orad,zshift+rad,lcar2};
  tp4 = newp;
  Point(tp4) = {0,orad,zshift-rad,lcar2};
  tp5 = newp;
  Point(tp5) = {0,-rad+orad,zshift,lcar2};
  // One cirlce:
  tc1 = newreg;
  Circle(tc1) = {tp2,tp1,tp3};
  tc2 = newreg;
  Circle(tc2) = {tp3,tp1,tp5};
  tc3 = newreg;
  Circle(tc3) = {tp5,tp1,tp4};
  tc4 = newreg;
  Circle(tc4) = {tp4,tp1,tp2};
  // The extrusion to the torus:
  tll1 = newreg;
  Line Loop(tll1) = {tc1,tc2,tc3,tc4};
  ts1 = newreg;
  Plane Surface(ts1) = {tll1};
  // Gmsh cannot rotate beyond PI, so split the extrusion up in three parts.
  ts2[] = Extrude {{0,0,1}, {0,0,0}, 2*Pi/3}{Surface{ts1}; Layers{10};
Recombine;};
  ts3[] = Extrude {{0,0,1}, {0,0,0}, 2*Pi/3}{Surface{ts2[0]};
Layers{10}; Recombine;};
  ts4[] = Extrude {{0,0,1}, {0,0,0}, 2*Pi/3}{Surface{ts3[0]};
Layers{10}; Recombine;};

Return
==================== *snap* ====================

which does the job. Not sure at all what "Layers{10}" is doing.

Now, to embed this thing into a larger volume, I think I need to store
the torus surface in some way. (At least that's what I take from the
swiss cheese example.) Is that correct?

I guess the information has to be in ts2/ts3/ts4 somehow, but I don't
know how to extract it. A quick

==================== *snip* ====================
theloops[t] = newreg;
Surface Loop(theloops[t]) = {ts2[2], ts3[2], ts4[2]};

thetorus = newreg;
Volume(thetorus) = theloops[t];
Physical Volume (t) = thetorus;
==================== *snap* ====================

doesn't work.
Any ideas?

Cheers,
Nico