NiHu
2.0
|
The C++ NiHu core does not contain versatile mesh building methods for creating parametric meshes or to import different mesh formats. NiHu provides a single mesh building interface, the NiHu::create_mesh function that reads two mesh description matrices: one for the vertex locations and one for the element nodal connectivities.
The NiHu::create_mesh function takes two matrices as its first arguments:
nodes
is the nodal location matrixelements
is the nodal connectivity matrix.As NiHu uses the linear algebra library Eigen for matrix manipulations, we use two typedef
-s for Eigen matrices.
dMatrix
denotes a dynamically resizeable matrix with real (double
) coefficients,uMatrix
denotes the same with unsigned
coefficients.We instantiate the two matrices by allocating their coefficients, and initialising them using Eigen's comma initialiser syntax:
nodes
contain 3D locations.elements
contain an element id followed by as many element nodal indices as needed by the element type. Unused coefficients are left zero.Apparently, we are building a heterogeneous mesh consisting of linear quadrangles (NiHu::quad_1_elem) and triangles (NiHu::tria_1_elem). The mesh is finally built by calling the NiHu::create_mesh function
The additional arguments NiHu::quad_1_tag () and NiHu::tria_1_tag () are additional type information telling the compiler which element types are used in the mesh. From this information, the compiler builds a specific mesh type that stores the specified element types separately, in an optimised way.
auto
keyword. In fact, it is but this information is not needed to use the library.
The next example builds a circle from line elements in 2D:
The NiHu::create_mesh function is a template that can be called with any indexable matrix types. The only requirement against the matrix types is that they should be indexable with integers, using a (row,col)
-type syntax.
This feature, together with the NiHu::mex::real_matrix class, makes easy Matlab MEX integration possible.
NiHu
can import meshes stored in OFF. This can easily be done using the NiHu::read_off_mesh function. The usage of this function is demonstrated below.
The element types to be read from the file are listed by passing the NiHu::read_off_mesh function instances of the corresponding tags.