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::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.
 
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::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.
 

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, nodal volume 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.

Only a mesh with one element type is supported, 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 31 of file mesh.cpp.

33 d_h(0.), d_dim(dim), d_encDataPopulated(false), d_needEncData(false),
34 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 36 of file mesh.cpp.

38 d_h(0.), d_dim(modelDeck->d_dim),
40 d_filename(meshDeck->d_filename), d_encDataPopulated(false),
42 d_nPart(0) {
43
44 // perform check on input data
45 if (d_spatialDiscretization != "finite_difference" and
46 d_spatialDiscretization != "weak_finite_element" and
47 d_spatialDiscretization != "nodal_finite_element" and
48 d_spatialDiscretization != "truss_finite_element") {
49 throw std::runtime_error("Spatial discretization type " + d_spatialDiscretization + " not known. Check input data.");
50 }
51
52 if (d_dim < 0 or d_dim > 3) {
53 throw std::runtime_error(
55 << "Error: Check Dimension in input data.\n");
56 }
57
58 if (d_filename.empty()) {
59 throw std::runtime_error(
61 << "Error: Filename for mesh data not specified.\n");
62 }
63
64 // read mesh data from file
66}
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:71
Collects a message with stream syntax for use in an exception.
Definition io.h:52
std::string d_filename
Filename to read mesh data.
Definition meshDeck.h:31
bool d_populateElementNodeConnectivity
Flag to indicate if we should populate element-node connectivity data in meshes.
Definition modelDeck.h:62
size_t d_dim
Dimension.
Definition modelDeck.h:108
std::string d_spatialDiscretization
Tag for spatial discretization.
Definition modelDeck.h:49

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 489 of file mesh.cpp.

489 {
490 if (!d_enc.empty())
491 d_enc.shrink_to_fit();
492 d_numElems = 0;
493 if (!d_nec.empty())
494 d_nec.shrink_to_fit();
495}
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 425 of file mesh.cpp.

425 {
426 std::vector<double> p1(3,0.);
427 std::vector<double> p2(3,0.);
428 for (const auto& x : d_nodes) {
429 if (util::isLess(x.d_x, p1[0]))
430 p1[0] = x.d_x;
431 if (util::isLess(x.d_y, p1[1]))
432 p1[1] = x.d_y;
433 if (util::isLess(x.d_z, p1[2]))
434 p1[2] = x.d_z;
435 if (util::isLess(p2[0], x.d_x))
436 p2[0] = x.d_x;
437 if (util::isLess(p2[1], x.d_y))
438 p2[1] = x.d_y;
439 if (util::isLess(p2[2], x.d_z))
440 p2[2] = x.d_z;
441 }
442
443 d_bbox = std::make_pair(p1, p2);
444}
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:22

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 446 of file mesh.cpp.

446 {
447
448 double guess = 0.;
449 if (d_nodes.size() < 2) {
450 d_h = 0.;
451 return;
452 }
453
454 guess = (d_nodes[0] - d_nodes[1]).length();
455 for (size_t i = 0; i < d_nodes.size(); i++)
456 for (size_t j = 0; j < d_nodes.size(); j++)
457 if (i != j) {
458 double val = d_nodes[i].dist(d_nodes[j]);
459
460 if (util::isLess(val, 1.0E-12)) {
461
462 std::cout << "Check nodes are too close = "
463 << util::io::printStr<util::Point>({d_nodes[i],
464 d_nodes[j]})
465 << "\n";
466 std::cout << "Distance = " << val << ", guess = " << guess << "\n";
467 }
468 if (util::isLess(val, guess))
469 guess = val;
470 }
471
472 d_h = guess;
473}

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 340 of file mesh.cpp.

340 {
341
342 auto quads = fe::elem(d_eType, 2);
343 auto *quads_p = quads.get();
344
345 // check if we have valid element-node connectivity data for nodal volume
346 // calculations
347 if (d_nec.size() != d_numNodes || d_enc.empty()) {
348 throw std::runtime_error(
350 << "Error: Can not compute nodal volume for given finite "
351 "element mesh as the element-node connectivity data is "
352 "invalid."
353 << std::endl);
354 }
355
356 if (false) {
357 print(0, 0);
358 std::cout << "\n-------- Node data ----------\n";
359 std::cout << util::io::printStr(d_nodes, 0) << "\n";
360 std::cout << "\n-------- Element data ----------\n";
361 std::cout << util::io::printStr(d_enc, 0) << "\n";
362 }
363
364 //
365 // compute nodal volume
366 //
367 d_vol.resize(d_numNodes);
368
369 tf::Executor executor(util::parallel::getNThreads());
370 tf::Taskflow taskflow;
371
372 taskflow.for_each_index(
373 (std::size_t) 0, this->d_numNodes, (std::size_t) 1, [this, quads_p](std::size_t i) {
374 double v = 0.0;
375
376 for (auto e : this->d_nec[i]) {
377
378 std::vector<size_t> e_ns = this->getElementConnectivity(e);
379
380 // locate global node i in local list of element el
381 int loc_i = -1;
382 for (size_t l = 0; l < e_ns.size(); l++)
383 if (e_ns[l] == i)
384 loc_i = l;
385
386 if (loc_i == -1) {
387 throw std::runtime_error(
389 << "Error: Check node element connectivity.\n");
390 }
391
392 // get quad data
393 std::vector<util::Point> e_nodes;
394 for (auto k : e_ns)
395 e_nodes.emplace_back(this->d_nodes[k]);
396
397 // get volume of element
398 double vol = quads_p->elemSize(e_nodes);
399 double factor = 1.;
400 if (vol < 0.)
401 factor = -1.;
402
403 std::vector<fe::QuadData> qds = quads_p->getQuadDatas(e_nodes);
404
405 // compute V_e and add it to volume
406 for (auto qd : qds)
407 v += qd.d_shapes[loc_i] * factor * qd.d_w;
408 } // loop over elements
409
410 // update
411 this->d_vol[i] = v;
412 }
413 ); // for_each
414
415 executor.run(taskflow).get();
416}
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:96
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 71 of file mesh.cpp.

71 {
72
73 util::io::log("Mesh: Reading element data.\n");
74
75 int file_type = -1;
76 // find the extension of file and call correct reader
77 if (util::io::getExtensionFromFile(filename) == "csv")
78 file_type = 0;
79 else if (util::io::getExtensionFromFile(filename) == "msh")
80 file_type = 1;
81 else if (util::io::getExtensionFromFile(filename) == "vtu")
82 file_type = 2;
83 else {
84 throw std::runtime_error(
86 << "Error: Currently only '.csv', '.msg', and '.vtu' "
87 "files are supported for reading mesh.\n");
88 }
89
90 if (d_spatialDiscretization != "finite_difference" and file_type == 0) {
91
92 throw std::runtime_error(
94 << "Error: For discretization = " << d_spatialDiscretization
95 << " .vtu or .msh mesh file is required.\n");
96 }
97
98 //
99 bool is_fd = false;
100 if (d_spatialDiscretization == "finite_difference")
101 is_fd = true;
102
103 // read node and elements
104 if (file_type == 0)
106 else if (file_type == 1) {
108 &d_enc, &d_nec, &d_vol, false);
109 d_encDataPopulated = true;
110 }
111 else if (file_type == 2) {
112 //
113 // old reading of mesh
114 //
115 // rw::reader::readVtuFile(filename, d_dim, &d_nodes, d_eType, d_numElems,
116 // &d_enc, &d_nec, &d_vol, false);
117
118 //
119 // new reading of mesh
120 // We read the data from file one by one depending on what data we need
121 //
122
123 // read node
124 rw::reader::readVtuFileNodes(filename, d_dim, &d_nodes, ref_config);
125
126 // read volume if required
127 bool found_volume_data = false;
128 if (is_fd) {
129 found_volume_data =
130 rw::reader::readVtuFilePointData(filename, "Node_Volume", &d_vol);
131
132 // try another tag for nodal volume
133 if (!found_volume_data)
134 found_volume_data =
135 rw::reader::readVtuFilePointData(filename, "Volume", &d_vol);
136 }
137
138 // read element data (only if this is fe simulation or if we need
139 // element-node connectivity data for nodal volume calculation)
140 if (!is_fd || !found_volume_data) {
142 &d_nec);
143 d_encDataPopulated = true;
144 }
145
146 // check if file has fixity data
147 rw::reader::readVtuFilePointData(filename, "Fixity", &d_fix);
148 }
149
150 // compute data from mesh data
151 d_numNodes = d_nodes.size();
154
155 //
156 // assign default values to fixity
157 //
158 if (d_fix.size() != d_numNodes)
159 d_fix = std::vector<uint8_t>(d_nodes.size(), uint8_t(0));
160
161 //
162 // compute nodal volume if required
163 //
164 bool compute_vol = false;
165 if (is_fd and d_vol.empty()) compute_vol = true;
166
167 // if this is weak finite element simulation then check from policy if
168 // volume is to be computed
169 if (d_spatialDiscretization == "weak_finite_element")
170 compute_vol = false;
171
173 compute_vol, std::string("mesh filename = ") + filename);
174}
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:252
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:172
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:213
void readVtuFileNodes(const std::string &filename, size_t dim, std::vector< util::Point > *nodes, bool ref_config=false)
Reads nodal coordinates.
Definition reader.cpp:139
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:18
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:356
std::string getExtensionFromFile(std::string const &filename)
Get extension from the filename.
Definition io.h:351
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, nodal volume 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 252 of file mesh.cpp.

