68 static constexpr int num = 3;
83 std::tuple<Utils::Vector3d, Utils::Vector3d, Utils::Vector3d, Utils::Vector3d>
112 auto const dx = fp2 - fp3;
113 auto const len = dx.
norm();
114 auto const dr = len -
r0;
123 auto const lambda = len /
r0;
124 auto const spring = (std::pow(lambda, 0.5) + std::pow(lambda, -2.5)) /
125 (lambda + std::pow(lambda, -3.));
126 fac -=
ks * spring * dr;
128 auto const f = (fac / len) * dx;
135 auto const dx = fp2 - fp3;
136 auto const len_sq = dx.
norm2();
137 auto const v_ij = vel3 - vel2;
138 auto const fac =
kvisc * (dx * v_ij) / len_sq;
139 auto const f = fac * dx;
150 auto const aa = (phi -
phi0);
152 auto const fac =
kb * aa;
159 auto const BminA = fp3 - fp2;
161 auto const factorFaNc =
162 (fp2 - fp3) * (fp1 - fp3) / BminA.
norm() / Nc.norm2();
163 auto const factorFaNd =
164 (fp2 - fp3) * (fp4 - fp3) / BminA.norm() / Nd.norm2();
165 auto const factorFbNc =
166 (fp2 - fp3) * (fp2 - fp1) / BminA.norm() / Nc.norm2();
167 auto const factorFbNd =
168 (fp2 - fp3) * (fp2 - fp4) / BminA.norm() / Nd.norm2();
170 force1 -= fac * BminA.norm() / Nc.norm2() * Nc;
171 force2 += fac * (factorFaNc * Nc + factorFaNd * Nd);
172 force3 += fac * (factorFbNc * Nc + factorFbNd * Nd);
173 force4 -= fac * BminA.norm() / Nd.norm2() * Nd;
183 auto handle_triangle =
188 auto const h = (1. / 3.) * (c1 + c2 + c3);
190 auto const t = sqrt(A / A0) - 1.0;
192 auto const m1 = h - c1;
193 auto const m2 = h - c2;
194 auto const m3 = h - c3;
196 auto const fac =
kal * A0 * (2 * t + t * t) /
197 (m1.norm2() + m2.norm2() + m3.norm2());
200 f1 += (fac / 3.0) * m1;
201 f2 += (fac / 3.0) * m2;
202 f3 += (fac / 3.0) * m3;
205 handle_triangle(
A01, fp1, fp2, fp3, force1, force2, force3);
206 handle_triangle(
A02, fp2, fp3, fp4, force2, force3, force4);
208 return std::make_tuple(force2, force1, force3, force4);
Vector implementation and trait types for boost qvm interoperability.
constexpr T norm2() const
double angle_btw_triangles(const Vector3d &P1, const Vector3d &P2, const Vector3d &P3, const Vector3d &P4)
Computes the angle between two triangles in 3D space.
double area_triangle(const Vector3d &P1, const Vector3d &P2, const Vector3d &P3)
Computes the area of triangle between vectors P1,P2,P3, by computing the cross product P1P2 x P1P3 an...
Vector3d get_n_triangle(const Vector3d &P1, const Vector3d &P2, const Vector3d &P3)
Computes the normal vector of a triangle.
constexpr auto tiny_oif_elasticity_coefficient
Tiny OIF elasticity cutoff.
Parameters for OIF local forces.
double A02
Equilibrium surface of the second triangle.
OifLocalForcesBond(double r0, double ks, double kslin, double phi0, double kb, double A01, double A02, double kal, double kvisc)
double phi0
Equilibrium angle between the two triangles.
double r0
Equilibrium bond length of triangle edges.
double kslin
Linear stretching coefficient of triangle edges.
std::tuple< Utils::Vector3d, Utils::Vector3d, Utils::Vector3d, Utils::Vector3d > calc_forces(Utils::Vector3d const &fp2, Utils::Vector3d const &fp1, Utils::Vector3d const &fp3, Utils::Vector3d const &fp4, Utils::Vector3d const &vel2, Utils::Vector3d const &vel3) const
Compute the OIF local forces.
double kb
Bending coefficient for the angle between the two triangles.
double A01
Equilibrium surface of the first triangle.
double kvisc
Viscous damping coefficient of triangle edges.
double ks
Non-linear stretching coefficient of triangle edges.
double kal
Stretching coefficient of a triangle surface.