KASKADE 7 development version
Loading...
Searching...
No Matches
Utilities

Miscellaneous support routines and classes. More...

Topics

 Combinatorics
 Functions for counting and enumerating combinatorial structures.
 Multithreading
 Support routines and data structures for multithreaded execution.
 Exceptions
 A hierarchy of exception classes providing more or less detailed information.

Classes

struct  Kaskade::Creator< Product >
 Abstract base class of creators that can be registered at the pluggable factory. More...
class  Kaskade::Factory< K, P >
 A pluggable factory. More...
class  Kaskade::Deprecated
 Convenience class for marking deprecated functions. A static object of this class can be created inside deprecated functions. It will output a warning message to stderr if the deprecated function is called, but only once. More...
struct  Kaskade::ConvertTo< T, Real >
 Reports the converted type. More...
class  Kaskade::Timings
 Supports gathering and reporting execution times information for nested program parts. More...
class  Kaskade::ScopedTimingSection
 A scope guard object that automatically closes a timing section on destruction. More...
class  Kaskade::TaskTiming
 A class that gathers data on task timing and provides gnuplot visualization. More...

Functions

template<class LocalCoordinate>
LocalCoordinate::field_type checkInside (Dune::GeometryType const &gt, LocalCoordinate const &x)
 Checks whether a point is inside or outside the reference element, and how much.
template<class Cell>
std::pair< Dune::FieldVector< double, Cell::dimension >, Dune::FieldVector< double, Cell::dimension > > boundingBox (Cell const &cell)
 Computes the bounding box of a cell.
template<int d, class Real>
Real Kaskade::bezier (int p, int i, Dune::FieldVector< Real, d > const &x)
 Computes the i-th Bezier function of order p at the given point in the unit simplex.
constexpr int Kaskade::binomial (int n, int k)
 Computes the binomial coefficient \( \binom{n}{k} \).
template<size_t m>
size_t Kaskade::multinomial (std::array< size_t, m > const &ks)
 Computes the multinomial coefficient \( \binom{n}{k_1,\dots,k_m}\), where \( n = \sum_{i=1}^m k_i \).
std::vector< double > Kaskade::lobattoNodes (int n)
 Computes the n Lobatto nodes on [-1,1] including the interval end points.
std::vector< double > Kaskade::radauNodes (int n)
 Computes the n Radau nodes on [-1,1] including the right end point.
std::vector< double > Kaskade::gaussNodes (int n)
 Computes the n Gauß nodes on [-1,1] excluding the interval end points.
bool Kaskade::getKaskadeOptions (int argc, char **argv, Options const &options)
 Supports the extraction of program option values from command line arguments.
template<class A>
auto Kaskade::moveUnique (A &&a)
 Creates a dynamically allocated object from an r-value reference.
template<class A>
A Kaskade::duplicate (A const &a)
 Creates a copy of a given object.
template<class R>
constexpr R Kaskade::power (R base, int exp)
 Computes integral powers of values in a multiplicative half-group.
template<class R>
constexpr R Kaskade::square (R x)
 returns the square of its argument.
template<class R>
constexpr R Kaskade::faculty (int n)
 Computes faculties. Is this somewhere in the standard? no.
constexpr int Kaskade::sqrti (int n)
 Computes floor(sqrt(n)) for integers n at compile time.
template<class T>
T & Kaskade::removeConst (T const &t)
 A convenience template for removing the const qualifier from references and pointers.

Detailed Description

Miscellaneous support routines and classes.

Function Documentation

◆ bezier()

template<int d, class Real>
Real Kaskade::bezier ( int p,
int i,
Dune::FieldVector< Real, d > const & x )

Computes the i-th Bezier function of order p at the given point in the unit simplex.

The Bezier functions are the summands in

\[ 1 = 1^p = \left(\sum_{j=0}^d \lambda_j\right)^p, \]

where \( \lambda_j \) are the barycentric coordinates.

Parameters
pthe order of Bezier functions
ithe number of the Bezier function of order p. 0 <= i < numberOfMultiindices(d,p) has to hold.
xthe simplex coordinates, i.e. \( \lambda = (x,1-\|x\|_1) \).
See also
numberOfMultiindices

Definition at line 39 of file bezier.hh.

◆ binomial()

◆ boundingBox()

template<class Cell>
std::pair< Dune::FieldVector< double, Cell::dimension >, Dune::FieldVector< double, Cell::dimension > > boundingBox ( Cell const & cell)

Computes the bounding box of a cell.

Template Parameters
Cellthe type of cell considered. Usually a typename GridView::template Codim<0>::Entity.
Returns
a pair of Dune::FieldVector<double,dim> which are the minimal and the maximal coordiantes of the bounding box.

Definition at line 720 of file fixdune.hh.

◆ checkInside()

template<class LocalCoordinate>
LocalCoordinate::field_type checkInside ( Dune::GeometryType const & gt,
LocalCoordinate const & x )

