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 "Node.h"
15#include "Boundary.h"
16#include "Cell.h"
17
18class Particle;
19
26class Mesh {
27
28public:
29
33
36 virtual ~Mesh();
37
40 void createGrid( bool is_two_phase_simulation );
41
46 void setCellDimension(double cell_dimension_x, double cell_dimension_y, double cell_dimension_z);
47
50 void setCellDimension(const Vector3d& cell_dimension);
51
56 void setNumCells(int number_cells_x, int number_cells_y, int number_cells_z);
57
60 void setNumCells(const Vector3i& number_cells);
61
64 void setNumGhosts(int ghosts);
65
70 inline void setOrigin(double x, double y, double z) { this->minLimit=Vector3d(x,y,z); }
71
75 inline void setOrigin(const Vector3d& origin_coordinate) { this->minLimit=origin_coordinate; }
76
82 void activateNodes(const vector<int>& id_list, bool active_value=true);
83
85
90 void activateNode(int id, bool active_value=true);
91
94 inline unsigned int getNumNodes() const { return (unsigned int) this->gridNodes.size(); }
95
98 inline vector<Node*>* getNodes() { return &(this->gridNodes); }
99
102 inline vector<Cell*>* getCells() { return &(this->gridCells); }
103
107 inline const Vector3d& getCellDimension() const { return this->cellDim; }
108
112 inline const Vector3i& getNumCells() const { return this->nCells; }
113
117 Vector3i getTotalCells() const;
118
121 inline int getNumGhosts() const { return this->nGhosts; }
122
126 inline const Vector3d& getMinLimits() const { return this->minLimit;}
127
131 inline const Vector3d& getMaxLimits() const { return this->maxLimit; }
132
138 vector<int> getNodesInCell(const Vector3d& point) const;
139
146 void getContributionNodes(const Vector3d& point, vector<int>& contributionIds) const;
147
150 inline Boundary* getBoundary() { return &(this->boundary); }
151
155 void setBoundaryRestrictions(vector<Boundary::BoundaryType> restrictions);
156
161
165 void setBoundaryRestrictionsFluid(vector<Boundary::BoundaryType> restrictions);
166
171 bool getIsInsideMesh(const Vector3d& point) const;
172
175
176private:
177
179
180 Vector3i nCells;
181
182 Vector3i nRows;
183
184 Vector3d cellDim;
185
186 Vector3d minLimit;
187
188 Vector3d maxLimit;
189
190 std::vector<Node*> gridNodes;
191
192 std::vector<Cell*> gridCells;
193
195
201 int getCellIdbyPosition(const Vector3d& point) const;
202
208 Vector3d getGridCoordinates(const Vector3d& point) const;
209
215 Vector3i getParentNodeCoordinates(const Vector3d& point) const;
216
222 int getParentCellIdConstribution(const Vector3d& point) const;
223
227};
228
229inline void Mesh::activateNode(int nodeId, const bool activeValue) {
230
231 gridNodes.at(nodeId)->setActive(activeValue);
232}
233
234#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:26
Vector3i getTotalCells() const
Return total cells including ghosts.
const Vector3d & getMaxLimits() const
Return higher mesh coordinates.
Definition Mesh.h:131
void setOrigin(double x, double y, double z)
Set origin of coordinates.
Definition Mesh.h:70
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:188
Vector3d minLimit
lower coordinates domain without ghosts
Definition Mesh.h:186
std::vector< Node * > gridNodes
all nodes in mesh
Definition Mesh.h:190
void setOrigin(const Vector3d &origin_coordinate)
Set origin of coordinates.
Definition Mesh.h:75
Vector3d cellDim
cell dimension in each direction
Definition Mesh.h:184
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:121
Vector3i nCells
number of cells in each direction without ghost
Definition Mesh.h:180
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:229
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:98
Vector3i nRows
number of rows in each direction
Definition Mesh.h:182
const Vector3d & getCellDimension() const
Return the cells dimension in each direction.
Definition Mesh.h:107
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:112
std::vector< Cell * > gridCells
all cells in mesh
Definition Mesh.h:192
void createGrid(bool is_two_phase_simulation)
Create a structured mesh grid.
vector< Cell * > * getCells()
Return cells in mesh.
Definition Mesh.h:102
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:150
virtual ~Mesh()
Default destructor.
const Vector3d & getMinLimits() const
Return lower mesh coordinates.
Definition Mesh.h:126
int nGhosts
number of ghost cells
Definition Mesh.h:178
unsigned int getNumNodes() const
Return total nodes in mesh.
Definition Mesh.h:94
int getCellIdbyPosition(const Vector3d &point) const
Return the cell id in a position coordinates.
void setBoundaryRestrictionsFluid(vector< Boundary::BoundaryType > restrictions)
Configures the restriction of fluid phase at the boundary nodes.
Boundary boundary
mesh boundary
Definition Mesh.h:194
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