https://mooseframework.inl.gov
Functions
CompileTimeDerivativesMaterialInternal::details Namespace Reference

Functions

template<std::size_t first, std::size_t second, std::size_t... tail>
constexpr bool is_sorted ()
 Check if the given index sequence is sorted ()internal function) More...
 
template<std::size_t N>
constexpr std::size_t factorial ()
 Compile time evaluation of the factorial of N. More...
 
template<std::size_t N, std::size_t M>
constexpr std::size_t num_derivatives ()
 Number of distinct order N derivatives of a function with M variables. More...
 
template<std::size_t... first, std::size_t... second>
constexpr auto merge (std::index_sequence< first... >, std::index_sequence< second... >)
 Merge two index sequences into one. More...
 
template<std::size_t Nmax, std::size_t first, std::size_t... tail>
constexpr auto increment (std::index_sequence< first, tail... >)
 Increment the first number in an index sequence, but roll over into the next number if it reaches Nmax. More...
 
template<std::size_t M, std::size_t... N>
constexpr std::size_t total_derivatives (std::index_sequence< N... >)
 Compute the total number of distinct derivatives for all orders N. More...
 
template<std::size_t... Ns>
constexpr auto zeroes (std::index_sequence< Ns... >)
 Take an index sequence and return an index sequence of the same length with all entries replaced by zeroes. More...
 

Function Documentation

◆ factorial()

template<std::size_t N>
constexpr std::size_t CompileTimeDerivativesMaterialInternal::details::factorial ( )

Compile time evaluation of the factorial of N.

Definition at line 42 of file CompileTimeDerivativesMaterialInternal.h.

Referenced by num_derivatives().

43 {
44  if constexpr (N == 0)
45  return 1;
46  else if constexpr (N == 1)
47  return 1;
48  else
49  return N * factorial<N - 1>();
50 }
if(!dmm->_nl) SETERRQ(PETSC_COMM_WORLD

◆ increment()

template<std::size_t Nmax, std::size_t first, std::size_t... tail>
constexpr auto CompileTimeDerivativesMaterialInternal::details::increment ( std::index_sequence< first, tail... >  )

Increment the first number in an index sequence, but roll over into the next number if it reaches Nmax.

This basically increments a base-Nmax number with its digits in reverse!

Definition at line 78 of file CompileTimeDerivativesMaterialInternal.h.

Referenced by FillBetweenPointVectorsTools::fillBetweenPointVectorsGenerator().

79 {
80  if constexpr (first + 1 == Nmax)
81  {
82  if constexpr (sizeof...(tail) == 0)
83  return std::index_sequence<>{};
84  else
85  return merge(std::index_sequence<0>{}, increment<Nmax>(std::index_sequence<tail...>{}));
86  }
87  else
88  return std::index_sequence<first + 1, tail...>{};
89 }
constexpr auto merge(std::index_sequence< first... >, std::index_sequence< second... >)
Merge two index sequences into one.

◆ is_sorted()

template<std::size_t first, std::size_t second, std::size_t... tail>
constexpr bool CompileTimeDerivativesMaterialInternal::details::is_sorted ( )

Check if the given index sequence is sorted ()internal function)

Definition at line 24 of file CompileTimeDerivativesMaterialInternal.h.

Referenced by CompileTimeDerivativesMaterialInternal::is_sorted(), CompileTimeDerivativesMaterial< N, is_ad, MaxD >::loopDeclareProperties(), CompileTimeDerivativesMaterial< N, is_ad, MaxD >::loopEvaluate(), ParsedCurveGenerator::ParsedCurveGenerator(), and TimeSequenceStepperBase::setupSequence().

25 {
26  if constexpr (first <= second)
27  {
28  if constexpr (sizeof...(tail) == 0)
29  return true;
30  else
31  return is_sorted<second, tail...>();
32  }
33  else
34  return false;
35 }
constexpr bool is_sorted(std::index_sequence< first >)
A sequence of size 1 is always sorted.

◆ merge()

template<std::size_t... first, std::size_t... second>
constexpr auto CompileTimeDerivativesMaterialInternal::details::merge ( std::index_sequence< first... >  ,
std::index_sequence< second... >   
)

Merge two index sequences into one.

Definition at line 67 of file CompileTimeDerivativesMaterialInternal.h.

Referenced by Moose::Builder::build(), increment(), TimeIntegrator::init(), and Parser::parse().

68 {
69  return std::index_sequence<first..., second...>{};
70 }

◆ num_derivatives()

template<std::size_t N, std::size_t M>
constexpr std::size_t CompileTimeDerivativesMaterialInternal::details::num_derivatives ( )

Number of distinct order N derivatives of a function with M variables.

Definition at line 57 of file CompileTimeDerivativesMaterialInternal.h.

58 {
59  return factorial<N + M - 1>() / (factorial<N>() * factorial<M - 1>());
60 }
unsigned int factorial(unsigned int n)

◆ total_derivatives()

template<std::size_t M, std::size_t... N>
constexpr std::size_t CompileTimeDerivativesMaterialInternal::details::total_derivatives ( std::index_sequence< N... >  )

Compute the total number of distinct derivatives for all orders N.

Definition at line 96 of file CompileTimeDerivativesMaterialInternal.h.

97 {
98  return (num_derivatives<N, M>() + ...);
99 }

◆ zeroes()

template<std::size_t... Ns>
constexpr auto CompileTimeDerivativesMaterialInternal::details::zeroes ( std::index_sequence< Ns... >  )

Take an index sequence and return an index sequence of the same length with all entries replaced by zeroes.

Definition at line 107 of file CompileTimeDerivativesMaterialInternal.h.

Referenced by CompileTimeDerivativesMaterialInternal::zeroes().

108 {
109  return std::index_sequence<(void(Ns), 0)...>{};
110 }
class infix_ostream_iterator if void
Definition: InfixIterator.h:26