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& nodal_momentum_fluid)
47 {
48 (void)nodal_momentum_fluid;
49 return;
50 }
51
55 inline void setTotalForce(const Vector3d& total_nodal_force) { this->totalForce=total_nodal_force; }
56
60 virtual inline void setTotalForceFluid(const Vector3d& total_nodal_force_fluid)
61 {
62 (void)total_nodal_force_fluid;
63 return;
64 }
65
68 inline int getId() const { return this->id; }
69
72 inline bool getActive() const { return this->active; }
73
76 inline double getMass() const { return this->mass; }
77
80 virtual inline double getMassFluid() const { return 0.0; }
81
85 inline const Vector3d& getCoordinates() const { return this->coordinates; }
86
89 inline const Vector3d& getMomentum() const { return this->momentum; }
90
92 inline Vector3d& getMomentumRef() { return this->momentum; }
93
96 virtual inline const Vector3d* getMomentumFluid() const { return NULL; }
97
100 inline const Vector3d& getInternalForce() const { return this->internalForce; }
101
103 inline Vector3d& getInternalForceRef() { return this->internalForce; }
104
107 inline const Vector3d& getExternalForce() const { return this->externalForce; }
108
110 inline Vector3d& getExternalForceRef() { return this->externalForce; }
111
114 inline const Vector3d& getTotalForce() const { return this->totalForce; }
115
118 virtual inline const Vector3d* getTotalForceFluid() const { return NULL; }
119
122 inline const Vector3d& getVelocity() const { return this->velocity; }
123
126 virtual inline const Vector3d* getVelocityFluid() const { return NULL; }
127
130 inline void addMass(double mass_increment) { this->mass+=mass_increment; }
131
133 inline double& getMassRef() { return this->mass; }
134
137 inline void addDensityLevelSet(double density_increment) { this->densityLevelSet+=density_increment; }
138
141 inline double& getDensityLevelSetRef(){ return this->densityLevelSet; }
142
145 virtual inline void addMassFluid(double fluid_mass_increment)
146 {
147 (void)fluid_mass_increment;
148 return;
149 }
152 inline void addMomentum(const Vector3d& momentum_increment) { this->momentum+=momentum_increment; }
153
156 virtual inline void addMomentumFluid(const Vector3d& fluid_momentum_increment)
157 {
158 (void)fluid_momentum_increment;
159 return;
160 }
161
164 inline void addInternalForce(const Vector3d& internal_force_increment) { this->internalForce+=internal_force_increment; }
165
168 virtual inline void addInternalForceFluid(const Vector3d& internal_force_fluid_increment) {
169 (void)internal_force_fluid_increment;
170 return;
171 }
172
175 inline void addExternalForce(const Vector3d& external_force_increment) { this->externalForce+=external_force_increment; }
176
179 virtual inline void addExternalForceFluid(const Vector3d& external_force_fluid_increment) {
180 (void)external_force_fluid_increment;
181 return;
182 }
183
186 virtual void resetValues();
187
190 virtual inline void updateTotalForce() { this->totalForce = this->internalForce + this->externalForce + this->dampingForce; }
191
194 virtual void updateDampingForce();
195
198 inline void updateVelocity(){ this->velocity = this->momentum / this->mass; }
199
202 virtual inline void integrateMomentum(double dt) { this->momentum += this->totalForce*dt; }
203
206 void setDistanceLevelSet(double distance) { this->distanceLevelSet = distance; }
207
209 double getDistanceLevelSet() { return this->distanceLevelSet; }
210
213 double getDensityLevelSet() { return this->densityLevelSet; }
214
217 void setVolume(double volume) { this->volume = volume; }
218
220 double getVolume() { return this->volume; }
221
222protected:
223
224 bool active;
225
226 int id;
227
228 double mass;
229 double volume;
232
233 Vector3d coordinates;
234 Vector3d momentum;
235 Vector3d velocity;
236 Vector3d externalForce;
237 Vector3d internalForce;
238 Vector3d dampingForce;
239 Vector3d totalForce;
240};
241
242inline Node::Node() {
243
244 active=false;
245 id=0;
246 mass=0.0;
247 volume=0.0;
249 densityLevelSet=0.0;
250 coordinates.setZero();
251 momentum.setZero();
252 velocity.setZero();
253 externalForce.setZero();
254 internalForce.setZero();
255 totalForce.setZero();
256 dampingForce.setZero();
257}
258
259inline void Node::resetValues()
260{
261 active=false;
262 mass=0.0;
263 momentum.setZero();
264 externalForce.setZero();
265 internalForce.setZero();
266 densityLevelSet=0.0;
267}
268
269inline Node::~Node() { }
270
271#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:137
int getId() const
Return the nodal identification.
Definition Node.h:68
Vector3d & getMomentumRef()
Return a reference of momentum for atomic calculation.
Definition Node.h:92
Vector3d momentum
nodal momentum: , or momentum in solid in two-phase calculations:
Definition Node.h:234
Vector3d dampingForce
nodal damping force: , or damping force in solid in two-phase calculations:
Definition Node.h:238
virtual void addMomentumFluid(const Vector3d &fluid_momentum_increment)
Add fluid momentum increment to the nodal momentum of fluid.
Definition Node.h:156
Vector3d velocity
nodal velocity: , or velocity in solid in two-phase calculations:
Definition Node.h:235
virtual const Vector3d * getMomentumFluid() const
Return the nodal momentum of fluid phase.
Definition Node.h:96
double getDensityLevelSet()
Get the density level set function value of the node.
Definition Node.h:213
void updateVelocity()
Update nodal velocity.
Definition Node.h:198
double getMass() const
Return the nodal mass.
Definition Node.h:76
double distanceLevelSet
distance level set function value of the node:
Definition Node.h:230
virtual void updateTotalForce()
Calculate the total nodal force.
Definition Node.h:190
void addMass(double mass_increment)
Add a mass increment to the nodal mass.
Definition Node.h:130
void addInternalForce(const Vector3d &internal_force_increment)
Add a internal force increment to the nodal internal force.
Definition Node.h:164
virtual void integrateMomentum(double dt)
Definition Node.h:202
bool getActive() const
Return the activate state of the node.
Definition Node.h:72
int id
nodal identification
Definition Node.h:226
virtual void resetValues()
Delete all values stored in node.
Definition Node.h:259
const Vector3d & getExternalForce() const
Return the nodal external force.
Definition Node.h:107
double & getMassRef()
Get a reference of the mass.
Definition Node.h:133
double mass
nodal mass: , or solid mass in two-phase calculations:
Definition Node.h:228
Vector3d & getInternalForceRef()
Return a reference of internal force for atomic calculation.
Definition Node.h:103
virtual void updateDampingForce()
Calculate the damping nodal force.
void setTotalForce(const Vector3d &total_nodal_force)
Configure the total nodal force.
Definition Node.h:55
double densityLevelSet
density level set function value of the node:
Definition Node.h:231
virtual void setTotalForceFluid(const Vector3d &total_nodal_force_fluid)
Configure the total nodal force in fluid phase.
Definition Node.h:60
double getDistanceLevelSet()
Get the distance level set function value of the node.
Definition Node.h:209
virtual void setMomentumFluid(const Vector3d &nodal_momentum_fluid)
Configure the nodal momentum of fluid phase.
Definition Node.h:46
const Vector3d & getVelocity() const
Return the nodal velocity.
Definition Node.h:122
virtual void addInternalForceFluid(const Vector3d &internal_force_fluid_increment)
Add a internal force increment of fluid to the nodal internal force.
Definition Node.h:168
virtual void addMassFluid(double fluid_mass_increment)
Add fluid mass increment to the nodal mass.
Definition Node.h:145
Vector3d coordinates
nodal coordinates:
Definition Node.h:233
Vector3d & getExternalForceRef()
Return a reference of external force for atomic calculation.
Definition Node.h:110
bool active
is active node
Definition Node.h:224
void setId(int node_id)
Configure node identification.
Definition Node.h:26
virtual ~Node()
Default destructor.
Definition Node.h:269
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:80
Vector3d externalForce
nodal external force: , or external force in solid in two-phase calculations:
Definition Node.h:236
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:239
virtual void addExternalForceFluid(const Vector3d &external_force_fluid_increment)
Add a external force of fluid increment to the nodal external force.
Definition Node.h:179
Vector3d internalForce
nodal internal force: , or internal force in solid in two-phase calculations:
Definition Node.h:237
void setActive(bool node_activate)
Configure the active state on the node.
Definition Node.h:30
double getVolume()
Get the nodal volume.
Definition Node.h:220
double volume
nodal volume:
Definition Node.h:229
const Vector3d & getTotalForce() const
Return the nodal total force.
Definition Node.h:114
const Vector3d & getCoordinates() const
Return the nodal coordinates.
Definition Node.h:85
virtual const Vector3d * getVelocityFluid() const
Return the nodal velocity of fluid phase.
Definition Node.h:126
void setDistanceLevelSet(double distance)
Set the distance level set function value of the node.
Definition Node.h:206
Node()
Default constructor.
Definition Node.h:242
void addExternalForce(const Vector3d &external_force_increment)
Add a external force increment to the nodal external force.
Definition Node.h:175
const Vector3d & getMomentum() const
Return the nodal momentum.
Definition Node.h:89
const Vector3d & getInternalForce() const
Return the nodal internal force.
Definition Node.h:100
void addMomentum(const Vector3d &momentum_increment)
Add a momentum increment to the nodal momentum.
Definition Node.h:152
void setMomentum(const Vector3d &nodal_momentum)
Configure the nodal momentum.
Definition Node.h:42
virtual const Vector3d * getTotalForceFluid() const
Return the nodal total force of fluid phase.
Definition Node.h:118
void setVolume(double volume)
Set the nodal volume.
Definition Node.h:217
double & getDensityLevelSetRef()
Get a reference of the density level set.
Definition Node.h:141