https://mooseframework.inl.gov
Namespaces | Enumerations | Functions | Variables
MathUtils.h File Reference

Go to the source code of this file.

Namespaces

 MathUtils
 

Enumerations

enum  MathUtils::ComputeType { MathUtils::ComputeType::value, MathUtils::ComputeType::derivative }
 

Functions

Real MathUtils::poly1Log (Real x, Real tol, unsigned int derivative_order)
 
Real MathUtils::poly2Log (Real x, Real tol, unsigned int derivative_order)
 
Real MathUtils::poly3Log (Real x, Real tol, unsigned int derivative_order)
 
Real MathUtils::poly4Log (Real x, Real tol, unsigned int derivative_order)
 
Real MathUtils::taylorLog (Real x)
 
Point MathUtils::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 center point and Cartesian coordinates of triangle's vertices. More...
 
Point MathUtils::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 center point and Cartesian coordinates of tetrahedon's vertices. More...
 
Point MathUtils::circumcenter2D (const Point &p0, const Point &p1, const Point &p2)
 Evaluate circumcenter of a triangle given three arbitrary points. More...
 
Point MathUtils::circumcenter3D (const Point &p0, const Point &p1, const Point &p2, const Point &p3)
 Evaluate circumcenter of a tetrahedrom given four arbitrary points. More...
 
template<typename T >
MathUtils::round (T x)
 
template<typename T >
MathUtils::sign (T x)
 
template<typename T >
MathUtils::pow (T x, int e)
 
template<typename T >
MathUtils::heavyside (T x)
 
template<typename T >
MathUtils::regularizedHeavyside (T x, Real smoothing_length)
 
template<typename T >
MathUtils::regularizedHeavysideDerivative (T x, Real smoothing_length)
 
template<typename T >
MathUtils::positivePart (T x)
 
template<typename T >
MathUtils::negativePart (T x)
 
template<typename T , typename T2 , typename T3 , typename std::enable_if< libMesh::ScalarTraits< T >::value &&libMesh::ScalarTraits< T2 >::value &&libMesh::ScalarTraits< T3 >::value, int >::type = 0>
void MathUtils::addScaled (const T &a, const T2 &b, T3 &result)
 
template<typename T , typename T2 , typename T3 , typename std::enable_if< libMesh::ScalarTraits< T >::value, int >::type = 0>
void MathUtils::addScaled (const T &scalar, const libMesh::NumericVector< T2 > &numeric_vector, libMesh::NumericVector< T3 > &result)
 
template<typename T , typename T2 , template< typename > class W, template< typename > class W2, typename std::enable_if< std::is_same< typename W< T >::index_type, unsigned int >::value &&std::is_same< typename W2< T2 >::index_type, unsigned int >::value, int >::type = 0>
libMesh::CompareTypes< T, T2 >::supertype MathUtils::dotProduct (const W< T > &a, const W2< T2 > &b)
 
template<typename C , typename T , typename R = typename libMesh::CompareTypes<typename C::value_type, T>::supertype>
MathUtils::poly (const C &c, const T x, const bool derivative=false)
 Evaluate a polynomial with the coefficients c at x. More...
 
template<typename C , typename T , typename R = typename libMesh::CompareTypes<typename C::value_type, T>::supertype>
MathUtils::polynomial (const C &c, const T x)
 Evaluate a polynomial with the coefficients c at x. More...
 
template<typename C , typename T , typename R = typename libMesh::CompareTypes<typename C::value_type, T>::supertype>
MathUtils::polynomialDerivative (const C &c, const T x)
 Returns the derivative of polynomial(c, x) with respect to x. More...
 
template<typename T , typename T2 >
MathUtils::clamp (const T &x, T2 lowerlimit, T2 upperlimit)
 
template<typename T , typename T2 >
MathUtils::smootherStep (T x, T2 start, T2 end, bool derivative=false)
 
template<ComputeType compute_type, typename X , typename S , typename E >
auto MathUtils::smootherStep (const X &x, const S &start, const E &end)
 
template<typename T >
void MathUtils::mooseSetToZero (T &v)
 Helper function templates to set a variable to zero. More...
 
template<typename T >
void MathUtils::mooseSetToZero (T *&)
 
template<>
void MathUtils::mooseSetToZero (std::vector< Real > &vec)
 
std::vector< std::vector< unsigned int > > MathUtils::multiIndex (unsigned int dim, unsigned int order)
 generate a complete multi index table for given dimension and order i.e. More...
 
template<ComputeType compute_type, typename X , typename X1 , typename X2 , typename Y1 , typename Y2 >
auto MathUtils::linearInterpolation (const X &x, const X1 &x1, const X2 &x2, const Y1 &y1, const Y2 &y2)
 
template<typename T1 , typename T2 >
std::size_t MathUtils::euclideanMod (T1 dividend, T2 divisor)
 perform modulo operator for Euclidean division that ensures a non-negative result More...
 
template<typename T >
MathUtils::gradName (const T &base_prop_name)
 automatic prefixing for naming material properties based on gradients of coupled variables/functors More...
 
template<typename T >
MathUtils::timeDerivName (const T &base_prop_name)
 automatic prefixing for naming material properties based on time derivatives of coupled variables/functors More...
 
void MathUtils::kron (RealEigenMatrix &product, const RealEigenMatrix &mat_A, const RealEigenMatrix &mat_B)
 Computes the Kronecker product of two matrices. More...
 
std::vector< std::vector< unsigned int > > multiIndexHelper (unsigned int N, unsigned int K)
 A helper function for MathUtils::multiIndex. More...
 

Variables

static constexpr Real MathUtils::sqrt2 = 1.4142135623730951
 std::sqrt is not constexpr, so we add sqrt(2) as a constant (used in Mandel notation) More...
 

Function Documentation

◆ multiIndexHelper()

std::vector<std::vector<unsigned int> > multiIndexHelper ( unsigned int  N,
unsigned int  K 
)

A helper function for MathUtils::multiIndex.

Definition at line 333 of file MathUtils.C.

Referenced by MathUtils::multiIndex().

334 {
335  std::vector<std::vector<unsigned int>> n_choose_k;
336  std::vector<unsigned int> row;
337  std::string bitmask(K, 1); // K leading 1's
338  bitmask.resize(N, 0); // N-K trailing 0's
339 
340  do
341  {
342  row.clear();
343  row.push_back(0);
344  for (unsigned int i = 0; i < N; ++i) // [0..N-1] integers
345  if (bitmask[i])
346  row.push_back(i + 1);
347  row.push_back(N + 1);
348  n_choose_k.push_back(row);
349  } while (std::prev_permutation(bitmask.begin(), bitmask.end()));
350 
351  return n_choose_k;
352 }