geometry package¶
Subpackages¶
Submodules¶
geometry.geometry module¶
This library is based on the module pulse.geometry by Henrik Finsberg. It has been extended to account for arbitrary geometries.
-
class
geometry.geometry.
CRLBasis
[source]¶ Bases:
geometry.geometry.CRLBasis
A collection of local basis functions (circumferential, radial, longitudinal).
Parameters: - c0 (
dolfin.function.function.Function
) – A function containing the circumferential basis. - r0 (
dolfin.function.function.Function
) – A function containing the radial basis. - l0 (
dolfin.function.function.Function
) – A function containing the sheet longitudinal basis.
- c0 (
-
geometry.geometry.
CRLBasis_
¶ alias of
geometry.geometry.CRLBasis
-
class
geometry.geometry.
Geometry
(mesh=None, markers=None, markerfunctions=None, microstructure=None, crl_basis=None)[source]¶ Bases:
object
-
c0
¶ Circumferential basis.
-
cfun
¶ Cell mesh function.
-
ds
¶ Returns the mesh surface measure using self.ffun as subdomain_data
-
dx
¶ Returns the mesh volume measure using self.cfun as subdomain_data
-
efun
¶ Edge mesh function. Not available if self.dim() < 3.
-
f0
¶ Fibre microstructure.
-
facet_normal
¶
-
ffun
¶ Facet mesh function.
-
classmethod
from_file
(h5name, h5group='', comm=None)[source]¶ Loads a geometry from a h5 file. The function has to be called from the subclass that should instantiate the geometry
Example
# A 2D geometry is stored in a file "geometry2d.h5" geo = Geometry2D.from_file("geometry2d.h5") # A heart geometry is stored in a file "heart_geometry.h5" geo = HeartGeometry.from_file("heart_geometry.h5")
Parameters: - cls (class) – The class from which the function is called.
- h5name (str) – The path to the h5 file containing the geometry.
- h5group (str) – The h5 group of the geometry.
- comm – MPI communicator.
-
l0
¶ Longitudinal basis.
-
n0
¶ Sheet normals microstructure.
-
r0
¶ Radial basis.
-
s0
¶ Sheet microstructure.
-
save
(h5name, h5group='', other_functions=None, other_attributes=None, overwrite_file=False, overwrite_group=True)[source]¶ Saves a geometry to a h5 file.
Parameters: - h5name (str) – The location and name of the output file without file extension.
- h5group (str) – The h5 group of the geometry.
- other_functions – Extra mesh functions.
- other_attributes – Extra mesh attributes.
- overwrite_file (bool) – True if existing file should be overwritten.
- overwrite_group (bool) – True if existing group should be overwritten.
-
vfun
¶ Vertex mesh function.
-
-
class
geometry.geometry.
Geometry2D
(*args, **kwargs)[source]¶ Bases:
geometry.geometry.Geometry
-
class
geometry.geometry.
HeartGeometry
(*args, **kwargs)[source]¶ Bases:
geometry.geometry.Geometry
-
class
geometry.geometry.
MarkerFunctions
[source]¶ Bases:
geometry.geometry.MarkerFunctions
A collection of mesh marker functions.
Parameters: - vfun (
dolfin.cpp.mesh.MeshFunction
) – A mesh function for vertex markers. - efun (
dolfin.cpp.mesh.MeshFunction
) – A mesh function for edge markers. - ffun (
dolfin.cpp.mesh.MeshFunction
) – A mesh function for facet markers. - cfun (
dolfin.cpp.mesh.MeshFunction
) – A mesh function for cell markers.
- vfun (
-
class
geometry.geometry.
MarkerFunctions2D
[source]¶ Bases:
geometry.geometry.MarkerFunctions2D
A collection of mesh marker functions for 2D geometries.
Parameters: - vfun (
dolfin.cpp.mesh.MeshFunction
) – A mesh function for vertex markers. - ffun (
dolfin.cpp.mesh.MeshFunction
) – A mesh function for facet markers. - cfun (
dolfin.cpp.mesh.MeshFunction
) – A mesh function for cell markers.
- vfun (
-
geometry.geometry.
MarkerFunctions2D_
¶ alias of
geometry.geometry.MarkerFunctions2D
-
geometry.geometry.
MarkerFunctions_
¶ alias of
geometry.geometry.MarkerFunctions
-
class
geometry.geometry.
Microstructure
[source]¶ Bases:
geometry.geometry.Microstructure
A collection of the microstructure fields of the geometry.
Parameters: - f0 (
dolfin.function.function.Function
) – A function containing the fibre field. - s0 (
dolfin.function.function.Function
) – A function containing the sheet field. - s0 (
dolfin.function.function.Function
) – A function containing the sheet normal field.
- f0 (
-
geometry.geometry.
Microstructure_
¶ alias of
geometry.geometry.Microstructure
-
class
geometry.geometry.
MultiGeometry
(geometries=None, labels=None)[source]¶ Bases:
object
-
add_geometry
(geometry, label)[source]¶ Adds a Geometry object to the MultiGeometry. Geometry object must be of the same type as other Geometry objects contained in the MultiGeometry.
Parameters: - geometry (
geometry.Geometry
) – The geometry to add to the MultiGeometry. - label (str) – A label for the geometry.
- geometry (
-
geometry.utils module¶
This library is based on the module pulse.geometry by Henrik Finsberg. It has been extended to account for arbitrary geometries.
-
geometry.utils.
check_h5group
(h5name, h5group, delete=False, comm=<sphinx.ext.autodoc.importer._MockObject object>)[source]¶
-
geometry.utils.
load_geometry_from_h5
(h5name, h5group='', fendo=None, fepi=None, include_sheets=True, comm=<sphinx.ext.autodoc.importer._MockObject object>)[source]¶ Load geometry and other mesh data from a h5file to an object. If the file contains muliple fiber fields you can spefify the angles, and if the file contais sheets and cross-sheets this can also be included
Parameters: - h5name (str) – Name of the h5file
- h5group (str) – The group within the file
- fendo (int) – Helix fiber angle (endocardium) (if available)
- fepi (int) – Helix fiber angle (epicardium) (if available)
- include_sheets (bool) – Include sheets and cross-sheets
Returns: An object with geometry data
Return type: object
-
geometry.utils.
namedtuple_as_dict
(named_tuple)[source]¶ Returns an ordered dictionary of the namedtuple object.
Parameters: named_tuple (namedtuple) – namedtuple object :returns An ordered dictionary version of named_tuple :rtype dict
-
geometry.utils.
open_h5py
(h5name, file_mode='a', comm=<sphinx.ext.autodoc.importer._MockObject object>)[source]¶
-
geometry.utils.
save_geometry_to_h5
(mesh, h5name, h5group='', markers=None, markerfunctions={}, microstructure={}, local_basis={}, comm=<sphinx.ext.autodoc.importer._MockObject object>, other_functions={}, other_attributes={}, overwrite_file=False, overwrite_group=True)[source]¶ Save geometry and other geometrical functions to a HDF file.
Parameters: - mesh (
dolfin.mesh
) – The mesh - h5name (str) – Path to the file
- h5group (str) – Folder within the file. Default is “” which means in the top folder.
- markers (dict) – A dictionary with markers. See get_markers.
- fields (list) – A list of functions for the microstructure
- local_basis (list) – A list of functions for the crl basis
- meshfunctions (dict) – A dictionary with keys being the dimensions the the values beeing the meshfunctions.
- comm (
dolfin.MPI
) – MPI communicator - other_functions (dict) – Dictionary with other functions you want to save
- other_attributes (dict) – Dictionary with other attributes you want to save
- overwrite_file (bool) – If true, and the file exists, the file will be overwritten (default: False)
- overwrite_group (bool) – If true and h5group exist, the group will be overwritten.
- mesh (