API Reference#

class cardiac_geometries.Geometry(mesh: dolfinx.mesh.Mesh, markers: dict[str, tuple[int, int]] = <factory>, cfun: dolfinx.mesh.MeshTags | None = None, ffun: dolfinx.mesh.MeshTags | None = None, efun: dolfinx.mesh.MeshTags | None = None, vfun: dolfinx.mesh.MeshTags | None = None, f0: dolfinx.fem.function.Function | None = None, s0: dolfinx.fem.function.Function | None = None, n0: dolfinx.fem.function.Function | None = None, info: dict[str, typing.Any] = <factory>, additional_data: dict[str, dolfinx.mesh.MeshTags | dolfinx.fem.function.Function] = <factory>, quadrature_degree: int = 4)[source]#
property ds#

Surface measure for the mesh using the facet function ffun if it exists as subdomain data.

property dx#

Volume measure for the mesh using the cell function cfun if it exists as subdomain data.

property facet_normal: FacetNormal#

Facet normal vector for the mesh.

classmethod from_file(comm: Comm, path: str | Path, ghost_mode: GhostMode = GhostMode.none, backend: str | None = None) → Geometry[source]#

Read geometry from a file using io4dolfinx.

Parameters:
  • comm (MPI.Comm) – The MPI communicator to use for reading the mesh.

  • path (str | Path) – The path to the file containing the geometry data.

  • ghost_mode (dolfinx.mesh.GhostMode, optional) – The ghost mode to use when reading the mesh, by default dolfinx.mesh.GhostMode.none. Note that if you need to refine the mesh later, you should use dolfinx.mesh.GhostMode.none.

  • backend (str | None, optional) – The io4dolfinx backend, “adios2” or “h5py”. By default it is inferred from the suffix of path (.h5 gives h5py, otherwise adios2).

Returns:

An instance of the Geometry class containing the mesh, markers, and functions.

Return type:

Geometry

classmethod from_folder(comm: Comm, folder: str | Path, ghost_mode: GhostMode = GhostMode.none) → Geometry[source]#

Read geometry from a folder containing mesh and markers files.

Parameters:
  • comm (MPI.Comm) – The MPI communicator to use for reading the mesh and markers.

  • folder (str | Path) – The path to the folder containing the geometry data.

  • ghost_mode (dolfinx.mesh.GhostMode, optional) – The ghost mode to use when reading the mesh, by default dolfinx.mesh.GhostMode.none. Note that if you need to refine the mesh later, you should use dolfinx.mesh.GhostMode.none.

Returns:

An instance of the Geometry class containing the mesh, markers, and functions.

Return type:

Geometry

Raises:

ValueError – If the required mesh file is not found in the specified folder.

refine(n=1, outdir: Path | None = None) → Geometry[source]#

Refine the mesh and transfer the meshtags to new geometry. Also regenerate fibers if self.info is found. If self.info is not found, it currently raises a NotImplementedError, however fiber could be interpolated from the old mesh to the new mesh but this will result in a loss of information about the fiber orientation.

Parameters:
  • n (int, optional) – Number of times to refine the mesh, by default 1

  • outdir (Path | None, optional) – Output directory to save the refined mesh and meshtags, by default None in which case the mesh is not saved.

Returns:

A new Geometry object with the refined mesh and updated meshtags.

Return type:

Geometry

Raises:

NotImplementedError – If self.info is not found, indicating that fiber interpolation after refinement is not implemented yet.

rotate(target_normal, base_marker)[source]#

Rotate the geometry so that the base normal aligns with the target normal.

Parameters:
  • target_normal (np.ndarray) – The target normal vector to align the base normal with.

  • base_marker (str) – The marker for the base of the geometry.

Returns:

The rotated Geometry object. Only returned if inplace is False.

Return type:

Geometry

save(path: str | Path, backend: str | None = None) → None[source]#

Save the geometry to a file using io4dolfinx.

Parameters:
  • path (str | Path) – The path to the file where the geometry will be saved. The file will be created if it does not exist, or overwritten if it does.

  • backend (str | None, optional) – The io4dolfinx backend, “adios2” or “h5py”. By default it is inferred from the suffix of path (.h5 gives h5py, otherwise adios2).

save_folder(folder: str | Path, backend: str = 'adios2') → None[source]#

Save the geometry to a folder containing mesh and markers files.

Parameters:
  • folder (str | Path) – The path to the folder where the geometry will be saved. The folder will be created if it does not exist.

  • backend (str, optional) – The io4dolfinx backend used for the geometry file, “adios2” (written to geometry.bp) or “h5py” (written to geometry.h5), by default “adios2”.

class cardiac_geometries.geometry.Geometry(mesh: dolfinx.mesh.Mesh, markers: dict[str, tuple[int, int]] = <factory>, cfun: dolfinx.mesh.MeshTags | None = None, ffun: dolfinx.mesh.MeshTags | None = None, efun: dolfinx.mesh.MeshTags | None = None, vfun: dolfinx.mesh.MeshTags | None = None, f0: dolfinx.fem.function.Function | None = None, s0: dolfinx.fem.function.Function | None = None, n0: dolfinx.fem.function.Function | None = None, info: dict[str, typing.Any] = <factory>, additional_data: dict[str, dolfinx.mesh.MeshTags | dolfinx.fem.function.Function] = <factory>, quadrature_degree: int = 4)[source]#
property ds#

Surface measure for the mesh using the facet function ffun if it exists as subdomain data.

property dx#

Volume measure for the mesh using the cell function cfun if it exists as subdomain data.

property facet_normal: FacetNormal#

Facet normal vector for the mesh.

classmethod from_file(comm: Comm, path: str | Path, ghost_mode: GhostMode = GhostMode.none, backend: str | None = None) → Geometry[source]#

Read geometry from a file using io4dolfinx.

Parameters:
  • comm (MPI.Comm) – The MPI communicator to use for reading the mesh.

  • path (str | Path) – The path to the file containing the geometry data.

  • ghost_mode (dolfinx.mesh.GhostMode, optional) – The ghost mode to use when reading the mesh, by default dolfinx.mesh.GhostMode.none. Note that if you need to refine the mesh later, you should use dolfinx.mesh.GhostMode.none.

  • backend (str | None, optional) – The io4dolfinx backend, “adios2” or “h5py”. By default it is inferred from the suffix of path (.h5 gives h5py, otherwise adios2).

Returns:

An instance of the Geometry class containing the mesh, markers, and functions.

Return type:

Geometry

classmethod from_folder(comm: Comm, folder: str | Path, ghost_mode: GhostMode = GhostMode.none) → Geometry[source]#

Read geometry from a folder containing mesh and markers files.

