Mesh

class Mesh(h5group)

This class deals with mesh-based data used by a Lionbolt solve (and thus needed for post-processing and plotting).

Print an object of this class to view all available attributes.

Parameters:

h5group (h5py.Group) – The HDF5 group corresponding to the mesh.

h5

The HDF5 group from which this object is built.

Type:

h5py.Group

problem_type

Either ‘slab’ or ‘general’ depending on the dimensionality of the mesh.

Type:

str

num_materials

Number of materials present in this mesh.

Type:

int

num_elements

Number of finite elements in this mesh.

Type:

int

num_spatial_dofs

Number of spatial degrees of freedom in this mesh. Note that this is given by visiting every element and adding up the number of nodes it has, even if two nodes in different elements describe the same physical point. This is consistent with discontinuous Galerkin methods which treat these nodes as distinct.

Type:

int

num_global_nodes

Number of nodes in the global mesh, i.e., number of unique physical points.

Type:

int

connectivity()

Gives the connectivity of the mesh. This maps from spatial d.o.f. to global node index.

Returns:

c – Connectivity array.

Return type:

int [:]

Examples

Suppose you want to determine the spatial coordinates of element e local node k. Let rg represent the global mesh and o represent the offset array. You can use:

>>> s = o[e] + k # Spatial d.o.f. of element e, local node k
>>> kg = c[s]    # Global node index of this spatial d.o.f.
>>> print(rg[kg,:])
[1.02, 0.53, 9.03]
destroy()

Deallocates all data

extended_nodes()

Gives the extended nodes, i.e., the mesh nodes indexed by spatial d.o.f.

Returns:

r – Array giving coordinates of the mesh in terms of the spatial d.o.f. Indexed like [spatial d.o.f., direction]

Return type:

np.float64 [:,:]

mat2sd()

Maps from a material to the set of spatial d.o.f.s having this material.

Although, note that material assignments are indeed element based, having this array be extended to spatial d.o.f.s is a matter of utility for Terpdose’s post-processing functionalities.

Returns:

m2sd – The set of spatial d.o.f.s with a given material. Indexed like [material][spatial d.o.f.]

Return type:

list(int [:])

nodes()

Gives the global mesh.

Returns:

rg – Array giving the coordinates of the global mesh. Indexed like [node, direction]

Return type:

np.float64 [:,:]

num_element_nodes()

Gives the number of nodes in an element.

Returns:

NK – Array giving the number of nodes in the given element.

Return type:

int [:]

Examples

Let element e describe a first-order tetrahedral element:

>>> print(NK[e])
4
offset()

Gives the offset array of the mesh. This is a rank-one array that allows one to quickly map between an element and local node index to the spatial d.o.f. index, namely by taking the element index and giving the spatial d.o.f. reached up to that element. See Examples below for a more concrete demonstration.

Returns:

o – Offset array indexed by element.

Return type:

int [:]

Examples

Suppose you want to know the spatial d.o.f. of the kth node found in element e, and assign it to variable s. Use:

>>> s = o[e] + k
volumes()

Gives the volume of a chosen element. Needed for finite element analysis.

Returns:

vol – Volume of a given element.

Return type:

int [:]