FELiCS.SpaceDisc.FELiCSMesh#
Module Contents#
Classes#
Wrapper class for the DOLFINx mesh, with support for custom coordinate systems |
|
Refined export mesh built from a base |
Attributes#
- FELiCS.SpaceDisc.FELiCSMesh.comm#
- FELiCS.SpaceDisc.FELiCSMesh.logger#
- class FELiCS.SpaceDisc.FELiCSMesh.FELiCSMesh(coordinateSystemName, meshFileName=None, gdim=None, m=0, inputMesh=None)#
Wrapper class for the DOLFINx mesh, with support for custom coordinate systems and FELiCS-specific utilities.
This class allows loading and saving of mesh data, extraction of cell and coordinate information, and computation of connectivity for use in FEM simulations. It supports both Cartesian and Cylindrical coordinate systems and provides functionality to convert and export mesh data in a FELiCS HDF5-based format.
Initialize the FELiCSMesh object
- Parameters:
coordinateSystemName (
str) – Name of the coordinate system ("Cartesian"or"Cylindrical").meshFileName (
str, optional) – Path to the Gmsh mesh file to load. Ignored ifinputMeshis given.gdim (
int, optional) – Geometric dimension of the mesh. IfNoneand a mesh file is read, it is inferred from the Gmsh model.m (
int, optional) – Spectral wave number used in the associatedCoordinateSystem. If nonzero, the logical dimensiondimis set togdim + 1.inputMesh (
dolfinx.mesh.Mesh, optional) – Existing DOLFINx mesh object to wrap instead of reading from a file. In this case,meshFileNameand Gmsh are not used.
- Variables:
dolfinxMesh (
dolfinx.mesh.Mesh) – The wrapped DOLFINx mesh object.facet_tags (
dolfinx.mesh.MeshTagsorNone) – Boundary facet tags parsed from the Gmsh model when a mesh file is read. Not set when the mesh is provided viainputMesh.gdim (
int) – Geometric dimension of the mesh.dim (
int) – Logical dimension of the system, including a possible spectral dimension (dim == gdimifm == 0).coordinateSystemName (
str) – Name of the selected coordinate system.coordinateSystem (
CoordinateSystem) – Tensor-based coordinate system initialized for the mesh.meshCells (
numpy.ndarray) – Array containing the cell connectivity in FELiCS ordering; populated bycalcConnectivity().
- property exportMesh#
Lazy-loaded refined export mesh for exporting simulation results.
On first access, a uniformly refined P1 mesh is created from this instance and wrapped in an
ExportMesh. Subsequent accesses return the cached export mesh.- Returns:
An
ExportMeshinstance associated with this base mesh.- Return type:
- property coordinateSystem#
Coordinate system object associated with the mesh.
- Returns:
Tensor-based coordinate system initialized for the mesh.
- Return type:
CoordinateSystem
- property axisNames#
Names of the axes in the coordinate system. These include both spectral and mesh dimensions. Currently implemented systems are:
Cartesian: [‘x’, ‘y’, ‘z’]
Cylindrical: [‘x’, ‘r’, ‘t’]
- Returns:
List of coordinate names (e.g., [‘x’, ‘y’, ‘z’]).
- Return type:
listofstr
- property meshAxisNames#
Names of the axes in the mesh’s coordinate system. Currently implemented systems are:
Cartesian: [‘x’, ‘y’, ‘z’]
Cylindrical: [‘x’, ‘r’, ‘t’]
- Returns:
List of coordinate names (e.g., [‘x’, ‘y’, ‘z’]).
- Return type:
listofstr
- setTrueDimension(dim)#
Set the true dimension of the system, updating the coordinate system.
This must be called if a spectral dimension is included, in which case the true dimension is higher than the geometrical dimension of the mesh.
- Parameters:
dim (
int) – True dimension of the system, including a possible spectral dimension.
- saveInFELiCSFormat(filename)#
Save the refined (export) mesh in the FELiCS HDF5-based format.
The method uses the lazily constructed
exportMeshto obtain a refined P1 mesh, then writes its vertex coordinates and triangular cell connectivity to an HDF5 file.- Parameters:
filename (
str) – Path to the output HDF5 file where the mesh will be saved.
- calcConnectivity()#
Compute and update the internal mesh cell connectivity array.
The connectivity is extracted from the DOLFINx topology and stored in
meshCellsas an(n_cells, n_vertices_per_cell)array.
- cells()#
Returns the cell connectivity array of the mesh.
- Returns:
Array of mesh cells with vertex indices.
- Return type:
numpy.ndarray
- coordinates()#
Retrieves the vertex coordinates of the mesh.
- Returns:
Array of vertex coordinates, truncated to the mesh’s geometric dimension.
- Return type:
numpy.ndarray
- getBCInfo()#
Retrieve boundary condition tags and corresponding boundary facets.
- Returns:
numpy.ndarray– Unique boundary condition IDs.dolfinx.mesh.MeshTags– Mesh tags object representing the boundary facets.
- class FELiCS.SpaceDisc.FELiCSMesh.ExportMesh(base_mesh: FELiCSMesh)#
Bases:
FELiCSMeshRefined export mesh built from a base
FELiCSMesh.This subclass creates a uniformly refined P1 mesh from an existing
FELiCSMeshinstance. It is primarily used for exporting simulation results on a finer mesh than the one used for computation.