Parameters:
  • comm (MPI.Comm) – The MPI communicator to use for reading the mesh and markers.

  • folder (str | Path) – The path to the folder containing the geometry data.

  • ghost_mode (dolfinx.mesh.GhostMode, optional) – The ghost mode to use when reading the mesh, by default dolfinx.mesh.GhostMode.none. Note that if you need to refine the mesh later, you should use dolfinx.mesh.GhostMode.none.

Returns:

An instance of the Geometry class containing the mesh, markers, and functions.

Return type:

Geometry

Raises:

ValueError – If the required mesh file is not found in the specified folder.

refine(n=1, outdir: Path | None = None) → Geometry[source]#

Refine the mesh and transfer the meshtags to new geometry. Also regenerate fibers if self.info is found. If self.info is not found, it currently raises a NotImplementedError, however fiber could be interpolated from the old mesh to the new mesh but this will result in a loss of information about the fiber orientation.

Parameters:
  • n (int, optional) – Number of times to refine the mesh, by default 1

  • outdir (Path | None, optional) – Output directory to save the refined mesh and meshtags, by default None in which case the mesh is not saved.

Returns:

A new Geometry object with the refined mesh and updated meshtags.

Return type:

Geometry

Raises:

NotImplementedError – If self.info is not found, indicating that fiber interpolation after refinement is not implemented yet.

rotate(target_normal, base_marker)[source]#

Rotate the geometry so that the base normal aligns with the target normal.

Parameters:
  • target_normal (np.ndarray) – The target normal vector to align the base normal with.

  • base_marker (str) – The marker for the base of the geometry.

Returns:

The rotated Geometry object. Only returned if inplace is False.

Return type:

Geometry

save(path: str | Path, backend: str | None = None) → None[source]#

Save the geometry to a file using io4dolfinx.

Parameters:
  • path (str | Path) – The path to the file where the geometry will be saved. The file will be created if it does not exist, or overwritten if it does.

  • backend (str | None, optional) – The io4dolfinx backend, “adios2” or “h5py”. By default it is inferred from the suffix of path (.h5 gives h5py, otherwise adios2).

save_folder(folder: str | Path, backend: str = 'adios2') → None[source]#

Save the geometry to a folder containing mesh and markers files.

Parameters:
  • folder (str | Path) – The path to the folder where the geometry will be saved. The folder will be created if it does not exist.

  • backend (str, optional) – The io4dolfinx backend used for the geometry file, “adios2” (written to geometry.bp) or “h5py” (written to geometry.h5), by default “adios2”.

cardiac_geometries.geometry.IO_BACKEND_SUFFIXES: dict[str, str] = {'adios2': '.bp', 'h5py': '.h5'}#

io4dolfinx backends that support checkpointing (mesh, meshtags and functions), mapped to the file suffix used for the geometry file.

cardiac_geometries.geometry.geometry_path(folder: str | Path, backend: str = 'adios2') → Path[source]#

Path of the geometry file in folder written with backend, i.e. geometry.bp for adios2 and geometry.h5 for h5py.

cardiac_geometries.geometry.infer_io_backend(path: str | Path) → str[source]#

Infer the io4dolfinx backend from the suffix of path, defaulting to adios2 for unknown suffixes.

cardiac_geometries.geometry.save_geometry(path: Path, mesh: Mesh, markers: dict[str, tuple[int, int]] | None = None, info: dict[str, Any] | None = None, cfun: MeshTags | None = None, ffun: MeshTags | None = None, efun: MeshTags | None = None, vfun: MeshTags | None = None, f0: Function | None = None, s0: Function | None = None, n0: Function | None = None, additional_data: dict[str, MeshTags | Function] | None = None, backend: str | None = None) → None[source]#

Save a geometry to path using io4dolfinx.

backend is the io4dolfinx backend (“adios2” or “h5py”). If None it is inferred from the suffix of path (.h5/.hdf5 gives h5py, otherwise adios2).

cardiac_geometries.mesh.biv_ellipsoid(outdir: str | ~pathlib.Path, char_length: float = 0.5, base_cut_z: float = 1.0, box_size: float = 20.0, rv_wall_thickness: float = 0.4, lv_wall_thickness: float = 0.5, rv_offset_x: float = 1.0, lv_radius_x: float = 2.2, lv_radius_y: float = 2.2, lv_radius_z: float = 4.5, rv_radius_x: float = 3.2, rv_radius_y: float = 2.3, rv_radius_z: float = 4.3, create_fibers: bool = False, fiber_angle_endo: float = 60, fiber_angle_epi: float = -60, fiber_space: str = 'P_1', verbose: bool = False, order: int = 1, comm: ~mpi4py.MPI.Comm = <mpi4py.MPI.Intracomm object>, ghost_mode: ~dolfinx.cpp.mesh.GhostMode = GhostMode.none, io_backend: str = 'adios2') → Geometry[source]#

Create BiV ellipsoidal geometry

Parameters:
  • outdir (str | Path) – Directory where to save the results.

  • char_length (float, optional) – Characteristic length of mesh, by default 0.5

  • box_size (float, optional) – Size of the cutting box, by default 20.0

  • lv_radius_x (float, optional) – Radius of the left ventricle in the x-direction, by default 2.2

  • lv_radius_y (float, optional) – Radius of the left ventricle in the y-direction, by default 2.2

  • lv_radius_z (float, optional) – Radius of the left ventricle in the z-direction, by default 4.5

  • rv_radius_x (float, optional) – Radius of the right ventricle in the x-direction, by default 3.2

  • rv_radius_y (float, optional) – Radius of the right ventricle in the y-direction, by default 2.3

  • rv_radius_z (float, optional) – Radius of the right ventricle in the z-direction, by default 4.3

  • create_fibers (bool, optional) – If True create analytic fibers, by default False

  • fiber_angle_endo (float, optional) – Angle for the endocardium, by default 60

  • fiber_angle_epi (float, optional) – Angle for the epicardium, by default -60

  • fiber_space (str, optional) – Function space for fibers of the form family_degree, by default “P_1”

  • verbose (bool, optional) – If True print information from gmsh, by default False

  • order (int, optional) – Order of the mesh elements. With order higher than one the elements are curved to follow the boundaries, by default 1

  • comm (MPI.Comm, optional) – MPI communicator, by default MPI.COMM_WORLD

  • ghost_mode (dolfinx.mesh.GhostMode, optional) – Ghost mode for the dolfinx mesh, by default dolfinx.mesh.GhostMode.none

  • io_backend (str, optional) – io4dolfinx backend used to write the geometry, “adios2” (geometry.bp) or “h5py” (geometry.h5), by default “adios2”

