# [Gmsh] Fields and Volume

DILASSER Guillaume Guillaume.DILASSER at cea.fr
Thu Jun 15 15:34:43 CEST 2017

```Hi Vincent,

I think you can simply add the statement “Mesh.CharacteristicLengthFromBoundary = 0 ;” somewhere in the script of your first model to solve the issue. This will force Gmsh not to use the characteristic length of the surface mesh when computing the volume mesh, but instead only rely on the fields you provide. Let me know if it worked,

Sincerely Yours,

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>

De : gmsh [mailto:gmsh-bounces at ace20.montefiore.ulg.ac.be] De la part de Vincent HUBER
Envoyé : mercredi 14 juin 2017 15:26
À : gmsh at onelab.info
Objet : [Gmsh] Fields and Volume

Hello everyone,

I work with Gmsh 3.0.2

I have a cylinder inside a cube.
I want to refine the boundary of the cylinder.

To do so, I use a combination of MathEval fields.
If I declare the cylinder as a volume, it is meshed with very small elements.
If I do not declare the cylinder as a volume, only the region near the interface is correctly meshed.

How can I have both :
·         the cylinder as a volume
·         the reffinement near the interface ?

With the cylinder as a volume

h=0.1;

x=1;

y=1;

z=1;

ratio = 3.;

distance=h;

p0 = newp; Point(p0) = {0,0,0,50*h};

pc = newp; Point(pc) = {0,0,-z,h};

p1 = newp; Point(p1) = {-x,-y,-z,h};

p2 = newp; Point(p2) = {-x, y,-z,h};

p3 = newp; Point(p3) = { x, y,-z,h};

p4 = newp; Point(p4) = { x,-y,-z,h};

r1 = newp; Point(r1) = {      0,  radius, -z, h};

r2 = newp; Point(r2) = { radius,       0, -z, h};

r3 = newp; Point(r3) = {      0, -radius, -z, h};

r4 = newp; Point(r4) = {-radius,       0, -z, h};

l1 = newl; Line(l1) = {p1,p2};

l2 = newl; Line(l2) = {p2,p3};

l3 = newl; Line(l3) = {p3,p4};

l4 = newl; Line(l4) = {p4,p1};

c1 = newl; Circle(c1) = {r1,pc,r2};

c2 = newl; Circle(c2) = {r2,pc,r3};

c3 = newl; Circle(c3) = {r3,pc,r4};

c4 = newl; Circle(c4) = {r4,pc,r1};

outer = newll; Line Loop(outer) = {l1,l2,l3,l4};

inner = newll; Line Loop(inner) = {c1,c2,c3,c4};

s1 = news; Plane Surface(s1) = {outer,-inner};

s2 = news; Plane Surface(s2) = {inner};

extruded[] = Extrude{0,0,2.*z} {

Surface{s1,s2};

};

Physical Point("center") = {p0};

Physical Volume("Omega1") = {extruded[1]};

Physical Volume("Omega2") = {extruded[11]};

Field[1] = MathEval;

Field[2] = MathEval;

Field[2].F = "0.1";

Field[3] = Min;

Field[3].FieldsList = {1,2};

Background Field = 3;

With the reffinement I target

h=0.1;

x=1;

y=1;

z=1;

ratio = 3.;

distance=h;

p0 = newp; Point(p0) = {0,0,0,50*h};

pc = newp; Point(pc) = {0,0,-z,h};

p1 = newp; Point(p1) = {-x,-y,-z,h};

p2 = newp; Point(p2) = {-x, y,-z,h};

p3 = newp; Point(p3) = { x, y,-z,h};

p4 = newp; Point(p4) = { x,-y,-z,h};

r1 = newp; Point(r1) = {      0,  radius, -z, h};

r2 = newp; Point(r2) = { radius,       0, -z, h};

r3 = newp; Point(r3) = {      0, -radius, -z, h};

r4 = newp; Point(r4) = {-radius,       0, -z, h};

l1 = newl; Line(l1) = {p1,p2};

l2 = newl; Line(l2) = {p2,p3};

l3 = newl; Line(l3) = {p3,p4};

l4 = newl; Line(l4) = {p4,p1};

c1 = newl; Circle(c1) = {r1,pc,r2};

c2 = newl; Circle(c2) = {r2,pc,r3};

c3 = newl; Circle(c3) = {r3,pc,r4};

c4 = newl; Circle(c4) = {r4,pc,r1};

outer = newll; Line Loop(outer) = {l1,l2,l3,l4};

inner = newll; Line Loop(inner) = {c1,c2,c3,c4};

s1 = news; Plane Surface(s1) = {outer};

//s2 = news; Plane Surface(s2) = {inner};

extruded[] = Extrude{0,0,2.*z} {

Surface{s1};

};

Physical Point("center") = {p0};

Physical Volume("Omega1") = {extruded[1]};

//Physical Volume("Omega2") = {extruded[11]};

Field[1] = MathEval;

Field[2] = MathEval;

Field[2].F = "0.1";

Field[3] = Min;

Field[3].FieldsList = {1,2};

Background Field = 3;

All the best,
​
--
Vincent HUBER
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://onelab.info/pipermail/gmsh/attachments/20170615/7f28ce48/attachment-0001.html>
```