carputils
Doxygen code documentation for the python framework controlling openCARP
Public Member Functions | List of all members
carputils.mesh.block.Block Class Reference

Generate a block mesh with the mesher command line utility. More...

Public Member Functions

def __init__ (self, centre=(0., 0., 0.), size=(1., 1., 1.), resolution=0.1, etype='tetra', periodic=0, periodic_tag=1234, pertb=0.0)
 
def resolution (self)
 Return the currently set mesh resolution. More...
 
def set_bath (self, thickness, both_sides=True)
 Add a bath region of the specified thickness. More...
 
def set_fibres (self, fibre_endo=None, fibre_epi=None, sheet_endo=None, sheet_epi=None)
 Set the angles for generated fibres in the generated geometry. More...
 
def corner_at_origin (self)
 Put the corner of the tissue block at the origin. More...
 
def tissue_limits (self)
 Return the lower and upper limits of the block, excluding the bath. More...
 
def bath_limits (self)
 Return the lower and upper limits of the block, including the bath. More...
 
def shape (self, bath=True)
 Determine the number of points in each dimension. More...
 
def add_region (self, region)
 Add a region definition. More...
 
def mesher_opts (self, meshname)
 Generate a list of command line arguments for mesher. More...
 

Detailed Description

Generate a block mesh with the mesher command line utility.

This class describes a tissue block with optional additional bath region. For example, to define a 2x2x2mm block centred on the origin with 1mm bath on the positive z side:

>>> geom = Block(size=(2,2,2))
>>> geom.set_bath(thickness=(0,0,1), both_sides=False)

Regions may also be specified using the :class:BoxRegion, :class:SphereRegion and :class:CylinderRegion objects:

>>> reg = BoxRegion((-1,-1,-1), (1,1,0), tag=10)
>>> geom.add_region(reg)

Generate a list of command line options to pass to mesher to generate the described mesh with the :meth:mesher_opts method:

>>> opts = geom.mesher_opts('meshname') # meshname.pts, meshname.elem, etc.

.. note::

While the mesher executable takes arguments in centimetres and
micrometres, this class expects *all* physical sizes to be specified in
millimetres. Arguments are converted to the correct units when
generating the mesher command line.
Parameters
centrearray-like, optional Coordinate of centre of Block, defaults to (0,0,0)
sizearray-like, optional Size of Block, defaults to (1,1,1)
resolutionfloat, optional Resolution at which to tesselate block into mesh, defaults to 0.1
etypestr, optional Element type to generate, either 'tetra' or 'hexa' in 3D, or 'quad' or 'tri' in 2D, defaults to 'tetra' in 3D and 'quad' in 2D
periodicint, optional If set, the edges along a given direction are connected by linear elements to implement periodic boundary conditions. The range of values spans 0 (none), 1 (X), 2 (Y) and 3 (XY)
periodic_tagint, optional Tag value assigned to the connecting linear elements. As default the value 1234 is used.

Constructor & Destructor Documentation

◆ __init__()

def carputils.mesh.block.Block.__init__ (   self,
  centre = (0., 0., 0.),
  size = (1., 1., 1.),
  resolution = 0.1,
  etype = 'tetra',
  periodic = 0,
  periodic_tag = 1234,
  pertb = 0.0 
)

Member Function Documentation

◆ add_region()

def carputils.mesh.block.Block.add_region (   self,
  region 
)

Add a region definition.

Parameters
regionBoxRegion or SphereRegion or CylinderRegion The region description.

◆ bath_limits()

def carputils.mesh.block.Block.bath_limits (   self)

Return the lower and upper limits of the block, including the bath.

Returns
lower array The coordinate of the lower left corner of the block
upper array The coordinate of the upper right corner of the block

◆ corner_at_origin()

def carputils.mesh.block.Block.corner_at_origin (   self)

Put the corner of the tissue block at the origin.

◆ mesher_opts()

def carputils.mesh.block.Block.mesher_opts (   self,
  meshname 
)

Generate a list of command line arguments for mesher.

Parameters
meshnamestr The base name of the mesh to be generated.
Returns
list The mesher argument list.

◆ resolution()

def carputils.mesh.block.Block.resolution (   self)

Return the currently set mesh resolution.

Returns
float The mesh resolution.

◆ set_bath()

def carputils.mesh.block.Block.set_bath (   self,
  thickness,
  both_sides = True 
)

Add a bath region of the specified thickness.

Note that this method does not use the mesher convention of positive bath size meaning bath on one side and negative bath size meaning bath on both sides. Instead always use positive thickness values and the optional both_sides parameter to control this behaviour.

Parameters
thicknessarray-like The thickness of bath to add, one value per coordinate axis
both_sidebool or array-like of bools, optional If True, generate bath on both sides of the object, if False only on one side. Pass an array of bools to control this behaviour for individual directions.

◆ set_fibres()

def carputils.mesh.block.Block.set_fibres (   self,
  fibre_endo = None,
  fibre_epi = None,
  sheet_endo = None,
  sheet_epi = None 
)

Set the angles for generated fibres in the generated geometry.

Parameters
fibre_endofloat, optional Set the principal fibre direction on the endocardium
fibre_epifloat, optional Set the principal fibre direction on the epicardium
sheet_endofloat, optional Set the sheet direction on the endocardium
sheet_epifloat, optional Set the shhet direction on the epicardium

◆ shape()

def carputils.mesh.block.Block.shape (   self,
  bath = True 
)

Determine the number of points in each dimension.

◆ tissue_limits()

def carputils.mesh.block.Block.tissue_limits (   self)

Return the lower and upper limits of the block, excluding the bath.

Returns
lower array The coordinate of the lower left corner of the tissue block
upper array The coordinate of the upper right corner of the tissue block

The documentation for this class was generated from the following file: