MPM-Geomechanics
Material Point Method for simulating geo-materials under large deformation conditions
Loading...
Searching...
No Matches
Mesh.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// Copyright (c) 2021-2025 MPM-Geomechanics Development Team
3
4#ifndef MESH_H_
5#define MESH_H_
6
7#include <vector>
8using std::vector;
9
10#include "../inc/Eigen/Core"
11using Eigen::Vector3d;
12using Eigen::Vector3i;
13
14#include <unordered_map>
15using std::unordered_map;
16
17#include "Node.h"
18#include "Boundary.h"
19#include "Cell.h"
20
21class Particle;
22
29class Mesh {
30
31public:
32
36
39 virtual ~Mesh();
40
43 void createGrid( bool is_two_phase_simulation=false );
44
49 void setCellDimension(double cell_dimension_x, double cell_dimension_y, double cell_dimension_z);
50
53 void setCellDimension(const Vector3d& cell_dimension);
54
59 void setNumCells(int number_cells_x, int number_cells_y, int number_cells_z);
60
63 void setNumCells(const Vector3i& number_cells);
64
67 void setNumGhosts(int ghosts);
68
73 inline void setOrigin(double x, double y, double z) { this->minLimit=Vector3d(x,y,z); }
74
78 inline void setOrigin(const Vector3d& origin_coordinate) { this->minLimit=origin_coordinate; }
79
85 void activateNodes(const vector<int>& id_list, bool active_value=true);
86
88
93 void activateNode(int id, bool active_value=true);
94
97 inline unsigned int getNumNodes() const { return (unsigned int) this->gridNodes.size(); }
98
101 inline vector<Node*>* getNodes() { return &(this->gridNodes); }
102
105 inline vector<Cell*>* getCells() { return &(this->gridCells); }
106
110 inline const Vector3d& getCellDimension() const { return this->cellDim; }
111
115 inline const Vector3i& getNumCells() const { return this->nCells; }
116
120 Vector3i getTotalCells() const;
121
124 inline int getNumGhosts() const { return this->nGhosts; }
125
129 inline const Vector3d& getMinLimits() const { return this->minLimit;}
130
134 inline const Vector3d& getMaxLimits() const { return this->maxLimit; }
135
141 vector<int> getNodesInCell(const Vector3d& point) const;
142
149 void getContributionNodes(const Vector3d& point, vector<int>& contributionIds) const;
150
153 inline Boundary* getBoundary() { return &(this->boundary); }
154
157 unordered_map<int, Node::ContactNodeData>& getContactNodes() { return contactNodes; }
158
162 void setBoundaryRestrictions(vector<Boundary::BoundaryType> restrictions);
163
168
172 void setBoundaryRestrictionsFluid(vector<Boundary::BoundaryType> restrictions);
173
178 bool getIsInsideMesh(const Vector3d& point) const;
179
182
184 void clearContactNodes() { contactNodes.clear(); };
185
186
187private:
188
190
191 Vector3i nCells;
192
193 Vector3i nRows;
194
195 Vector3d cellDim;
196
197 Vector3d minLimit;
198
199 Vector3d maxLimit;
200
201 std::vector<Node*> gridNodes;
202
203 std::vector<Cell*> gridCells;
204
206
207 unordered_map<int, Node::ContactNodeData> contactNodes;
208
214 int getCellIdbyPosition(const Vector3d& point) const;
215
221 Vector3d getGridCoordinates(const Vector3d& point) const;
222
228 Vector3i getParentNodeCoordinates(const Vector3d& point) const;
229
235 int getParentCellIdConstribution(const Vector3d& point) const;
236
240};
241
242inline void Mesh::activateNode(int nodeId, const bool activeValue) {
243
244 gridNodes.at(nodeId)->setActive(activeValue);
245}
246
247#endif /* MESH_H_ */
Mesh boundary nodes.
Definition Boundary.h:58
BoundaryType
Determines the type of restrictions to be imposed to the mesh.
Definition Boundary.h:64
BoundaryPlane
Planes at the mesh boundary.
Definition Boundary.h:68
Class representing a rectangular grid mesh.
Definition Mesh.h:29
Vector3i getTotalCells() const
Return total cells including ghosts.
const Vector3d & getMaxLimits() const
Return higher mesh coordinates.
Definition Mesh.h:134
void setOrigin(double x, double y, double z)
Set origin of coordinates.
Definition Mesh.h:73
vector< int > getNodesInCell(const Vector3d &point) const
Return the nodes of the cell containing a point.
void setCellDimension(const Vector3d &cell_dimension)
Set cells dimension in each direction.
Mesh()
default constructor
void setNumCells(const Vector3i &number_cells)
Set number of cell in each direction.
Vector3d maxLimit
high coordinates of domain without ghosts
Definition Mesh.h:199
Vector3d minLimit
lower coordinates domain without ghosts
Definition Mesh.h:197
std::vector< Node * > gridNodes
all nodes in mesh
Definition Mesh.h:201
unordered_map< int, Node::ContactNodeData > contactNodes
nodes in contact
Definition Mesh.h:207
void setOrigin(const Vector3d &origin_coordinate)
Set origin of coordinates.
Definition Mesh.h:78
Vector3d cellDim
cell dimension in each direction
Definition Mesh.h:195
Vector3d getGridCoordinates(const Vector3d &point) const
Return the grid coordinates of a position.
bool getIsInsideMesh(const Vector3d &point) const
Verify if the position is inside the limits.
int getNumGhosts() const
Get number of ghosts.
Definition Mesh.h:124
Vector3i nCells
number of cells in each direction without ghost
Definition Mesh.h:191
Vector3i getParentNodeCoordinates(const Vector3d &point) const
Return the grid parent node coordinate of a position.
void getContributionNodes(const Vector3d &point, vector< int > &contributionIds) const
Return the nodes contributing at point.
void configureBoundaries()
Updates the boundary nodes index.
void activateNode(int id, bool active_value=true)
Activate node by its id.
Definition Mesh.h:242
void setCellDimension(double cell_dimension_x, double cell_dimension_y, double cell_dimension_z)
Set cells dimension in each direction.
void setBoundaryRestrictionsSeismic()
int getParentCellIdConstribution(const Vector3d &point) const
Return the id of the parent node contributing at the point.
vector< Node * > * getNodes()
Return nodes in mesh.
Definition Mesh.h:101
Vector3i nRows
number of rows in each direction
Definition Mesh.h:193
void clearContactNodes()
\Clear Contact Nodes
Definition Mesh.h:184
const Vector3d & getCellDimension() const
Return the cells dimension in each direction.
Definition Mesh.h:110
void setBoundaryRestrictions(vector< Boundary::BoundaryType > restrictions)
Configures the restriction of the boundary nodes.
void setNumCells(int number_cells_x, int number_cells_y, int number_cells_z)
Set number of cell in each direction.
const Vector3i & getNumCells() const
Return total cells in the mesh without ghosts.
Definition Mesh.h:115
std::vector< Cell * > gridCells
all cells in mesh
Definition Mesh.h:203
vector< Cell * > * getCells()
Return cells in mesh.
Definition Mesh.h:105
void computeNodeVolumes()
Return compute the nodal volumes.
void setNumGhosts(int ghosts)
Set number of ghosts around the domain.
void setRestriction(Boundary::BoundaryPlane plane, Boundary::BoundaryType restriction)
Configures the restriction of the boundary nodes.
Boundary * getBoundary()
return mesh boundaries
Definition Mesh.h:153
virtual ~Mesh()
Default destructor.
const Vector3d & getMinLimits() const
Return lower mesh coordinates.
Definition Mesh.h:129
int nGhosts
number of ghost cells
Definition Mesh.h:189
unsigned int getNumNodes() const
Return total nodes in mesh.
Definition Mesh.h:97
int getCellIdbyPosition(const Vector3d &point) const
Return the cell id in a position coordinates.
unordered_map< int, Node::ContactNodeData > & getContactNodes()
return nodes where there is contact between two bodies
Definition Mesh.h:157
void setBoundaryRestrictionsFluid(vector< Boundary::BoundaryType > restrictions)
Configures the restriction of fluid phase at the boundary nodes.
void createGrid(bool is_two_phase_simulation=false)
Create a structured mesh grid.
Boundary boundary
mesh boundary
Definition Mesh.h:205
void activateNodes(const vector< int > &id_list, bool active_value=true)
Activate nodes by its id.
Represents a Lagrangian material point This class contain all Lagrangian variables that represents th...
Definition Particle.h:25