PeriDEM 0.3.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
mesh::Mesh Class Reference

A class for mesh data. More...

#include <mesh.h>

Collaboration diagram for mesh::Mesh:

Public Member Functions

 Mesh (size_t dim=0)
 Constructor.
 
 Mesh (const inp::MeshDeck *meshDeck, const inp::ModelDeck *modelDeck)
 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::PointgetElementConnectivityNodes (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.
 
void loadFromTriangleElements2D (std::vector< util::Point > nodes, std::vector< size_t > enc, const inp::MeshDeck *meshDeck, const inp::ModelDeck *modelDeck)
 Populate mesh from 2D triangle data (0-based node indices in enc) without reading a file.
 
void loadFromTetraElements3D (std::vector< util::Point > nodes, std::vector< size_t > enc, const inp::MeshDeck *meshDeck, const inp::ModelDeck *modelDeck)
 Populate mesh from 3D tetrahedron data (0-based node indices in enc) without reading a file.
 
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 setZCoordinateZero ()
 For \(d_{\mathrm{dim}} = 2\), set \(z = 0\) on all reference nodes (x–y plane). Call before computeBBox() when nodes may carry numerical noise in \(z\).
 
void computeBBox ()
 Compute the bounding box from d_nodes (after setZCoordinateZero() for 2D if applicable).
 
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
 Characteristic mesh spacing (minimum nodal distance); always from computeMeshSize() after nodes exist.
 
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::Pointd_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.
 

Private Member Functions

void finalizeMeshDerivedFieldsFromCurrentNodes (bool compute_vol_from_elements, const std::string &volume_error_note)
 After nodes, enc, nec, and dof-related fields are set: 2D z clear, bbox, optional nodal volume, mesh size h, volume sanity check, and optional connectivity read from file.
 

Detailed Description

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.

Definition at line 53 of file mesh.h.

Constructor & Destructor Documentation

◆ Mesh() [1/2]

mesh::Mesh::Mesh ( size_t  dim = 0)
explicit

Constructor.

Parameters
dimDimension of the domain

Definition at line 30 of file mesh.cpp.

32 d_h(0.), d_dim(dim), d_encDataPopulated(false), d_needEncData(false),
33 d_nPart(0) {}
bool d_needEncData
Flag that indicates whether we need enc data (set by input mesh deck in constructor)
Definition mesh.h:512
bool d_encDataPopulated
Flag that indicates whether element-node connectivity data is read from file.
Definition mesh.h:515
size_t d_numElems
Number of elements.
Definition mesh.h:406
size_t d_eType
Element type.
Definition mesh.h:417
size_t d_numNodes
Number of nodes.
Definition mesh.h:403
size_t d_dim
Dimension of the mesh.
Definition mesh.h:496
size_t d_nPart
Number of partitions.
Definition mesh.h:477
size_t d_numDofs
Number of dofs = (dimension) times (number of nodes)
Definition mesh.h:518
size_t d_eNumVertex
Number of vertex per element.
Definition mesh.h:432
double d_h
Characteristic mesh spacing (minimum nodal distance); always from computeMeshSize() after nodes exist...
Definition mesh.h:544

◆ Mesh() [2/2]

mesh::Mesh::Mesh ( const inp::MeshDeck meshDeck,
const inp::ModelDeck modelDeck 
)
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.

Parameters
meshDeckInput mesh deck which contains user-specified information
modelDeckInput model deck which contains user-specified information

Definition at line 35 of file mesh.cpp.

37 d_h(0.), d_dim(modelDeck->d_dim),
39 d_filename(meshDeck->d_filename), d_encDataPopulated(false),
41 d_nPart(0) {
42
43 // perform check on input data
44 if (d_spatialDiscretization != "finite_difference" and
45 d_spatialDiscretization != "weak_finite_element" and
46 d_spatialDiscretization != "nodal_finite_element" and
47 d_spatialDiscretization != "truss_finite_element") {
48 throw std::runtime_error("Spatial discretization type " + d_spatialDiscretization + " not known. Check input data.");
49 }
50
51 if (d_dim < 0 or d_dim > 3) {
52 std::cerr << "Error: Check Dimension in input data.\n";
53 exit(1);
54 }
55
56 if (d_filename.empty()) {
57 std::cerr << "Error: Filename for mesh data not specified.\n";
58 exit(1);
59 }
60
61 // read mesh data from file
63}
std::string d_filename
Filename to read mesh data.
Definition mesh.h:509
std::string d_spatialDiscretization
Tag for spatial discretization type.
Definition mesh.h:506
void createData(const std::string &filename, bool ref_config=false)
Reads mesh data from the file and populates other data.
Definition mesh.cpp:68
std::string d_filename
Filename to read mesh data.
Definition meshDeck.h:29
bool d_populateElementNodeConnectivity
Flag to indicate if we should populate element-node connectivity data in meshes.
Definition modelDeck.h:60
size_t d_dim
Dimension.
Definition modelDeck.h:106
std::string d_spatialDiscretization
Tag for spatial discretization.
Definition modelDeck.h:47

References createData(), d_filename, and d_spatialDiscretization.

Here is the call graph for this function:

Member Function Documentation

◆ clearElementData()

void mesh::Mesh::clearElementData ( )

Clear element-node connectivity data.

Definition at line 480 of file mesh.cpp.

480 {
481 if (!d_enc.empty())
482 d_enc.shrink_to_fit();
483 d_numElems = 0;
484 if (!d_nec.empty())
485 d_nec.shrink_to_fit();
486}
std::vector< size_t > d_enc
Element-node connectivity data.
Definition mesh.h:443
std::vector< std::vector< size_t > > d_nec
Node-element connectivity data.
Definition mesh.h:449

References d_enc, d_nec, and d_numElems.

◆ computeBBox()

void mesh::Mesh::computeBBox ( )

Compute the bounding box from d_nodes (after setZCoordinateZero() for 2D if applicable).

Definition at line 416 of file mesh.cpp.

416 {
417 std::vector<double> p1(3,0.);
418 std::vector<double> p2(3,0.);
419 for (const auto& x : d_nodes) {
420 if (util::isLess(x.d_x, p1[0]))
421 p1[0] = x.d_x;
422 if (util::isLess(x.d_y, p1[1]))
423 p1[1] = x.d_y;
424 if (util::isLess(x.d_z, p1[2]))
425 p1[2] = x.d_z;
426 if (util::isLess(p2[0], x.d_x))
427 p2[0] = x.d_x;
428 if (util::isLess(p2[1], x.d_y))
429 p2[1] = x.d_y;
430 if (util::isLess(p2[2], x.d_z))
431 p2[2] = x.d_z;
432 }
433
434 d_bbox = std::make_pair(p1, p2);
435}
std::pair< std::vector< double >, std::vector< double > > d_bbox
Bounding box.
Definition mesh.h:541
std::vector< util::Point > d_nodes
Vector of initial (reference) coordinates of nodes.
Definition mesh.h:435
bool isLess(const double &a, const double &b)
Returns true if a < b.
Definition function.cpp:20

References d_bbox, d_nodes, and util::isLess().

Referenced by finalizeMeshDerivedFieldsFromCurrentNodes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ computeMeshSize()

void mesh::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 437 of file mesh.cpp.

437 {
438
439 double guess = 0.;
440 if (d_nodes.size() < 2) {
441 d_h = 0.;
442 return;
443 }
444
445 guess = (d_nodes[0] - d_nodes[1]).length();
446 for (size_t i = 0; i < d_nodes.size(); i++)
447 for (size_t j = 0; j < d_nodes.size(); j++)
448 if (i != j) {
449 double val = d_nodes[i].dist(d_nodes[j]);
450
451 if (util::isLess(val, 1.0E-12)) {
452
453 std::cout << "Check nodes are too close = "
454 << util::io::printStr<util::Point>({d_nodes[i],
455 d_nodes[j]})
456 << "\n";
457 std::cout << "Distance = " << val << ", guess = " << guess << "\n";
458 }
459 if (util::isLess(val, guess))
460 guess = val;
461 }
462
463 d_h = guess;
464}

References d_h, d_nodes, and util::isLess().

Referenced by finalizeMeshDerivedFieldsFromCurrentNodes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ computeVol()

void mesh::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 333 of file mesh.cpp.

333 {
334
335 auto quads = fe::elem(d_eType, 2);
336 auto *quads_p = quads.get();
337
338 // check if we have valid element-node connectivity data for nodal volume
339 // calculations
340 if (d_nec.size() != d_numNodes || d_enc.empty()) {
341 std::cerr << "Error: Can not compute nodal volume for given finite "
342 "element mesh as the element-node connectivity data is "
343 "invalid."
344 << std::endl;
345 exit(EXIT_FAILURE);
346 }
347
348 if (false) {
349 print(0, 0);
350 std::cout << "\n-------- Node data ----------\n";
351 std::cout << util::io::printStr(d_nodes, 0) << "\n";
352 std::cout << "\n-------- Element data ----------\n";
353 std::cout << util::io::printStr(d_enc, 0) << "\n";
354 }
355
356 //
357 // compute nodal volume
358 //
359 d_vol.resize(d_numNodes);
360
361 tf::Executor executor(util::parallel::getNThreads());
362 tf::Taskflow taskflow;
363
364 taskflow.for_each_index(
365 (std::size_t) 0, this->d_numNodes, (std::size_t) 1, [this, quads_p](std::size_t i) {
366 double v = 0.0;
367
368 for (auto e : this->d_nec[i]) {
369
370 std::vector<size_t> e_ns = this->getElementConnectivity(e);
371
372 // locate global node i in local list of element el
373 int loc_i = -1;
374 for (size_t l = 0; l < e_ns.size(); l++)
375 if (e_ns[l] == i)
376 loc_i = l;
377
378 if (loc_i == -1) {
379 std::cerr << "Error: Check node element connectivity.\n";
380 exit(1);
381 }
382
383 // get quad data
384 std::vector<util::Point> e_nodes;
385 for (auto k : e_ns)
386 e_nodes.emplace_back(this->d_nodes[k]);
387
388 // get volume of element
389 double vol = quads_p->elemSize(e_nodes);
390 double factor = 1.;
391 if (vol < 0.)
392 factor = -1.;
393
394 std::vector<fe::QuadData> qds = quads_p->getQuadDatas(e_nodes);
395
396 // compute V_e and add it to volume
397 for (auto qd : qds)
398 v += qd.d_shapes[loc_i] * factor * qd.d_w;
399 } // loop over elements
400
401 // update
402 this->d_vol[i] = v;
403 }
404 ); // for_each
405
406 executor.run(taskflow).get();
407}
std::vector< size_t > getElementConnectivity(const size_t &i) const
Get the connectivity of element.
Definition mesh.h:213
std::vector< double > d_vol
Vector of volume of each node.
Definition mesh.h:467
void print(int nt=0, int lvl=0) const
Prints the information about the object.
Definition mesh.h:309
std::unique_ptr< BaseElem > elem(size_t type, size_t order)
std::string printStr(const T &msg, int nt=print_default_tab)
Returns formatted string for output.
Definition io.h:53
unsigned int getNThreads()
Get number of threads to be used by taskflow.

References d_enc, d_eType, d_nec, d_nodes, d_numNodes, d_vol, fe::elem(), getElementConnectivity(), util::parallel::getNThreads(), print(), and util::io::printStr().

Referenced by finalizeMeshDerivedFieldsFromCurrentNodes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createData()

void mesh::Mesh::createData ( const std::string &  filename,
bool  ref_config = false 
)

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.

Parameters
filenameName of the mesh file
ref_configFlag which specifies if we need to subtract the displacement from nodes obtained from vtu file to get reference position of nodes

Definition at line 68 of file mesh.cpp.

68 {
69
70 util::io::log("Mesh: Reading element data.\n");
71
72 int file_type = -1;
73 // find the extension of file and call correct reader
74 if (util::io::getExtensionFromFile(filename) == "csv")
75 file_type = 0;
76 else if (util::io::getExtensionFromFile(filename) == "msh")
77 file_type = 1;
78 else if (util::io::getExtensionFromFile(filename) == "vtu")
79 file_type = 2;
80 else {
81 std::cerr << "Error: Currently only '.csv', '.msg', and '.vtu' "
82 "files are supported for reading mesh.\n";
83 exit(EXIT_FAILURE);
84 }
85
86 if (d_spatialDiscretization != "finite_difference" and file_type == 0) {
87
88 std::cerr << "Error: For discretization = " << d_spatialDiscretization
89 << " .vtu or .msh mesh file is required.\n";
90 exit(1);
91 }
92
93 //
94 bool is_fd = false;
95 if (d_spatialDiscretization == "finite_difference")
96 is_fd = true;
97
98 // read node and elements
99 if (file_type == 0)
101 else if (file_type == 1) {
103 &d_enc, &d_nec, &d_vol, false);
104 d_encDataPopulated = true;
105 }
106 else if (file_type == 2) {
107 //
108 // old reading of mesh
109 //
110 // rw::reader::readVtuFile(filename, d_dim, &d_nodes, d_eType, d_numElems,
111 // &d_enc, &d_nec, &d_vol, false);
112
113 //
114 // new reading of mesh
115 // We read the data from file one by one depending on what data we need
116 //
117
118 // read node
119 rw::reader::readVtuFileNodes(filename, d_dim, &d_nodes, ref_config);
120
121 // read volume if required
122 bool found_volume_data = false;
123 if (is_fd) {
124 found_volume_data =
125 rw::reader::readVtuFilePointData(filename, "Node_Volume", &d_vol);
126
127 // try another tag for nodal volume
128 if (!found_volume_data)
129 found_volume_data =
130 rw::reader::readVtuFilePointData(filename, "Volume", &d_vol);
131 }
132
133 // read element data (only if this is fe simulation or if we need
134 // element-node connectivity data for nodal volume calculation)
135 if (!is_fd || !found_volume_data) {
137 &d_nec);
138 d_encDataPopulated = true;
139 }
140
141 // check if file has fixity data
142 rw::reader::readVtuFilePointData(filename, "Fixity", &d_fix);
143 }
144
145 // compute data from mesh data
146 d_numNodes = d_nodes.size();
149
150 //
151 // assign default values to fixity
152 //
153 if (d_fix.size() != d_numNodes)
154 d_fix = std::vector<uint8_t>(d_nodes.size(), uint8_t(0));
155
156 //
157 // compute nodal volume if required
158 //
159 bool compute_vol = false;
160 if (is_fd and d_vol.empty()) compute_vol = true;
161
162 // if this is weak finite element simulation then check from policy if
163 // volume is to be computed
164 if (d_spatialDiscretization == "weak_finite_element")
165 compute_vol = false;
166
168 compute_vol, std::string("mesh filename = ") + filename);
169}
void finalizeMeshDerivedFieldsFromCurrentNodes(bool compute_vol_from_elements, const std::string &volume_error_note)
After nodes, enc, nec, and dof-related fields are set: 2D z clear, bbox, optional nodal volume,...
Definition mesh.cpp:247
std::vector< uint8_t > d_fix
Vector of fixity mask of each node.
Definition mesh.h:459
static int vtk_map_element_to_num_nodes[16]
Map from element type to number of nodes (for vtk)
void readVtuFileCells(const std::string &filename, size_t dim, size_t &element_type, size_t &num_elem, std::vector< size_t > *enc, std::vector< std::vector< size_t > > *nec)
Reads cell data, i.e. element-node connectivity and node-element connectivity.
Definition reader.cpp:168
bool readVtuFilePointData(const std::string &filename, const std::string &tag, std::vector< uint8_t > *data)
Reads data of specified tag from the vtu file.
Definition reader.cpp:208
void readVtuFileNodes(const std::string &filename, size_t dim, std::vector< util::Point > *nodes, bool ref_config=false)
Reads nodal coordinates.
Definition reader.cpp:137
void readCsvFile(const std::string &filename, size_t dim, std::vector< util::Point > *nodes, std::vector< double > *volumes)
Reads mesh data into node file and element file.
Definition reader.cpp:16
void readMshFile(const std::string &filename, size_t dim, std::vector< util::Point > *nodes, size_t &element_type, size_t &num_elem, std::vector< size_t > *enc, std::vector< std::vector< size_t > > *nec, std::vector< double > *volumes, bool is_fd=false)
Reads mesh data into node file and element file.
Definition reader.cpp:351
std::string getExtensionFromFile(std::string const &filename)
Get extension from the filename.
Definition io.h:308
void log(std::ostringstream &oss, bool screen_out=false, int printMpiRank=print_default_mpi_rank)
Global method to log the message.
Definition io.cpp:41

