carputils.mesh.Ellipsoid

class carputils.mesh.Ellipsoid(r_a, r_b, r_c, aout=None, bout=None, cout=None, v0=1.0471975511965976, v1=3.141592653589793, div_trans=2, div_vert=25, div_circ=50, flat_top=True, cumulative_offset=True, *args, **kwargs)

Generate a mesh of an ellipsoidal shell.

An ellipsoidal shell is generated with hexahedral and prism elements, divided into tetrahedra if desired. The shell is defined in terms of its internal axes a, b and c, with the outer axes currently being a scalar multiple of those (thickness).

v0 determines the azimuthal angle of the top (base) of the geometry, and v1 determines the azimuthal angle of the bottom (apex). By default, v1 is at the maximum of pi, and is therefore closed at that point. The mesh may be adjusted to have a flat (constant z coordiate) base place by use of the flat_top argument (on by default). Disabling this will case a constant-v base place.

Mesh discretisation is controlled by the div_trans, div_vert and div_circ arguments. div_trans controls the number of hexahedra/prisms generated transmurally, div_vert controls the number of layers of elements are generated between the apex and base, and div_circ controls the number of hexahedra/prisms are in the layer at the equator (v=pi/2) layer of the ellipsoid. This is used to calculate a target circumferential element size, which is in turn used to determine the number of elements to be generated at other layers such that they are of a consistent size.

Args:
r_a : float
Internal radius (x direction) of the ellipsoid shell
r_b : float
Internal radius (y direction) of the ellipsoid shell
r_c : float
Internal radius (z direction) of the ellipsoid shell
aout : float
External radius (x direction) of the ellipsoid shell, defaults to 1.25a
bout : float
External radius (y direction) of the ellipsoid shell, defaults to 1.25b
cout : float
External radius (z direction) of the ellipsoid shell, defaults to 1.15c
v0 : float, optional
Azimuthal angle of the top of the mesh, defaults to pi/3
v1 : float, optional
Aximuthal angle of the bottom of the mesh, defaults to pi (closed apex)
div_trans : int, optional
Number of elements across the radial thickness, defaults to 2
div_vert : int, optional
Number of layers of elements vertically, defaults to 25
div_circ : int, optional
Number of elements around the equator (v=pi/2), defaults to 50
flat_top : bool, optional
True to make a flat (constant z) top to the mesh, defaults to true
cumulative_offset : bool, optional
True to add a cumulative offset to the points, defaults to true
tetrahedrise : bool, optional
True to subdivide the mesh into tetrahedra
fibre_rule : callable, optional
Function describing the transmural variation of fibre angle, takes a single normalised transmural distance on [0,1] and returns a helix angle in radians, defaults to circumferentially oriented fibres
cavity_volume()

Calculate the volume of the cavity analytically.

The actual volume may be less due to discretisation effects.

Returns:
float
The cavity volume
generate_carp_apex_vtx(basename)

Generate vtx file with apex node.

Args:
basename : str
Mesh base name (without extension)
classmethod with_resolution(radius, resolution, lengthratio=1.5, wallthickness=None, apexthickness=None, **kwargs)

Simplified interface to generate ellipsoid with target resolution.

Args:
radius : float
Inner radius of ellipsoid cavity
resolution : float
Target mesh edge length
lengthratio : float, optional
Ratio of ellipsoid apical-basal radius to short axis-radius (default: 1.5)
wallthickness : float, optional
Thickness of ellipsoid wall (default: radius/5)
apexthickness : float, optional
Thickness of wall at apex (default: wallthickness)