Checks whether a point is inside or outside the reference element, and how much.

Computational geometry predicates are notoriously difficult to get right. In Dune, it may happen that a point inside a cell is reported not to be contained in any of its children. Often this is due to rounding errors. This function returns not just a binary decision subject to rounding errors, but a floating point value that gives the magnitude of being inside or outside, such that the result can be tested by arbitrary tolerances or sorted according to magnitude.

Template Parameters
LocalCoordinatethe type of local coordinate vectors. Usually a Dune::FieldVector<ctype,dim>.
Todo
The current implementation is just for cubes and simplices. Pyramids and prisms are not covered.
Returns
a value less or equal to zero if the point is inside, a value greater zero if outside

Definition at line 692 of file fixdune.hh.

Referenced by Kaskade::findCell(), and Kaskade::findCellOnLevel().

◆ duplicate()

template<class A>
A Kaskade::duplicate ( A const & a)

Creates a copy of a given object.

Use this if you need a temporary copy that can be moved from.

Template Parameters
Aneeds to be copy constructible and (preferably) moveable.

Definition at line 48 of file memory.hh.

Referenced by Kaskade::MultiplicativeMultiGrid< Entry, Index, Smoother, Prolongation >::makeJacobiMultiGrid().

◆ faculty()

template<class R>
R Kaskade::faculty ( int n)
constexpr

Computes faculties. Is this somewhere in the standard? no.

Definition at line 63 of file power.hh.

◆ gaussNodes()

std::vector< double > Kaskade::gaussNodes ( int n)

Computes the n Gauß nodes on [-1,1] excluding the interval end points.

◆ getKaskadeOptions()

bool Kaskade::getKaskadeOptions ( int argc,
char ** argv,
Options const & options )

Supports the extraction of program option values from command line arguments.

Based on boost::program_options, command line arguments (or their default values) can be stored in variables as follows:

bool a;
int b;
("a",a,false,"defines boolean parameter a")
("b",b,42, "defines integer parameter b"));
bool getKaskadeOptions(int argc, char **argv, Options const &options)
Supports the extraction of program option values from command line arguments.

If an argument "--help" is given, the list of allowed options is printed.

Returns
true if an argument "--help" has been provided, otherwise false.

◆ lobattoNodes()

std::vector< double > Kaskade::lobattoNodes ( int n)

Computes the n Lobatto nodes on [-1,1] including the interval end points.

◆ moveUnique()

template<class A>
auto Kaskade::moveUnique ( A && a)

Creates a dynamically allocated object from an r-value reference.

Use this if you get an object of a runtime-polymorphic class hierarchy only as an r-value, e.g. from a makeSomething() function, and you don't care for its actual type:

std::unique_ptr<Base> = moveUnique(makeComplexDerivedClass(arguments));
auto moveUnique(A &&a)
Creates a dynamically allocated object from an r-value reference.
Definition memory.hh:33
Template Parameters
Aneeds to be move (preferably) or copy constructible.

Definition at line 33 of file memory.hh.

Referenced by Kaskade::MultiplicativeMultiGrid< Entry, Index, Smoother, Prolongation >::makeBlockJacobiPMultiGrid(), Kaskade::MultiplicativeMultiGrid< Entry, Index, Smoother, Prolongation >::makeJacobiMultiGrid(), makeMultigrid(), Kaskade::MultiplicativeMultiGrid< Entry, Index, Smoother, Prolongation >::makeMultiplicativePMultiGrid(), and makePMultiGridStack().

◆ multinomial()

template<size_t m>
size_t Kaskade::multinomial ( std::array< size_t, m > const & ks)

Computes the multinomial coefficient \( \binom{n}{k_1,\dots,k_m}\), where \( n = \sum_{i=1}^m k_i \).

Template Parameters
mthe number of multinomials
Parameters
ksan array of nonegative integers

The multinomial coefficient is

\[ \binom{n}{k_1,\dots,k_m} = \frac{n!}{k_1! \cdots k_m!}. \]

Definition at line 61 of file combinatorics.hh.

Referenced by bezier().

◆ power()

◆ radauNodes()

std::vector< double > Kaskade::radauNodes ( int n)

Computes the n Radau nodes on [-1,1] including the right end point.

◆ removeConst()

template<class T>
T & Kaskade::removeConst ( T const & t)

A convenience template for removing the const qualifier from references and pointers.

Use this instead of

const_cast<T&>(t)

in polymorphic lambda functions where the type T is not named (just inferred from auto) and hence more involved to obtain, e.g. using decltype.

Definition at line 30 of file typeTraits.hh.

◆ sqrti()

int Kaskade::sqrti ( int n)
constexpr

Computes floor(sqrt(n)) for integers n at compile time.

Definition at line 96 of file power.hh.

Referenced by Kaskade::Elastomechanics::yieldStrength().

◆ square()