References d_dim, d_enc, d_encDataPopulated, d_eNumVertex, d_eType, d_fix, d_nec, d_nodes, d_numDofs, d_numElems, d_numNodes, d_spatialDiscretization, d_vol, finalizeMeshDerivedFieldsFromCurrentNodes(), 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ finalizeMeshDerivedFieldsFromCurrentNodes()

void mesh::Mesh::finalizeMeshDerivedFieldsFromCurrentNodes ( bool  compute_vol_from_elements,
const std::string &  volume_error_note 
)
private

After nodes, enc, nec, and dof-related fields are set: 2D z clear, bbox, optional nodal volume, mesh size h, volume sanity check, and optional connectivity read from file.

Parameters
volume_error_noteOptional extra line for the volume check failure message (e.g. filename or in-memory hint).

Definition at line 247 of file mesh.cpp.

248 {
249
251 computeBBox();
252 if (compute_vol_from_elements) {
253 util::io::log("Mesh: Computing nodal volume.\n");
254 computeVol();
255 }
256
258
259 size_t counter = 0;
260 for (const auto &v : d_vol) {
261
262 if (v < 0.01 * std::pow(d_h, d_dim)) {
263
264 std::cerr << "Error: Check nodal volume " << v
265 << " is less than " << 0.01 * std::pow(d_h, d_dim)
266 << ", Node = " << counter << " at position = "
267 << d_nodes[counter].printStr() << "\n";
268 if (!volume_error_note.empty())
269 std::cerr << volume_error_note << "\n";
270 std::cerr << printStr() << "\n";
271
272 exit(1);
273 }
274
275 counter++;
276 }
277
278 if (d_needEncData and (!d_encDataPopulated or d_enc.empty()))
280}
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing printable information about the object.
Definition mesh.cpp:488
bool readElementData(const std::string &filename)
Reads element-node connectivity data from file. This function is meant for cases when mesh was create...
Definition mesh.cpp:282
void computeMeshSize()
Compute the mesh size.
Definition mesh.cpp:437
void setZCoordinateZero()
For , set on all reference nodes (x–y plane). Call before computeBBox() when nodes may carry numeric...
Definition mesh.cpp:409
void computeVol()
Compute the nodal volume.
Definition mesh.cpp:333
void computeBBox()
Compute the bounding box from d_nodes (after setZCoordinateZero() for 2D if applicable).
Definition mesh.cpp:416

