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/*
2 * Mesh.cpp
3 *
4 * Created on: 13 de abr de 2021
5 * Author: Fabricio Fernandez <fabricio.hmf@gmail.com>
6 */
7
8#ifndef MESH_H_
9#define MESH_H_
10
11#include <vector>
12using std::vector;
13
14#include "../inc/Eigen/Core"
15using Eigen::Vector3d;
16using Eigen::Vector3i;
17
18#include "Node.h"
19#include "Boundary.h"
20
21class Particle;
22
29class Mesh {
30
31public:
32
36
39 virtual ~Mesh();
40
43 void createGrid( bool is_two_phase_simulation );
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
91 void activateNode(int id, bool active_value=true);
92
95 inline unsigned int getNumNodes() const { return (unsigned int) this->gridNodes.size(); }
96
99 inline vector<Node*>* getNodes() { return &(this->gridNodes); }
100
104 inline const Vector3d& getCellDimension() const { return this->cellDim; }
105
109 inline const Vector3i& getNumCells() const { return this->nCells; }
110
114 Vector3i getTotalCells() const;
115
118 inline int getNumGhosts() const { return this->nGhosts; }
119
123 inline const Vector3d& getMinLimits() const { return this->minLimit;}
124
128 inline const Vector3d& getMaxLimits() const { return this->maxLimit; }
129
135 vector<int> getNodesInCell(const Vector3d& point) const;
136
143 void getContributionNodes(const Vector3d& point, vector<int>& contributionIds) const;
144
147 inline Boundary* getBoundary() { return &(this->boundary); }
148
152 void setBoundaryRestrictions(vector<Boundary::BoundaryType> restrictions);
153
157 void setBoundaryRestrictionsFluid(vector<Boundary::BoundaryType> restrictions);
158
163 bool getIsInsideMesh(const Vector3d& point) const;
164
165private:
166
168
169 Vector3i nCells;
170
171 Vector3i nRows;
172
173 Vector3d cellDim;
174
175 Vector3d minLimit;
176
177 Vector3d maxLimit;
178
179 std::vector<Node*> gridNodes;
180
182
188 int getCellIdbyPosition(const Vector3d& point) const;
189
195 Vector3d getGridCoordinates(const Vector3d& point) const;
196
202 Vector3i getParentNodeCoordinates(const Vector3d& point) const;
203
209 int getParentCellIdConstribution(const Vector3d& point) const;
210
214};
215
216inline void Mesh::activateNode(int nodeId, const bool activeValue) {
217
218 gridNodes.at(nodeId)->setActive(activeValue);
219}
220
221#endif /* MESH_H_ */
Mesh boundary nodes.
Definition Boundary.h:47
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:128
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:177
Vector3d minLimit
lower coordinates domain without ghosts
Definition Mesh.h:175
std::vector< Node * > gridNodes
all nodes in mesh
Definition Mesh.h:179
void setOrigin(const Vector3d &origin_coordinate)
Set origin of coordinates.
Definition Mesh.h:78
Vector3d cellDim
cell dimension in each direction
Definition Mesh.h:173
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:118
Vector3i nCells
number of cells in each direction without ghost
Definition Mesh.h:169
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:216
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:99
Vector3i nRows
number of rows in each direction
Definition Mesh.h:171
const Vector3d & getCellDimension() const
Return the cells dimension in each direction.
Definition Mesh.h:104
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:109
void createGrid(bool is_two_phase_simulation)
Create a structured mesh grid.
void setNumGhosts(int ghosts)
Set number of ghosts around the domain.
Boundary * getBoundary()
return mesh boundaries
Definition Mesh.h:147
virtual ~Mesh()
Default destructor.
const Vector3d & getMinLimits() const
Return lower mesh coordinates.
Definition Mesh.h:123
int nGhosts
number of ghost cells
Definition Mesh.h:167
unsigned int getNumNodes() const
Return total nodes in mesh.
Definition Mesh.h:95
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:181
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:29