Returns:

A Geometry with the mesh, markers, markers functions and fibers.

Return type:

cardiac_geometries.geometry.Geometry

cardiac_geometries.mesh.cylinder(outdir: ~pathlib.Path | str, r_inner: float = 10.0, r_outer: float = 15.0, height: float = 40.0, floor_thickness: float = 0.0, roof_thickness: float = 0.0, char_length: float = 5.0, create_fibers: bool = False, fiber_angle_endo: float = 60, fiber_angle_epi: float = -60, fiber_space: str = 'P_1', aha: bool = False, verbose: bool = False, order: int = 1, comm: ~mpi4py.MPI.Comm = <mpi4py.MPI.Intracomm object>, ghost_mode: ~dolfinx.cpp.mesh.GhostMode = GhostMode.none, io_backend: str = 'adios2') → Geometry[source]#

Create a cylindrical geometry

Parameters:
  • outdir (Optional[Path], optional) – Directory where to save the results.

  • r_inner (float, optional) – Radius on the endocardium layer, by default 10.0

  • r_outer (float, optional) – Radius on the epicardium layer, by default 15.0

  • height (float, optional) – Longest radius on the endocardium layer, by default 40.0

  • floor_thickness (float, optional) – Thickness of the floor, by default 0.0

  • roof_thickness (float, optional) – Thickness of the roof, by default 0.0

  • char_length (float, optional) – Characteristic length of mesh, by default 5.0

  • create_fibers (bool, optional) – If True create analytic fibers, by default False

  • fiber_angle_endo (float, optional) – Angle for the endocardium, by default 60

  • fiber_angle_epi (float, optional) – Angle for the epicardium, by default -60

  • fiber_space (str, optional) – Function space for fibers of the form family_degree, by default “P_1”

  • aha (bool, optional) – If True create 17-segment AHA regions

  • verbose (bool, optional) – If True print information from gmsh, by default False

  • order (int, optional) – Order of the mesh elements. With order higher than one the elements are curved to follow the boundaries, by default 1

  • comm (MPI.Comm, optional) – MPI communicator, by default MPI.COMM_WORLD

  • ghost_mode (dolfinx.mesh.GhostMode, optional) – Ghost mode for the dolfinx mesh, by default dolfinx.mesh.GhostMode.none

  • io_backend (str, optional) – io4dolfinx backend used to write the geometry, “adios2” (geometry.bp) or “h5py” (geometry.h5), by default “adios2”

Returns:

A Geometry with the mesh, markers, markers functions and fibers.

Return type:

cardiac_geometries.geometry.Geometry

cardiac_geometries.mesh.cylinder_D_shaped(outdir: ~pathlib.Path | str, r_inner: float = 13.0, r_outer: float = 20.0, height: float = 40.0, inner_flat_face_distance: float = 10.0, outer_flat_face_distance: float = 17.0, floor_thickness: float = 0.0, roof_thickness: float = 0.0, char_length: float = 10.0, create_fibers: bool = False, fiber_angle_endo: float = 60, fiber_angle_epi: float = -60, fiber_space: str = 'P_1', aha: bool = False, fillet_radius: float | None = None, verbose: bool = False, order: int = 1, comm: ~mpi4py.MPI.Comm = <mpi4py.MPI.Intracomm object>, ghost_mode: ~dolfinx.cpp.mesh.GhostMode = GhostMode.none, io_backend: str = 'adios2') → Geometry[source]#

Create a D-shaped thick cylindrical shell mesh using GMSH.

Both the inner and outer surfaces have two flat faces on opposite sides.

Parameters:
  • outdir (Optional[Path], optional) – Directory where to save the results.

  • r_inner (float, optional) – Radius on the endocardium layer, by default 13.0

  • r_outer (float, optional) – Radius on the epicardium layer, by default 20.0

  • height (float, optional) – Longest radius on the endocardium layer, by default 10.0

  • inner_flat_face_distance (float) – The distance of the inner flat face from the center (along the x-axis). This value must be less than inner_radius. Default is 10.0.

  • outer_flat_face_distance (float) – The distance of the outer flat face from the center (along the x-axis). This value must be less than outer_radius. Default is 17.0.

  • floor_thickness (float, optional) – Thickness of the floor, by default 0.0

  • roof_thickness (float, optional) – Thickness of the roof, by default 0.0

  • char_length (float, optional) – Characteristic length of mesh, by default 10.0

  • create_fibers (bool, optional) – If True create analytic fibers, by default False

  • fiber_angle_endo (float, optional) – Angle for the endocardium, by default 60

  • fiber_angle_epi (float, optional) – Angle for the epicardium, by default -60

  • fiber_space (str, optional) – Function space for fibers of the form family_degree, by default “P_1”

  • aha (bool, optional) – If True create 17-segment AHA regions

  • fillet_radius (float | None, optional) – Radius for the fillet on the flat faces. If None no fillet is created. By default None.

  • verbose (bool, optional) – If True print information from gmsh, by default False

  • order (int, optional) – Order of the mesh elements. With order higher than one the elements are curved to follow the boundaries, by default 1

  • comm (MPI.Comm, optional) – MPI communicator, by default MPI.COMM_WORLD

  • ghost_mode (dolfinx.mesh.GhostMode, optional) – Ghost mode for the dolfinx mesh, by default dolfinx.mesh.GhostMode.none

  • io_backend (str, optional) – io4dolfinx backend used to write the geometry, “adios2” (geometry.bp) or “h5py” (geometry.h5), by default “adios2”

Returns:

A Geometry with the mesh, markers, markers functions and fibers.

Return type:

cardiac_geometries.geometry.Geometry

cardiac_geometries.mesh.cylinder_elliptical(outdir: ~pathlib.Path | str, r_inner_x: float = 10.0, r_inner_y: float = 10.0, r_outer_x: float = 20.0, r_outer_y: float = 20.0, height: float = 40.0, char_length: float = 10.0, create_fibers: bool = False, fiber_angle_endo: float = 60, fiber_angle_epi: float = -60, fiber_space: str = 'P_1', aha: bool = False, verbose: bool = False, order: int = 1, comm: ~mpi4py.MPI.Comm = <mpi4py.MPI.Intracomm object>, io_backend: str = 'adios2') → Geometry[source]#

Create a cylindrical geometry

