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" 27 Real poly1Log(Real x, Real tol,
unsigned int derivative_order);
28 Real poly2Log(Real x, Real tol,
unsigned int derivative_order);
29 Real poly3Log(Real x, Real tol,
unsigned int derivative_order);
30 Real poly4Log(Real x, Real tol,
unsigned int derivative_order);
67 Point
circumcenter2D(
const Point & p0,
const Point & p1,
const Point & p2);
73 Point
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;
118 template <
typename T>
122 return x < 0.0 ? 0.0 : 1.0;
125 template <
typename T>
129 if (x <= -smoothing_length)
131 else if (x < smoothing_length)
137 template <
typename T>
141 if (x < smoothing_length && x > -smoothing_length)
148 template <
typename T>
152 return x > 0.0 ? x : 0.0;
155 template <
typename T>
159 return x < 0.0 ? x : 0.0;
175 template <
typename T,
178 typename std::enable_if<libMesh::ScalarTraits<T>::value,
int>::type = 0>
184 result.
add(scalar, numeric_vector);
194 typename std::enable_if<std::is_same<typename W<T>::index_type,
unsigned int>::value &&
195 std::is_same<typename W2<T2>::index_type,
unsigned int>::value,
203 template <
typename T,
209 typename std::enable_if<std::is_same<typename W<T>::index_type,
210 std::tuple<unsigned int, unsigned int>>::value &&
211 std::is_same<typename W2<T2>::index_type,
212 std::tuple<unsigned int, unsigned int>>::value,
217 return a.contract(b);
233 template <
typename C,
237 poly(
const C & c,
const T x,
const bool derivative =
false)
239 const auto size = c.size();
247 for (std::size_t i = 1; i < size - 1; ++i)
252 for (std::size_t i = 1; i < size; ++i)
268 template <
typename C,
274 auto size = c.size();
280 for (std::size_t i = 1; i <= size; ++i)
289 template <
typename C,
295 auto size = c.size();
300 R
value = c[size] * size;
301 for (std::size_t i = 1; i < size; ++i)
307 template <
typename T,
typename T2>
309 clamp(
const T & x, T2 lowerlimit, T2 upperlimit)
318 template <
typename T,
typename T2>
322 mooseAssert(
"start < end",
"Start value must be lower than end value for smootherStep");
332 x = (x - start) / (end - start);
335 return libMesh::Utility::pow<3>(x) * (x * (x * 6.0 - 15.0) + 10.0);
344 template <ComputeType compute_type,
typename X,
typename S,
typename E>
348 mooseAssert(
"start < end",
"Start value must be lower than end value for smootherStep");
358 const auto u = (x - start) / (end - start);
362 return libMesh::Utility::pow<3>(u) * (u * (u * 6.0 - 15.0) + 10.0);
370 template <
typename T>
381 template <
typename T>
385 mooseError(
"mooseSetToZero does not accept pointers");
413 std::vector<std::vector<unsigned int>>
multiIndex(
unsigned int dim,
unsigned int order);
415 template <ComputeType compute_type,
typename X,
typename X1,
typename X2,
typename Y1,
typename Y2>
419 const auto m = (y2 - y1) / (x2 - x1);
423 return m * (x - x1) + y1;
432 template <
typename T1,
typename T2>
436 return (dividend % divisor + divisor) % divisor;
443 template <
typename T>
447 return "grad_" + base_prop_name;
454 template <
typename T>
458 return "d" + base_prop_name +
"_dt";
472 std::vector<std::vector<unsigned int>>
multiIndexHelper(
unsigned int N,
unsigned int K);
void addScaled(const T &a, const T2 &b, T3 &result)
void mooseSetToZero(T &v)
Helper function templates to set a variable to zero.
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sin(_arg) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tan
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.
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...
void kron(RealEigenMatrix &product, const RealEigenMatrix &mat_A, const RealEigenMatrix &mat_B)
Computes the Kronecker product of two matrices.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
T regularizedHeavysideDerivative(T x, Real smoothing_length)
Real poly1Log(Real x, Real tol, unsigned int derivative_order)
Real poly2Log(Real x, Real tol, unsigned int derivative_order)
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
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 ...
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template cos(_arg) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(cos
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
libMesh::CompareTypes< T, T2 >::supertype dotProduct(const W< T > &a, const W2< T2 > &b)
R polynomial(const C &c, const T x)
Evaluate a polynomial with the coefficients c at x.
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic > RealEigenMatrix
Real poly3Log(Real x, Real tol, unsigned int derivative_order)
T smootherStep(T x, T2 start, T2 end, bool derivative=false)
Point circumcenter3D(const Point &p0, const Point &p1, const Point &p2, const Point &p3)
Evaluate circumcenter of a tetrahedrom given four arbitrary points.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
T gradName(const T &base_prop_name)
automatic prefixing for naming material properties based on gradients of coupled variables/functors ...
T timeDerivName(const T &base_prop_name)
automatic prefixing for naming material properties based on time derivatives of coupled variables/fun...
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.
Real poly4Log(Real x, Real tol, unsigned int derivative_order)
T regularizedHeavyside(T x, Real smoothing_length)
T clamp(const T &x, T2 lowerlimit, T2 upperlimit)
virtual void add(const numeric_index_type i, const T value)=0
std::vector< std::vector< unsigned int > > multiIndexHelper(unsigned int N, unsigned int K)
A helper function for MathUtils::multiIndex.
static constexpr Real sqrt2
std::sqrt is not constexpr, so we add sqrt(2) as a constant (used in Mandel notation) ...
auto linearInterpolation(const X &x, const X1 &x1, const X2 &x2, const Y1 &y1, const Y2 &y2)
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template pow< 2 >(tan(_arg))+1.0) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(sqrt
R polynomialDerivative(const C &c, const T x)
Returns the derivative of polynomial(c, x) with respect to x.