18 return (a - b) > ((std::abs(a) < std::abs(b) ? std::abs(b) : std::abs(a)) *
23 return (b - a) > ((std::abs(a) < std::abs(b) ? std::abs(b) : std::abs(a)) *
28 const double &x_max) {
33 double x_mid = 0.5 * (x_min + x_max);
34 double l = x_mid - x_min;
41 return (x - x_min) / l;
43 return (x_max - x) / l;
49 const double &x_max) {
51 double x_mid = 0.5 * (x_min + x_max);
52 double l = x_mid - x_min;
59 return (x - x_min) / l;
61 return (x_max - x) / l;
81 double period = std::floor(x / (x1 + x2));
84 return x - period * x2;
86 return (period + 1.) * x1;
91 return a * std::exp(-std::pow(r, 2) / beta);
95 const std::vector<double> ¶ms) {
97 if (params.size() < 6) {
98 throw std::runtime_error(
100 <<
"Error: Not enough parameters to compute guassian 2-d "
112 const std::vector<double> ¶ms) {
114 if (params.size() < 10) {
115 throw std::runtime_error(
117 <<
"Error: Not enough parameters to compute guassian 2-d "
132 return 2. * m1 * m2 / (m1 + m2);
136 return 2. * m1 * m2 / (m1 + m2);
140 const double &horizon,
int horizonPower) {
142 throw std::invalid_argument(
143 "normalContactStiffness: horizon must be positive");
145 (M_PI * std::pow(horizon, horizonPower));
151 throw std::invalid_argument(
152 "selfContactStiffness: horizon must be positive");
154 return (18. / (M_PI * std::pow(horizon, horizonPower))) * K;
Collects a message with stream syntax for use in an exception.
double selfContactStiffness(const double &K, const double &horizon, int horizonPower=5)
Contact stiffness for a body against itself.
double normalContactStiffness(const double &K1, const double &K2, const double &horizon, int horizonPower=5)
Silling normal contact stiffness from two bulk moduli and the horizon.
bool isGreater(const double &a, const double &b)
Returns true if a > b.
double hatFunction(const double &x, const double &x_min, const double &x_max)
Computes hat function at given point.
double linearStepFunc(const double &x, const double &x1, const double &x2)
Compute linear step function.
double doubleGaussian2d(const util::Point &x, const size_t &dof, const std::vector< double > ¶ms)
Compute sum of two gaussian function in 2-d.
double equivalentMass(const double &m1, const double &m2)
Compute harmonic mean of m1 and m2.
double hatFunctionQuick(const double &x, const double &x_min, const double &x_max)
Computes hat function at given point.
double gaussian(const double &r, const double &a, const double &beta)
Compute gaussian function in 1-d.
bool isLess(const double &a, const double &b)
Returns true if a < b.
double gaussian2d(const util::Point &x, const size_t &dof, const std::vector< double > ¶ms)
Compute gaussian function in 2-d.
double harmonicMean(const double &m1, const double &m2)
A structure to represent 3d vectors.
double dist(const Point &b) const
Computes the distance between a given point from this point.