Parameters:
  • outdir (Optional[Path], optional) – Directory where to save the results.

  • r_inner_x (float, optional) – Radius on the endocardium layer along the x-axis, by default 10.0

  • r_inner_y (float, optional) – Radius on the endocardium layer along the y-axis, by default 10.0

  • r_outer_x (float, optional) – Radius on the epicardium layer along the x-axis, by default 20.0

  • r_outer_y (float, optional) – Radius on the epicardium layer along the y-axis, by default 20.0

  • height (float, optional) – Longest radius on the endocardium layer, by default 10.0

  • char_length (float, optional) – Characteristic length of mesh, by default 10.0

  • create_fibers (bool, optional) – If True create analytic fibers, by default False

  • fiber_angle_endo (float, optional) – Angle for the endocardium, by default 60

  • fiber_angle_epi (float, optional) – Angle for the epicardium, by default -60

  • fiber_space (str, optional) – Function space for fibers of the form family_degree, by default “P_1”

  • aha (bool, optional) – If True create 17-segment AHA regions

  • verbose (bool, optional) – If True print information from gmsh, by default False

  • order (int, optional) – Order of the mesh elements. With order higher than one the elements are curved to follow the boundaries, by default 1

  • comm (MPI.Comm, optional) – MPI communicator, by default MPI.COMM_WORLD

  • io_backend (str, optional) – io4dolfinx backend used to write the geometry, “adios2” (geometry.bp) or “h5py” (geometry.h5), by default “adios2”

Returns:

A Geometry with the mesh, markers, markers functions and fibers.

Return type:

cardiac_geometries.geometry.Geometry

cardiac_geometries.mesh.cylinder_racetrack(outdir: ~pathlib.Path | str, r_inner: float = 13.0, r_outer: float = 20.0, height: float = 40.0, inner_flat_face_distance: float = 10.0, outer_flat_face_distance: float = 17.0, char_length: float = 10.0, create_fibers: bool = False, fiber_angle_endo: float = 60, fiber_angle_epi: float = -60, fiber_space: str = 'P_1', aha: bool = False, fillet_radius: float | None = None, verbose: bool = False, order: int = 1, comm: ~mpi4py.MPI.Comm = <mpi4py.MPI.Intracomm object>, ghost_mode: ~dolfinx.cpp.mesh.GhostMode = GhostMode.none, io_backend: str = 'adios2') → Geometry[source]#

Create a racetrack-shaped thick cylindrical shell mesh using GMSH.

Both the inner and outer surfaces have two flat faces on opposite sides.

Parameters:
  • outdir (Optional[Path], optional) – Directory where to save the results.

  • r_inner (float, optional) – Radius on the endocardium layer, by default 13.0

  • r_outer (float, optional) – Radius on the epicardium layer, by default 20.0

  • height (float, optional) – Longest radius on the endocardium layer, by default 10.0

  • inner_flat_face_distance (float) – The distance of the inner flat face from the center (along the x-axis). This value must be less than inner_radius. Default is 10.0.

  • outer_flat_face_distance (float) – The distance of the outer flat face from the center (along the x-axis). This value must be less than outer_radius. Default is 17.0.

  • char_length (float, optional) – Characteristic length of mesh, by default 10.0

  • create_fibers (bool, optional) – If True create analytic fibers, by default False

  • fiber_angle_endo (float, optional) – Angle for the endocardium, by default 60

  • fiber_angle_epi (float, optional) – Angle for the epicardium, by default -60

  • fiber_space (str, optional) – Function space for fibers of the form family_degree, by default “P_1”

  • aha (bool, optional) – If True create 17-segment AHA regions

  • fillet_radius (float | None, optional) – Radius for the fillet on the flat faces. If None no fillet is created. By default None.

  • verbose (bool, optional) – If True print information from gmsh, by default False

  • order (int, optional) – Order of the mesh elements. With order higher than one the elements are curved to follow the boundaries, by default 1

  • comm (MPI.Comm, optional) – MPI communicator, by default MPI.COMM_WORLD

  • ghost_mode (dolfinx.mesh.GhostMode, optional) – Ghost mode for the dolfinx mesh, by default dolfinx.mesh.GhostMode.none

  • io_backend (str, optional) – io4dolfinx backend used to write the geometry, “adios2” (geometry.bp) or “h5py” (geometry.h5), by default “adios2”

Returns:

A Geometry with the mesh, markers, markers functions and fibers.

Return type:

cardiac_geometries.geometry.Geometry

cardiac_geometries.mesh.doste_markers(markers: dict[str, tuple[int, int]]) → dict[str, list[int]][source]#

Markers for the method of Doste et al. (ldrb.dolfinx_doste) from the markers of the UKB geometries (ukb-atlas >= 2.0), which need the valves.

cardiac_geometries.mesh.from_volume(outdir: str | ~pathlib.Path, volume, surfaces: dict | None = None, rule=None, rule_data: list[str] | None = None, scale: float = 1.0, tol: float | None = None, comm: ~mpi4py.MPI.Comm = <mpi4py.MPI.Intracomm object>, create_fibers: bool = False, fiber_method: str = 'ldrb', fiber_space: str = 'P_1', fiber_angle_endo: float = 60.0, fiber_angle_epi: float = -60.0, io_backend: str = 'adios2') → Geometry[source]#

A geometry from a tetrahedral volume mesh and labelled boundary surfaces, e.g. a patient mesh made with another tool.

The volume is read with io4dolfinx’s pyvista backend, already distributed, and every boundary facet gets exactly one marker, either from the surface meshes in surfaces (marker name to a file pyvista reads, e.g. PLY; a facet gets the name of the surface with a triangle on its three vertices) or from rule (see cardiac_geometries.labelled.label_facets()). Use the marker names of the UKB geometries (LV_ENDO, RV_ENDO, EPI, BASE, MV, AV, TV, PV) so the fiber methods find their boundaries: Bayer’s base is BASE plus the valves, and the method of Doste et al. needs the valves.

Parameters:
  • outdir (str | Path) – Folder for the markers and the saved geometry

  • volume (str | Path) – The volume mesh (linear tetrahedra), a file io4dolfinx’s pyvista backend reads (e.g. VTU, VTK)

  • surfaces (dict | None) – Marker name to a triangle surface file

  • rule (Callable | None) – rule(coords, data) returns the marker name of each boundary facet, from its vertex coordinates (F, 3, 3, scaled) and data: the point data named in rule_data at those vertices, each (F, 3)

  • rule_data (list[str] | None) – Names of point data in the volume file that the rule needs

  • scale (float) – Multiplies all coordinates (volume and surfaces), e.g. 1e-3 from micrometres to mm. Never guessed

  • tol (float | None) – Distance within which a surface point matches a facet vertex (after scaling); by default round-off (1e-6 of the surfaces’ size)

  • comm (MPI.Comm) – The communicator

  • create_fibers – As in ukb(): fibers by the method of Bayer et al. (“ldrb”) or Doste et al. (“doste”)

  • fiber_method – As in ukb(): fibers by the method of Bayer et al. (“ldrb”) or Doste et al. (“doste”)

  • fiber_space – As in ukb(): fibers by the method of Bayer et al. (“ldrb”) or Doste et al. (“doste”)

  • fiber_angle_endo – As in ukb(): fibers by the method of Bayer et al. (“ldrb”) or Doste et al. (“doste”)

  • fiber_angle_epi – As in ukb(): fibers by the method of Bayer et al. (“ldrb”) or Doste et al. (“doste”)

  • io_backend (str) – io4dolfinx backend for the saved geometry

