15#include "libmesh/libmesh.h"
16#include "libmesh/utility.h"
17#include "libmesh/numeric_vector.h"
18#include "libmesh/compare_types.h"
19#include "libmesh/point.h"
25static constexpr Real
sqrt2 = 1.4142135623730951;
27Real
poly1Log(Real x, Real tol,
unsigned int derivative_order);
28Real
poly2Log(Real x, Real tol,
unsigned int derivative_order);
29Real
poly3Log(Real x, Real tol,
unsigned int derivative_order);
30Real
poly4Log(Real x, Real tol,
unsigned int derivative_order);
67Point
circumcenter2D(
const Point & p0,
const Point & p1,
const Point & p2);
73Point
circumcenter3D(
const Point & p0,
const Point & p1,
const Point & p2,
const Point & p3);
86 return x >= 0.0 ? 1.0 : -1.0;
115 return neg ? 1.0 / result : result;
122 return x < 0.0 ? 0.0 : 1.0;
129 if (x <= -smoothing_length)
131 else if (x < smoothing_length)
134 return 0.5 * (1 + sin(
libMesh::pi * x / 2 / smoothing_length));
144 if (x < smoothing_length && x > -smoothing_length)
157 return x > 0.0 ? x : 0.0;
164 return x < 0.0 ? x : 0.0;
183 typename std::enable_if<libMesh::ScalarTraits<T>::value,
int>::type = 0>
189 result.
add(scalar, numeric_vector);
195 template <
typename>
class W,
196 template <
typename>
class W2,
197 typename std::enable_if<std::is_same<typename W<T>::index_type,
unsigned int>
::value &&
198 std::is_same<typename W2<T2>::index_type,
unsigned int>
::value,
208 template <
typename>
class W,
209 template <
typename>
class W2,
210 typename std::enable_if<std::is_same<typename W<T>::index_type,
211 std::tuple<unsigned int, unsigned int>>
::value &&
212 std::is_same<typename W2<T2>::index_type,
213 std::tuple<unsigned int, unsigned int>>
::value,
218 return a.contract(b);
240 const auto size = c.size();
248 for (std::size_t i = 1; i < size - 1; ++i)
253 for (std::size_t i = 1; i < size; ++i)
275 auto size = c.size();
281 for (std::size_t i = 1; i <= size; ++i)
296 auto size = c.size();
301 R
value = c[size] * size;
302 for (std::size_t i = 1; i < size; ++i)
308template <
typename T,
typename T2>
310clamp(
const T & x, T2 lowerlimit, T2 upperlimit)
319template <
typename T,
typename T2>
323 mooseAssert(
"start < end",
"Start value must be lower than end value for smootherStep");
333 x = (x - start) / (end - start);
335 return 30.0 * libMesh::Utility::pow<2>(x) * (x * (x - 2.0) + 1.0) / (end - start);
336 return libMesh::Utility::pow<3>(x) * (x * (x * 6.0 - 15.0) + 10.0);
345template <ComputeType compute_type,
typename X,
typename S,
typename E>
349 mooseAssert(
"start < end",
"Start value must be lower than end value for smootherStep");
359 const auto u = (x - start) / (end - start);
361 return 30.0 * libMesh::Utility::pow<2>(u) * (u * (u - 2.0) + 1.0) / (end - start);
363 return libMesh::Utility::pow<3>(u) * (u * (u * 6.0 - 15.0) + 10.0);
386 mooseError(
"mooseSetToZero does not accept pointers");
414std::vector<std::vector<unsigned int>>
multiIndex(
unsigned int dim,
unsigned int order);
416template <ComputeType compute_type,
typename X,
typename X1,
typename X2,
typename Y1,
typename Y2>
420 const auto m = (y2 - y1) / (x2 - x1);
424 return m * (x - x1) + y1;
433template <
typename T1,
typename T2>
437 return (dividend % divisor + divisor) % divisor;
448 return "grad_" + base_prop_name;
459 return "d" + base_prop_name +
"_dt";
468void kron(RealEigenMatrix & product,
const RealEigenMatrix & mat_A,
const RealEigenMatrix & mat_B);
473std::vector<std::vector<unsigned int>>
multiIndexHelper(
unsigned int N,
unsigned int K);
std::vector< std::vector< unsigned int > > multiIndexHelper(unsigned int N, unsigned int K)
A helper function for MathUtils::multiIndex.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
virtual void add(const numeric_index_type i, const T value)=0
void mooseSetToZero(T &v)
Helper function templates to set a variable to zero.
Real poly1Log(Real x, Real tol, unsigned int derivative_order)
void kron(RealEigenMatrix &product, const RealEigenMatrix &mat_A, const RealEigenMatrix &mat_B)
Computes the Kronecker product of two matrices.
T regularizedHeavyside(const T &x, Real smoothing_length)
std::vector< std::vector< unsigned int > > multiIndex(unsigned int dim, unsigned int order)
generate a complete multi index table for given dimension and order i.e.
auto linearInterpolation(const X &x, const X1 &x1, const X2 &x2, const Y1 &y1, const Y2 &y2)
T gradName(const T &base_prop_name)
automatic prefixing for naming material properties based on gradients of coupled variables/functors
void addScaled(const T &a, const T2 &b, T3 &result)
T clamp(const T &x, T2 lowerlimit, T2 upperlimit)
T timeDerivName(const T &base_prop_name)
automatic prefixing for naming material properties based on time derivatives of coupled variables/fun...
T smootherStep(T x, T2 start, T2 end, bool derivative=false)
Real poly2Log(Real x, Real tol, unsigned int derivative_order)
R polynomial(const C &c, const T x)
Evaluate a polynomial with the coefficients c at x.
Real poly4Log(Real x, Real tol, unsigned int derivative_order)
R poly(const C &c, const T x, const bool derivative=false)
Evaluate a polynomial with the coefficients c at x.
Point circumcenter2D(const Point &p0, const Point &p1, const Point &p2)
Evaluate circumcenter of a triangle given three arbitrary points.
libMesh::CompareTypes< T, T2 >::supertype dotProduct(const W< T > &a, const W2< T2 > &b)
Real poly3Log(Real x, Real tol, unsigned int derivative_order)
T regularizedHeavysideDerivative(const T &x, Real smoothing_length)
Point barycentricToCartesian3D(const Point &p0, const Point &p1, const Point &p2, const Point &p3, const Real b0, const Real b1, const Real b2, const Real b3)
Evaluate Cartesian coordinates of any center point of a tetrahedron given Barycentric coordinates of ...
std::size_t euclideanMod(T1 dividend, T2 divisor)
perform modulo operator for Euclidean division that ensures a non-negative result
static constexpr Real sqrt2
std::sqrt is not constexpr, so we add sqrt(2) as a constant (used in Mandel notation)
R polynomialDerivative(const C &c, const T x)
Returns the derivative of polynomial(c, x) with respect to x.
Point barycentricToCartesian2D(const Point &p0, const Point &p1, const Point &p2, const Real b0, const Real b1, const Real b2)
Evaluate Cartesian coordinates of any center point of a triangle given Barycentric coordinates of cen...
Point circumcenter3D(const Point &p0, const Point &p1, const Point &p2, const Point &p3)
Evaluate circumcenter of a tetrahedrom given four arbitrary points.