References computeBBox(), computeMeshSize(), computeVol(), d_dim, d_enc, d_encDataPopulated, d_filename, d_h, d_needEncData, d_nodes, d_vol, util::io::log(), printStr(), readElementData(), and setZCoordinateZero().

Referenced by createData(), loadFromTetraElements3D(), and loadFromTriangleElements2D().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getBoundingBox() [1/2]

std::pair< std::vector< double >, std::vector< double > > & mesh::Mesh::getBoundingBox ( )
inline

Get the bounding box of the mesh.

Returns
box Bounding box

Definition at line 268 of file mesh.h.

268 {
269 return d_bbox;
270 };

References d_bbox.

◆ getBoundingBox() [2/2]

const std::pair< std::vector< double >, std::vector< double > > & mesh::Mesh::getBoundingBox ( ) const
inline

Get the bounding box of the mesh.

Returns
box Bounding box

Definition at line 262 of file mesh.h.

263 {
264 return d_bbox;
265 };

References d_bbox.

◆ getDimension()

size_t mesh::Mesh::getDimension ( ) const
inline

Get the dimension of the domain.

Returns
N Dimension

Definition at line 85 of file mesh.h.

85{ return d_dim; };

References d_dim.

Referenced by mesh::getMaxShearStressAndLoc(), mesh::getStrainStress(), and mesh_gen::anonymous_namespace{meshGenerator.cpp}::writeGmshMsh22From2DTriangleMesh().

