[Gmsh] torus in larger volume

Christophe Geuzaine cgeuzaine at ulg.ac.be
Thu Jan 31 19:58:16 CET 2013


On 04 Oct 2012, at 19:30, Nico Schlömer <nico.schloemer at gmail.com> wrote:

> I think I figured out why the code fails. Two things:
> 
> 1. When using Extrude, Gmsh directly creates a volume for the
> extruded entity. When creating a torus, however, you have to do that
> in at least three steps since Gmsh doesn't support angles larger than
> Pi. When extruding three times, three pieces of volume are defined,
> and if you go ahead and try to afterwards define a volume for the
> whole thing, you get clashes which manifest in error messages like
> "edge multiply defined".
> A possible work-around would be to explicitly delete the subvolumes.
> However, this is hardly possible now since Extrude does not return the
> ID of the created volume.
> 

Hi Nico - It does, in the first element of the array.


> 2. According to the manpages, Extrude by default returns the IDs of
> the lateral entities creates during the extrude. However, I found that
> this is not always the case. In the attached example, the Surface Loop
> is only sensibly defined when replacing ts4[2] by the number 71.
> 

The "trick" is that, by default, "Coherence" is applied after each extrusion. This means that the numbers you get after an extrusion might not refer to existing entities after another extrusion (they might have been deleted by the duplicate entity removal procedure). There are several workrounds; one is applied in the attached, modified file: temporally disable autamatic duplicate removals when you do your computations.

Hope this helps,

Christophe

-------------- next part --------------
A non-text attachment was scrubbed...
Name: torus2.geo
Type: application/octet-stream
Size: 1882 bytes
Desc: not available
URL: <http://www.geuz.org/pipermail/gmsh/attachments/20130131/ff045c42/attachment.geo>
-------------- next part --------------

> What are your thoughts on this?
> 
> --Nico
> 
> 
> On Thu, Oct 4, 2012 at 10:08 AM, Nico Schlömer <nico.schloemer at gmail.com> wrote:
>> So it appears that, if extrusion is performed like
>> 
>>  ts2[] = Extrude {{0,0,1}, {0,0,0}, 2*Pi/3}{Surface{ts1}; Layers{10};};
>> 
>> the extruded surfaces are stored in ts2[2], ts2[3], ts2[4], ts2[5].
>> 
>> When trying to mesh a torus, however,
>> 
>>  ts2[] = Extrude {{0,0,1}, {0,0,0}, 2*Pi/3}{Surface{ts1}; Layers{numLayers};};
>>  ts3[] = Extrude {{0,0,1}, {0,0,0}, 2*Pi/3}{Surface{ts2[0]};
>> Layers{numLayers};};
>>  ts4[] = Extrude {{0,0,1}, {0,0,0}, 2*Pi/3}{Surface{ts3[0]};
>> Layers{numLayers};};
>>  theloops[t] = newreg;
>>  Surface Loop(theloops[t]) = {ts2[2], ts2[3], ts2[4], ts2[5],
>>                               ts3[2], ts3[3], ts3[4], ts3[5],
>>                               ts4[2], ts4[3], ts4[4], ts4[5]};
>> 
>> I'm getting a bunch of error messages about edges appearing multiple
>> times in the mesh. Meshing is then not performed correctly either.
>> 
>> Code is attached.
>> 
>> --Nico
>> 
>> 
>> On Wed, Oct 3, 2012 at 3:40 PM, Nico Schlömer <nico.schloemer at gmail.com> wrote:
>>> (Not sure if my earlier message got through, sorry for the double post
>>> if it did.)
>>> 
>>> 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
> <torus.geo>_______________________________________________
> gmsh mailing list
> gmsh at geuz.org
> http://www.geuz.org/mailman/listinfo/gmsh

-- 
Prof. Christophe Geuzaine
University of Liege, Electrical Engineering and Computer Science 
http://www.montefiore.ulg.ac.be/~geuzaine