Returns:

The mesh, markers, facet tags and (optionally) fibers

Return type:

cardiac_geometries.geometry.Geometry

cardiac_geometries.mesh.lv_ellipsoid(outdir: ~pathlib.Path | str, r_short_endo: float = 7.0, r_short_epi: float = 10.0, r_long_endo: float = 17.0, r_long_epi: float = 20.0, psize_ref: float = 3, mu_apex_endo: float = -3.141592653589793, mu_base_endo: float = -1.2722641256100204, mu_apex_epi: float = -3.141592653589793, mu_base_epi: float = -1.318116071652818, create_fibers: bool = False, fiber_angle_endo: float = 60, fiber_angle_epi: float = -60, fiber_space: str = 'P_1', aha: bool = False, dmu_factor: float = 0.25, verbose: bool = False, order: int = 1, comm: ~mpi4py.MPI.Comm = <mpi4py.MPI.Intracomm object>, ghost_mode: ~dolfinx.cpp.mesh.GhostMode = GhostMode.none, io_backend: str = 'adios2') → Geometry[source]#

Create an LV ellipsoidal geometry

Parameters:
  • outdir (Optional[Path], optional) – Directory where to save the results.

  • r_short_endo (float, optional) – Shortest radius on the endocardium layer, by default 7.0

  • r_short_epi (float, optional) – Shortest radius on the epicardium layer, by default 10.0

  • r_long_endo (float, optional) – Longest radius on the endocardium layer, by default 17.0

  • r_long_epi (float, optional) – Longest radius on the epicardium layer, by default 20.0

  • psize_ref (float, optional) – The reference point size (smaller values yield as finer mesh, by default 3

  • mu_apex_endo (float, optional) – Angle for the endocardial apex, by default -math.pi

  • mu_base_endo (float, optional) – Angle for the endocardial base, by default -math.acos(5 / 17)

  • mu_apex_epi (float, optional) – Angle for the epicardial apex, by default -math.pi

  • mu_base_epi (float, optional) – Angle for the epicardial apex, by default -math.acos(5 / 20)

  • create_fibers (bool, optional) – If True create analytic fibers, by default False

  • fiber_angle_endo (float, optional) – Angle for the endocardium, by default 60

  • fiber_angle_epi (float, optional) – Angle for the epicardium, by default -60

  • fiber_space (str, optional) – Function space for fibers of the form family_degree, by default “P_1”

  • aha (bool, optional) – If True create 17-segment AHA regions

  • dmu_factor (float, optional) – Factor to determine the aha segmentation width, by default 1/4

  • verbose (bool, optional) – If True print information from gmsh, by default False

  • order (int, optional) – Order of the mesh elements. With order higher than one the elements are curved to follow the boundaries, by default 1

  • comm (MPI.Comm, optional) – MPI communicator, by default MPI.COMM_WORLD

  • ghost_mode (dolfinx.mesh.GhostMode, optional) – Ghost mode for the dolfinx mesh, by default dolfinx.mesh.GhostMode.none

  • io_backend (str, optional) – io4dolfinx backend used to write the geometry, “adios2” (geometry.bp) or “h5py” (geometry.h5), by default “adios2”

Returns:

A Geometry with the mesh, markers, markers functions and fibers.

Return type:

cardiac_geometries.geometry.Geometry

cardiac_geometries.mesh.lv_ellipsoid_2D(outdir: ~pathlib.Path | str, r_short_endo: float = 7.0, r_short_epi: float = 10.0, r_long_endo: float = 17.0, r_long_epi: float = 20.0, psize_ref: float = 3, mu_apex_endo: float = 3.141592653589793, mu_base_endo: float = 1.2722641256100204, mu_apex_epi: float = 3.141592653589793, mu_base_epi: float = 1.318116071652818, create_fibers: bool = False, fiber_angle_endo: float = 60, fiber_angle_epi: float = -60, fiber_space: str = 'P_1', verbose: bool = False, order: int = 1, comm: ~mpi4py.MPI.Comm = <mpi4py.MPI.Intracomm object>, ghost_mode: ~dolfinx.cpp.mesh.GhostMode = GhostMode.none, io_backend: str = 'adios2') → Geometry[source]#

Create the meridian of an LV ellipsoid, for axisymmetric problems

The mesh lies in the plane z = 0, with the long axis along x and the radial direction along y, and has geometric dimension 2. The angles mu must be in [0, pi] so that y = r_short sin(mu) >= 0: unlike lv_ellipsoid, whose default angles are negative, the defaults here give the same ellipsoid with the meridian in the upper half plane. APEX marks the segment of the axis between the two apices, where an axisymmetric problem needs its symmetry condition.

The fibers have three components: the axial, the radial and the circumferential one. The fiber angle varies linearly in the transmural coordinate of the ellipsoid itself (see cardiac_geometries.fibers.lv_ellipsoid.transmural_coordinate), as a planar Laplace problem on the meridian is not the axisymmetric one.

Parameters:
  • outdir (Optional[Path], optional) – Directory where to save the results.

  • r_short_endo (float, optional) – Shortest radius on the endocardium layer, by default 7.0

  • r_short_epi (float, optional) – Shortest radius on the epicardium layer, by default 10.0

  • r_long_endo (float, optional) – Longest radius on the endocardium layer, by default 17.0

  • r_long_epi (float, optional) – Longest radius on the epicardium layer, by default 20.0

  • psize_ref (float, optional) – The reference point size (smaller values yield as finer mesh, by default 3

  • mu_apex_endo (float, optional) – Angle for the endocardial apex, by default math.pi

  • mu_base_endo (float, optional) – Angle for the endocardial base, by default math.acos(5 / 17)

  • mu_apex_epi (float, optional) – Angle for the epicardial apex, by default math.pi

  • mu_base_epi (float, optional) – Angle for the epicardial base, by default math.acos(5 / 20)

  • create_fibers (bool, optional) – If True create analytic fibers, by default False

  • fiber_angle_endo (float, optional) – Angle for the endocardium, by default 60

  • fiber_angle_epi (float, optional) – Angle for the epicardium, by default -60

  • fiber_space (str, optional) – Function space for fibers of the form family_degree, by default “P_1”

  • verbose (bool, optional) – If True print information from gmsh, by default False

  • order (int, optional) – Order of the mesh elements. With order higher than one the elements are curved to follow the boundaries, by default 1

  • comm (MPI.Comm, optional) – MPI communicator, by default MPI.COMM_WORLD

  • ghost_mode (dolfinx.mesh.GhostMode, optional) – Ghost mode for the dolfinx mesh, by default dolfinx.mesh.GhostMode.none

  • io_backend (str, optional) – io4dolfinx backend used to write the geometry, “adios2” (geometry.bp) or “h5py” (geometry.h5), by default “adios2”

Returns:

A Geometry with the mesh, markers, markers functions and fibers.

Return type:

cardiac_geometries.geometry.Geometry

cardiac_geometries.mesh.slab(outdir: ~pathlib.Path | str, lx: float = 20.0, ly: float = 7.0, lz: float = 3.0, dx: float = 1.0, create_fibers: bool = True, fiber_angle_endo: float = 60, fiber_angle_epi: float = -60, fiber_space: str = 'P_1', verbose: bool = False, use_dolfinx: bool = False, order: int = 1, comm: ~mpi4py.MPI.Comm = <mpi4py.MPI.Intracomm object>, ghost_mode: ~dolfinx.cpp.mesh.GhostMode = GhostMode.none, io_backend: str = 'adios2') → Geometry[source]#

Create slab geometry

Parameters:
  • outdir (Optional[Path], optional) – Directory where to save the results.

  • lx (float, optional) – Length of slab the x-direction, by default 20.0

  • ly (float, optional) – Length of slab the x-direction, by default 7.0

  • lz (float, optional) – Length of slab the z-direction, by default 3.0

  • dx (float, optional) – Element size, by default 1.0

  • create_fibers (bool, optional) – If True create analytic fibers, by default True

  • fiber_angle_endo (float, optional) – Angle for the endocardium, by default 60

  • fiber_angle_epi (float, optional) – Angle for the epicardium, by default -60

  • fiber_space (str, optional) – Function space for fibers of the form family_degree, by default “P_1”

  • verbose (bool, optional) – If True print information from gmsh, by default False

  • use_dolfinx (bool, optional) – If True use dolfinx to create the mesh, by default False (gmsh)

  • order (int, optional) – Order of the mesh elements. With order higher than one the elements are curved to follow the boundaries, by default 1

  • comm (MPI.Comm, optional) – MPI communicator, by default MPI.COMM_WORLD

  • ghost_mode (dolfinx.mesh.GhostMode, optional) – Ghost mode for the dolfinx mesh, by default dolfinx.mesh.GhostMode.none

  • io_backend (str, optional) – io4dolfinx backend used to write the geometry, “adios2” (geometry.bp) or “h5py” (geometry.h5), by default “adios2”

Returns:

A Geometry with the mesh, markers, markers functions and fibers.

Return type:

cardiac_geometries.geometry.Geometry

cardiac_geometries.mesh.slab_in_bath(outdir: ~pathlib.Path | str, lx: float = 1.0, ly: float = 0.01, lz: float = 0.5, bx: float = 0.0, by: float = 0.0, bz: float = 0.1, dx: float = 0.001, verbose: bool = False, order: int = 1, comm: ~mpi4py.MPI.Comm = <mpi4py.MPI.Intracomm object>, ghost_mode: ~dolfinx.cpp.mesh.GhostMode = GhostMode.none, io_backend: str = 'adios2') → Geometry[source]#

Create slab geometry

Parameters:
  • outdir (Path) – Directory where to save the results.

  • lx (float, optional) – Length of slab the x-direction, by default 1.0

  • ly (float, optional) – Length of slab the x-direction, by default 0.5

  • lz (float, optional) – Length of slab the z-direction, by default 0.01

  • bx (float, optional) – Thickness of bath the x-direction, by default 0.0

  • by (float, optional) – Thickness of bath the x-direction, by default 0.0

  • bz (float, optional) – Thickness of bath the z-direction, by default 0.1

  • dx (float, optional) – Element size, by default 0.001

  • verbose (bool, optional) – If True print information from gmsh, by default False

  • order (int, optional) – Order of the mesh elements. With order higher than one the elements are curved to follow the boundaries, by default 1

  • comm (MPI.Comm, optional) – MPI communicator, by default MPI.COMM_WORLD

  • ghost_mode (dolfinx.mesh.GhostMode, optional) – Ghost mode for the dolfinx mesh, by default dolfinx.mesh.GhostMode.none

  • io_backend (str, optional) – io4dolfinx backend used to write the geometry, “adios2” (geometry.bp) or “h5py” (geometry.h5), by default “adios2”

Returns:

A Geometry with the mesh, markers, markers functions and fibers.

Return type:

cardiac_geometries.geometry.Geometry

cardiac_geometries.mesh.ukb(outdir: str | ~pathlib.Path, mode: int = -1, std: float = 1.5, case: str = 'ED', char_length_max: float = 5.0, char_length_min: float = 5.0, fiber_angle_endo: float = 60, fiber_angle_epi: float = -60, create_fibers: bool = True, fiber_space: str = 'P_1', clipped: bool = False, use_burns: bool = False, burns_path: ~pathlib.Path | None = None, refine: int = 0, order: int = 1, comm: ~mpi4py.MPI.Comm = <mpi4py.MPI.Intracomm object>, ghost_mode: ~dolfinx.cpp.mesh.GhostMode = GhostMode.none, geometry: str = 'biv', fiber_method: str | None = None, io_backend: str = 'adios2', aha: bool = False, rv_regions: bool = False, rv_septum_fraction: float | None = None) → Geometry[source]#

Create a mesh from the UK-Biobank atlas using the ukb-atlas package.

Parameters:
  • outdir (str | Path) – Directory where to save the results.

  • mode (int, optional) – Mode for the UKB mesh, by default -1

  • std (float, optional) – Standard deviation for the UKB mesh, by default 1.5

  • case (str, optional) – Case for the UKB mesh (either “ED” or “ES”), by default “ED”

  • char_length_max (float, optional) – Maximum characteristic length of the mesh, by default 2.0

  • char_length_min (float, optional) – Minimum characteristic length of the mesh, by default 2.0

  • fiber_angle_endo (float, optional) – Fiber angle for the endocardium, by default 60

  • fiber_angle_epi (float, optional) – Fiber angle for the epicardium, by default -60

  • create_fibers (bool, optional) – If True create rule-based fibers, by default True

  • fiber_space (str, optional) – Function space for fibers of the form family_degree, by default “P_1”

  • clipped (bool, optional) – If True create a clipped mesh, by default False

  • use_burns (bool) – If true, use the atlas from Richard Burns to generate the surfaces. This will override the all parameter and use the burns atlas instead.

  • burns_path (Path | None) – Path to the burns atlas file. This will be a .mat file which will be loaded using scipy.io.loadmat. This needs to be specified if use_burns.

  • refine (int, optional) – Number of times to refine the surfaces of the atlas before meshing, placing the new nodes on smooth surfaces through the nodes of the atlas. This makes meshes of higher order more accurate, by default 0

  • order (int, optional) – Order of the mesh elements. With order higher than one the elements are curved to follow the boundaries, by default 1

  • comm (MPI.Comm, optional) – MPI communicator, by default MPI.COMM_WORLD

  • ghost_mode (dolfinx.mesh.GhostMode, optional) – Ghost mode for the dolfinx mesh, by default dolfinx.mesh.GhostMode.none

  • geometry (str, optional) – Which geometry to create: biventricular (“biv”) or LV only (“lv”), with open valves, or with the valves closed by caps (“biv-closed”, “lv-closed”). The closed geometries also mesh the cavities, which are marked as “LV_CAVITY” and “RV_CAVITY” in the cell tags, while the myocardium is marked as “Wall”. Fibers are only created in the wall. By default “biv”.

  • fiber_method (str | None, optional) – Rule-based method for the fibers: “doste” for the method of Doste et al. (2019), which handles the outflow tracts, or “ldrb” for the method of Bayer et al. (2012). With “doste”, fiber_angle_endo and fiber_angle_epi are the angles in the LV, while the RV and outflow tracts get the angles from the paper. By default “doste”, or “ldrb” for clipped meshes, which have no outflow tracts.

  • io_backend (str, optional) – io4dolfinx backend used to write the geometry, “adios2” (geometry.bp) or “h5py” (geometry.h5), by default “adios2”

  • aha (bool, optional) – If True, the cell tags are the 17 AHA segments of the LV, the RV free wall (“RV”) and the LV above the mitral plane (“LVOT”), see cardiac_geometries.aha.biv_aha(). Only for the “biv” geometry (not clipped), and it needs ukb-atlas >= 2.2 for the landmarks. By default False

  • rv_regions (bool, optional) – If True (with aha), the RV is divided into the 15 regions of Zhong et al. (2012) (tags 18-32) and the septum is split between the LV and the RV by a transventricular Laplace solution; the LV above the mitral plane is 33. See cardiac_geometries.aha.biv_regions(). By default False

  • rv_septum_fraction (float | None, optional) – With rv_regions, the share of the septum, in the transventricular coordinate from the RV side, that belongs to the RV, in [0, 1]: 0 gives the whole septum to the LV, 1 to the RV, 0.5 splits it at the middle (Cobiveco) and 1/3 approximates Doste et al. (2019). Only allowed with rv_regions. By default None, meaning 0.5

Returns:

A Geometry with the mesh, markers, markers functions and fibers.

Return type:

cardiac_geometries.geometry.Geometry

class cardiac_geometries.utils.BaseData(centroid, vector, normal)[source]#
centroid: ndarray[tuple[Any, ...], dtype[float64]]#

Alias for field number 0

count(value, /)#

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)#

Return first index of value.

Raises ValueError if the value is not present.

normal: ndarray[tuple[Any, ...], dtype[float64]]#

Alias for field number 2

vector: ndarray[tuple[Any, ...], dtype[float64]]#

Alias for field number 1

class cardiac_geometries.utils.GMshGeometry(mesh, cfun, ffun, efun, vfun, markers)[source]#
cfun: MeshTags | None#

Alias for field number 1

count(value, /)#

Return number of occurrences of value.

efun: MeshTags | None#

Alias for field number 3

ffun: MeshTags | None#

Alias for field number 2

index(value, start=0, stop=9223372036854775807, /)#

Return first index of value.

Raises ValueError if the value is not present.

markers: dict[str, tuple[int, int]]#

Alias for field number 5

mesh: Mesh#

Alias for field number 0

vfun: MeshTags | None#

Alias for field number 4

cardiac_geometries.utils.compute_base_data(mesh: Mesh, facet_tags: MeshTags, marker) → BaseData[source]#

Compute the centroid, vector and normal of the base

Parameters:
  • mesh (dolfinx.mesh.Mesh) – The mesh

  • facet_tags (dolfinx.mesh.MeshTags) – The facet tags

  • marker (_type_) – Marker for the base

Returns:

NamedTuple containing the centroid, vector and normal of the base

Return type:

BaseData

cardiac_geometries.utils.extract_submesh(mesh: Mesh, cfun: MeshTags, ffun: MeshTags, cell_markers: Iterable[int]) → tuple[Mesh, MeshTags, ndarray[tuple[Any, ...], dtype[int32]]][source]#

Create a submesh of the cells tagged with any of cell_markers.

Returns the submesh, the facet tags of ffun on the submesh, and the parent cell of each (owned and ghost) cell of the submesh.

cardiac_geometries.utils.parse_element(space_string: str, mesh: Mesh, dim: int, discontinuous: bool = False) → _ElementBase[source]#

Parse a string representation of a basix element family

cardiac_geometries.utils.rotate_geometry_and_fields(mesh: Mesh, ffun: MeshTags, base_marker: int, target_normal: Sequence[float] = (1.0, 0.0, 0.0), fields: Sequence[Function] | None = None) → tuple[Mesh, ndarray, list[Function]][source]#

Rotates the mesh and vector fields so that the base normal points in the +x direction.

cardiac_geometries.utils.space_from_string(space_string: str, mesh: Mesh, dim: int, discontinuous: bool = False) → FunctionSpace[source]#

Constructed a finite elements space from a string representation of the space

Parameters:
  • space_string (str) – A string on the form {family}_{degree} which determines the space. Example ‘Lagrange_1’.

  • mesh (df.Mesh) – The mesh

  • dim (int) – 1 for scalar space, 3 for vector space.

  • discontinuous (bool) – If true force element to be discontinuous, by default False

cardiac_geometries.utils.tag_dimensions(tdim: int) → list[tuple[str, str, int]][source]#

The tags of a mesh of topological dimension tdim and the dimension of their entities. A mesh of dimension 2 has no edge tags: its edges are its facets.

cardiac_geometries.utils.transfer_to_parent(u_sub: Function, V: FunctionSpace, parent_cells: ndarray[tuple[Any, ...], dtype[int32]]) → Function[source]#

Copy a function on a submesh into V on the parent mesh, cell by cell.

V must use the same element as the space of u_sub, and parent_cells is the parent cell of each cell of the submesh (see extract_submesh). The degrees of freedom of the parent outside the submesh are zero. The local dofs are copied as is, which is exact for elements whose dofs do not need permuting between the meshes, such as Lagrange of degree at most 2 and quadrature elements.

class cardiac_geometries.fibers.Microstructure(f0, s0, n0)[source]#
count(value, /)#

Return number of occurrences of value.

f0: Function#

Alias for field number 0

index(value, start=0, stop=9223372036854775807, /)#

Return first index of value.

Raises ValueError if the value is not present.

n0: Function#

Alias for field number 2

s0: Function#

Alias for field number 1

cardiac_geometries.fibers.lv_ellipsoid.compute_system(t_func: Function, r_short_endo=0.025, r_short_epi=0.035, r_long_endo=0.09, r_long_epi=0.097, alpha_endo: float = -60, alpha_epi: float = 60, long_axis: int = 0, **kwargs) → Microstructure[source]#

Compute the microstructure for the given time function.

Parameters:
  • t_func (dolfinx.fem.Function) – Solution of the Laplace equation

  • r_short_endo (float, optional) – Short radius at the endocardium, by default 0.025

  • r_short_epi (float, optional) – Short radius at the epicardium, by default 0.035

  • r_long_endo (float, optional) – Long radius at the endocardium, by default 0.09

  • r_long_epi (float, optional) – Long radius at the epicardium, by default 0.097

  • alpha_endo (float, optional) – Angle at the endocardium, by default -60

  • alpha_epi (float, optional) – Angle at the epicardium, by default 60

  • long_axis (int, optional) – Long axis, by default 0 (x-axis)

Returns:

The microstructure

Return type:

utils.Microstructure

cardiac_geometries.fibers.lv_ellipsoid.create_microstructure(mesh, ffun, markers, function_space='P_1', r_short_endo=0.025, r_short_epi=0.035, r_long_endo=0.09, r_long_epi=0.097, alpha_endo: float = -60, alpha_epi: float = 60, long_axis: int = 0, outdir: str | Path | None = None, transmural: str = 'laplace', **kwargs)[source]#

Create the microstructure of an LV ellipsoid.

transmural selects the transmural coordinate the fiber angle varies linearly in: "laplace", the solution of a Laplace problem between ENDO and EPI, or "analytic", the coordinate of the ellipsoid itself (see transmural_coordinate), which is the one of the benchmark of Land et al. (2015). Use "analytic" on the meridian of an axisymmetric geometry, where a planar Laplace problem is not the axisymmetric one.

cardiac_geometries.fibers.lv_ellipsoid.mu_theta(x: ndarray, y: ndarray, z: ndarray, rs: ndarray, rl: ndarray, long_axis: int = 0) → tuple[ndarray, ndarray, list[int]][source]#

Get the angles mu and theta from the coordinates x, y, z given the long axis.

Parameters:
  • x (np.ndarray) – The x-coordinates

  • y (np.ndarray) – The y-coordinates

  • z (np.ndarray) – The z-coordinates

  • rs (np.ndarray) – The short radius

  • rl (np.ndarray) – The long radius

  • long_axis (int, optional) – The long axis, by default 0 (x-axis)

Returns:

The angles mu and theta and the permutation of the axes

Return type:

tuple[np.ndarray, np.ndarray, list[int]]

Raises:

ValueError – If the long axis is not 0, 1 or 2

cardiac_geometries.fibers.lv_ellipsoid.transmural_coordinate(V: FunctionSpace, r_short_endo=0.025, r_short_epi=0.035, r_long_endo=0.09, r_long_epi=0.097, long_axis: int = 0, num_iterations: int = 60) → Function[source]#

The transmural coordinate t in [0, 1] of the ellipsoid, as defined in the benchmark of Land et al. (2015): the point lies on the ellipsoid with radii r_short(t) and r_long(t), interpolated linearly between the endocardium (t = 0) and the epicardium (t = 1).

The root is found by bisection, as (r^2 - x_long^2) / r_short(t)^2 + x_long^2 / r_long(t)^2 - 1 decreases with t. Points just outside the wall get t = 0 or t = 1.

Parameters:
  • V (dolfinx.fem.FunctionSpace) – Scalar function space of the transmural coordinate

  • r_short_endo (float, optional) – Short radius at the endocardium, by default 0.025

  • r_short_epi (float, optional) – Short radius at the epicardium, by default 0.035

  • r_long_endo (float, optional) – Long radius at the endocardium, by default 0.09

  • r_long_epi (float, optional) – Long radius at the epicardium, by default 0.097

  • long_axis (int, optional) – Long axis, by default 0 (x-axis)

  • num_iterations (int, optional) – Number of bisection steps, by default 60

Returns:

The transmural coordinate

Return type:

dolfinx.fem.Function

cardiac_geometries.fibers.slab.compute_system(t_func: Function, alpha_endo: float = -60, alpha_epi: float = 60, endo_epi_axis='y') → Microstructure[source]#

Compute ldrb system for slab, assuming linear angle between endo and epi

Parameters:
  • t_func (dolfin.Function) – Solution to laplace equation with 0 on endo and 1 on epi

  • alpha_endo (float, optional) – Angle on endocardium, by default -60

  • alpha_epi (float, optional) – Angle on epicardium, by default 60

Returns:

Tuple with fiber, sheet and sheet normal

Return type:

Microstructure

cardiac_geometries.fibers.slab.create_microstructure(mesh: Mesh, ffun: MeshTags, markers: dict[str, tuple[int, int]], alpha_endo: float, alpha_epi: float, function_space: str = 'P_1', outdir: str | Path | None = None, **kwargs: dict) → Microstructure[source]#

Generate microstructure for slab using LDRB algorithm

Parameters:
  • mesh (dolfinx.mesh.Mesh) – A slab mesh

  • ffun (dolfinx.mesh.MeshTags) – Facet function defining the boundaries

  • markers (Dict[str, Tuple[int, int]]) – Markers with keys Y0 and Y1 representing the endo and epi planes respectively. The values should be a tuple whose first value is the value of the marker (corresponding to ffun) and the second value is the dimension

  • alpha_endo (float) – Angle on the endocardium

  • alpha_epi (float) – Angle on the epicardium

  • function_space (str) – Function space to interpolate the fibers, by default P_1

  • outdir (Optional[Union[str, Path]], optional) – Output directory to store the results, by default None. If no output directory is specified the results will not be stored, but only returned.

Returns:

Tuple with fiber, sheet and sheet normal

Return type:

Microstructure