253 {
254
256 computeBBox();
257 if (compute_vol_from_elements) {
258 util::io::log("Mesh: Computing nodal volume.\n");
259 computeVol();
260 }
261
263
264 size_t counter = 0;
265 for (const auto &v : d_vol) {
266
267 if (v < 0.01 * std::pow(d_h, d_dim)) {
268
269 std::cerr << "Error: Check nodal volume " << v
270 << " is less than " << 0.01 * std::pow(d_h, d_dim)
271 << ", Node = " << counter << " at position = "
272 << d_nodes[counter].printStr() << "\n";
273 if (!volume_error_note.empty())
274 std::cerr << volume_error_note << "\n";
275 throw std::runtime_error(
277 << printStr() << "\n");
278 }
279
280 counter++;
281 }
282
283 if (d_needEncData and (!d_encDataPopulated or d_enc.empty()))
285}
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing printable information about the object.
Definition mesh.cpp:497
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:287
void computeMeshSize()
Compute the mesh size.
Definition mesh.cpp:446
void setZCoordinateZero()
For , set on all reference nodes (x–y plane). Call before computeBBox() when nodes may carry numeric...
Definition mesh.cpp:418
void computeVol()
Compute the nodal volume.
Definition mesh.cpp:340
void computeBBox()
Compute the bounding box from d_nodes (after setZCoordinateZero() for 2D if applicable).
Definition mesh.cpp:425

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 214 of file mesh.cpp.

217 {
218
219 if (enc.size() % 4 != 0)
220 throw std::runtime_error(
221 "Mesh::loadFromTetraElements3D: connectivity length must be a multiple of 4.");
222
223 d_nodes = std::move(nodes);
224 d_enc = std::move(enc);
226 d_numNodes = d_nodes.size();
227 d_eNumVertex = 4;
228 d_numElems = d_enc.size() / 4;
229 d_dim = modelDeck->d_dim;
231 d_filename = meshDeck->d_filename;
233 d_encDataPopulated = true;
234 d_fix.assign(d_numNodes, 0);
235 d_vol.clear();
236
237 d_nec.assign(d_numNodes, {});
238 for (size_t e = 0; e < d_numElems; ++e) {
239 for (unsigned k = 0; k < 4; ++k) {
240 size_t nid = d_enc[4 * e + k];
241 d_nec[nid].push_back(e);
242 }
243 }
244
246
248 d_spatialDiscretization == "finite_difference",
249 "(in-memory tetrahedron mesh)");
250}
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 as set by the model deck.

Definition at line 176 of file mesh.cpp.

