Phyth v0.1.0
A dimensional safe C++ header-only mechanics and electromagnetics simulation library.
Loading...
Searching...
No Matches
PointForce.hpp
Go to the documentation of this file.
1#ifndef PHYTH_POINT_FORCE_HPP
2#define PHYTH_POINT_FORCE_HPP
3
4#include "ForceSource.hpp"
7
8namespace Phyth::Mechanics {
31 class PointForce : public ForceSource {
32 public:
45
58 ) const override {
59 const auto r = point - position_;
60 const auto r_mag = r.Length();
61
63 throw std::runtime_error("PointForce: stress diverges at force location");
64 }
65
66 const auto poisson_ratio = material_.GetPoissonRatio();
67 const Quantity<Joule> F_dot_r = force_.Dot(r);
68 const Scalar kelvin_prefactor = -1.0 / (8.0 * Consts::pi * (1.0 - poisson_ratio));
69
70 const auto r3 = r_mag * r_mag * r_mag;
71 const auto r5 = r3 * r_mag * r_mag;
72
73 const Scalar one_minus_2nu = 1.0 - 2.0 * poisson_ratio;
76
78
79 // Diagonal components
81 -
82 dipole_coeff * r.x * r.x / r5);
84 -
85 dipole_coeff * r.y * r.y / r5);
87 -
88 dipole_coeff * r.z * r.z / r5);
89
90 // Off-diagonal components (symmetric)
91 stress(0, 1) = stress(1, 0) = kelvin_prefactor * (
92 one_minus_2nu * (force_.x * r.y + force_.y * r.x) / r3 - dipole_coeff * r.
93 x * r.y / r5);
94 stress(0, 2) = stress(2, 0) = kelvin_prefactor * (
95 one_minus_2nu * (force_.x * r.z + force_.z * r.x) / r3 - dipole_coeff * r.
96 x * r.z / r5);
97 stress(1, 2) = stress(2, 1) = kelvin_prefactor * (
98 one_minus_2nu * (force_.y * r.z + force_.z * r.y) / r3 - dipole_coeff * r.
99 y * r.z / r5);
100
101 return stress;
102 }
103
114 ) const override {
116 return force_;
117 }
118 return {};
119 }
120
127 return force_;
128 }
129
138 ) const override {
139 return (point - position_).Length();
140 }
141
148 return position_;
149 }
150
157 return force_;
158 }
159
160 private:
164 };
165}
166
167#endif // PHYTH_POINT_FORCE_HPP
Linear elastic isotropic material model.
Scalar GetPoissonRatio() const
Get Poisson's ratio.
Abstract base class for all force/traction distributions.
Concentrated force acting at a single point in an elastic medium.
Vector3< Quantity< Newton > > GetTotalForce() const override
Get the total force of this source.
Vector3< Quantity< Newton > > force_
Vector3< Quantity< Newton > > GetForceAt(const Vector3< Quantity< Meter > > &point) const override
Get the force vector at a point.
Vector3< Quantity< Meter > > GetPosition() const
Get the force location.
PointForce(const Vector3< Quantity< Meter > > &position, const Vector3< Quantity< Newton > > &force, const IsotropicMaterial &material) noexcept
Construct a point force.
Quantity< Meter > GetMinimumDistanceTo(const Vector3< Quantity< Meter > > &point) const override
Get the minimum distance from a point to the force location.
Vector3< Quantity< Meter > > position_
Vector3< Quantity< Newton > > GetForce() const
Get the force vector.
Matrix3x3< Quantity< Pascal > > GetStressAt(const Vector3< Quantity< Meter > > &point) const override
Compute stress tensor at a point.
IsotropicMaterial material_
double epsilon
Definition Config.hpp:13
constexpr double pi
Definition Constants.hpp:5
Dimension< std::ratio< 1 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 0 >, std::ratio< 0 > > Length
constexpr bool is_unit_v
Definition Unit.hpp:79
3x3 matrix with Quantity components
Definition Matrix3x3.hpp:27
Physical quantity with a value and a compile-time unit.
Definition Quantity.hpp:27
3D vector with Quantity components
Definition Vector3.hpp:28