16#include "libmesh/libmesh.h"
17#include "libmesh/utility.h"
18#include "libmesh/numeric_vector.h"
19#include "libmesh/compare_types.h"
20#include "libmesh/point.h"
26static constexpr Real
sqrt2 = 1.4142135623730951;
28Real
poly1Log(Real x, Real tol,
unsigned int derivative_order);
29Real
poly2Log(Real x, Real tol,
unsigned int derivative_order);
30Real
poly3Log(Real x, Real tol,
unsigned int derivative_order);
31Real
poly4Log(Real x, Real tol,
unsigned int derivative_order);
68Point
circumcenter2D(
const Point & p0,
const Point & p1,
const Point & p2);
74Point
circumcenter3D(
const Point & p0,
const Point & p1,
const Point & p2,
const Point & p3);
87 return x >= 0.0 ? 1.0 : -1.0;
116 return neg ? 1.0 / result : result;
123 return x < 0.0 ? 0.0 : 1.0;
130 if (x <= -smoothing_length)
132 else if (x < smoothing_length)
135 return 0.5 * (1 + sin(
libMesh::pi * x / 2 / smoothing_length));
145 if (x < smoothing_length && x > -smoothing_length)
158 return x > 0.0 ? x : 0.0;
165 return x < 0.0 ? x : 0.0;
184 typename std::enable_if<libMesh::ScalarTraits<T>::value,
int>::type = 0>
190 result.
add(scalar, numeric_vector);
196 template <
typename>
class W,
197 template <
typename>
class W2,
198 typename std::enable_if<std::is_same<typename W<T>::index_type,
unsigned int>
::value &&
199 std::is_same<typename W2<T2>::index_type,
unsigned int>
::value,
209 template <
typename>
class W,
210 template <
typename>
class W2,
211 typename std::enable_if<std::is_same<typename W<T>::index_type,
212 std::tuple<unsigned int, unsigned int>>
::value &&
213 std::is_same<typename W2<T2>::index_type,
214 std::tuple<unsigned int, unsigned int>>
::value,
219 return a.contract(b);
234 if constexpr (MooseUtils::Has_size<T>::value)
237 for (
const auto & component :
value)
246 for (
const auto i : make_range(std::size_t(1),
Moose::dim))
253 for (
const auto j : make_range(std::size_t(1),
Moose::dim))
255 for (
const auto i : make_range(std::size_t(1),
Moose::dim))
276 if (MooseUtils::isZero(
value))
300 const auto size = c.size();
308 for (std::size_t i = 1; i < size - 1; ++i)
313 for (std::size_t i = 1; i < size; ++i)
335 auto size = c.size();
341 for (std::size_t i = 1; i <= size; ++i)
356 auto size = c.size();
361 R
value = c[size] * size;
362 for (std::size_t i = 1; i < size; ++i)
368template <
typename T,
typename T2>
370clamp(
const T & x, T2 lowerlimit, T2 upperlimit)
379template <
typename T,
typename T2>
383 mooseAssert(
"start < end",
"Start value must be lower than end value for smootherStep");
393 x = (x - start) / (end - start);
395 return 30.0 * libMesh::Utility::pow<2>(x) * (x * (x - 2.0) + 1.0) / (end - start);
396 return libMesh::Utility::pow<3>(x) * (x * (x * 6.0 - 15.0) + 10.0);
405template <ComputeType compute_type,
typename X,
typename S,
typename E>
409 mooseAssert(
"start < end",
"Start value must be lower than end value for smootherStep");
419 const auto u = (x - start) / (end - start);
421 return 30.0 * libMesh::Utility::pow<2>(u) * (u * (u - 2.0) + 1.0) / (end - start);
423 return libMesh::Utility::pow<3>(u) * (u * (u * 6.0 - 15.0) + 10.0);
446 mooseError(
"mooseSetToZero does not accept pointers");
474std::vector<std::vector<unsigned int>>
multiIndex(
unsigned int dim,
unsigned int order);
476template <ComputeType compute_type,
typename X,
typename X1,
typename X2,
typename Y1,
typename Y2>
480 const auto m = (y2 - y1) / (x2 - x1);
484 return m * (x - x1) + y1;
493template <
typename T1,
typename T2>
497 return (dividend % divisor + divisor) % divisor;
508 return "grad_" + base_prop_name;
519 return "d" + base_prop_name +
"_dt";
528void kron(RealEigenMatrix & product,
const RealEigenMatrix & mat_A,
const RealEigenMatrix & mat_B);
533std::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 normSquared(const T &value)
Return the square of the Euclidean (L2) norm of value.
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)
auto norm(const T &value)
Return the Euclidean (L2) norm of value.
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.
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.