Skip to content

Instantly share code, notes, and snippets.

@dajuno
Created January 13, 2016 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dajuno/6545e964cf9c499dc4e1 to your computer and use it in GitHub Desktop.
Save dajuno/6545e964cf9c499dc4e1 to your computer and use it in GitHub Desktop.
GMSH example physical groups
L = 1;
dx1 = 0.05*L;
R = 0.398942280*L; /* radius for a circle taking half of the unit square
area */
dx2 = dx1*2*R/L;
Point(1) = {-0.5*L, -0.5*L, -0.5*L, dx1};
Point(2) = { 0.5*L, -0.5*L, -0.5*L, dx1};
Point(3) = { 0.5*L, -0.5*L, 0.5*L, dx1};
Point(4) = {-0.5*L, -0.5*L, 0.5*L, dx1};
Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 4};
Line(4) = {4, 1};
lvox = newl;
Line Loop(lvox) = {1, 2, 3, 4};
p0 = newp; Point(p0) = {0, -0.5*L, 0, dx2};
p1 = newp; Point(p1) = {R, -0.5*L, 0, dx2};
p2 = newp; Point(p2) = {0, -0.5*L, R, dx2};
p3 = newp; Point(p3) = {-R, -0.5*L, 0, dx2};
p4 = newp; Point(p4) = {0, -0.5*L, -R, dx2};
c1 = newreg; Circle(c1) = {p1, p0, p2};
c2 = newreg; Circle(c2) = {p2, p0, p3};
c3 = newreg; Circle(c3) = {p3, p0, p4};
c4 = newreg; Circle(c4) = {p4, p0, p1};
lcirc = newl;
Line Loop(lcirc) = {c1, c2, c3, c4};
sc = news;
Plane Surface(sc) = {lcirc};
sv = news;
Plane Surface(sv) = {lvox, lcirc};
mat = Extrude {0, 1*L, 0} { Surface{sv}; };
pipe = Extrude {0, 1*L, 0} { Surface{sc}; };
// number from 0 to N for FEniCS compatibility
Physical Surface(0) = {sv}; // front matrix {Sq/Cir}
Physical Surface(1) = {sc}; // front inlet
Physical Surface(2) = {mat[0]}; // back matrix {Sq/Cir}
Physical Surface(3) = {pipe[0]}; // back outlet
Physical Surface(4) = {mat[2]}; // bottom
Physical Surface(5) = {mat[3]}; // right
Physical Surface(6) = {mat[4]}; // top
Physical Surface(7) = {mat[5]}; // left
Physical Surface(8) = {mat[6], mat[7], mat[8], mat[9]}; // interface
Physical Volume(0) = {mat[1]};
Physical Volume(1) = {pipe[1]};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment