grains.geometry.Mesh

class grains.geometry.Mesh(vertices, cells)[source]

Data structure for a general mesh.

This class by no means wants to provide intricate functionalities and does not strive to be efficient at all. Its purpose is to give some useful features the project relies on. The two main entities in the mesh are the vertices and the cells. They are expected to be passed by the user, so reading from various mesh files is not implemented. This keeps the class simple, requires few package dependencies and keeps the class focused as there are powerful tools to convert among mesh formats (see e.g. meshio).

Parameters
  • vertices (ndarray) – 2D numpy array with 2 columns, each row corresponding to a vertex, and the two columns giving the Cartesian coordinates of the vertex.

  • cells (ndarray) – Cell-vertex connectivities in a 2D numpy array, in which each row corresponds to a cell and the columns are the vertices of the cells. It is assumed that all the cells have the same number of vertices.

Notes

Although not necessary, it is highly recommended that the local vertex numbering in the cells are the same, either clockwise or counter-clockwise. Some methods, such as get_boundary() even requires it. If you are not sure whether the cells you provide have a consistent numbering, it is better to renumber them by calling the change_vertex_numbering() method.

__init__(vertices, cells)[source]

Todo

Error checking

Methods

__init__(vertices, cells)

associate_field(vertex_values[, name])

Associates a scalar, vector or tensor field to the nodes.

create_cell_set(name, cells)

Forms a group from a set of cells.

create_vertex_set(name, vertices)

Forms a group from a set of vertices.

get_boundary()

Extracts the boundary of the mesh.

get_edges()

Constructs edge-cell connectivities of the mesh.