FESTIM icon indicating copy to clipboard operation
FESTIM copied to clipboard

Default behaviour when users only pass mesh without markers

Open RemDelaporteMathurin opened this issue 1 year ago • 3 comments

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.

  1. Usage
import fenics as f

# example 2D mesh
nx = ny = 10
fenics_mesh = f.UnitSquareMesh(nx, ny)

my_mesh = F.Mesh(fenics_mesh)
  1. 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)
  1. Where the change would go We would add a new Mesh method define_markers() doing what's described above. Note: this method would be overwritten by Mesh1D and MeshFromXDMF.

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

RemDelaporteMathurin avatar Mar 14 '24 12:03 RemDelaporteMathurin

💡In 2D we could tag each surface (top, bottom, left right) with an index and document it

RemDelaporteMathurin avatar Apr 04 '24 19:04 RemDelaporteMathurin

#755 is in this direction

RemDelaporteMathurin avatar Apr 17 '24 19:04 RemDelaporteMathurin