CellModules
BodyHertzianPhysics.hpp
Go to the documentation of this file.
1#ifndef BODYMASSSPRINGDAMPER_HPP
2#define BODYMASSSPRINGDAMPER_HPP
3#define MOVABLE
4
12#include <mecacell/mecacell.h>
13#include <mecacell/movable.h>
15#include "../../../../src/core/BaseBody.hpp"
16#include <math.h>
17#include "Tensor.hpp"
18
23namespace HertzianPhysics {
24
32 template<typename cell_t, class plugin_t>
33 class BodyHertzianPhysics : public MecaCell::Movable, public virtual BaseBody<plugin_t> {
34
35 private:
36 double baseRadius;
37 double radius;
38 double volume;
39 double density;
40 double gammaCoef;
43 double youngModulus;
44 double adhesion;
52 inline void computeAdhesion() {
53 double E = 1.0 / (2.0 * (1.0 - poissonNumber * poissonNumber) / youngModulus);
54 double R = 1.0 / (2.0 / radius);
55 adhesion = (4.0 * sqrt(targetOverlap * radius) * E * sqrt(R)) /
56 (3.0 * M_PI * M_PI * R * R);
57 }
58
59 public:
60
67 : stressTensor()
68 {
69 baseRadius = 10.0; // 10 µm radius
71 volume = 4.0 * M_PI / 3.0 * pow(radius, 3); // µm³
72 density = 0.001; // Density of water ~ 1000 kg/m³ = 10¹⁵ ng/m³ = 10^-3 ng/µm³
73 poissonNumber = 0.5; // Coefficient between 0 and 1
74 youngModulus = 4000000000.0; // 4 kPa = 10³ kg/(m.s²) = 10¹⁵ ng/(m.s²) = 10⁹ ng/(µm.s²)
75 this->setMass(density * volume); // Mass = density * volume µg
76 gammaCoef = 100000000000.0;
79 }
80
85 inline double getBoundingBoxRadius() const { return radius; }
86
94 inline void setRadius(double rad) {
95 radius = rad;
96 volume = 4.0 * M_PI / 3.0 * pow(radius, 3.0);
97 this->setMass(density * volume); // Mass = density * 4π/3 * radius³ ng
99 }
100
105 inline double getVolume() const { return volume; }
106
111 inline double getRadius() const { return radius; }
112
118 inline double getBaseRadius() const { return baseRadius; }
119
125 inline void setBaseRadius(double _baseRadius) { baseRadius = _baseRadius; }
126
132 inline void growth(double delta) {
133 this->setRadius(baseRadius * std::cbrt(1 + delta));
134 }
135
143 inline void setDensity(double d) {
144 density = d;
145 this->setMass(density * volume); // Mass = density * 4π/3 * radius³ ng
146 }
147
152 inline double getAdhesion() const { return adhesion; }
153
158 inline void setTargetOverlap(double _targetOverlap) {
159 this->targetOverlap = _targetOverlap;
161 }
162
167 inline double getYoungModulus() const { return youngModulus; }
168
173 inline void setYoungModulus(double ym) { youngModulus = ym; }
174
180
186
191 inline double getPoissonNumber() const { return poissonNumber; }
192
197 inline void setPoissonNumber(double pn) { poissonNumber = pn; }
198
203 inline void moveTo(const MecaCell::Vec &v) { this->setPosition(v); }
204
209 inline bool getComputed() const { return computed; }
210
215 inline void setComputed(bool c) { computed = c; }
216
221 inline double getGamma() const { return this->getMass() * gammaCoef; }
222
227 inline void setGammaCoef(double g) { gammaCoef = g; }
228
234
239 inline void setStressTensor(Tensor st) { stressTensor = st; }
240
246 inline void addStress(Tensor st) { stressTensor += st; }
247
253 inline void divTensor(double div) { stressTensor /= div; }
254
262 inline double getPressure() const { return abs((stressTensor.get(0, 0) + stressTensor.get(1, 1) + stressTensor.get(2, 2)) / 3.0); }
263 };
264}
265
266#endif // BODYMASSSPRINGDAMPER_HPP
Defines the PluginHertzianPhysics class for Delaunay triangulation and Hertzian physics.
Class for managing Delaunay triangulation and mass-spring-based physics.
double getAdhesion() const
Gets the adhesion coefficient.
void setDensity(double d)
Sets the density.
void divTensor(double div)
Divides the stress tensor.
void growth(double delta)
Increases the radius so that the volume is multiplied by 1 + delta.
void setYoungModulus(double ym)
Sets the Young's modulus.
void computeAdhesion()
Computes the adhesion coefficient based on the different parameters.
void setStressTensor(Tensor st)
Sets the stress tensor.
void setRadius(double rad)
Sets the radius.
bool getComputed() const
Gets the computed flag.
void setGammaCoef(double g)
Sets the gamma coefficient.
void setBaseRadius(double _baseRadius)
Sets the base radius.
Tensor getStressTensor()
Gets the stress tensor.
double getPressure() const
Gets the internal pressure.
double getPoissonNumber() const
Gets the Poisson's ratio.
void moveTo(const MecaCell::Vec &v)
Moves a cell to position v.
double getBaseRadius() const
Gets the base radius.
void setComputed(bool c)
Sets the computed flag.
double getGamma() const
Gets the gamma value.
double getRadius() const
Gets the radius.
void setPoissonNumber(double pn)
Sets the Poisson's ratio.
double getVolume() const
Gets the volume.
double getBoundingBoxRadius() const
Gets the bounding box radius.
void setTargetOverlap(double _targetOverlap)
Sets the target overlap.
void addStress(Tensor st)
Adds stress to the stress tensor.
double getYoungModulus() const
Gets the Young's modulus.
MecaCell::Vec getPurposeVelocity() const
Gets the purpose velocity.
void setPurposeVelocity(MecaCell::Vec pf)
Sets the purpose velocity.
double getMass() const
Definition: movable.h:30
void setPosition(const Vec &p)
Definition: movable.h:31
void setMass(const double m)
Definition: movable.h:35
general purpose 3D vector/point class.
Definition: vector3D.h:20
static Vector3D zero()
constructs a zero vector
Definition: vector3D.h:170
Namespace for Hertzian physics-related classes and functions.
int abs(int x)
Computes the absolute value of an integer.
Definition: std.hpp:83
double cbrt(double x)
Computes the cube root of a number.
Definition: std.hpp:215
double sqrt(double x)
Computes the square root of a number.
Definition: std.hpp:32
double pow(double base, double exponent)
Computes the power of a number.
Definition: std.hpp:43
Represents a 3x3 tensor for stress calculations.
Definition: Tensor.hpp:10
double get(int i, int j) const
Gets the value at the specified position in the tensor.
Definition: Tensor.hpp:42