1

I have generated a gmsh mesh that I imported into FiPy via Gmsh2D. I would like to adress the surface Faces to set boundary conditions but I did not know how to.

In FiPy examples I found in the documentation it is suggested to name certain lines to address them later. How do I do this after I imported the mesh into fipy?

// note: if you do not use any labels, all Cells will be included.

Physical Surface("Outer") = {1};
Physical Surface("Middle") = {2};
Physical Surface("Inner") = {3};

// label the "north-west" part of the exterior boundary

// note: you only need to label the Face elements
// (Physical Line in 2D and Physical Surface in 3D) that correspond
// to boundaries you are interested in. FiPy does not need them to
// construct the Mesh.

Physical Line("NW") = {5};

-----------------

Edit:

For simple surface faces this will work: I overlooked mesh.exteriorFaces. For a simple circle this leads to the simple solution:

xfc, yfc = mesh.faceCenters()   # returns x faceCenters coordinate, ...
xcc, ycc = mesh.cellCenters()

plot(xfc[where(mesh.exteriorFaces == False)],yfc[where(mesh.exteriorFaces == False)],'ro', label='inside')    
plot(xfc[where(mesh.exteriorFaces == True)],yfc[where(mesh.exteriorFaces == True)],'ko', label='surface')    
legend() 

IdentifiedSurfaceCells

Nevertheless i am still searching for an answer on how to access the gmsh code from outside, but maybe this helps others:)

mcghgb
  • 25
  • 1
  • 5
  • The example code you quoted shows how to address boundary faces. What is it that you don't understand? Why doesn't this approach work for you? – jeguyer Jan 06 '20 at 15:30
  • the quoted code is the corresponding gmsh code. I would like to adress the pyhsical face "Outer" from within the python code – mcghgb Jan 06 '20 at 16:35

1 Answers1

1

"Outer" is not a physical face, it is a set of physical cells. To access the bounding faces of "Outer", you can add

Physical Line("Outer Boundary") = {1, 2, 3, 4, 5, 6, 7, 8};

to your Gmsh script, and then apply a constraint with

var.constrain(value, where=squaredCircle.physicalFaces["Outer Boundary"])

As you found, you can always access mesh.exteriorFaces to get the faces that define the boundaries of the entire mesh (i.e., faces which only have a cell on one side). The Gmsh domains defined with Physical Surface are not necessarily bounded by mesh.exteriorFaces.

jeguyer
  • 2,379
  • 1
  • 11
  • 15