[Gmsh] refining the mesh of a circle with Attractor Fields

Matthias Sitte matthias at familie-sitte.org
Tue Jun 20 08:44:37 CEST 2017


Hi Guillaume,

thanks for the quick reply.

I realized soon after sending my email that I did not attach a MWE. I 
was waiting for the email to appear on the mailing so that I could reply 
to myself on that one, but it took some time... It's attached now.

I managed to get it done by using fields *and* setting 
Mesh.CharacteristicLengthExtendFromBoundary to 0 -- see result in 
attached PNG.

Regarding your ideas:

1) I'm really trying to mesh a disk shape.

2) If there's an easier way to do it, great. I tried the characteristic 
length scale approach as well -- see attached MWE -- but that didn't 
work well. Either the inner part is completely meshed with small 
entities, or the result is very weird.

3) I did not know about the Line in Surface command. Will try that one, too.

Best,

Matthias


On 06/19/2017 05:10 PM, DILASSER Guillaume wrote:
>
> Hi Matthias,
>
> It would have been nice to see the script file you are working on to 
> better identify the error, nevertheless here are a few questions :
>
> ·Are you trying to mesh a disk or a donut shape ? In the latter case, 
> did you properly define the hole in the surface (see Plane Surface 
> here <http://gmsh.info/doc/texinfo/gmsh.html#Surfaces>)?
>
> ·Do you really need fields to control your mesh density ? Using point 
> characteristic lengths (see Point here 
> <http://gmsh.info/doc/texinfo/gmsh.html#Points>) may be enough and far 
> easier to implement.
>
> ·If you want to mesh a disk, you will want to embed the inner circle 
> in the disk defined by the outer one using the Line in Surface command 
> (see here 
> <http://gmsh.info/doc/texinfo/gmsh.html#Miscellaneous-mesh-commands>).
>
> Did it help ? Let me know if you still have questions,
>
> Guillaume DILASSER
>
> Doctorant SACM / LEAS
>
> CEA - Centre de Saclay - Bât.123 - PC 319c
>
> 91191 Gif sur Yvette Cedex - France -
>
> guillaume.dilasser at cea.fr <mailto:guillaume.dilasser at cea.fr>
>
> -----Message d'origine-----
> De : gmsh [mailto:gmsh-bounces at ace20.montefiore.ulg.ac.be] De la part 
> de Matthias Sitte
> Envoyé : lundi 19 juin 2017 13:18
> À : gmsh at onelab.info
> Objet : [Gmsh] refining the mesh of a circle with Attractor Fields
>
> Hi all,
>
> I'm trying to set up the following problem:
>
> 1) Create a circular geometry with radius R_outer using 4 Circles and 
> a Line Loop which defines the outer boundary of the mesh.
>
> 2) Create another closed circle (again made out of 4 Circles) with 
> radius R_inner inside the circular mesh.
>
> 3) Goal is to reduce lchar and create a finer mesh close the inner 
> circle, but keep the coarser mesh everywhere else.
>
> So far I've started from the example t10.geo and mostly got what I 
> wanted. But I observed that if I close the inner circle, all of the 
> mesh within the circle is meshed with reduced lchar, not the lchar I 
> would've expected. When I open the circle by leaving out segment(s), 
> the result looks better w.r.t. mesh size, but it's of course not what 
> I want. Am I missing something here?
>
> Best,
>
> Matthias
>
> _______________________________________________
>
> gmsh mailing list
>
> gmsh at onelab.info <mailto:gmsh at onelab.info>
>
> http://onelab.info/mailman/listinfo/gmsh
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://onelab.info/pipermail/gmsh/attachments/20170620/94a8f5a4/attachment-0001.html>
-------------- next part --------------
General.ExpertMode = 1;
Mesh.Algorithm = 6;
Mesh.Algorithm3D = 4;
Mesh.Format = 1;

height = 1.0;
outer_radius = 50.0;
inner_radius = 30.0;
lchar = 3.0;
lchar_fine = 0.5;

// Define the center point. Usually (0,0,0).
origin = newp; Point(origin) = { 0., 0., 0., lchar };

// Define the "inner region of interest".
inner_p0 = newp; Point(inner_p0) = { 0., inner_radius, 0., lchar_fine };
inner_p1 = newp; Point(inner_p1) = { -inner_radius, 0., 0., lchar_fine };
inner_p2 = newp; Point(inner_p2) = { 0., -inner_radius, 0., lchar_fine };
inner_p3 = newp; Point(inner_p3) = { inner_radius, 0., 0., lchar_fine };

inner_l0 = newl; Circle(inner_l0) = { inner_p0, origin, inner_p1 };
inner_l1 = newl; Circle(inner_l1) = { inner_p1, origin, inner_p2 };
inner_l2 = newl; Circle(inner_l2) = { inner_p2, origin, inner_p3 };
inner_l3 = newl; Circle(inner_l3) = { inner_p3, origin, inner_p0 };

inner_circumference = newll; Line Loop(inner_circumference) = { inner_l0, inner_l1, inner_l2, inner_l3 };
inner_btm_surface = news; Plane Surface(inner_btm_surface) = { inner_circumference };

inner[] = Extrude { 0, 0, height } { Surface{inner_btm_surface}; };
inner_top_surface = inner[0];
inner_volume = inner[1];
inner_side_surface = { inner[2], inner[3], inner[4], inner[5] };

// Define the "outer region of interest".
outer_p0 = newp; Point(outer_p0) = { 0., outer_radius, 0., lchar };
outer_p1 = newp; Point(outer_p1) = { -outer_radius, 0., 0., lchar };
outer_p2 = newp; Point(outer_p2) = { 0., -outer_radius, 0., lchar };
outer_p3 = newp; Point(outer_p3) = { outer_radius, 0., 0., lchar };

outer_l0 = newl; Circle(outer_l0) = { outer_p0, origin, outer_p1 };
outer_l1 = newl; Circle(outer_l1) = { outer_p1, origin, outer_p2 };
outer_l2 = newl; Circle(outer_l2) = { outer_p2, origin, outer_p3 };
outer_l3 = newl; Circle(outer_l3) = { outer_p3, origin, outer_p0 };

outer_circumference = newll; Line Loop(outer_circumference) = { outer_l0, outer_l1, outer_l2, outer_l3 };
outer_btm_surface = news; Plane Surface(outer_btm_surface) = { outer_circumference, inner_circumference };

outer[] = Extrude { 0, 0, height } { Surface{outer_btm_surface}; };
outer_top_surface = outer[0];
outer_volume = outer[1];
outer_side_surface = { outer[2], outer[3], outer[4], outer[5] };

// Define physical regions.
Physical Surface(2001) = { inner_btm_surface };
Physical Surface(2002) = { inner_top_surface };
Physical Surface(2003) = { inner[2], inner[3], inner[4], inner[5] };
Physical Surface(2004) = { outer_btm_surface };
Physical Surface(2005) = { outer_top_surface };
Physical Surface(2006) = { outer[2], outer[3], outer[4], outer[5] };
Physical Volume(3001) = { inner_volume };
Physical Volume(3002) = { outer_volume };

// We want to obtain mesh elements with size lchar/30 near the skyrmion radius,
// size lchar elsewhere.  To achieve this, we first define an "Attractor" field
// on the side faces which returns the distance to those faces.  We then define
// a "Threshold" field which uses the return value of the "Attractor" field to
// define a simple change in element size around the attractors:
//
// LcMax -                         /------------------
//                               /
//                             /
//                           /
// LcMin -o----------------/
//        |                |       |
//     Attractor       DistMin   DistMax
//
// Field[1] = Attractor;
// Field[1].FacesList = { inner[2], inner[3], inner[4], inner[5] };
// Field[1].NNodesByEdge = 50;

// Field[2] = Threshold;
// Field[2].IField = 1;
// Field[2].LcMin = 0.2 * lchar;
// Field[2].LcMax = 1.0 * lchar;
// Field[2].DistMin = 2.0 * lchar;
// Field[2].DistMax = 5.0 * lchar;

// Background Field = 2;

// Finally, do not extend the element sizes from the boundary into the domain,
// because we only want the boundary to be meshed finely, not the interior.
Mesh.CharacteristicLengthExtendFromBoundary = 0;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mesh.png
Type: image/png
Size: 718389 bytes
Desc: not available
URL: <http://onelab.info/pipermail/gmsh/attachments/20170620/94a8f5a4/attachment-0001.png>


More information about the gmsh mailing list