Here is the caller graph for this function:

◆ getElementConnectivities() [1/2]

std::vector< size_t > & mesh::Mesh::getElementConnectivities ( )
inline

Get the reference to element-node connectivity data.

Returns
reference Reference

Definition at line 241 of file mesh.h.

241 {
242 return d_enc;
243 };

References d_enc.

◆ getElementConnectivities() [2/2]

const std::vector< size_t > & mesh::Mesh::getElementConnectivities ( ) const
inline

Get the reference to element-node connectivity data.

Returns
reference Reference

Definition at line 236 of file mesh.h.

236 {
237 return d_enc;
238 };

References d_enc.

Referenced by mesh_gen::anonymous_namespace{meshGenerator.cpp}::writeGmshMsh22From2DTriangleMesh().

Here is the caller graph for this function:

◆ getElementConnectivitiesP() [1/2]

std::vector< size_t > * mesh::Mesh::getElementConnectivitiesP ( )
inline

Get the pointer to element-node connectivity data.

Returns
pointer Pointer

Definition at line 254 of file mesh.h.

254 {
255 return &d_enc;
256 };

References d_enc.

◆ getElementConnectivitiesP() [2/2]

const std::vector< size_t > * mesh::Mesh::getElementConnectivitiesP ( ) const
inline

Get the pointer to element-node connectivity data.

Returns
pointer Pointer

Definition at line 249 of file mesh.h.

249 {
250 return &d_enc;
251 };

References d_enc.

◆ getElementConnectivity()

std::vector< size_t > mesh::Mesh::getElementConnectivity ( const size_t &  i) const
inline

Get the connectivity of element.

Since we store connectivity in a single vector, we use mesh::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}\)]

Parameters
iId of an element
Returns
vector Vector of nodal ids

Definition at line 213 of file mesh.h.

213 {
214 return std::vector<size_t>(d_enc.begin() + d_eNumVertex * i,
215 d_enc.begin() + d_eNumVertex * i + d_eNumVertex);
216 };

References d_enc, and d_eNumVertex.

Referenced by computeVol(), mesh::getCurrentQuadPoints(), mesh::getMaxShearStressAndLoc(), and mesh::getStrainStress().

Here is the caller graph for this function:

◆ getElementConnectivityNodes()

std::vector< util::Point > mesh::Mesh::getElementConnectivityNodes ( const size_t &  i) const
inline

Get the vertices of element.

Parameters
iId of an element
Returns
vector Vector of vertices

Definition at line 224 of file mesh.h.

