PeriDEM 0.2.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
|
A class for mesh data. More...
#include <mesh.h>
Public Member Functions | |
Mesh (size_t dim=0) | |
Constructor. | |
Mesh (inp::MeshDeck *deck) | |
Constructor. | |
std::string | printStr (int nt=0, int lvl=0) const |
Returns the string containing printable information about the object. | |
void | print (int nt=0, int lvl=0) const |
Prints the information about the object. | |
Accessor methods | |
size_t | getDimension () const |
Get the dimension of the domain. | |
size_t | getNumNodes () const |
Get the number of nodes. | |
size_t | getNumElements () const |
Get the number of elements. | |
size_t | getNumDofs () const |
Get the number of dofs. | |
size_t | getElementType () const |
Get the type of element in mesh. | |
double | getMeshSize () const |
Get the mesh size. | |
util::Point | getNode (const size_t &i) const |
Get coordinates of node i. | |
double | getNodalVolume (const size_t &i) const |
Get nodal volume of node i. | |
const std::vector< util::Point > & | getNodes () const |
Get the nodes data. | |
std::vector< util::Point > & | getNodes () |
Get the nodes data. | |
const std::vector< util::Point > * | getNodesP () const |
Get the pointer to nodes data. | |
std::vector< util::Point > * | getNodesP () |
Get the pointer to nodes data. | |
const std::vector< uint8_t > * | getFixityP () const |
Get the pointer to fixity data. | |
std::vector< uint8_t > * | getFixityP () |
Get the pointer to fixity data. | |
const std::vector< uint8_t > & | getFixity () const |
Get the reference to fixity data. | |
std::vector< uint8_t > & | getFixity () |
Get the reference to fixity data. | |
const std::vector< double > & | getNodalVolumes () const |
Get the nodal volume data. | |
std::vector< double > & | getNodalVolumes () |
Get the nodal volume data. | |
const std::vector< double > * | getNodalVolumesP () const |
Get the pointer to nodal volume data. | |
std::vector< double > * | getNodalVolumesP () |
Get the pointer to nodal volume data. | |
bool | isNodeFree (const size_t &i, const unsigned int &dof) const |
Return true if node is free. | |
std::vector< size_t > | getElementConnectivity (const size_t &i) const |
Get the connectivity of element. | |
std::vector< util::Point > | getElementConnectivityNodes (const size_t &i) const |
Get the vertices of element. | |
const std::vector< size_t > & | getElementConnectivities () const |
Get the reference to element-node connectivity data. | |
std::vector< size_t > & | getElementConnectivities () |
Get the reference to element-node connectivity data. | |
const std::vector< size_t > * | getElementConnectivitiesP () const |
Get the pointer to element-node connectivity data. | |
std::vector< size_t > * | getElementConnectivitiesP () |
Get the pointer to element-node connectivity data. | |
const std::pair< std::vector< double >, std::vector< double > > & | getBoundingBox () const |
Get the bounding box of the mesh. | |
std::pair< std::vector< double >, std::vector< double > > & | getBoundingBox () |
Get the bounding box of the mesh. | |
Setter methods | |
void | setFixity (const size_t &i, const unsigned int &dof, const bool &flag) |
Set the fixity to free (0) or fixed (1) | |
void | clearElementData () |
Clear element-node connectivity data. | |
Utility methods | |
void | createData (const std::string &filename, bool ref_config=false) |
Reads mesh data from the file and populates other data. | |
bool | readElementData (const std::string &filename) |
Reads element-node connectivity data from file. This function is meant for cases when mesh was created without element-node connectivity data but later during output, strain/stress were required which needs element-node connectivity data. | |
void | computeVol () |
Compute the nodal volume. | |
void | computeBBox () |
Compute the bounding box | |
void | computeMeshSize () |
Compute the mesh size. | |
Data Fields | |
size_t | d_dim |
Dimension of the mesh. | |
std::string | d_spatialDiscretization |
Tag for spatial discretization type. | |
std::string | d_filename |
Filename to read mesh data. | |
bool | d_needEncData |
Flag that indicates whether we need enc data (set by input mesh deck in constructor) | |
bool | d_encDataPopulated |
Flag that indicates whether element-node connectivity data is read from file. | |
size_t | d_numDofs |
Number of dofs = (dimension) times (number of nodes) | |
std::vector< size_t > | d_gMap |
Map from global reduced id to default global id. | |
std::vector< int > | d_gInvMap |
Map from global id to reduced global id. | |
std::pair< std::vector< double >, std::vector< double > > | d_bbox |
Bounding box. | |
double | d_h |
Mesh size. | |
Mesh data | |
size_t | d_numNodes |
Number of nodes. | |
size_t | d_numElems |
Number of elements. | |
size_t | d_eType |
Element type. | |
size_t | d_eNumVertex |
Number of vertex per element. | |
std::vector< util::Point > | d_nodes |
Vector of initial (reference) coordinates of nodes. | |
std::vector< size_t > | d_enc |
Element-node connectivity data. | |
std::vector< std::vector< size_t > > | d_nec |
Node-element connectivity data. | |
std::vector< uint8_t > | d_fix |
Vector of fixity mask of each node. | |
std::vector< double > | d_vol |
Vector of volume of each node. | |
Mesh data specific to parallel implementation | |
size_t | d_nPart |
Number of partitions. | |
std::string | d_partitionMethod |
Partitioning method. It could be either empty string or "metis_recursive" or "metis_kway". | |
std::vector< size_t > | d_nodePartition |
Node partition information. For each node i, d_nodePartition[i] specifies the partition number, i.e., the processor that owns the node in MPI application. | |
A class for mesh data.
In this class the mesh data such as nodes, element-node connectivity, node-element connectivity are stored. The class also stores fixity mask of nodes which indicates if x-, y-, or z-dof of the node is fixed or free.
We currently only support mesh with only one type of elements, i.e. mesh can not have mix of two types of elements. For example, we can not have mesh with triangle and quadrangle elements together.
This class is used in both finite difference implementation and finite element implementation. For finite difference, we only require nodal volume. If the mesh file contains nodal volume, we skip reading element-node and node-element connectivity, however if mesh file does not have nodal volume data, we read connectivity data and compute the nodal volume.
|
explicit |
Constructor.
dim | Dimension of the domain |
Definition at line 26 of file mesh.cpp.
|
explicit |
Constructor.
The constructor initializes the data using input deck, performs checks on input data, and reads mesh file and populates the mesh related data. The mesh file of **.csv**, **.vtu (VTK)** and **.msh (Gmsh)** are supported.
deck | Input deck which contains user-specified information |
Definition at line 31 of file mesh.cpp.
References createData(), d_dim, d_filename, d_spatialDiscretization, and inp::MeshDeck::printStr().
void fe::Mesh::clearElementData | ( | ) |
Clear element-node connectivity data.
Definition at line 396 of file mesh.cpp.
void fe::Mesh::computeBBox | ( | ) |
Compute the bounding box
Definition at line 332 of file mesh.cpp.
References util::isLess().
void fe::Mesh::computeMeshSize | ( | ) |
Compute the mesh size.
This method searches for minimum distance between any two mesh nodes and stores it as a mesh size.
Definition at line 353 of file mesh.cpp.
References util::isLess().
void fe::Mesh::computeVol | ( | ) |
Compute the nodal volume.
This method requires element-node connectivity data to compute the nodal volumes. Formula for volume of a node \( i\) is given by
\[ V_i = \sum_{e \in \mathbf{N}_i} \int_{T_e} N_i(x) dx, \]
where \(\mathbf{N}_i\) is a list of elements which have node \( i\) as its vertex, \( T_e\) is the element domain, \( N_i\) is the shape function of the node \( i\) in element e.
Definition at line 250 of file mesh.cpp.
References fe::BaseElem::elemSize(), util::parallel::getNThreads(), fe::BaseElem::getQuadDatas(), util::io::printStr(), util::vtk_type_quad, util::vtk_type_tetra, and util::vtk_type_triangle.
Reads mesh data from the file and populates other data.
This function calls reader methods in namespace rw::reader to read the mesh file. For finite difference implementation, we support **.csv** mesh file which has nodal coordinates and nodal volumes data.
However, for finite element implementation, we require either **.vtu** or **.msh** file with element-node connectivity data.
filename | Name of the mesh file |
ref_config | Flag which specifies if we need to subtract the displacement from nodes obtained from vtu file to get reference position of nodes |
Definition at line 67 of file mesh.cpp.
References util::io::getExtensionFromFile(), util::io::log(), rw::reader::readCsvFile(), rw::reader::readMshFile(), rw::reader::readVtuFileCells(), rw::reader::readVtuFileNodes(), rw::reader::readVtuFilePointData(), and util::vtk_map_element_to_num_nodes.
Referenced by Mesh().
|
inline |
Get the dimension of the domain.
Definition at line 82 of file mesh.h.
References d_dim.
Referenced by fe::getMaxShearStressAndLoc(), and fe::getStrainStress().
|
inline |
|
inline |
Get the connectivity of element.
Since we store connectivity in a single vector, we use fe::Mesh::d_eNumVertex to get the connectivity of element. Given element e, the connectivity of e begins from location \( i_0 = e*d\_eNumVertex + 0 \) upto \(i_{n-1} = e*d\_eNumVertex + d\_eNumVertex - 1\).
So the connectivity of e is d_enc[ \(i_0\)], d_enc[ \( i_1 \)], ..., d_end[ \(i_{n-1}\)]
i | Id of an element |
Definition at line 210 of file mesh.h.
References d_dim, d_enc, and d_eNumVertex.
Referenced by fe::getCurrentQuadPoints(), fe::getMaxShearStressAndLoc(), and fe::getStrainStress().
|
inline |
|
inline |
Get the type of element in mesh.
Definition at line 106 of file mesh.h.
References d_eType.
Referenced by fe::getCurrentQuadPoints(), fe::getMaxShearStressAndLoc(), and fe::getStrainStress().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Get the number of elements.
Definition at line 94 of file mesh.h.
References d_enc, and d_eNumVertex.
Referenced by fe::getCurrentQuadPoints(), fe::getMaxShearStressAndLoc(), and fe::getStrainStress().
|
inline |
Get the number of nodes.
Definition at line 88 of file mesh.h.
References d_numNodes.
Referenced by fe::getCurrentQuadPoints(), fe::getMaxShearStressAndLoc(), and fe::getStrainStress().
Return true if node is free.
i | Id of node |
dof | Dof to check for |
Definition at line 188 of file mesh.h.
Prints the information about the object.
nt | Number of tabs to append before printing |
lvl | Information level (higher means more information) |
Definition at line 306 of file mesh.h.
References d_dim, and printStr().
Returns the string containing printable information about the object.
nt | Number of tabs to append before printing |
lvl | Information level (higher means more information) |
Definition at line 404 of file mesh.cpp.
References util::io::getTabS(), and util::io::printBoxStr().
Referenced by print().
Reads element-node connectivity data from file. This function is meant for cases when mesh was created without element-node connectivity data but later during output, strain/stress were required which needs element-node connectivity data.
File must be either **.vtu** or **.msh** file and must have element-node connectivity data.
filename | Name of the mesh file |
Definition at line 203 of file mesh.cpp.
References util::io::getExtensionFromFile(), util::io::log(), rw::reader::readMshFileCells(), and rw::reader::readVtuFileCells().
Set the fixity to free (0) or fixed (1)
i | Id of node |
dof | Dof which is affected |
flag | Set fixity to fixed if true or free |
Bounding box.
Definition at line 513 of file mesh.h.
Referenced by fe::createUniformMesh(), getBoundingBox(), and getBoundingBox().
size_t fe::Mesh::d_dim |
Dimension of the mesh.
Definition at line 468 of file mesh.h.
Referenced by model::DEMModel::createParticles(), fe::createUniformMesh(), getDimension(), getElementConnectivity(), getElementConnectivityNodes(), getNodalVolume(), getNode(), isNodeFree(), Mesh(), and print().
std::vector<size_t> fe::Mesh::d_enc |
Element-node connectivity data.
Structure: First d_eNumVertex data gives the connectivity of first element, and next d_eNumVertex data gives the connectivity of second element and so on and so fourth.
Definition at line 415 of file mesh.h.
Referenced by fe::createUniformMesh(), getElementConnectivities(), getElementConnectivities(), getElementConnectivitiesP(), getElementConnectivitiesP(), getElementConnectivity(), getElementConnectivityNodes(), and getNumElements().
bool fe::Mesh::d_encDataPopulated |
size_t fe::Mesh::d_eNumVertex |
Number of vertex per element.
This information is useful in getting the connectivity for a given element. We assume that the mesh has only one type of elements and based on that assumption we store the element-node connectivity in a single vector.
The value for different elements are
Definition at line 404 of file mesh.h.
Referenced by fe::createUniformMesh(), fe::getCurrentQuadPoints(), getElementConnectivity(), getElementConnectivityNodes(), fe::getMaxShearStressAndLoc(), getNumElements(), and fe::getStrainStress().
size_t fe::Mesh::d_eType |
Element type.
We follow VTK convention to identify the elements:
Definition at line 389 of file mesh.h.
Referenced by fe::createUniformMesh(), and getElementType().
std::string fe::Mesh::d_filename |
std::vector<uint8_t> fe::Mesh::d_fix |
Vector of fixity mask of each node.
First bit represents x-dof, second represents y-dof, and third represents z-dof. 0 represents free dof and 1 represents fixed dof.
We store data in uint8_t type which can hold 8 bit. At present we only use first 3 bits.
Definition at line 431 of file mesh.h.
Referenced by fe::createUniformMesh(), getFixity(), getFixity(), getFixityP(), getFixityP(), and isNodeFree().
std::vector<int> fe::Mesh::d_gInvMap |
std::vector<size_t> fe::Mesh::d_gMap |
Map from global reduced id to default global id.
We assign number to each free dof where number ranges from 0 to total number of free dofs. This is referred to set of global reduced id. This new set of ids are subset of set of global ids of all dofs, and therefore, "reduced" word is used.
d_gMap provides a map from global reduced id to global id.
double fe::Mesh::d_h |
Mesh size.
Definition at line 516 of file mesh.h.
Referenced by fe::createUniformMesh(), and getMeshSize().
std::vector<std::vector<size_t> > fe::Mesh::d_nec |
bool fe::Mesh::d_needEncData |
std::vector<size_t> fe::Mesh::d_nodePartition |
Node partition information. For each node i, d_nodePartition[i] specifies the partition number, i.e., the processor that owns the node in MPI application.
For uniform square mesh, the volume is simply \( h^2 \) in 2-d and \( h^3\) in 3-d, where \( h\) is the mesh size. For general mesh, the volume is computed using the element-node connectivity of the mesh.
Definition at line 463 of file mesh.h.
Referenced by fe::metisGraphPartition().
std::vector<util::Point> fe::Mesh::d_nodes |
Vector of initial (reference) coordinates of nodes.
Definition at line 407 of file mesh.h.
Referenced by fe::createUniformMesh(), getElementConnectivityNodes(), getNode(), getNodes(), getNodes(), getNodesP(), and getNodesP().
size_t fe::Mesh::d_nPart |
Number of partitions.
Definition at line 449 of file mesh.h.
Referenced by fe::metisGraphPartition().
size_t fe::Mesh::d_numDofs |
Number of dofs = (dimension) times (number of nodes)
Definition at line 490 of file mesh.h.
Referenced by fe::createUniformMesh(), and getNumDofs().
size_t fe::Mesh::d_numElems |
size_t fe::Mesh::d_numNodes |
Number of nodes.
Definition at line 375 of file mesh.h.
Referenced by fe::createUniformMesh(), and getNumNodes().
std::string fe::Mesh::d_partitionMethod |
Partitioning method. It could be either empty string or "metis_recursive" or "metis_kway".
Definition at line 454 of file mesh.h.
Referenced by fe::metisGraphPartition().
std::string fe::Mesh::d_spatialDiscretization |
std::vector<double> fe::Mesh::d_vol |
Vector of volume of each node.
For uniform square mesh, the volume is simply \( h^2 \) in 2-d and \( h^3\) in 3-d, where \( h\) is the mesh size. For general mesh, the volume is computed using the element-node connectivity of the mesh.
Definition at line 439 of file mesh.h.
Referenced by fe::createUniformMesh(), getNodalVolume(), getNodalVolumes(), getNodalVolumes(), getNodalVolumesP(), and getNodalVolumesP().