FESTIM
FESTIM copied to clipboard
Default behaviour when users only pass mesh without markers
I think it would be interesting to have a default behaviour when users only pass a mesh (cells) but no surface or volume markers.
The behaviour could be to tag all cells with 1 and tag all surfaces with 1.
- Usage
import fenics as f
# example 2D mesh
nx = ny = 10
fenics_mesh = f.UnitSquareMesh(nx, ny)
my_mesh = F.Mesh(fenics_mesh)
- Example of tagging non-1D meshes
import fenics as f
# example 2D mesh
nx = ny = 10
fenics_mesh = f.UnitSquareMesh(nx, ny)
# create volume_markers and tag all cells with 1
volume_markers = f.MeshFunction("size_t", fenics_mesh, fenics_mesh.topology().dim())
volume_markers.set_all(1)
# create surface_markers and tag the boundary facets with 1
surface_markers = f.MeshFunction(
"size_t", fenics_mesh, fenics_mesh.topology().dim() - 1
)
# tag all facets with 0
surface_markers.set_all(0)
# tag boundary with 1
class Boundary(f.SubDomain):
def inside(self, x, on_boundary):
return on_boundary
boundary = Boundary()
boundary.mark(surface_markers, 1)
- Where the change would go
We would add a new
Meshmethoddefine_markers()doing what's described above. Note: this method would be overwritten byMesh1DandMeshFromXDMF.
In this method of Mesh we could have a check if self.surface_markers == None and then call self.define_markers()
https://github.com/festim-dev/FESTIM/blob/31864c86690750ab854942c82110c3f711187246/festim/meshing/mesh.py#L34-L38
💡In 2D we could tag each surface (top, bottom, left right) with an index and document it
#755 is in this direction