225 {
226 std::vector<util::Point> nds;
227 for (size_t k = 0; k < d_eNumVertex; k++)
228 nds.emplace_back(d_nodes[d_enc[d_eNumVertex * i + k]]);
229 return nds;
230 };

References d_enc, d_eNumVertex, and d_nodes.

◆ getElementType()

size_t mesh::Mesh::getElementType ( ) const
inline

Get the type of element in mesh.

Returns
type Element type (using VTK convention)

Definition at line 109 of file mesh.h.

109{ return d_eType; };

References d_eType.

Referenced by mesh::getCurrentQuadPoints(), mesh::getMaxShearStressAndLoc(), mesh::getStrainStress(), and mesh_gen::anonymous_namespace{meshGenerator.cpp}::writeGmshMsh22From2DTriangleMesh().

Here is the caller graph for this function:

◆ getFixity() [1/2]

std::vector< uint8_t > & mesh::Mesh::getFixity ( )
inline

Get the reference to fixity data.

Returns
reference Reference to fixity data

Definition at line 165 of file mesh.h.

165{ return d_fix; };

References d_fix.

◆ getFixity() [2/2]

const std::vector< uint8_t > & mesh::Mesh::getFixity ( ) const
inline

Get the reference to fixity data.

Returns
reference Reference to fixity data

Definition at line 162 of file mesh.h.

162{ return d_fix; };

References d_fix.

◆ getFixityP() [1/2]

std::vector< uint8_t > * mesh::Mesh::getFixityP ( )
inline

Get the pointer to fixity data.

Returns
pointer Pointer to fixity data

Definition at line 156 of file mesh.h.

156{ return &d_fix; };

References d_fix.

◆ getFixityP() [2/2]

const std::vector< uint8_t > * mesh::Mesh::getFixityP ( ) const
inline

Get the pointer to fixity data.

Returns
pointer Pointer to fixity data

Definition at line 153 of file mesh.h.

153{ return &d_fix; };

References d_fix.

◆ getMeshSize()

double mesh::Mesh::getMeshSize ( ) const
inline

Get the mesh size.

Returns
h Mesh size

Definition at line 115 of file mesh.h.

115{ return d_h; };

References d_h.

◆ getNodalVolume()

double mesh::Mesh::getNodalVolume ( const size_t &  i) const
inline

Get nodal volume of node i.

Parameters
iId of the node
Returns
vol Volume

Definition at line 129 of file mesh.h.

129{ return d_vol[i]; };

References d_vol.

◆ getNodalVolumes() [1/2]

std::vector< double > & mesh::Mesh::getNodalVolumes ( )
inline

Get the nodal volume data.

Returns
Vector Vector of nodal volume

Definition at line 174 of file mesh.h.

174{ return d_vol; };

References d_vol.

◆ getNodalVolumes() [2/2]

const std::vector< double > & mesh::Mesh::getNodalVolumes ( ) const
inline

Get the nodal volume data.

Returns
Vector Vector of nodal volume

Definition at line 171 of file mesh.h.

171{ return d_vol; };

References d_vol.

◆ getNodalVolumesP() [1/2]

std::vector< double > * mesh::Mesh::getNodalVolumesP ( )
inline

Get the pointer to nodal volume data.

Returns
pointer Pointer to nodal volume data

Definition at line 183 of file mesh.h.

183{ return &d_vol; };

References d_vol.

◆ getNodalVolumesP() [2/2]

const std::vector< double > * mesh::Mesh::getNodalVolumesP ( ) const
inline

Get the pointer to nodal volume data.

Returns
pointer Pointer to nodal volume data

Definition at line 180 of file mesh.h.

180{ return &d_vol; };

References d_vol.

◆ getNode()

util::Point mesh::Mesh::getNode ( const size_t &  i) const
inline

Get coordinates of node i.

Parameters
iId of the node
Returns
coords Coordinates

Definition at line 122 of file mesh.h.

122{ return d_nodes[i]; };

References d_nodes.

◆ getNodes() [1/2]

std::vector< util::Point > & mesh::Mesh::getNodes ( )
inline

Get the nodes data.

Returns
nodes Nodes data

Definition at line 138 of file mesh.h.

138{ return d_nodes; };

References d_nodes.

◆ getNodes() [2/2]

const std::vector< util::Point > & mesh::Mesh::getNodes ( ) const
inline

Get the nodes data.

Returns
nodes Nodes data

Definition at line 135 of file mesh.h.

135{ return d_nodes; };

References d_nodes.

Referenced by mesh_gen::anonymous_namespace{meshGenerator.cpp}::writeGmshMsh22From2DTriangleMesh().

Here is the caller graph for this function:

◆ getNodesP() [1/2]

std::vector< util::Point > * mesh::Mesh::getNodesP ( )
inline

Get the pointer to nodes data.

Returns
pointer Pointer to nodes data

Definition at line 147 of file mesh.h.

147{ return &d_nodes; };

References d_nodes.

◆ getNodesP() [2/2]

const std::vector< util::Point > * mesh::Mesh::getNodesP ( ) const
inline

Get the pointer to nodes data.

Returns
pointer Pointer to nodes data

Definition at line 144 of file mesh.h.

144{ return &d_nodes; };

References d_nodes.

◆ getNumDofs()

size_t mesh::Mesh::getNumDofs ( ) const
inline

Get the number of dofs.

Returns
N Number of dofs

Definition at line 103 of file mesh.h.

103{ return d_numDofs; };

References d_numDofs.

◆ getNumElements()

size_t mesh::Mesh::getNumElements ( ) const
inline

Get the number of elements.

Returns
N Number of elements

Definition at line 97 of file mesh.h.

97{ return d_enc.size()/d_eNumVertex; };

References d_enc, and d_eNumVertex.

Referenced by mesh::getCurrentQuadPoints(), mesh::getMaxShearStressAndLoc(), and mesh::getStrainStress().

Here is the caller graph for this function:

◆ getNumNodes()