179 {
180
181 if (enc.size() % 3 != 0)
182 throw std::runtime_error(
183 "Mesh::loadFromTriangleElements2D: connectivity length must be a multiple of 3.");
184
185 d_nodes = std::move(nodes);
186 d_enc = std::move(enc);
188 d_numNodes = d_nodes.size();
189 d_eNumVertex = 3;
190 d_numElems = d_enc.size() / 3;
191 d_dim = modelDeck->d_dim;
193 d_filename = meshDeck->d_filename;
195 d_encDataPopulated = true;
196 d_fix.assign(d_numNodes, 0);
197 d_vol.clear();
198
199 d_nec.assign(d_numNodes, {});
200 for (size_t e = 0; e < d_numElems; ++e) {
201 for (unsigned k = 0; k < 3; ++k) {
202 size_t nid = d_enc[3 * e + k];
203 d_nec[nid].push_back(e);
204 }
205 }
206
208
210 d_spatialDiscretization == "finite_difference",
211 "(in-memory triangle mesh)");
212}
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 497 of file mesh.cpp.

497 {
498
499 auto tabS = util::io::getTabS(nt);
500 std::ostringstream oss;
501 oss << tabS << "------- Mesh --------" << std::endl << std::endl;
502 oss << tabS << "Dimension = " << d_dim << std::endl;
503 oss << tabS << "Spatial discretization type = " << d_spatialDiscretization << std::endl;
504 oss << tabS << "Mesh size = " << d_h << std::endl;
505 oss << tabS << "Num nodes = " << d_numNodes << std::endl;
506 oss << tabS << "Num elements = " << d_numElems << std::endl;
507 oss << tabS << "Element type = " << d_eType << std::endl;
508 oss << tabS << "Num nodes per element = " << d_eNumVertex << std::endl;
509 oss << tabS << "Num nodal vol = " << d_vol.size() << std::endl;
510 oss << tabS << "Bounding box: " << std::endl;
511 oss << util::io::printBoxStr(d_bbox, nt + 1);
512 oss << tabS << std::endl;
513
514 return oss.str();
515}
std::string printBoxStr(const std::pair< util::Point, util::Point > &box, int nt=print_default_tab)
Returns formatted string for output.
Definition io.h:231
std::string getTabS(int nt)
Returns tab spaces of a given size.
Definition io.h:82

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 287 of file mesh.cpp.

287 {
288
289 if (d_encDataPopulated and !d_enc.empty()) {
290 util::io::log("Mesh: Element data is populated already.\n");
291 return false;
292 }
293
294 util::io::log("Mesh: Reading element-node connectivity data.\n");
295
296 int file_type = -1;
297 // find the extension of file and call correct reader
298 if (util::io::getExtensionFromFile(filename) == "csv")
299 file_type = 0;
300 else if (util::io::getExtensionFromFile(filename) == "msh")
301 file_type = 1;
302 else if (util::io::getExtensionFromFile(filename) == "vtu")
303 file_type = 2;
304 else {
305 throw std::runtime_error(
307 << "Error: Currently only '.csv', '.msg', and '.vtu' "
308 "files are supported for reading mesh.\n");
309 }
310
311 if (file_type == 0) {
312 throw std::runtime_error(
314 << "Error: readElementData() requires file to be either "
315 ".vtu or .msh mesh file.\n");
316 }
317
318 if (file_type == 1) {
320 &d_enc,
321 &d_nec);
322 d_encDataPopulated = true;
323 // createData() may have skipped cells when Node_Volume was present, leaving
324 // d_eNumVertex from the default element type (1). Refresh after cell read.
326 return true;
327 }
328 else if (file_type == 2) {
330 &d_enc,
331 &d_nec);
332 d_encDataPopulated = true;
334 return true;
335 }
336
337 return false;
338}
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:407

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 478 of file mesh.cpp.

479 {
480
481 // to set i^th bit as true of integer a,
482 // a |= 1UL << (i % 8)
483
484 // to set i^th bit as false of integer a,
485 // a &= ~(1UL << (i % 8))
486
487 flag ? (d_fix[i] |= 1UL << dof) : (d_fix[i] &= ~(1UL << dof));
488}

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 418 of file mesh.cpp.

418 {
419 if (d_dim != 2)
420 return;
421 for (auto &p : d_nodes)
422 p.d_z = 0.;
423}

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 for each remaining node.

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 \( 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 \( 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: