3.5-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
Classes | Namespaces | Functions
math.hh File Reference

Define some often used mathematical functions. More...

#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <dune/common/typetraits.hh>
#include <dune/common/fvector.hh>
#include <dune/common/fmatrix.hh>
#include <dune/common/dynmatrix.hh>
#include <dune/common/float_cmp.hh>

Go to the source code of this file.

Description

Define some often used mathematical functions.

Classes

struct  Dumux::InterpolationPolicy::Linear
 interpolate linearly between two given values More...
 
struct  Dumux::InterpolationPolicy::LinearTable
 interpolate linearly in a piecewise linear function (tabularized function) More...
 

Namespaces

namespace  Dumux
 
namespace  Dumux::InterpolationPolicy
 forward declaration of the linear interpolation policy (default)
 

Functions

template<class Scalar >
constexpr Scalar Dumux::arithmeticMean (Scalar x, Scalar y, Scalar wx=1.0, Scalar wy=1.0) noexcept
 Calculate the (weighted) arithmetic mean of two scalar values. More...
 
template<class Scalar >
constexpr Scalar Dumux::harmonicMean (Scalar x, Scalar y, Scalar wx=1.0, Scalar wy=1.0) noexcept
 Calculate the (weighted) harmonic mean of two scalar values. More...
 
template<class Scalar >
Scalar Dumux::geometricMean (Scalar x, Scalar y) noexcept
 Calculate the geometric mean of two scalar values. More...
 
template<class Scalar , int m, int n>
void Dumux::harmonicMeanMatrix (Dune::FieldMatrix< Scalar, m, n > &K, const Dune::FieldMatrix< Scalar, m, n > &Ki, const Dune::FieldMatrix< Scalar, m, n > &Kj)
 Calculate the harmonic mean of a fixed-size matrix. More...
 
template<class Scalar , class SolContainer >
int Dumux::invertLinearPolynomial (SolContainer &sol, Scalar a, Scalar b)
 Invert a linear polynomial analytically. More...
 
template<class Scalar , class SolContainer >
int Dumux::invertQuadraticPolynomial (SolContainer &sol, Scalar a, Scalar b, Scalar c)
 Invert a quadratic polynomial analytically. More...
 
template<class Scalar , class SolContainer >
int Dumux::invertCubicPolynomial (SolContainer *sol, Scalar a, Scalar b, Scalar c, Scalar d, std::size_t numPostProcessIterations=1)
 Invert a cubic polynomial analytically. More...
 
template<class Scalar , int dim>
bool Dumux::isLarger (const Dune::FieldVector< Scalar, dim > &pos, const Dune::FieldVector< Scalar, dim > &smallerVec)
 Comparison of two position vectors. More...
 
template<class Scalar , int dim>
bool Dumux::isSmaller (const Dune::FieldVector< Scalar, dim > &pos, const Dune::FieldVector< Scalar, dim > &largerVec)
 Comparison of two position vectors. More...
 
template<class Scalar , int dim>
bool Dumux::isBetween (const Dune::FieldVector< Scalar, dim > &pos, const Dune::FieldVector< Scalar, dim > &smallerVec, const Dune::FieldVector< Scalar, dim > &largerVec)
 Comparison of three position vectors. More...
 
template<class Policy = InterpolationPolicy::Linear, class Scalar , class ... Parameter>
Scalar Dumux::interpolate (Scalar ip, Parameter &&... params)
 a generic function to interpolate given a set of parameters and an interpolation point More...
 
template<class Scalar >
std::vector< Scalar > Dumux::linspace (const Scalar begin, const Scalar end, std::size_t samples, bool endPoint=true)
 Generates linearly spaced vectors. More...
 
template<class Scalar >
Scalar Dumux::antoine (Scalar temperature, Scalar A, Scalar B, Scalar C)
 Evaluates the Antoine equation used to calculate the vapour pressure of various liquids. More...
 