size_t mesh::Mesh::getNumNodes ( ) const
inline

Get the number of nodes.

Returns
N number of nodes

Definition at line 91 of file mesh.h.

91{ return d_numNodes; };

References d_numNodes.

Referenced by mesh::getCurrentQuadPoints(), mesh::getMaxShearStressAndLoc(), and mesh::getStrainStress().

Here is the caller graph for this function:

◆ isNodeFree()

bool mesh::Mesh::isNodeFree ( const size_t &  i,
const unsigned int &  dof 
) const
inline

Return true if node is free.

Parameters
iId of node
dofDof to check for
Returns
bool True if dof is free else false

Definition at line 191 of file mesh.h.

191 {
192
193 // below checks if d_fix has 1st bit (if dof=0), 2nd bit (if dof=1), 3rd
194 // bit (if dof=2) is set to 1 or 0. If set to 1, then it means it is fixed,
195 // and therefore it returns false
196 return !(d_fix[i] >> dof & 1UL);
197 };

References d_fix.

◆ loadFromTetraElements3D()

void mesh::Mesh::loadFromTetraElements3D ( std::vector< util::Point nodes,
std::vector< size_t >  enc,
const inp::MeshDeck meshDeck,
const inp::ModelDeck modelDeck 
)

Populate mesh from 3D tetrahedron data (0-based node indices in enc) without reading a file.

Definition at line 209 of file mesh.cpp.

212 {
213
214 if (enc.size() % 4 != 0)
215 throw std::runtime_error(
216 "Mesh::loadFromTetraElements3D: connectivity length must be a multiple of 4.");
217
218 d_nodes = std::move(nodes);
219 d_enc = std::move(enc);
221 d_numNodes = d_nodes.size();
222 d_eNumVertex = 4;
223 d_numElems = d_enc.size() / 4;
224 d_dim = modelDeck->d_dim;
226 d_filename = meshDeck->d_filename;
228 d_encDataPopulated = true;
229 d_fix.assign(d_numNodes, 0);
230 d_vol.clear();
231
232 d_nec.assign(d_numNodes, {});
233 for (size_t e = 0; e < d_numElems; ++e) {
234 for (unsigned k = 0; k < 4; ++k) {
235 size_t nid = d_enc[4 * e + k];
236 d_nec[nid].push_back(e);
237 }
238 }
239
241
243 d_spatialDiscretization == "finite_difference",
244 "(in-memory tetrahedron mesh)");
245}
static const int vtk_type_tetra
Integer flag for tetrahedron element.

References inp::ModelDeck::d_dim, d_dim, d_enc, d_encDataPopulated, d_eNumVertex, d_eType, inp::MeshDeck::d_filename, d_filename, d_fix, d_nec, d_needEncData, d_nodes, d_numDofs, d_numElems, d_numNodes, inp::ModelDeck::d_populateElementNodeConnectivity, inp::ModelDeck::d_spatialDiscretization, d_spatialDiscretization, d_vol, finalizeMeshDerivedFieldsFromCurrentNodes(), and util::vtk_type_tetra.

Referenced by mesh_gen::fillMeshFromActiveGmshModel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadFromTriangleElements2D()

void mesh::Mesh::loadFromTriangleElements2D ( std::vector< util::Point nodes,
std::vector< size_t >  enc,
const inp::MeshDeck meshDeck,
const inp::ModelDeck modelDeck 
)

Populate mesh from 2D triangle data (0-based node indices in enc) without reading a file.

Used after Gmsh generates a mesh in memory. Requires finite_difference or populated element connectivity consistent with the model deck.

Definition at line 171 of file mesh.cpp.

174 {
175
176 if (enc.size() % 3 != 0)
177 throw std::runtime_error(
178 "Mesh::loadFromTriangleElements2D: connectivity length must be a multiple of 3.");
179
180 d_nodes = std::move(nodes);
181 d_enc = std::move(enc);
183 d_numNodes = d_nodes.size();
184 d_eNumVertex = 3;
185 d_numElems = d_enc.size() / 3;
186 d_dim = modelDeck->d_dim;
188 d_filename = meshDeck->d_filename;
190 d_encDataPopulated = true;
191 d_fix.assign(d_numNodes, 0);
192 d_vol.clear();
193
194 d_nec.assign(d_numNodes, {});
195 for (size_t e = 0; e < d_numElems; ++e) {
196 for (unsigned k = 0; k < 3; ++k) {
197 size_t nid = d_enc[3 * e + k];
198 d_nec[nid].push_back(e);
199 }
200 }
201
203
205 d_spatialDiscretization == "finite_difference",
206 "(in-memory triangle mesh)");
207}
static const int vtk_type_triangle
Integer flag for triangle element.

References inp::ModelDeck::d_dim, d_dim, d_enc, d_encDataPopulated, d_eNumVertex, d_eType, inp::MeshDeck::d_filename, d_filename, d_fix, d_nec, d_needEncData, d_nodes, d_numDofs, d_numElems, d_numNodes, inp::ModelDeck::d_populateElementNodeConnectivity, inp::ModelDeck::d_spatialDiscretization, d_spatialDiscretization, d_vol, finalizeMeshDerivedFieldsFromCurrentNodes(), and util::vtk_type_triangle.

Referenced by mesh_gen::fillMeshFromActiveGmshModel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print()

void mesh::Mesh::print ( int  nt = 0,
int  lvl = 0 
) const
inline

Prints the information about the object.

Parameters
ntNumber of tabs to append before printing
lvlInformation level (higher means more information)

Definition at line 309 of file mesh.h.

309{ std::cout << printStr(nt, lvl); };

References printStr().

Referenced by computeVol().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ printStr()

std::string mesh::Mesh::printStr ( int  nt = 0,
int  lvl = 0 
) const

Returns the string containing printable information about the object.

