geometry package

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(c0, r0, l0)

Bases: tuple

c0

Alias for field number 0

l0

Alias for field number 2

r0

Alias for field number 1

class geometry.geometry.Geometry(mesh=None, markers=None, markerfunctions=None, microstructure=None, crl_basis=None)

Bases: object

c0

Circumferential basis.

cfun

Cell mesh function.

dim()

Returns the topological dimension of the geometry.

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)

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)

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.
topology()

Returns the topology of the geometry.

vfun

Vertex mesh function.

class geometry.geometry.Geometry2D(*args, **kwargs)

Bases: geometry.geometry.Geometry

class geometry.geometry.HeartGeometry(*args, **kwargs)

Bases: geometry.geometry.Geometry

class geometry.geometry.MarkerFunctions(vfun, efun, ffun, cfun)

Bases: tuple

cfun

Alias for field number 3

efun

Alias for field number 1

ffun

Alias for field number 2

vfun

Alias for field number 0

class geometry.geometry.MarkerFunctions2D(vfun, ffun, cfun)

Bases: tuple

cfun

Alias for field number 2

ffun

Alias for field number 1

vfun

Alias for field number 0

class geometry.geometry.Microstructure(f0, s0, n0)

Bases: tuple

f0

Alias for field number 0

n0

Alias for field number 2

s0

Alias for field number 1

class geometry.geometry.MixedMeshGeometry(geometries=None, labels=None)

Bases: object

add_mesh(geometry, label)
geometry.geometry.get_attribute(obj, key1, key2, default=None)

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>)
geometry.utils.load_geometry_from_h5(h5name, h5group='', fendo=None, fepi=None, include_sheets=True, comm=<sphinx.ext.autodoc.importer._MockObject object>)

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.load_local_basis(h5file, lgroup, mesh, geo)
geometry.utils.load_markers(h5file, mesh, ggroup, dgroup)
geometry.utils.load_microstructure(h5file, fgroup, mesh, geo, include_sheets=True)
geometry.utils.namedtuple_as_dict(named_tuple)

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>)
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)

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.
geometry.utils.set_namedtuple_default(NamedTuple, default=None)

Set default values of a namedtuple type. None by default.

Parameters:
  • NamedTuple (namedtuple) – namedtuple type
  • default (object) – default value

Module contents