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
88 void activateNode(int id, bool active_value=true);
89
92 inline unsigned int getNumNodes() const { return (unsigned int) this->gridNodes.size(); }
93
96 inline vector<Node*>* getNodes() { return &(this->gridNodes); }
97
100 inline vector<Cell*>* getCells() { return &(this->gridCells); }
101
105 inline const Vector3d& getCellDimension() const { return this->cellDim; }
106
110 inline const Vector3i& getNumCells() const { return this->nCells; }
111
115 Vector3i getTotalCells() const;
116
119 inline int getNumGhosts() const { return this->nGhosts; }
120
124 inline const Vector3d& getMinLimits() const { return this->minLimit;}
125
129 inline const Vector3d& getMaxLimits() const { return this->maxLimit; }
130
136 vector<int> getNodesInCell(const Vector3d& point) const;
137
144 void getContributionNodes(const Vector3d& point, vector<int>& contributionIds) const;
145
148 inline Boundary* getBoundary() { return &(this->boundary); }
149
153 void setBoundaryRestrictions(vector<Boundary::BoundaryType> restrictions);
154
158 void setBoundaryRestrictionsFluid(vector<Boundary::BoundaryType> restrictions);
159
164 bool getIsInsideMesh(const Vector3d& point) const;
165
168
169private:
170
172
173 Vector3i nCells;
174
175 Vector3i nRows;
176
177 Vector3d cellDim;
178
179 Vector3d minLimit;
180
181 Vector3d maxLimit;
182
183 std::vector<Node*> gridNodes;
184
185 std::vector<Cell*> gridCells;
186
188
194 int getCellIdbyPosition(const Vector3d& point) const;
195
201 Vector3d getGridCoordinates(const Vector3d& point) const;
202
208 Vector3i getParentNodeCoordinates(const Vector3d& point) const;
209
215 int getParentCellIdConstribution(const Vector3d& point) const;
216
220};
221
222inline void Mesh::activateNode(int nodeId, const bool activeValue) {
223
224 gridNodes.at(nodeId)->setActive(activeValue);
225}
226
227#endif /* MESH_H_ */
Mesh boundary nodes.
Definition Boundary.h:58
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:129
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:181
Vector3d minLimit
lower coordinates domain without ghosts
Definition Mesh.h:179
std::vector< Node * > gridNodes
all nodes in mesh
Definition Mesh.h:183
void setOrigin(const Vector3d &origin_coordinate)
Set origin of coordinates.
Definition Mesh.h:75
Vector3d cellDim
cell dimension in each direction
Definition Mesh.h:177
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:119
Vector3i nCells
number of cells in each direction without ghost
Definition Mesh.h:173
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:222
void setCellDimension(double cell_dimension_x, double cell_dimension_y, double cell_dimension_z)
Set cells dimension in each direction.
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:96
Vector3i nRows
number of rows in each direction
Definition Mesh.h:175
const Vector3d & getCellDimension() const
Return the cells dimension in each direction.
Definition Mesh.h:105
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:110
std::vector< Cell * > gridCells
all cells in mesh
Definition Mesh.h:185
void createGrid(bool is_two_phase_simulation)
Create a structured mesh grid.
vector< Cell * > * getCells()
Return cells in mesh.
Definition Mesh.h:100
void computeNodeVolumes()
Return compute the nodal volumes.
void setNumGhosts(int ghosts)
Set number of ghosts around the domain.
Boundary * getBoundary()
return mesh boundaries
Definition Mesh.h:148
virtual ~Mesh()
Default destructor.
const Vector3d & getMinLimits() const
Return lower mesh coordinates.
Definition Mesh.h:124
int nGhosts
number of ghost cells
Definition Mesh.h:171
unsigned int getNumNodes() const
Return total nodes in mesh.
Definition Mesh.h:92
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:187
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