Parameters
ntNumber of tabs to append before printing
lvlInformation level (higher means more information)
Returns
string String containing printable information about the object

Definition at line 488 of file mesh.cpp.

488 {
489
490 auto tabS = util::io::getTabS(nt);
491 std::ostringstream oss;
492 oss << tabS << "------- Mesh --------" << std::endl << std::endl;
493 oss << tabS << "Dimension = " << d_dim << std::endl;
494 oss << tabS << "Spatial discretization type = " << d_spatialDiscretization << std::endl;
495 oss << tabS << "Mesh size = " << d_h << std::endl;
496 oss << tabS << "Num nodes = " << d_numNodes << std::endl;
497 oss << tabS << "Num elements = " << d_numElems << std::endl;
498 oss << tabS << "Element type = " << d_eType << std::endl;
499 oss << tabS << "Num nodes per element = " << d_eNumVertex << std::endl;
500 oss << tabS << "Num nodal vol = " << d_vol.size() << std::endl;
501 oss << tabS << "Bounding box: " << std::endl;
502 oss << util::io::printBoxStr(d_bbox, nt + 1);
503 oss << tabS << std::endl;
504
505 return oss.str();
506}
std::string printBoxStr(const std::pair< util::Point, util::Point > &box, int nt=print_default_tab)
Returns formatted string for output.
Definition io.h:188
std::string getTabS(int nt)
Returns tab spaces of a given size.
Definition io.h:39

References d_bbox, d_dim, d_eNumVertex, d_eType, d_h, d_numElems, d_numNodes, d_spatialDiscretization, d_vol, util::io::getTabS(), and util::io::printBoxStr().

Referenced by finalizeMeshDerivedFieldsFromCurrentNodes(), and print().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readElementData()

bool mesh::Mesh::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.

File must be either **.vtu** or **.msh** file and must have element-node connectivity data.

Parameters
filenameName of the mesh file

Definition at line 282 of file mesh.cpp.

282 {
283
284 if (d_encDataPopulated and !d_enc.empty()) {
285 util::io::log("Mesh: Element data is populated already.\n");
286 return false;
287 }
288
289 util::io::log("Mesh: Reading element-node connectivity data.\n");
290
291 int file_type = -1;
292 // find the extension of file and call correct reader
293 if (util::io::getExtensionFromFile(filename) == "csv")
294 file_type = 0;
295 else if (util::io::getExtensionFromFile(filename) == "msh")
296 file_type = 1;
297 else if (util::io::getExtensionFromFile(filename) == "vtu")
298 file_type = 2;
299 else {
300 std::cerr << "Error: Currently only '.csv', '.msg', and '.vtu' "
301 "files are supported for reading mesh.\n";
302 exit(EXIT_FAILURE);
303 }
304
305 if (file_type == 0) {
306 std::cerr << "Error: readElementData() requires file to be either "
307 ".vtu or .msh mesh file.\n";
308 exit(EXIT_FAILURE);
309 }
310
311 if (file_type == 1) {
313 &d_enc,
314 &d_nec);
315 d_encDataPopulated = true;
316 // createData() may have skipped cells when Node_Volume was present, leaving
317 // d_eNumVertex from the default element type (1). Refresh after cell read.
319 return true;
320 }
321 else if (file_type == 2) {
323 &d_enc,
324 &d_nec);
325 d_encDataPopulated = true;
327 return true;
328 }
329
330 return false;
331}
void readMshFileCells(const std::string &filename, size_t dim, size_t &element_type, size_t &num_elem, std::vector< size_t > *enc, std::vector< std::vector< size_t > > *nec)
Reads cell data, i.e. element-node connectivity and node-element connectivity.
Definition reader.cpp:401

References d_dim, d_enc, d_encDataPopulated, d_eNumVertex, d_eType, d_nec, d_numElems, util::io::getExtensionFromFile(), util::io::log(), rw::reader::readMshFileCells(), rw::reader::readVtuFileCells(), and util::vtk_map_element_to_num_nodes.

Referenced by finalizeMeshDerivedFieldsFromCurrentNodes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFixity()

void mesh::Mesh::setFixity ( const size_t &  i,
const unsigned int &  dof,
const bool &  flag 
)

Set the fixity to free (0) or fixed (1)

Parameters
iId of node
dofDof which is affected
flagSet fixity to fixed if true or free

Definition at line 469 of file mesh.cpp.

470 {
471
472 // to set i^th bit as true of integer a,
473 // a |= 1UL << (i % 8)
474
475 // to set i^th bit as false of integer a,
476 // a &= ~(1UL << (i % 8))
477
478 flag ? (d_fix[i] |= 1UL << dof) : (d_fix[i] &= ~(1UL << dof));
479}

References d_fix.

◆ setZCoordinateZero()

void mesh::Mesh::setZCoordinateZero ( )

For \(d_{\mathrm{dim}} = 2\), set \(z = 0\) on all reference nodes (x–y plane). Call before computeBBox() when nodes may carry numerical noise in \(z\).

Definition at line 409 of file mesh.cpp.

409 {
410 if (d_dim != 2)
411 return;
412 for (auto &p : d_nodes)
413 p.d_z = 0.;
414}

References d_dim, and d_nodes.

Referenced by finalizeMeshDerivedFieldsFromCurrentNodes().

Here is the caller graph for this function:

Field Documentation

◆ d_bbox

std::pair<std::vector<double>, std::vector<double> > mesh::Mesh::d_bbox

Bounding box.

Definition at line 541 of file mesh.h.

Referenced by computeBBox(), mesh::createUniformMesh(), getBoundingBox(), getBoundingBox(), and printStr().

◆ d_dim

◆ d_enc

std::vector<size_t> mesh::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 443 of file mesh.h.

