MPM-Geomechanics
Material Point Method for simulating geo-materials under large deformation conditions
Loading...
Searching...
No Matches
Node.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 NODE_H_
5#define NODE_H_
6
7#include "Eigen/Core"
8using Eigen::Vector3d;
9
12class Node {
13
14public:
15
18 virtual ~Node();
19
22 Node();
23
26 inline void setId(int node_id) { this->id=node_id; }
27
30 inline void setActive(bool node_activate) { this->active=node_activate; }
31
34 inline void setCoordinates(const Vector3d& nodal_coordinates) { this->coordinates=nodal_coordinates; }
35
38 inline void setVelocity(const Vector3d& nodal_velocity) { this->velocity=nodal_velocity; }
39
42 inline void setMomentum(const Vector3d& nodal_momentum) { this->momentum=nodal_momentum; }
43
46 virtual inline void setMomentumFluid(const Vector3d& ) { return; }
47
51 inline void setTotalForce(const Vector3d& total_nodal_force) { this->totalForce=total_nodal_force; }
52
56 virtual inline void setTotalForceFluid(const Vector3d&) { return; }
57
60 inline int getId() const { return this->id; }
61
64 inline bool getActive() const { return this->active; }
65
68 inline double getMass() const { return this->mass; }
69
72 virtual inline double getMassFluid() const { return 0.0; }
73
77 inline const Vector3d& getCoordinates() const { return this->coordinates; }
78
81 inline const Vector3d& getMomentum() const { return this->momentum; }
82
85 virtual inline const Vector3d* getMomentumFluid() const { return NULL; }
86
89 inline const Vector3d& getInternalForce() const { return this->internalForce; }
90
93 inline const Vector3d& getExternalForce() const { return this->externalForce; }
94
97 inline const Vector3d& getTotalForce() const { return this->totalForce; }
98
101 virtual inline const Vector3d* getTotalForceFluid() const { return NULL; }
102
105 inline const Vector3d& getVelocity() const { return this->velocity; }
106
109 virtual inline const Vector3d* getVelocityFluid() const { return NULL; }
110
113 inline void addMass(double mass_increment) { this->mass+=mass_increment; }
114
117 inline void addDensityLevelSet(double density_increment) { this->densityLevelSet+=density_increment; }
118
121 virtual inline void addMassFluid(double) { return; }
122
125 inline void addMomentum(const Vector3d& momentum_increment) { this->momentum+=momentum_increment; }
126
129 virtual inline void addMomentumFluid(const Vector3d&) { return; }
130
133 inline void addInternalForce(const Vector3d& internal_force_increment) { this->internalForce+=internal_force_increment; }
134
137 virtual inline void addInternalForceFluid(const Vector3d&) { return; }
138
141 inline void addExternalForce(const Vector3d& external_force_increment) { this->externalForce+=external_force_increment; }
142
145 virtual inline void addExternalForceFluid(const Vector3d&) { return; }
146
149 virtual void resetValues();
150
153 virtual inline void updateTotalForce() { this->totalForce = this->internalForce + this->externalForce + this->dampingForce; }
154
157 virtual void updateDampingForce();
158
161 inline void updateVelocity(){ this->velocity = this->momentum / this->mass; }
162
165 virtual inline void integrateMomentum(double dt) { this->momentum += this->totalForce*dt; }
166
168 void setDistanceLevelSet(double distance) { this->distanceLevelSet = distance; }
169
171 double getDistanceLevelSet() { return this->distanceLevelSet; }
172
175 double getDensityLevelSet() { return this->densityLevelSet; }
176
178 void setVolume(double volume) { this->volume = volume; }
179
181 double getVolume() { return this->volume; }
182
183protected:
184
185 bool active;
186
187 int id;
188
189 double mass;
190 double volume;
193
194 Vector3d coordinates;
195 Vector3d momentum;
196 Vector3d velocity;
197 Vector3d externalForce;
198 Vector3d internalForce;
199 Vector3d dampingForce;
200 Vector3d totalForce;
201};
202
203inline Node::Node() {
204
205 active=false;
206 id=0;
207 mass=0.0;
208 volume=0.0;
210 densityLevelSet=0.0;
211 coordinates.setZero();
212 momentum.setZero();
213 velocity.setZero();
214 externalForce.setZero();
215 internalForce.setZero();
216 totalForce.setZero();
217 dampingForce.setZero();
218}
219
220inline void Node::resetValues()
221{
222 active=false;
223 mass=0.0;
224 momentum.setZero();
225 externalForce.setZero();
226 internalForce.setZero();
227 densityLevelSet=0.0;
228}
229
230inline Node::~Node() { }
231
232#endif /* NODE_H_ */
Represents a mesh node.
Definition Node.h:12
void addDensityLevelSet(double density_increment)
Add a density increment to the nodal density level set.
Definition Node.h:117
int getId() const
Return the nodal identification.
Definition Node.h:60
Vector3d momentum
nodal momentum: , or momentum in solid in two-phase calculations:
Definition Node.h:195
Vector3d dampingForce
nodal damping force: , or damping force in solid in two-phase calculations:
Definition Node.h:199
Vector3d velocity
nodal velocity: , or velocity in solid in two-phase calculations:
Definition Node.h:196
virtual const Vector3d * getMomentumFluid() const
Return the nodal momentum of fluid phase.
Definition Node.h:85
double getDensityLevelSet()
Get the density level set function value of the node.
Definition Node.h:175
void updateVelocity()
Update nodal velocity.
Definition Node.h:161
double getMass() const
Return the nodal mass.
Definition Node.h:68
double distanceLevelSet
distance level set function value of the node:
Definition Node.h:191
virtual void updateTotalForce()
Calculate the total nodal force.
Definition Node.h:153
void addMass(double mass_increment)
Add a mass increment to the nodal mass.
Definition Node.h:113
void addInternalForce(const Vector3d &internal_force_increment)
Add a internal force increment to the nodal internal force.
Definition Node.h:133
virtual void integrateMomentum(double dt)
Definition Node.h:165
bool getActive() const
Return the activate state of the node.
Definition Node.h:64
int id
nodal identification
Definition Node.h:187
virtual void resetValues()
Delete all values stored in node.
Definition Node.h:220
const Vector3d & getExternalForce() const
Return the nodal external force.
Definition Node.h:93
double mass
nodal mass: , or solid mass in two-phase calculations:
Definition Node.h:189
virtual void updateDampingForce()
Calculate the damping nodal force.
void setTotalForce(const Vector3d &total_nodal_force)
Configure the total nodal force.
Definition Node.h:51
virtual void addInternalForceFluid(const Vector3d &)
Add a internal force increment of fluid to the nodal internal force.
Definition Node.h:137
double densityLevelSet
density level set function value of the node:
Definition Node.h:192
virtual void addExternalForceFluid(const Vector3d &)
Add a external force of fluid increment to the nodal external force.
Definition Node.h:145
double getDistanceLevelSet()
Get the distance level set function value of the node.
Definition Node.h:171
virtual void setTotalForceFluid(const Vector3d &)
Configure the total nodal force in fluid phase.
Definition Node.h:56
const Vector3d & getVelocity() const
Return the nodal velocity.
Definition Node.h:105
Vector3d coordinates
nodal coordinates:
Definition Node.h:194
bool active
is active node
Definition Node.h:185
void setId(int node_id)
Configure node identification.
Definition Node.h:26
virtual ~Node()
Default destructor.
Definition Node.h:230
void setVelocity(const Vector3d &nodal_velocity)
Configure the nodal velocity.
Definition Node.h:38
virtual double getMassFluid() const
Return the nodal mass of fluid phase.
Definition Node.h:72
Vector3d externalForce
nodal external force: , or external force in solid in two-phase calculations:
Definition Node.h:197
void setCoordinates(const Vector3d &nodal_coordinates)
Configure the nodal coordinates.
Definition Node.h:34
Vector3d totalForce
nodal total force: , or total force in solid in two-phase calculations:
Definition Node.h:200
Vector3d internalForce
nodal internal force: , or internal force in solid in two-phase calculations:
Definition Node.h:198
void setActive(bool node_activate)
Configure the active state on the node.
Definition Node.h:30
virtual void addMassFluid(double)
Add fluid mass increment to the nodal mass.
Definition Node.h:121
double getVolume()
Get the nodal volume.
Definition Node.h:181
virtual void setMomentumFluid(const Vector3d &)
Configure the nodal momentum of fluid phase.
Definition Node.h:46
double volume
nodal volume:
Definition Node.h:190
const Vector3d & getTotalForce() const
Return the nodal total force.
Definition Node.h:97
const Vector3d & getCoordinates() const
Return the nodal coordinates.
Definition Node.h:77
virtual const Vector3d * getVelocityFluid() const
Return the nodal velocity of fluid phase.
Definition Node.h:109
void setDistanceLevelSet(double distance)
Set the distance level set function value of the node.
Definition Node.h:168
Node()
Default constructor.
Definition Node.h:203
void addExternalForce(const Vector3d &external_force_increment)
Add a external force increment to the nodal external force.
Definition Node.h:141
const Vector3d & getMomentum() const
Return the nodal momentum.
Definition Node.h:81
const Vector3d & getInternalForce() const
Return the nodal internal force.
Definition Node.h:89
void addMomentum(const Vector3d &momentum_increment)
Add a momentum increment to the nodal momentum.
Definition Node.h:125
void setMomentum(const Vector3d &nodal_momentum)
Configure the nodal momentum.
Definition Node.h:42
virtual void addMomentumFluid(const Vector3d &)
Add fluid momentum increment to the nodal momentum of fluid.
Definition Node.h:129
virtual const Vector3d * getTotalForceFluid() const
Return the nodal total force of fluid phase.
Definition Node.h:101
void setVolume(double volume)
Set the nodal volume.
Definition Node.h:178