template<class ValueType >
constexpr int Dumux::sign (const ValueType &value) noexcept
 Sign or signum function. More...
 
template<class Scalar >
Dune::FieldVector< Scalar, 3 > Dumux::crossProduct (const Dune::FieldVector< Scalar, 3 > &vec1, const Dune::FieldVector< Scalar, 3 > &vec2)
 Cross product of two vectors in three-dimensional Euclidean space. More...
 
template<class Scalar >
Scalar Dumux::crossProduct (const Dune::FieldVector< Scalar, 2 > &vec1, const Dune::FieldVector< Scalar, 2 > &vec2)
 Cross product of two vectors in two-dimensional Euclidean space retuning scalar. More...
 
template<class Scalar >
Scalar Dumux::tripleProduct (const Dune::FieldVector< Scalar, 3 > &vec1, const Dune::FieldVector< Scalar, 3 > &vec2, const Dune::FieldVector< Scalar, 3 > &vec3)
 Triple product of three vectors in three-dimensional Euclidean space retuning scalar. More...
 
template<class Scalar , int m, int n>
Dune::FieldMatrix< Scalar, n, m > Dumux::getTransposed (const Dune::FieldMatrix< Scalar, m, n > &M)
 Transpose a FieldMatrix. More...
 
template<class Scalar >
Dune::DynamicMatrix< Scalar > Dumux::getTransposed (const Dune::DynamicMatrix< Scalar > &M)
 Transpose a DynamicMatrix. More...
 
template<class Scalar >
Dune::DynamicMatrix< Scalar > Dumux::multiplyMatrices (const Dune::DynamicMatrix< Scalar > &M1, const Dune::DynamicMatrix< Scalar > &M2)
 Multiply two dynamic matrices. More...
 
template<class Scalar , int rows1, int cols1, int cols2>
Dune::FieldMatrix< Scalar, rows1, cols2 > Dumux::multiplyMatrices (const Dune::FieldMatrix< Scalar, rows1, cols1 > &M1, const Dune::FieldMatrix< Scalar, cols1, cols2 > &M2)
 Multiply two field matrices. More...
 
template<class MatrixType >
Dune::DenseMatrix< MatrixType >::field_type Dumux::trace (const Dune::DenseMatrix< MatrixType > &M)
 Trace of a dense matrix. More...
 
template<class MAT , class V >
Dune::DenseVector< V >::derived_type Dumux::mv (const Dune::DenseMatrix< MAT > &M, const Dune::DenseVector< V > &v)
 Returns the result of the projection of a vector v with a Matrix M. More...
 
template<class FieldScalar , class V >
std::enable_if_t< Dune::IsNumber< FieldScalar >::value, typename Dune::DenseVector< V >::derived_type > Dumux::mv (const FieldScalar m, const Dune::DenseVector< V > &v)
 Returns the result of a vector v multiplied by a scalar m. More...
 
template<class V1 , class MAT , class V2 >
Dune::DenseMatrix< MAT >::value_type Dumux::vtmv (const Dune::DenseVector< V1 > &v1, const Dune::DenseMatrix< MAT > &M, const Dune::DenseVector< V2 > &v2)
 Evaluates the scalar product of a vector v2, projected by a matrix M, with a vector v1. More...
 
template<class V1 , class FieldScalar , class V2 >
std::enable_if_t< Dune::IsNumber< FieldScalar >::value, FieldScalar > Dumux::vtmv (const Dune::DenseVector< V1 > &v1, const FieldScalar m, const Dune::DenseVector< V2 > &v2)
 Evaluates the scalar product of a vector v2, scaled by a scalar m, with a vector v1. More...
 
template<class Scalar >
std::array< Scalar, 2 > Dumux::linearRegression (const std::vector< Scalar > &x, const std::vector< Scalar > &y)
 Returns the [intercept, slope] of the regression line fitted to a set of (x, y) data points. More...
 
Include dependency graph for math.hh: