[Gmsh] Fields and Volume
Vincent HUBER
vincent.huber at gmail.com
Wed Jun 14 15:25:50 CEST 2017
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.;
radius=Sqrt(2.*(x/ratio)^2);
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[1].F = Sprintf("(Fabs(%g-Sqrt(x*x+y*y)))+%g/5",radius,h);
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.;
radius=Sqrt(2.*(x/ratio)^2);
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[1].F = Sprintf("(Fabs(%g-Sqrt(x*x+y*y)))+%g/5",radius,h);
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/20170614/d310b245/attachment.html>
More information about the gmsh
mailing list