Referenced by clearElementData(), computeVol(), createData(), mesh::createUniformMesh(), finalizeMeshDerivedFieldsFromCurrentNodes(), getElementConnectivities(), getElementConnectivities(), getElementConnectivitiesP(), getElementConnectivitiesP(), getElementConnectivity(), getElementConnectivityNodes(), getNumElements(), loadFromTetraElements3D(), loadFromTriangleElements2D(), readElementData(), and mesh::removeNodesInBoxes().

◆ d_encDataPopulated

bool mesh::Mesh::d_encDataPopulated

Flag that indicates whether element-node connectivity data is read from file.

Definition at line 515 of file mesh.h.

Referenced by createData(), finalizeMeshDerivedFieldsFromCurrentNodes(), loadFromTetraElements3D(), loadFromTriangleElements2D(), and readElementData().

◆ d_eNumVertex

size_t mesh::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

  • Line element: 2,
  • Triangle element: 3,
  • Quadrilateral element: 4,
  • Tetrahedral element: 4

Definition at line 432 of file mesh.h.

Referenced by createData(), mesh::createUniformMesh(), getElementConnectivity(), getElementConnectivityNodes(), mesh::getMaxShearStressAndLoc(), getNumElements(), loadFromTetraElements3D(), loadFromTriangleElements2D(), printStr(), readElementData(), and mesh::removeNodesInBoxes().

◆ d_eType

size_t mesh::Mesh::d_eType

Element type.

We follow VTK convention to identify the elements:

  • Line element = 3,
  • Triangle element = 5,
  • Pixel element = 8,
  • Quadrilateral element = 9,
  • Tetrahedral element = 10

Definition at line 417 of file mesh.h.

Referenced by computeVol(), createData(), mesh::createUniformMesh(), getElementType(), loadFromTetraElements3D(), loadFromTriangleElements2D(), printStr(), and readElementData().

◆ d_filename

std::string mesh::Mesh::d_filename

Filename to read mesh data.

Definition at line 509 of file mesh.h.

Referenced by finalizeMeshDerivedFieldsFromCurrentNodes(), loadFromTetraElements3D(), loadFromTriangleElements2D(), and Mesh().

◆ d_fix

std::vector<uint8_t> mesh::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 459 of file mesh.h.

Referenced by createData(), mesh::createUniformMesh(), getFixity(), getFixity(), getFixityP(), getFixityP(), isNodeFree(), loadFromTetraElements3D(), loadFromTriangleElements2D(), mesh::removeNodesInBoxes(), and setFixity().

◆ d_gInvMap

std::vector<int> mesh::Mesh::d_gInvMap

Map from global id to reduced global id.

This is a inverse of d_gMap

Definition at line 538 of file mesh.h.

◆ d_gMap

std::vector<size_t> mesh::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.

Note
Needed only when the discretization is "weak_finite_element" for the assembly of the mass matrix.

Definition at line 532 of file mesh.h.

◆ d_h

double mesh::Mesh::d_h

Characteristic mesh spacing (minimum nodal distance); always from computeMeshSize() after nodes exist.

Definition at line 544 of file mesh.h.

Referenced by computeMeshSize(), mesh::createUniformMesh(), finalizeMeshDerivedFieldsFromCurrentNodes(), getMeshSize(), printStr(), and mesh::removeNodesInBoxes().

◆ d_nec

std::vector<std::vector<size_t> > mesh::Mesh::d_nec

Node-element connectivity data.

At present, this data is never populated.

Definition at line 449 of file mesh.h.

Referenced by clearElementData(), computeVol(), createData(), loadFromTetraElements3D(), loadFromTriangleElements2D(), and readElementData().

◆ d_needEncData

bool mesh::Mesh::d_needEncData

Flag that indicates whether we need enc data (set by input mesh deck in constructor)

Definition at line 512 of file mesh.h.

Referenced by finalizeMeshDerivedFieldsFromCurrentNodes(), loadFromTetraElements3D(), and loadFromTriangleElements2D().

◆ d_nodePartition

std::vector<size_t> mesh::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 491 of file mesh.h.

Referenced by mesh::metisGraphPartition().

◆ d_nodes

◆ d_nPart

size_t mesh::Mesh::d_nPart

Number of partitions.

Definition at line 477 of file mesh.h.

Referenced by mesh::metisGraphPartition().

◆ d_numDofs

size_t mesh::Mesh::d_numDofs

Number of dofs = (dimension) times (number of nodes)

Definition at line 518 of file mesh.h.

Referenced by createData(), mesh::createUniformMesh(), getNumDofs(), loadFromTetraElements3D(), loadFromTriangleElements2D(), and mesh::removeNodesInBoxes().

◆ d_numElems

size_t mesh::Mesh::d_numElems

◆ d_numNodes

size_t mesh::Mesh::d_numNodes

◆ d_partitionMethod

std::string mesh::Mesh::d_partitionMethod

Partitioning method. It could be either empty string or "metis_recursive" or "metis_kway".

Definition at line 482 of file mesh.h.

Referenced by mesh::metisGraphPartition().

◆ d_spatialDiscretization

std::string mesh::Mesh::d_spatialDiscretization

Tag for spatial discretization type.

List of valid values are:

  • finite_difference
  • weak_finite_element
  • nodal_finite_element
  • truss_finite_element

Definition at line 506 of file mesh.h.

Referenced by createData(), loadFromTetraElements3D(), loadFromTriangleElements2D(), Mesh(), and printStr().

◆ d_vol

std::vector<double> mesh::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 467 of file mesh.h.

Referenced by computeVol(), createData(), mesh::createUniformMesh(), finalizeMeshDerivedFieldsFromCurrentNodes(), getNodalVolume(), getNodalVolumes(), getNodalVolumes(), getNodalVolumesP(), getNodalVolumesP(), loadFromTetraElements3D(), loadFromTriangleElements2D(), printStr(), and mesh::removeNodesInBoxes().


The documentation for this class was generated from the following files: