OGS
MathLib Namespace Reference

Namespaces

namespace  detail
 
namespace  details
 
namespace  KelvinVector
 
namespace  LinAlg
 
namespace  Nonlinear
 
namespace  ODE
 
namespace  VectorizedTensor
 

Classes

class  CubicSolver
 
class  EigenBlockMatrixViewFunctor
 
struct  EigenIOFormat
 
class  EigenLinearSolver
 
class  EigenLinearSolverBase
 
class  EigenLisLinearSolver
 
class  EigenMatrix
 
struct  EigenOption
 Option for Eigen sparse solver. More...
 
class  EigenVector
 Global vector based on Eigen vector. More...
 
struct  GaussLegendre
 
struct  GaussLegendrePyramid
 
struct  GaussLegendrePyramid< 2 >
 
struct  GaussLegendrePyramid< 3 >
 
struct  GaussLegendreTet
 
struct  GaussLegendreTet< 2 >
 
struct  GaussLegendreTet< 3 >
 
struct  GaussLegendreTet< 4 >
 
struct  GaussLegendreTri
 
struct  GaussLegendreTri< 2 >
 
struct  GaussLegendreTri< 3 >
 
struct  GaussLegendreTri< 4 >
 
class  KahanSum
 
class  LinearIntervalInterpolation
 Class (template) LinearIntervalInterpolation is a functional object performing an interval mapping \(f: [a,b] \to [c,d]\). More...
 
struct  LinearSolverOptionsParser
 
struct  LinearSolverOptionsParser< EigenLinearSolver >
 
struct  LinearSolverOptionsParser< EigenLisLinearSolver >
 
struct  LinearSolverOptionsParser< PETScLinearSolver >
 
class  LisMatrix
 LisMatrix is a wrapper class for matrix types of the linear iterative solvers library. More...
 
class  LisVector
 Lis vector wrapper class. More...
 
struct  MatrixSpecifications
 
struct  MatrixVectorTraits
 
class  PETScLinearSolver
 
class  PETScMatrix
 Wrapper class for PETSc matrix routines for matrix. More...
 
struct  PETScMatrixOption
 This a struct data containing the configuration information to create a PETSc type matrix. More...
 
class  PETScVector
 Wrapper class for PETSc vector. More...
 
struct  PiecewiseLinearCurveConfig
 
class  PiecewiseLinearInterpolation
 
class  PiecewiseLinearMonotonicCurve
 Class for strong monotonic curves. More...
 
class  Point3d
 
class  Point3dWithID
 
struct  RowColumnIndices
 
struct  SetMatrixSparsity
 
struct  SetMatrixSparsity< EigenMatrix, SPARSITY_PATTERN >
 Sets the sparsity pattern of the underlying EigenMatrix. More...
 
struct  SetMatrixSparsity< LisMatrix, SPARSITY_PATTERN >
 Sets the sparsity pattern of the underlying LisMatrix. More...
 
class  WeightedPoint
 
struct  WeightedSum
 

Typedefs

template<typename IndexType >
using SparsityPattern = std::vector<IndexType>
 A vector telling how many nonzeros there are in each global matrix row.
 

Enumerations

enum  TriangleTest { GAUSS , BARYCENTRIC }
 
enum class  VecNormType { NORM1 , NORM2 , INFINITY_N , INVALID }
 
enum class  LinearSolverBehaviour : int { RECOMPUTE , RECOMPUTE_AND_STORE , REUSE }
 

Functions

PiecewiseLinearCurveConfig parsePiecewiseLinearCurveConfig (BaseLib::ConfigTree const &config)
 
std::vector< double > readDoublesFromBinaryFile (const std::string &filename)
 
template<typename CurveType >
std::unique_ptr< CurveType > createPiecewiseLinearCurve (BaseLib::ConfigTree const &config)
 
template<int D, typename M >
constexpr Eigen::CwiseNullaryOp< EigenBlockMatrixViewFunctor< D, M >, typename EigenBlockMatrixViewFunctor< D, M >::Matrix > eigenBlockMatrixView (const Eigen::MatrixBase< M > &matrix)
 
double orientation3d (MathLib::Point3d const &p, MathLib::Point3d const &a, MathLib::Point3d const &b, MathLib::Point3d const &c)
 
double calcTetrahedronVolume (MathLib::Point3d const &a, MathLib::Point3d const &b, MathLib::Point3d const &c, MathLib::Point3d const &d)
 
double calcTriangleArea (MathLib::Point3d const &a, MathLib::Point3d const &b, MathLib::Point3d const &c)
 
bool isPointInTetrahedron (MathLib::Point3d const &p, MathLib::Point3d const &a, MathLib::Point3d const &b, MathLib::Point3d const &c, MathLib::Point3d const &d, double eps)
 
bool isPointInTriangle (MathLib::Point3d const &p, MathLib::Point3d const &a, MathLib::Point3d const &b, MathLib::Point3d const &c, double eps_pnt_out_of_plane, double eps_pnt_out_of_tri, MathLib::TriangleTest algorithm)
 
bool gaussPointInTriangle (MathLib::Point3d const &q, MathLib::Point3d const &a, MathLib::Point3d const &b, MathLib::Point3d const &c, double eps_pnt_out_of_plane, double eps_pnt_out_of_tri)
 
bool barycentricPointInTriangle (MathLib::Point3d const &p, MathLib::Point3d const &a, MathLib::Point3d const &b, MathLib::Point3d const &c, double eps_pnt_out_of_plane, double eps_pnt_out_of_tri)
 
bool isPointInTriangleXY (MathLib::Point3d const &p, MathLib::Point3d const &a, MathLib::Point3d const &b, MathLib::Point3d const &c)
 
bool dividedByPlane (const MathLib::Point3d &a, const MathLib::Point3d &b, const MathLib::Point3d &c, const MathLib::Point3d &d)
 
bool isCoplanar (const MathLib::Point3d &a, const MathLib::Point3d &b, const MathLib::Point3d &c, const MathLib::Point3d &d)
 Checks if the four given points are located on a plane.
 
static std::array< std::array< double, 3 >, GaussLegendreTet< 3 >::NPoints > initGLTet3X ()
 
static std::array< std::array< double, 3 >, GaussLegendreTet< 4 >::NPoints > initGLTet4X ()
 
template<typename Matrix >
Eigen::Map< Matrix > createZeroedMatrix (std::vector< double > &data, Eigen::MatrixXd::Index rows, Eigen::MatrixXd::Index cols)
 
Eigen::Map< Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > > createZeroedMatrix (std::vector< double > &data, Eigen::MatrixXd::Index rows, Eigen::MatrixXd::Index cols)
 
template<typename Matrix >
Eigen::Map< const Matrix > toMatrix (std::vector< double > const &data, Eigen::MatrixXd::Index rows, Eigen::MatrixXd::Index cols)
 
Eigen::Map< const Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > > toMatrix (std::vector< double > const &data, Eigen::MatrixXd::Index rows, Eigen::MatrixXd::Index cols)
 
template<typename Matrix >
Eigen::Map< Matrix > toMatrix (std::vector< double > &data, Eigen::MatrixXd::Index rows, Eigen::MatrixXd::Index cols)
 
Eigen::Map< Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > > toMatrix (std::vector< double > &data, Eigen::MatrixXd::Index rows, Eigen::MatrixXd::Index cols)
 
template<typename Vector >
Eigen::Map< Vector > createZeroedVector (std::vector< double > &data, Eigen::VectorXd::Index size)
 
template<typename Vector >
Eigen::Map< const Vector > toVector (std::vector< double > const &data, Eigen::VectorXd::Index size)
 Creates an Eigen mapped vector from the given data vector.
 
template<typename Vector >
Eigen::Map< Vector > toVector (std::vector< double > &data, Eigen::VectorXd::Index size)
 Creates an Eigen mapped vector from the given data vector.
 
Eigen::Map< const Eigen::VectorXd > toVector (std::vector< double > const &data)
 
Eigen::Map< Eigen::VectorXd > toVector (std::vector< double > &data)
 
void applyKnownSolution (EigenMatrix &A, EigenVector &b, EigenVector &, const std::vector< EigenMatrix::IndexType > &vec_knownX_id, const std::vector< double > &vec_knownX_x)
 
template<typename MAT_T >
bool finalizeMatrixAssembly (MAT_T &)
 
template<typename VEC_T >
void finalizeVectorAssembly (VEC_T &)
 General function to finalize the vector assembly.
 
std::string convertVecNormTypeToString (VecNormType normType)
 convert VecNormType to string
 
VecNormType convertStringToVecNormType (const std::string &str)
 convert string to VecNormType
 
void ignoreOtherLinearSolvers (const BaseLib::ConfigTree &config, const std::string &solver_name)
 
bool checkLisError (int err)
 
bool finalizeMatrixAssembly (LisMatrix &mat)
 finish assembly to make this matrix be ready for use
 
 SPECIALIZE_MATRIX_VECTOR_TRAITS (PETScMatrix, PETScMatrix::IndexType)
 
 SPECIALIZE_MATRIX_VECTOR_TRAITS (PETScVector, PETScVector::IndexType)
 
bool finalizeMatrixAssembly (PETScMatrix &mat, const MatAssemblyType asm_type=MAT_FINAL_ASSEMBLY)
 General interface for the matrix assembly.
 
void applyKnownSolution (PETScMatrix &A, PETScVector &b, PETScVector &x, const std::vector< PetscInt > &vec_knownX_id, const std::vector< PetscScalar > &vec_knownX_x)
 apply known solutions to a system of linear equations
 
void finalizeVectorAssembly (PETScVector &vec)
 Function to finalize the vector assembly.
 
template<typename MATRIX , typename SPARSITY_PATTERN >
void setMatrixSparsity (MATRIX &matrix, SPARSITY_PATTERN const &sparsity_pattern)
 
void setVector (PETScVector &v, std::initializer_list< double > values)
 
void setVector (PETScVector &v, MatrixVectorTraits< PETScVector >::Index const index, double const value)
 
void setMatrix (PETScMatrix &m, std::initializer_list< double > values)
 
void setMatrix (PETScMatrix &m, Eigen::MatrixXd const &tmp)
 
void addToMatrix (PETScMatrix &m, std::initializer_list< double > values)
 
double calcProjPntToLineAndDists (Point3d const &pp, Point3d const &pa, Point3d const &pb, double &lambda, double &d0)
 
double getAngle (Point3d const &p0, Point3d const &p1, Point3d const &p2)
 
MathLib::Point3d operator* (Eigen::Matrix3d const &mat, MathLib::Point3d const &p)
 
double sqrDist (MathLib::Point3d const &p0, MathLib::Point3d const &p1)
 
bool lessEq (Point3d const &a, Point3d const &b, double eps)
 
bool operator< (Point3d const &a, Point3d const &b)
 
std::ostream & operator<< (std::ostream &os, const Point3d &p)
 
bool operator== (Point3d const &a, Point3d const &b)
 
double sqrDist2d (MathLib::Point3d const &p0, MathLib::Point3d const &p1)
 
std::ostream & operator<< (std::ostream &os, MathLib::WeightedPoint const &wp)
 

Variables

static const double p = 0.1126879257180162 / 6.
 
static const double q = 0.0734930431163619 / 6.
 
static const double r = 0.0425460207770812 / 6.
 
static const double s = 81. / 2240. / 6.
 
static const double t = 161051. / 2304960. / 6.
 
static const double u = 409. / 31395. / 6.
 
static const double v = 2679769. / 32305455. / 6.
 
const Point3d ORIGIN {{{0.0, 0.0, 0.0}}}
 

Typedef Documentation

◆ SparsityPattern

template<typename IndexType >
using MathLib::SparsityPattern = std::vector<IndexType>

A vector telling how many nonzeros there are in each global matrix row.

Definition at line 19 of file SparsityPattern.h.

Enumeration Type Documentation

◆ LinearSolverBehaviour

enum class MathLib::LinearSolverBehaviour : int
strong
Enumerator
RECOMPUTE 
RECOMPUTE_AND_STORE 
REUSE 

Definition at line 15 of file LinearSolverBehaviour.h.

◆ TriangleTest

Enumerator
GAUSS 
BARYCENTRIC 

Definition at line 19 of file GeometricBasics.h.

20{
21 GAUSS,
23};

◆ VecNormType

enum class MathLib::VecNormType
strong

Norm type. Not declared as class type in order to use the members as integers.

Enumerator
NORM1 

\(\sum_i |x_i|\)

NORM2 

\(\sqrt(\sum_i (x_i)^2)\)

INFINITY_N 

\(\mathrm{max}_i |x_i|\)

INVALID 

Definition at line 22 of file LinAlgEnums.h.

Function Documentation

◆ addToMatrix()

void MathLib::addToMatrix ( PETScMatrix & m,
std::initializer_list< double > values )

Definition at line 71 of file UnifiedMatrixSetters.cpp.

72{
73 using IndexType = PETScMatrix::IndexType;
74
75 auto const rows = m.getNumberOfRows();
76 auto const cols = m.getNumberOfColumns();
77
78 assert((IndexType)values.size() == rows * cols);
79
80 Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> tmp(
81 rows, cols);
82
83 auto it = values.begin();
84 for (IndexType r = 0; r < rows; ++r)
85 {
86 for (IndexType c = 0; c < cols; ++c)
87 {
88 tmp(r, c) = *(it++);
89 }
90 }
91
92 std::vector<IndexType> row_idcs(rows);
93 std::vector<IndexType> col_idcs(cols);
94
95 std::iota(row_idcs.begin(), row_idcs.end(), 0);
96 std::iota(col_idcs.begin(), col_idcs.end(), 0);
97
98 m.add(row_idcs, col_idcs, tmp);
99}
PetscInt getNumberOfColumns() const
Get the number of columns.
Definition PETScMatrix.h:76
void add(const PetscInt i, const PetscInt j, const PetscScalar value)
Add value to a single entry.
PetscInt getNumberOfRows() const
Get the number of rows.
Definition PETScMatrix.h:74

References MathLib::PETScMatrix::add(), MathLib::PETScMatrix::getNumberOfColumns(), MathLib::PETScMatrix::getNumberOfRows(), and r.

Referenced by setMatrix().

◆ applyKnownSolution() [1/2]

void MathLib::applyKnownSolution ( EigenMatrix & A,
EigenVector & b,
EigenVector & ,
const std::vector< EigenMatrix::IndexType > & vec_knownX_id,
const std::vector< double > & vec_knownX_x )

apply known solutions to a system of linear equations

Parameters
ACoefficient matrix
bRHS vector
vec_knownX_ida vector of known solution entry IDs
vec_knownX_xa vector of known solutions

Definition at line 17 of file EigenTools.cpp.

21{
22 using SpMat = EigenMatrix::RawMatrixType;
23 static_assert(SpMat::IsRowMajor, "matrix is assumed to be row major!");
24
25 auto& A_eigen = A.getRawMatrix();
26 auto& b_eigen = b.getRawVector();
27
28 // A_eigen(k, j) = 0.
29 // set row to zero
30 for (auto row_id : vec_knownX_id)
31 {
32 for (SpMat::InnerIterator it(A_eigen, row_id); it; ++it)
33 {
34 if (it.col() != decltype(it.col())(row_id))
35 {
36 it.valueRef() = 0.0;
37 }
38 }
39 }
40
41 SpMat AT = A_eigen.transpose();
42
43 // Reserve space for at least one value (on the diagonal). For deactivated
44 // subdomains some rows and columns might end empty (in the A matrix) and so
45 // no space is reserved for the Dirichlet conditions in the transposed
46 // matrix. Then the coeffRef call will do costly reallocations.
47 AT.reserve(Eigen::VectorXi::Constant(A_eigen.rows(), 1));
48
49 for (std::size_t ix = 0; ix < vec_knownX_id.size(); ix++)
50 {
51 SpMat::Index const row_id = vec_knownX_id[ix];
52 auto const x = vec_knownX_x[ix];
53
54 // b_i -= A_eigen(i,k)*val, i!=k
55 // set column to zero, subtract from rhs
56 for (SpMat::InnerIterator it(AT, row_id); it; ++it)
57 {
58 if (it.col() == row_id)
59 {
60 continue;
61 }
62
63 b_eigen[it.col()] -= it.value() * x;
64 it.valueRef() = 0.0;
65 }
66
67 auto& c = AT.coeffRef(row_id, row_id);
68 if (c != 0.0)
69 {
70 b_eigen[row_id] = x * c;
71 }
72 else
73 {
74 b_eigen[row_id] = x;
75 c = 1.0;
76 }
77 }
78
79 A_eigen = AT.transpose();
80}
Eigen::SparseMatrix< double, Eigen::RowMajor > RawMatrixType
Definition EigenMatrix.h:31
RawMatrixType & getRawMatrix()
RawVectorType & getRawVector()
return a raw Eigen vector object

References MathLib::EigenMatrix::getRawMatrix(), and MathLib::EigenVector::getRawVector().

Referenced by NumLib::TimeDiscretizedODESystem< ODESystemTag::FirstOrderImplicitQuasilinear, NonlinearSolverTag::Newton >::applyKnownSolutionsNewton(), NumLib::TimeDiscretizedODESystem< ODESystemTag::FirstOrderImplicitQuasilinear, NonlinearSolverTag::Newton >::applyKnownSolutionsPETScSNES(), and NumLib::TimeDiscretizedODESystem< ODESystemTag::FirstOrderImplicitQuasilinear, NonlinearSolverTag::Picard >::applyKnownSolutionsPicard().

◆ applyKnownSolution() [2/2]

void MathLib::applyKnownSolution ( PETScMatrix & A,
PETScVector & b,
PETScVector & x,
const std::vector< PetscInt > & vec_knownX_id,
const std::vector< PetscScalar > & vec_knownX_x )

apply known solutions to a system of linear equations

Parameters
ACoefficient matrix
bRHS vector
xSolution vector
vec_knownX_idA vector of known solution entry IDs
vec_knownX_xA vector of known solutions

Definition at line 21 of file PETScTools.cpp.

24{
26
27#ifndef NDEBUG
28 if (std::any_of(vec_knownX_id.begin(), vec_knownX_id.end(),
29 [](PetscInt const i) { return i < 0; }))
30 {
32 "Found negative indices in the vector of Dirichlet boundary "
33 "conditions.");
34 }
35#endif // NDEBUG
36
37 A.setRowsColumnsZero(vec_knownX_id);
39
42 if (vec_knownX_id.size() > 0)
43 {
44 x.set(vec_knownX_id, vec_knownX_x);
45 b.set(vec_knownX_id, vec_knownX_x);
46 }
47
50}
#define OGS_FATAL(...)
Definition Error.h:26
void finalizeAssembly(const MatAssemblyType asm_type=MAT_FINAL_ASSEMBLY)
Perform MPI collection of assembled entries in buffer.
Definition PETScMatrix.h:67
void setRowsColumnsZero(std::vector< PetscInt > const &row_pos)
Set the specified rows to zero except diagonal entries, i.e. , where This function must be called...
void finalizeAssembly()
Perform MPI collection of assembled entries in buffer.
void set(const PetscInt i, const PetscScalar value)

References MathLib::PETScMatrix::finalizeAssembly(), MathLib::PETScVector::finalizeAssembly(), OGS_FATAL, MathLib::PETScVector::set(), and MathLib::PETScMatrix::setRowsColumnsZero().

◆ barycentricPointInTriangle()

bool MathLib::barycentricPointInTriangle ( MathLib::Point3d const & p,
MathLib::Point3d const & a,
MathLib::Point3d const & b,
MathLib::Point3d const & c,
double eps_pnt_out_of_plane = std::numeric_limits< float >::epsilon(),
double eps_pnt_out_of_tri = std::numeric_limits< float >::epsilon() )

Tests if the given point p is within the triangle, defined by its edge nodes a, b and c. Using two eps-values it is possible to test an 'epsilon' neighbourhood around the triangle as well as an 'epsilon' outside the triangles plane. Algorithm based on "Fundamentals of Computer Graphics" by Peter Shirley.

Parameters
ptest point
aedge node of triangle
bedge node of triangle
cedge node of triangle
eps_pnt_out_of_planeeps allowing for p to be slightly off the plane spanned by abc
eps_pnt_out_of_trieps allowing for p to be slightly off outside of abc
Returns
true if the test point p is within the 'epsilon'-neighbourhood of the triangle

Definition at line 148 of file GeometricBasics.cpp.

154{
155 if (std::abs(MathLib::orientation3d(p, a, b, c)) > eps_pnt_out_of_plane)
156 {
157 return false;
158 }
159
160 auto const& vp = p.asEigenVector3d();
161 Eigen::Vector3d const& pa = a.asEigenVector3d() - vp;
162 Eigen::Vector3d const& pb = b.asEigenVector3d() - vp;
163 Eigen::Vector3d const& pc = c.asEigenVector3d() - vp;
164 double const area_x_2(calcTriangleArea(a, b, c) * 2);
165
166 double const alpha((pb.cross(pc).norm()) / area_x_2);
167 if (alpha < -eps_pnt_out_of_tri || alpha > 1 + eps_pnt_out_of_tri)
168 {
169 return false;
170 }
171 double const beta((pc.cross(pa).norm()) / area_x_2);
172 if (beta < -eps_pnt_out_of_tri || beta > 1 + eps_pnt_out_of_tri)
173 {
174 return false;
175 }
176 double const gamma(1 - alpha - beta);
177 return !(gamma < -eps_pnt_out_of_tri || gamma > 1 + eps_pnt_out_of_tri);
178}
double orientation3d(MathLib::Point3d const &p, MathLib::Point3d const &a, MathLib::Point3d const &b, MathLib::Point3d const &c)

References MathLib::Point3d::asEigenVector3d(), calcTriangleArea(), orientation3d(), and p.

Referenced by isPointInTriangle().

◆ calcProjPntToLineAndDists()

double MathLib::calcProjPntToLineAndDists ( MathLib::Point3d const & pp,
MathLib::Point3d const & pa,
MathLib::Point3d const & pb,
double & lambda,
double & d0 )

calcProjPntToLineAndDists computes the orthogonal projection of a point p to the line described by the points a and b, \(g(\lambda) = a + \lambda (b - a)\), the distance between p and the projected point and the distances between the projected point and the end points pa, pb of the line

Parameters
ppthe (mesh) point
pafirst point of line
pbsecond point of line
lambdathe projected point described by the line equation above
d0distance of the projected point to line point a
Returns
the distance between pp and the orthogonal projection of pp

Definition at line 19 of file MathTools.cpp.

21{
22 auto const& a = pa.asEigenVector3d();
23 auto const& b = pb.asEigenVector3d();
24 auto const& p = pp.asEigenVector3d();
25
26 // g(lambda) = a + lambda v, v = b-a
27 Eigen::Vector3d const v = b - a;
28
29 // orthogonal projection: (p - g(lambda))^T * v = 0
30 // <=> (a-p - lambda (b-a))^T * (b-a) = 0
31 // <=> (a-p)^T * (b-a) = lambda (b-a)^T ) (b-a)
32 lambda = (((p - a).transpose() * v) / v.squaredNorm())(0, 0);
33
34 // compute projected point
35 Eigen::Vector3d const proj_pnt = a + lambda * v;
36
37 d0 = (proj_pnt - a).norm();
38
39 return (p - proj_pnt).norm();
40}

References MathLib::Point3d::asEigenVector3d(), p, and v.

Referenced by GeoLib::Polyline::getDistanceAlongPolyline(), and MeshLib::LineRule::isPntInElement().

◆ calcTetrahedronVolume()

double MathLib::calcTetrahedronVolume ( MathLib::Point3d const & a,
MathLib::Point3d const & b,
MathLib::Point3d const & c,
MathLib::Point3d const & d )

Calculates the volume of a tetrahedron. The formula is V=1/6*|a(b x c)| with a=x1->x2, b=x1->x3 and c=x1->x4.

Definition at line 30 of file GeometricBasics.cpp.

34{
35 Eigen::Vector3d const w = b.asEigenVector3d() - a.asEigenVector3d();
36 Eigen::Vector3d const u = c.asEigenVector3d() - a.asEigenVector3d();
37 Eigen::Vector3d const v = d.asEigenVector3d() - a.asEigenVector3d();
38 return std::abs(u.cross(v).dot(w)) / 6.0;
39}

References MathLib::Point3d::asEigenVector3d(), u, and v.

Referenced by MeshLib::HexRule::computeVolume(), MeshLib::PrismRule::computeVolume(), MeshLib::PyramidRule::computeVolume(), and MeshLib::TetRule::computeVolume().

◆ calcTriangleArea()

double MathLib::calcTriangleArea ( MathLib::Point3d const & a,
MathLib::Point3d const & b,
MathLib::Point3d const & c )

Calculates the area of the triangle defined by its edge nodes a, b and c. The formula is \(A= \frac{1}{2} \cdot |u \times v|\), i.e. half of the area of the parallelogram specified by the vectors \(u=b-a\) and \(v=c-a\).

Definition at line 41 of file GeometricBasics.cpp.

43{
44 Eigen::Vector3d const u = c.asEigenVector3d() - a.asEigenVector3d();
45 Eigen::Vector3d const v = b.asEigenVector3d() - a.asEigenVector3d();
46 Eigen::Vector3d const w = u.cross(v);
47 return 0.5 * w.norm();
48}

References MathLib::Point3d::asEigenVector3d(), u, and v.

Referenced by barycentricPointInTriangle(), MeshLib::QuadRule::computeVolume(), MeshLib::TriRule::computeVolume(), and GeoLib::IO::TINInterface::readTIN().

◆ checkLisError()

bool MathLib::checkLisError ( int err)
inline

check Lis error codes

Parameters
errLis error code
Returns
success or not

Definition at line 31 of file LisCheck.h.

32{
33 bool ok = (err == LIS_SUCCESS);
34 if (!ok)
35 {
36 ERR("***ERROR: Lis error code = {:d}", err);
37 }
38 return ok;
39}
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:45

References ERR().

Referenced by MathLib::LisMatrix::LisMatrix(), MathLib::LisMatrix::LisMatrix(), MathLib::LisMatrix::~LisMatrix(), MathLib::SetMatrixSparsity< LisMatrix, SPARSITY_PATTERN >::operator()(), MathLib::LisMatrix::setZero(), MathLib::LisVector::size(), and MathLib::EigenLisLinearSolver::solve().

◆ convertStringToVecNormType()

VecNormType MathLib::convertStringToVecNormType ( const std::string & str)

convert string to VecNormType

Definition at line 32 of file LinAlgEnums.cpp.

33{
34 if (str == "NORM1")
35 {
36 return VecNormType::NORM1;
37 }
38 if (str == "NORM2")
39 {
40 return VecNormType::NORM2;
41 }
42 if (str == "INFINITY_N")
43 {
44 return VecNormType::INFINITY_N;
45 }
46 return VecNormType::INVALID;
47}

References INFINITY_N, INVALID, NORM1, and NORM2.

Referenced by NumLib::createConvergenceCriterionDeltaX(), NumLib::createConvergenceCriterionPerComponentDeltaX(), NumLib::createConvergenceCriterionPerComponentResidual(), and NumLib::createConvergenceCriterionResidual().

◆ convertVecNormTypeToString()

std::string MathLib::convertVecNormTypeToString ( VecNormType normType)

convert VecNormType to string

Definition at line 17 of file LinAlgEnums.cpp.

18{
19 switch (normType)
20 {
21 case VecNormType::NORM1:
22 return "NORM1";
23 case VecNormType::NORM2:
24 return "NORM2";
25 case VecNormType::INFINITY_N:
26 return "INFINITY_N";
27 default:
28 return "INVALID";
29 }
30}

References INFINITY_N, NORM1, and NORM2.

◆ createPiecewiseLinearCurve()

template<typename CurveType >
std::unique_ptr< CurveType > MathLib::createPiecewiseLinearCurve ( BaseLib::ConfigTree const & config)

Create a curve

Parameters
configConfigTree object has a tag of <curve>

Definition at line 40 of file CreatePiecewiseLinearCurve.h.

42{
43 auto [xs, ys] = parsePiecewiseLinearCurveConfig(config);
44 return std::make_unique<CurveType>(std::move(xs), std::move(ys));
45}
PiecewiseLinearCurveConfig parsePiecewiseLinearCurveConfig(BaseLib::ConfigTree const &config)

References parsePiecewiseLinearCurveConfig().

Referenced by MaterialLib::PorousMedium::createCapillaryPressureModel(), MaterialLib::PorousMedium::createRelativePermeabilityModel(), and ProjectData::parseCurves().

◆ createZeroedMatrix() [1/2]

template<typename Matrix >
Eigen::Map< Matrix > MathLib::createZeroedMatrix ( std::vector< double > & data,
Eigen::MatrixXd::Index rows,
Eigen::MatrixXd::Index cols )

Creates an Eigen mapped matrix having its entries stored in the given data vector.

Returns
An Eigen mapped matrix of the given size. All values of the matrix are set to zero.
Precondition
The passed data vector must have zero size.
Postcondition
The data has size rows * cols.
Note
The data vector will have the same storage order (row or column major) as the requested matrix type.

Definition at line 32 of file EigenMapTools.h.

35{
36 static_assert(Matrix::IsRowMajor || Matrix::IsVectorAtCompileTime,
37 "The default storage order in OGS is row major storage for "
38 "dense matrices.");
39 assert(Matrix::RowsAtCompileTime == Eigen::Dynamic ||
40 Matrix::RowsAtCompileTime == rows);
41 assert(Matrix::ColsAtCompileTime == Eigen::Dynamic ||
42 Matrix::ColsAtCompileTime == cols);
43 assert(data.empty()); // in order that resize fills the vector with zeros.
44
45 data.resize(rows * cols);
46 return {data.data(), rows, cols};
47}

Referenced by ProcessLib::ThermoRichardsMechanics::ThermoRichardsMechanicsLocalAssembler< ShapeFunctionDisplacement, ShapeFunction, DisplacementDim, ConstitutiveTraits >::addToLocalMatrixData(), ProcessLib::ComponentTransport::LocalAssemblerData< ShapeFunction, GlobalDim >::assemble(), ProcessLib::HeatConduction::LocalAssemblerData< ShapeFunction, GlobalDim >::assemble(), ProcessLib::HeatTransportBHE::HeatTransportBHELocalAssemblerBHE< ShapeFunction, BHEType >::assemble(), ProcessLib::HeatTransportBHE::HeatTransportBHELocalAssemblerSoil< ShapeFunction >::assemble(), ProcessLib::HT::MonolithicHTFEM< ShapeFunction, GlobalDim >::assemble(), ProcessLib::RichardsComponentTransport::LocalAssemblerData< ShapeFunction, GlobalDim >::assemble(), ProcessLib::RichardsFlow::LocalAssemblerData< ShapeFunction, GlobalDim >::assemble(), ProcessLib::RichardsMechanics::RichardsMechanicsLocalAssembler< ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim >::assemble(), ProcessLib::SteadyStateDiffusion::LocalAssemblerData< ShapeFunction, GlobalDim >::assemble(), ProcessLib::StokesFlow::LocalAssemblerData< ShapeFunctionLiquidVelocity, ShapeFunctionPressure, GlobalDim >::assemble(), ProcessLib::TES::TESLocalAssembler< ShapeFunction_, GlobalDim >::assemble(), ProcessLib::TH2M::TH2MLocalAssembler< ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim >::assemble(), ProcessLib::ThermalTwoPhaseFlowWithPP::ThermalTwoPhaseFlowWithPPLocalAssembler< ShapeFunction, GlobalDim >::assemble(), ProcessLib::ThermoRichardsFlow::ThermoRichardsFlowLocalAssembler< ShapeFunction, GlobalDim >::assemble(), ProcessLib::TwoPhaseFlowWithPP::TwoPhaseFlowWithPPLocalAssembler< ShapeFunction, GlobalDim >::assemble(), ProcessLib::TwoPhaseFlowWithPrho::TwoPhaseFlowWithPrhoLocalAssembler< ShapeFunction, GlobalDim >::assemble(), ProcessLib::WellboreSimulator::WellboreSimulatorFEM< ShapeFunction, GlobalDim >::assemble(), ProcessLib::ComponentTransport::LocalAssemblerData< ShapeFunction, GlobalDim >::assembleComponentTransportEquation(), ProcessLib::ComponentTransport::LocalAssemblerData< ShapeFunction, GlobalDim >::assembleHeatTransportEquation(), ProcessLib::HT::StaggeredHTFEM< ShapeFunction, GlobalDim >::assembleHeatTransportEquation(), ProcessLib::ComponentTransport::LocalAssemblerData< ShapeFunction, GlobalDim >::assembleHydraulicEquation(), ProcessLib::HT::StaggeredHTFEM< ShapeFunction, GlobalDim >::assembleHydraulicEquation(), ProcessLib::LiquidFlow::LiquidFlowLocalAssembler< ShapeFunction, GlobalDim >::assembleMatrixAndVector(), ProcessLib::ComponentTransport::LocalAssemblerData< ShapeFunction, GlobalDim >::assembleReactionEquationConcrete(), ProcessLib::CentralDifferencesJacobianAssembler::assembleWithJacobian(), ProcessLib::ForwardDifferencesJacobianAssembler::assembleWithJacobian(), ProcessLib::HeatConduction::LocalAssemblerData< ShapeFunction, GlobalDim >::assembleWithJacobian(), ProcessLib::HeatTransportBHE::HeatTransportBHELocalAssemblerBHE< ShapeFunction, BHEType >::assembleWithJacobian(), ProcessLib::HeatTransportBHE::HeatTransportBHELocalAssemblerSoil< ShapeFunction >::assembleWithJacobian(), ProcessLib::HydroMechanics::HydroMechanicsLocalAssembler< ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim >::assembleWithJacobian(), ProcessLib::LargeDeformation::LargeDeformationLocalAssembler< ShapeFunction, DisplacementDim >::assembleWithJacobian(), ProcessLib::LIE::SmallDeformation::SmallDeformationLocalAssemblerMatrix< ShapeFunction, DisplacementDim >::assembleWithJacobian(), ProcessLib::RichardsMechanics::RichardsMechanicsLocalAssembler< ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim >::assembleWithJacobian(), ProcessLib::SmallDeformation::SmallDeformationLocalAssembler< ShapeFunction, DisplacementDim >::assembleWithJacobian(), ProcessLib::SmallDeformationNonlocal::SmallDeformationNonlocalLocalAssembler< ShapeFunction, DisplacementDim >::assembleWithJacobian(), ProcessLib::TH2M::TH2MLocalAssembler< ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim >::assembleWithJacobian(), ProcessLib::ThermoHydroMechanics::ThermoHydroMechanicsLocalAssembler< ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim >::assembleWithJacobian(), ProcessLib::ThermoMechanics::ThermoMechanicsLocalAssembler< ShapeFunction, DisplacementDim >::assembleWithJacobian(), ProcessLib::ThermoRichardsFlow::ThermoRichardsFlowLocalAssembler< ShapeFunction, GlobalDim >::assembleWithJacobian(), ProcessLib::ComponentTransport::LocalAssemblerData< ShapeFunction, GlobalDim >::assembleWithJacobianComponentTransportEquation(), ProcessLib::HydroMechanics::HydroMechanicsLocalAssembler< ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim >::assembleWithJacobianForDeformationEquations(), ProcessLib::PhaseField::PhaseFieldLocalAssembler< ShapeFunction, DisplacementDim >::assembleWithJacobianForDeformationEquations(), ProcessLib::ThermoMechanicalPhaseField::ThermoMechanicalPhaseFieldLocalAssembler< ShapeFunction, DisplacementDim >::assembleWithJacobianForDeformationEquations(), ProcessLib::ThermoMechanics::ThermoMechanicsLocalAssembler< ShapeFunction, DisplacementDim >::assembleWithJacobianForDeformationEquations(), ProcessLib::ThermoMechanicalPhaseField::ThermoMechanicalPhaseFieldLocalAssembler< ShapeFunction, DisplacementDim >::assembleWithJacobianForHeatConductionEquations(), ProcessLib::ThermoMechanics::ThermoMechanicsLocalAssembler< ShapeFunction, DisplacementDim >::assembleWithJacobianForHeatConductionEquations(), ProcessLib::ThermoMechanicalPhaseField::ThermoMechanicalPhaseFieldLocalAssembler< ShapeFunction, DisplacementDim >::assembleWithJacobianForPhaseFieldEquations(), ProcessLib::HydroMechanics::HydroMechanicsLocalAssembler< ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim >::assembleWithJacobianForPressureEquations(), ProcessLib::ComponentTransport::LocalAssemblerData< ShapeFunction, GlobalDim >::assembleWithJacobianHydraulicEquation(), ProcessLib::PhaseField::PhaseFieldLocalAssembler< ShapeFunction, DisplacementDim >::assembleWithJacobianPhaseFieldEquations(), ProcessLib::ComponentTransport::LocalAssemblerData< ShapeFunction, GlobalDim >::calculateIntPtDarcyVelocity(), createZeroedMatrix(), ProcessLib::HydroMechanics::HydroMechanicsLocalAssembler< ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim >::getEpsilon(), ProcessLib::PhaseField::PhaseFieldLocalAssembler< ShapeFunction, DisplacementDim >::getEpsilon(), ProcessLib::getIntegrationPointDimMatrixData(), ProcessLib::getIntegrationPointKelvinVectorData(), ProcessLib::getIntegrationPointScalarData(), ProcessLib::HydroMechanics::HydroMechanicsLocalAssembler< ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim >::getIntPtDarcyVelocity(), ProcessLib::LIE::HydroMechanics::HydroMechanicsLocalAssemblerMatrix< ShapeFunctionDisplacement, ShapeFunctionPressure, GlobalDim >::getIntPtDarcyVelocity(), ProcessLib::LiquidFlow::LiquidFlowLocalAssembler< ShapeFunction, GlobalDim >::getIntPtDarcyVelocity(), ProcessLib::RichardsComponentTransport::LocalAssemblerData< ShapeFunction, GlobalDim >::getIntPtDarcyVelocity(), ProcessLib::RichardsFlow::LocalAssemblerData< ShapeFunction, GlobalDim >::getIntPtDarcyVelocity(), ProcessLib::SteadyStateDiffusion::LocalAssemblerData< ShapeFunction, GlobalDim >::getIntPtDarcyVelocity(), ProcessLib::TES::TESLocalAssembler< ShapeFunction_, GlobalDim >::getIntPtDarcyVelocity(), ProcessLib::ThermoHydroMechanics::ThermoHydroMechanicsLocalAssembler< ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim >::getIntPtDarcyVelocity(), ProcessLib::ThermoRichardsFlow::ThermoRichardsFlowLocalAssembler< ShapeFunction, GlobalDim >::getIntPtDarcyVelocity(), ProcessLib::HT::HTFEM< ShapeFunction, GlobalDim >::getIntPtDarcyVelocityLocal(), ProcessLib::LIE::HydroMechanics::HydroMechanicsLocalAssemblerFracture< ShapeFunctionDisplacement, ShapeFunctionPressure, GlobalDim >::getIntPtFractureStress(), ProcessLib::LIE::SmallDeformation::SmallDeformationLocalAssemblerFracture< ShapeFunction, DisplacementDim >::getIntPtFractureStress(), ProcessLib::LIE::HydroMechanics::HydroMechanicsLocalAssemblerFracture< ShapeFunctionDisplacement, ShapeFunctionPressure, GlobalDim >::getIntPtFractureVelocity(), ProcessLib::HeatConduction::LocalAssemblerData< ShapeFunction, GlobalDim >::getIntPtHeatFlux(), ProcessLib::ThermoMechanicalPhaseField::ThermoMechanicalPhaseFieldLocalAssembler< ShapeFunction, DisplacementDim >::getIntPtHeatFlux(), ProcessLib::ComponentTransport::LocalAssemblerData< ShapeFunction, GlobalDim >::getIntPtMolarFlux(), and ProcessLib::Deformation::CollectIntegrationPointDataForExtrapolation< InternalVariable >::operator()().

◆ createZeroedMatrix() [2/2]

Eigen::Map< Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > > MathLib::createZeroedMatrix ( std::vector< double > & data,
Eigen::MatrixXd::Index rows,
Eigen::MatrixXd::Index cols )
inline

Creates an Eigen mapped matrix having its entries stored in the given data vector.

This is a convenience method which makes the specification of dynamically allocated Eigen matrices as return type easier.

Definition at line 57 of file EigenMapTools.h.

60{
61 return createZeroedMatrix<
62 Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>>(
63 data, rows, cols);
64}
Eigen::Map< Matrix > createZeroedMatrix(std::vector< double > &data, Eigen::MatrixXd::Index rows, Eigen::MatrixXd::Index cols)

References createZeroedMatrix().

◆ createZeroedVector()

template<typename Vector >
Eigen::Map< Vector > MathLib::createZeroedVector ( std::vector< double > & data,
Eigen::VectorXd::Index size )

Creates an Eigen mapped vector having its entries stored in the given data vector.

Returns
An Eigen mapped vector of the given size. All values of the vector are set to zero.
Precondition
The passed data vector must have zero size.
Postcondition
The data has size size.

Definition at line 153 of file EigenMapTools.h.

155{
156 static_assert(Vector::IsVectorAtCompileTime, "A vector type is required.");
157 assert(Vector::SizeAtCompileTime == Eigen::Dynamic ||
158 Vector::SizeAtCompileTime == size);
159 assert(data.empty()); // in order that resize fills the vector with zeros.
160
161 data.resize(size);
162 return {data.data(), size};
163}

Referenced by ProcessLib::ThermoRichardsMechanics::ThermoRichardsMechanicsLocalAssembler< ShapeFunctionDisplacement, ShapeFunction, DisplacementDim, ConstitutiveTraits >::addToLocalMatrixData(), ProcessLib::ComponentTransport::LocalAssemblerData< ShapeFunction, GlobalDim >::assemble(), ProcessLib::HT::MonolithicHTFEM< ShapeFunction, GlobalDim >::assemble(), ProcessLib::RichardsComponentTransport::LocalAssemblerData< ShapeFunction, GlobalDim >::assemble(), ProcessLib::RichardsFlow::LocalAssemblerData< ShapeFunction, GlobalDim >::assemble(), ProcessLib::RichardsMechanics::RichardsMechanicsLocalAssembler< ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim >::assemble(), ProcessLib::StokesFlow::LocalAssemblerData< ShapeFunctionLiquidVelocity, ShapeFunctionPressure, GlobalDim >::assemble(), ProcessLib::TES::TESLocalAssembler< ShapeFunction_, GlobalDim >::assemble(), ProcessLib::TH2M::TH2MLocalAssembler< ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim >::assemble(), ProcessLib::ThermalTwoPhaseFlowWithPP::ThermalTwoPhaseFlowWithPPLocalAssembler< ShapeFunction, GlobalDim >::assemble(), ProcessLib::ThermoRichardsFlow::ThermoRichardsFlowLocalAssembler< ShapeFunction, GlobalDim >::assemble(), ProcessLib::TwoPhaseFlowWithPP::TwoPhaseFlowWithPPLocalAssembler< ShapeFunction, GlobalDim >::assemble(), ProcessLib::TwoPhaseFlowWithPrho::TwoPhaseFlowWithPrhoLocalAssembler< ShapeFunction, GlobalDim >::assemble(), ProcessLib::WellboreSimulator::WellboreSimulatorFEM< ShapeFunction, GlobalDim >::assemble(), ProcessLib::ComponentTransport::LocalAssemblerData< ShapeFunction, GlobalDim >::assembleHydraulicEquation(), ProcessLib::HT::StaggeredHTFEM< ShapeFunction, GlobalDim >::assembleHydraulicEquation(), ProcessLib::LiquidFlow::LiquidFlowLocalAssembler< ShapeFunction, GlobalDim >::assembleMatrixAndVector(), ProcessLib::ComponentTransport::LocalAssemblerData< ShapeFunction, GlobalDim >::assembleReactionEquationConcrete(), ProcessLib::CentralDifferencesJacobianAssembler::assembleWithJacobian(), ProcessLib::ForwardDifferencesJacobianAssembler::assembleWithJacobian(), ProcessLib::HeatConduction::LocalAssemblerData< ShapeFunction, GlobalDim >::assembleWithJacobian(), ProcessLib::HeatTransportBHE::HeatTransportBHELocalAssemblerBHE< ShapeFunction, BHEType >::assembleWithJacobian(), ProcessLib::HeatTransportBHE::HeatTransportBHELocalAssemblerSoil< ShapeFunction >::assembleWithJacobian(), ProcessLib::HydroMechanics::HydroMechanicsLocalAssembler< ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim >::assembleWithJacobian(), ProcessLib::LargeDeformation::LargeDeformationLocalAssembler< ShapeFunction, DisplacementDim >::assembleWithJacobian(), ProcessLib::LIE::SmallDeformation::SmallDeformationLocalAssemblerMatrix< ShapeFunction, DisplacementDim >::assembleWithJacobian(), ProcessLib::RichardsMechanics::RichardsMechanicsLocalAssembler< ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim >::assembleWithJacobian(), ProcessLib::SmallDeformation::SmallDeformationLocalAssembler< ShapeFunction, DisplacementDim >::assembleWithJacobian(), ProcessLib::SmallDeformationNonlocal::SmallDeformationNonlocalLocalAssembler< ShapeFunction, DisplacementDim >::assembleWithJacobian(), ProcessLib::TH2M::TH2MLocalAssembler< ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim >::assembleWithJacobian(), ProcessLib::ThermoHydroMechanics::ThermoHydroMechanicsLocalAssembler< ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim >::assembleWithJacobian(), ProcessLib::ThermoMechanics::ThermoMechanicsLocalAssembler< ShapeFunction, DisplacementDim >::assembleWithJacobian(), ProcessLib::ThermoRichardsFlow::ThermoRichardsFlowLocalAssembler< ShapeFunction, GlobalDim >::assembleWithJacobian(), ProcessLib::ComponentTransport::LocalAssemblerData< ShapeFunction, GlobalDim >::assembleWithJacobianComponentTransportEquation(), ProcessLib::HydroMechanics::HydroMechanicsLocalAssembler< ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim >::assembleWithJacobianForDeformationEquations(), ProcessLib::PhaseField::PhaseFieldLocalAssembler< ShapeFunction, DisplacementDim >::assembleWithJacobianForDeformationEquations(), ProcessLib::ThermoMechanicalPhaseField::ThermoMechanicalPhaseFieldLocalAssembler< ShapeFunction, DisplacementDim >::assembleWithJacobianForDeformationEquations(), ProcessLib::ThermoMechanics::ThermoMechanicsLocalAssembler< ShapeFunction, DisplacementDim >::assembleWithJacobianForDeformationEquations(), ProcessLib::ThermoMechanicalPhaseField::ThermoMechanicalPhaseFieldLocalAssembler< ShapeFunction, DisplacementDim >::assembleWithJacobianForHeatConductionEquations(), ProcessLib::ThermoMechanics::ThermoMechanicsLocalAssembler< ShapeFunction, DisplacementDim >::assembleWithJacobianForHeatConductionEquations(), ProcessLib::ThermoMechanicalPhaseField::ThermoMechanicalPhaseFieldLocalAssembler< ShapeFunction, DisplacementDim >::assembleWithJacobianForPhaseFieldEquations(), ProcessLib::HydroMechanics::HydroMechanicsLocalAssembler< ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim >::assembleWithJacobianForPressureEquations(), ProcessLib::ComponentTransport::LocalAssemblerData< ShapeFunction, GlobalDim >::assembleWithJacobianHydraulicEquation(), ProcessLib::PhaseField::PhaseFieldLocalAssembler< ShapeFunction, DisplacementDim >::assembleWithJacobianPhaseFieldEquations(), ProcessLib::RichardsComponentTransport::LocalAssemblerData< ShapeFunction, GlobalDim >::getIntPtSaturation(), ProcessLib::SmallDeformation::getMaterialForces(), and ProcessLib::SmallDeformationNonlocal::SmallDeformationNonlocalLocalAssembler< ShapeFunction, DisplacementDim >::getNodalValues().

◆ dividedByPlane()

bool MathLib::dividedByPlane ( const MathLib::Point3d & a,
const MathLib::Point3d & b,
const MathLib::Point3d & c,
const MathLib::Point3d & d )

Checks if a and b can be placed on a plane such that c and d lie on different sides of said plane. (In 2D space this checks if c and d are on different sides of a line through a and b.)

Parameters
afirst point on plane
bsecond point on plane
cfirst point to test
dsecond point to test
Returns
true, if such a plane can be found, false otherwise

Definition at line 200 of file GeometricBasics.cpp.

202{
203 for (unsigned x = 0; x < 3; ++x)
204 {
205 const unsigned y = (x + 1) % 3;
206 const double abc =
207 (b[x] - a[x]) * (c[y] - a[y]) - (b[y] - a[y]) * (c[x] - a[x]);
208 const double abd =
209 (b[x] - a[x]) * (d[y] - a[y]) - (b[y] - a[y]) * (d[x] - a[x]);
210
211 if ((abc > 0 && abd < 0) || (abc < 0 && abd > 0))
212 {
213 return true;
214 }
215 }
216 return false;
217}

Referenced by MeshLib::QuadRule::validate().

◆ eigenBlockMatrixView()

template<int D, typename M >
Eigen::CwiseNullaryOp< EigenBlockMatrixViewFunctor< D, M >, typename EigenBlockMatrixViewFunctor< D, M >::Matrix > MathLib::eigenBlockMatrixView ( const Eigen::MatrixBase< M > & matrix)
constexpr

Definition at line 49 of file EigenBlockMatrixView.h.

50{
51 using Matrix = typename EigenBlockMatrixViewFunctor<D, M>::Matrix;
52 return Matrix::NullaryExpr(
53 D * matrix.rows(), D * matrix.cols(),
54 EigenBlockMatrixViewFunctor<D, M>(matrix.derived()));
55}
Eigen::Matrix< Scalar, rows, cols, Eigen::ColMajor > Matrix

Referenced by ProcessLib::LargeDeformation::computeSigmaGeom().

◆ finalizeMatrixAssembly() [1/3]

bool MathLib::finalizeMatrixAssembly ( LisMatrix & mat)

finish assembly to make this matrix be ready for use

Definition at line 123 of file LisMatrix.cpp.

124{
125 LIS_MATRIX& A = mat.getRawMatrix();
126
127 if (!mat.isAssembled())
128 {
129 int ierr =
130 lis_matrix_set_type(A, static_cast<int>(mat.getMatrixType()));
131 checkLisError(ierr);
132 ierr = lis_matrix_assemble(A);
133 checkLisError(ierr);
134 mat.is_assembled_ = true;
135 }
136 return true;
137}
MatrixType getMatrixType() const
get this matrix type
Definition LisMatrix.h:141
LIS_MATRIX & getRawMatrix()
return a raw Lis matrix object
Definition LisMatrix.h:114
bool isAssembled() const
return if this matrix is already assembled or not
Definition LisMatrix.h:144
bool checkLisError(int err)
Definition LisCheck.h:31

◆ finalizeMatrixAssembly() [2/3]

◆ finalizeMatrixAssembly() [3/3]

bool MathLib::finalizeMatrixAssembly ( PETScMatrix & mat,
const MatAssemblyType asm_type = MAT_FINAL_ASSEMBLY )

General interface for the matrix assembly.

Parameters
matThe matrix to be finalized.
asm_typeAssembly type, either MAT_FLUSH_ASSEMBLY or MAT_FINAL_ASSEMBLY.

Definition at line 158 of file PETScMatrix.cpp.

159{
160 mat.finalizeAssembly(asm_type);
161 return true;
162}

◆ finalizeVectorAssembly() [1/2]

void MathLib::finalizeVectorAssembly ( PETScVector & vec)

Function to finalize the vector assembly.

Definition at line 295 of file PETScVector.cpp.

296{
297 vec.finalizeAssembly();
298}

◆ finalizeVectorAssembly() [2/2]

template<typename VEC_T >
void MathLib::finalizeVectorAssembly ( VEC_T & )

◆ gaussPointInTriangle()

bool MathLib::gaussPointInTriangle ( MathLib::Point3d const & q,
MathLib::Point3d const & a,
MathLib::Point3d const & b,
MathLib::Point3d const & c,
double eps_pnt_out_of_plane = std::numeric_limits< float >::epsilon(),
double eps_pnt_out_of_tri = std::numeric_limits< float >::epsilon() )

Tests if the given point q is within the triangle, defined by its edge nodes a, b and c. Using two eps-values it is possible to test an 'epsilon' neighbourhood around the triangle as well as an 'epsilon' outside the triangles plane.

Parameters
qtest point
aedge node of triangle
bedge node of triangle
cedge node of triangle
eps_pnt_out_of_planeeps allowing for p to be slightly off the plane spanned by abc ((orthogonal distance to the plane spaned by triangle)
eps_pnt_out_of_trieps allowing for p to be slightly off outside of abc
Returns
true if the test point p is within the 'epsilon'-neighbourhood of the triangle

Definition at line 108 of file GeometricBasics.cpp.

114{
115 auto const& pa = a.asEigenVector3d();
116 Eigen::Vector3d const v = b.asEigenVector3d() - pa;
117 Eigen::Vector3d const w = c.asEigenVector3d() - pa;
118
119 Eigen::Matrix2d mat;
120 mat(0, 0) = v.squaredNorm();
121 mat(0, 1) = v[0] * w[0] + v[1] * w[1] + v[2] * w[2];
122 mat(1, 0) = mat(0, 1);
123 mat(1, 1) = w.squaredNorm();
124 Eigen::Vector2d y(
125 v[0] * (q[0] - a[0]) + v[1] * (q[1] - a[1]) + v[2] * (q[2] - a[2]),
126 w[0] * (q[0] - a[0]) + w[1] * (q[1] - a[1]) + w[2] * (q[2] - a[2]));
127
128 y = mat.partialPivLu().solve(y);
129
130 const double lower(eps_pnt_out_of_tri);
131 const double upper(1 + lower);
132
133 if (-lower <= y[0] && y[0] <= upper && -lower <= y[1] && y[1] <= upper &&
134 y[0] + y[1] <= upper)
135 {
136 MathLib::Point3d const q_projected(std::array<double, 3>{
137 {a[0] + y[0] * v[0] + y[1] * w[0], a[1] + y[0] * v[1] + y[1] * w[1],
138 a[2] + y[0] * v[2] + y[1] * w[2]}});
139 if (MathLib::sqrDist(q, q_projected) <= eps_pnt_out_of_plane)
140 {
141 return true;
142 }
143 }
144
145 return false;
146}
double sqrDist(MathLib::Point3d const &p0, MathLib::Point3d const &p1)
Definition Point3d.cpp:26

References MathLib::Point3d::asEigenVector3d(), q, sqrDist(), and v.

Referenced by isPointInTriangle().

◆ getAngle()

double MathLib::getAngle ( Point3d const & p0,
Point3d const & p1,
Point3d const & p2 )

Let \(p_0, p_1, p_2 \in R^3\). The function getAngle computes the angle between the edges \((p_0,p_1)\) and \((p_1,p_2)\)

Parameters
p0start point of edge 0
p1end point of edge 0 and start point of edge 1
p2end point of edge 1
Returns
the angle between the edges

Definition at line 42 of file MathTools.cpp.

43{
44 auto const& b = p1.asEigenVector3d();
45 Eigen::Vector3d const v0 = p0.asEigenVector3d() - b;
46 Eigen::Vector3d const v1 = p2.asEigenVector3d() - b;
47
48 // apply Cauchy Schwarz inequality
49 return std::acos(v0.dot(v1) / (v0.norm() * v1.norm()));
50}

References MathLib::Point3d::asEigenVector3d().

Referenced by MeshToolsLib::anonymous_namespace{AngleSkewMetric.cpp}::getMinMaxAngle().

◆ ignoreOtherLinearSolvers()

void MathLib::ignoreOtherLinearSolvers ( BaseLib::ConfigTree const & config,
std::string const & solver_name )

Ignore linear solver settings not needed for the selected one.

The project files support specifying linear solver options for all known solver libraries (currently PETSC, LIS, Eigen) even though for a specific build only one of those settings is used. That clearly conflicts with the requirement of the config tree that each setting present in the project file must be read exactly once.

The purpose of this function is to explicitly ignore all the settings that are not relevant for the currently used linear solver

Parameters
configThe config tree snippet for the linear solver.
solver_nameThe tag under which the relevant configuration is found. All other configurations will be ignored.

This function is currently used in the option parsing code of our EigenLinearSolver, LisOption and PETScLinearSolver

Definition at line 23 of file LinearSolverOptions.cpp.

25{
26 for (auto const& s : known_linear_solvers)
27 {
28 if (s != solver_name)
29 {
30 config.ignoreConfigParameter(s);
31 }
32 }
33}
static std::set< std::string > known_linear_solvers
void ignoreConfigParameter(std::string const &param) const

References BaseLib::ConfigTree::ignoreConfigParameter(), known_linear_solvers, and s.

Referenced by MathLib::LinearSolverOptionsParser< EigenLinearSolver >::parseNameAndOptions(), MathLib::LinearSolverOptionsParser< EigenLisLinearSolver >::parseNameAndOptions(), and MathLib::LinearSolverOptionsParser< PETScLinearSolver >::parseNameAndOptions().

◆ initGLTet3X()

static std::array< std::array< double, 3 >, GaussLegendreTet< 3 >::NPoints > MathLib::initGLTet3X ( )
static

Definition at line 31 of file GaussLegendreTet.cpp.

32{
33 // Cf. Gellert, M., Harbord, R., 1991. Moderate degree cubature formulas for
34 // 3-D tetrahedral finite-element approximations. Communications in Applied
35 // Numerical Methods 7, 487-495. doi:10.1002/cnm.1630070609
36 const double a = 0.0673422422100983;
37 const double b = 0.3108859192633005;
38 const double c = 0.7217942490673264;
39 const double d = 0.0927352503108912;
40 const double e = 0.4544962958743506;
41 const double f = 0.045503704125649;
42
43 return {{{{a, b, b}},
44 {{b, a, b}},
45 {{b, b, a}},
46 {{b, b, b}},
47 {{c, d, d}},
48 {{d, c, d}},
49 {{d, d, c}},
50 {{d, d, d}},
51 {{e, e, f}},
52 {{e, f, e}},
53 {{e, f, f}},
54 {{f, e, e}},
55 {{f, e, f}},
56 {{f, f, e}}}};
57}

◆ initGLTet4X()

static std::array< std::array< double, 3 >, GaussLegendreTet< 4 >::NPoints > MathLib::initGLTet4X ( )
static

Definition at line 70 of file GaussLegendreTet.cpp.

71{
72 // Cf. Gellert, M., Harbord, R., 1991. Moderate degree cubature formulas for
73 // 3-D tetrahedral finite-element approximations. Communications in Applied
74 // Numerical Methods 7, 487-495. doi:10.1002/cnm.1630070609
75 const double a = 0.3797582452067875;
76 const double b = 0.1202417547932126;
77
78 return {{{{0.0, 1. / 3, 1. / 3}},
79 {{1. / 3, 0.0, 1. / 3}},
80 {{1. / 3, 1. / 3, 0.0}},
81 {{1. / 3, 1. / 3, 1. / 3}},
82 {{8. / 11, 1. / 11, 1. / 11}},
83 {{1. / 11, 8. / 11, 1. / 11}},
84 {{1. / 11, 1. / 11, 8. / 11}},
85 {{1. / 11, 1. / 11, 1. / 11}},
86 {{0.0, 0.0, 0.5}},
87 {{0.0, 0.5, 0.0}},
88 {{0.0, 0.5, 0.5}},
89 {{0.5, 0.0, 0.0}},
90 {{0.5, 0.0, 0.5}},
91 {{0.5, 0.5, 0.0}},
92 {{a, a, b}},
93 {{a, b, a}},
94 {{a, b, b}},
95 {{b, a, a}},
96 {{b, a, b}},
97 {{b, b, a}}}};
98}

◆ isCoplanar()

bool MathLib::isCoplanar ( const MathLib::Point3d & a,
const MathLib::Point3d & b,
const MathLib::Point3d & c,
const MathLib::Point3d & d )

Checks if the four given points are located on a plane.

Definition at line 219 of file GeometricBasics.cpp.

221{
222 Eigen::Vector3d const ab = b.asEigenVector3d() - a.asEigenVector3d();
223 Eigen::Vector3d const ac = c.asEigenVector3d() - a.asEigenVector3d();
224 Eigen::Vector3d const ad = d.asEigenVector3d() - a.asEigenVector3d();
225
226 auto const eps_squared =
227 std::pow(std::numeric_limits<double>::epsilon(), 2);
228 if (ab.squaredNorm() < eps_squared || ac.squaredNorm() < eps_squared ||
229 ad.squaredNorm() < eps_squared)
230 {
231 return true;
232 }
233
234 // In exact arithmetic <ac*ad^T, ab> should be zero
235 // if all four points are coplanar.
236 const double sqr_scalar_triple(std::pow(ac.cross(ad).dot(ab), 2));
237 // Due to evaluating the above numerically some cancellation or rounding
238 // can occur. For this reason a normalisation factor is introduced.
239 const double normalisation_factor =
240 (ab.squaredNorm() * ac.squaredNorm() * ad.squaredNorm());
241
242 // tolerance 1e-11 is chosen such that
243 // a = (0,0,0), b=(1,0,0), c=(0,1,0) and d=(1,1,1e-6) are considered as
244 // coplanar
245 // a = (0,0,0), b=(1,0,0), c=(0,1,0) and d=(1,1,1e-5) are considered as not
246 // coplanar
247 return (sqr_scalar_triple / normalisation_factor < 1e-11);
248}
Eigen::Vector3d const & asEigenVector3d() const
Definition Point3d.h:64

References MathLib::Point3d::asEigenVector3d().

Referenced by GeoLib::MinimalBoundingSphere::MinimalBoundingSphere(), anonymous_namespace{MeshRevision.cpp}::constructFourNodeElement(), GeoLib::Polyline::isCoplanar(), anonymous_namespace{MeshRevision.cpp}::reducePrism(), and MeshLib::QuadRule::validate().

◆ isPointInTetrahedron()

bool MathLib::isPointInTetrahedron ( MathLib::Point3d const & p,
MathLib::Point3d const & a,
MathLib::Point3d const & b,
MathLib::Point3d const & c,
MathLib::Point3d const & d,
double eps = std::numeric_limits< double >::epsilon() )

Tests if the given point p is located within a tetrahedron spanned by points a, b, c, d. If the tet specified by a, b, c, d is degenerated (i.e. all points are coplanar) the function will return false because there is no meaningful concept of "inside" for such elements.

Parameters
ptest point
aedge node of tetrahedron
bedge node of tetrahedron
cedge node of tetrahedron
dedge node of tetrahedron
epsAccounts for numerical inaccuracies by allowing a point to be slightly outside of the element and still be regarded as inside.
Returns
true if the test point p is not located outside of abcd (i.e. inside or on a plane/edge).

Definition at line 50 of file GeometricBasics.cpp.

53{
54 double const d0(MathLib::orientation3d(d, a, b, c));
55 // if tetrahedron is not coplanar
56 if (std::abs(d0) > std::numeric_limits<double>::epsilon())
57 {
58 bool const d0_sign(d0 > 0);
59 // if p is on the same side of bcd as a
60 double const d1(MathLib::orientation3d(d, p, b, c));
61 if (!(d0_sign == (d1 >= 0) || std::abs(d1) < eps))
62 {
63 return false;
64 }
65 // if p is on the same side of acd as b
66 double const d2(MathLib::orientation3d(d, a, p, c));
67 if (!(d0_sign == (d2 >= 0) || std::abs(d2) < eps))
68 {
69 return false;
70 }
71 // if p is on the same side of abd as c
72 double const d3(MathLib::orientation3d(d, a, b, p));
73 if (!(d0_sign == (d3 >= 0) || std::abs(d3) < eps))
74 {
75 return false;
76 }
77 // if p is on the same side of abc as d
78 double const d4(MathLib::orientation3d(p, a, b, c));
79 return d0_sign == (d4 >= 0) || std::abs(d4) < eps;
80 }
81 return false;
82}

References orientation3d(), and p.

Referenced by MeshLib::HexRule::isPntInElement(), MeshLib::PrismRule::isPntInElement(), MeshLib::PyramidRule::isPntInElement(), and MeshLib::TetRule::isPntInElement().

◆ isPointInTriangle()

bool MathLib::isPointInTriangle ( MathLib::Point3d const & p,
MathLib::Point3d const & a,
MathLib::Point3d const & b,
MathLib::Point3d const & c,
double eps_pnt_out_of_plane = std::numeric_limits< float >::epsilon(),
double eps_pnt_out_of_tri = std::numeric_limits< float >::epsilon(),
MathLib::TriangleTest algorithm = MathLib::GAUSS )

Tests if the given point p is within the triangle, defined by its edge nodes a, b and c.Using two eps-values it is possible to test an 'epsilon' neighbourhood around the triangle as well as an 'epsilon' outside the triangles plane.

Parameters
ptest point
aedge node of triangle
bedge node of triangle
cedge node of triangle
eps_pnt_out_of_planeeps allowing for p to be slightly off the plane spanned by abc
eps_pnt_out_of_trieps allowing for p to be slightly off outside of abc
algorithmdefines the method to use
Returns
true if the test point p is within the 'epsilon'-neighbourhood of the triangle

Definition at line 84 of file GeometricBasics.cpp.

91{
92 switch (algorithm)
93 {
94 case MathLib::GAUSS:
95 return gaussPointInTriangle(p, a, b, c, eps_pnt_out_of_plane,
96 eps_pnt_out_of_tri);
98 return barycentricPointInTriangle(p, a, b, c, eps_pnt_out_of_plane,
99 eps_pnt_out_of_tri);
100 default:
101 ERR("Selected algorithm for point in triangle testing not found, "
102 "falling back on default.");
103 }
104 return gaussPointInTriangle(p, a, b, c, eps_pnt_out_of_plane,
105 eps_pnt_out_of_tri);
106}
bool gaussPointInTriangle(MathLib::Point3d const &q, MathLib::Point3d const &a, MathLib::Point3d const &b, MathLib::Point3d const &c, double eps_pnt_out_of_plane, double eps_pnt_out_of_tri)
bool barycentricPointInTriangle(MathLib::Point3d const &p, MathLib::Point3d const &a, MathLib::Point3d const &b, MathLib::Point3d const &c, double eps_pnt_out_of_plane, double eps_pnt_out_of_tri)

References BARYCENTRIC, barycentricPointInTriangle(), ERR(), GAUSS, gaussPointInTriangle(), and p.

Referenced by GeoLib::Triangle::containsPoint(), GeoLib::EarClippingTriangulation::isEar(), MeshLib::QuadRule::isPntInElement(), and MeshLib::TriRule::isPntInElement().

◆ isPointInTriangleXY()

bool MathLib::isPointInTriangleXY ( MathLib::Point3d const & p,
MathLib::Point3d const & a,
MathLib::Point3d const & b,
MathLib::Point3d const & c )

Checks if the point \(p'\) is in the triangle defined by the points \(a', b', c'\), where the \(p', a', b', c' \) are the orthogonal projections to the \(x\)- \(y\) plane of the points \(p, a, b, c\), respectively.

Definition at line 180 of file GeometricBasics.cpp.

184{
185 // criterion: p-a = u0 * (b-a) + u1 * (c-a); 0 <= u0, u1 <= 1, u0+u1 <= 1
186 Eigen::Matrix2d mat;
187 mat(0, 0) = b[0] - a[0];
188 mat(0, 1) = c[0] - a[0];
189 mat(1, 0) = b[1] - a[1];
190 mat(1, 1) = c[1] - a[1];
191 Eigen::Vector2d y;
192 y << p[0] - a[0], p[1] - a[1];
193
194 y = mat.partialPivLu().solve(y);
195
196 // check if u0 and u1 fulfills the condition
197 return 0 <= y[0] && y[0] <= 1 && 0 <= y[1] && y[1] <= 1 && y[0] + y[1] <= 1;
198}

References p.

Referenced by MeshLib::isPointInElementXY().

◆ lessEq()

bool MathLib::lessEq ( Point3d const & a,
Point3d const & b,
double eps = std::numeric_limits< double >::epsilon() )

Lexicographic comparison of points taking an epsilon into account.

Parameters
afirst input point.
bsecond input point.
epstolerance used in comparison of coordinates.
Returns
true, if a is smaller than or equal to b according to the following test \( |a_i - b_i| > \epsilon \cdot \min (|a_i|, |b_i|) \) and \( |a_i - b_i| > \epsilon \) for all coordinates \( 0 \le i < 3 \).

Definition at line 31 of file Point3d.cpp.

32{
33 auto absAndRelDiffLargerThanEps = [eps](double const u,
34 double const v) -> bool
35 {
36 return std::abs(u - v) > eps * std::min(std::abs(v), std::abs(u)) &&
37 std::abs(u - v) > eps;
38 };
39
40 return std::lexicographical_compare(
41 a.data(), a.data() + 3, b.data(), b.data() + 3,
42 [&absAndRelDiffLargerThanEps](auto const u, auto const v)
43 {
44 if (absAndRelDiffLargerThanEps(u, v))
45 {
46 return u <= v;
47 }
48 return true;
49 });
50}

References MathLib::Point3d::data(), u, and v.

◆ operator*()

MathLib::Point3d MathLib::operator* ( Eigen::Matrix3d const & mat,
MathLib::Point3d const & p )

rotation of points

Parameters
mata rotation matrix
pa point to be transformed
Returns
a rotated point

Definition at line 19 of file Point3d.cpp.

21{
22 auto const& result = (mat * p.asEigenVector3d()).eval();
23 return MathLib::Point3d{{result[0], result[1], result[2]}};
24}

References p.

◆ operator<()

bool MathLib::operator< ( Point3d const & a,
Point3d const & b )
inline

Definition at line 71 of file Point3d.h.

72{
73 return std::lexicographical_compare(a.data(), a.data() + 3, b.data(),
74 b.data() + 3);
75}

References MathLib::Point3d::data().

◆ operator<<() [1/2]

std::ostream & MathLib::operator<< ( std::ostream & os,
const Point3d & p )
inline

overload the output operator for class Point

Definition at line 92 of file Point3d.h.

93{
94 os << p[0] << " " << p[1] << " " << p[2];
95 return os;
96}

References p.

◆ operator<<() [2/2]

std::ostream & MathLib::operator<< ( std::ostream & os,
MathLib::WeightedPoint const & wp )

Definition at line 17 of file WeightedPoint.cpp.

18{
19 auto const dim = wp.getDimension();
20 os << "WP[" << dim << "D]{{";
21 for (std::size_t comp = 0; comp < 3; ++comp)
22 {
23 if (comp != 0)
24 {
25 os << ", ";
26 }
27 os << wp[comp];
28 }
29 os << "}, weight=" << wp.getWeight() << '}';
30 return os;
31}

References MathLib::WeightedPoint::getDimension(), and MathLib::WeightedPoint::getWeight().

◆ operator==()

bool MathLib::operator== ( Point3d const & a,
Point3d const & b )
inline

Equality of Point3d's up to an epsilon.

Definition at line 114 of file Point3d.h.

115{
116 auto const sqr_dist(sqrDist(a, b));
117 auto const eps = std::numeric_limits<double>::epsilon();
118 return (sqr_dist < eps * eps);
119}

References sqrDist().

◆ orientation3d()

double MathLib::orientation3d ( MathLib::Point3d const & p,
MathLib::Point3d const & a,
MathLib::Point3d const & b,
MathLib::Point3d const & c )

Checks if a point p is on the left or right side of a plane spanned by three points a, b, c.

Parameters
ppoint to test
afirst point on plane
bsecond point on plane
cthird point on plane
Returns
If the triangle abc is ordered counterclockwise when viewed from p, the method will return a negative value, otherwise it will return a positive value. If p is coplanar with abc, the function will return 0.

Definition at line 19 of file GeometricBasics.cpp.

23{
24 Eigen::Vector3d const u = p.asEigenVector3d() - a.asEigenVector3d();
25 Eigen::Vector3d const v = p.asEigenVector3d() - b.asEigenVector3d();
26 Eigen::Vector3d const w = p.asEigenVector3d() - c.asEigenVector3d();
27 return u.cross(v).dot(w);
28}

References MathLib::Point3d::asEigenVector3d(), p, u, and v.

Referenced by barycentricPointInTriangle(), and isPointInTetrahedron().

◆ parsePiecewiseLinearCurveConfig()

PiecewiseLinearCurveConfig MathLib::parsePiecewiseLinearCurveConfig ( BaseLib::ConfigTree const & config)
Input File Parameter
curve__read_from_file
Input File Parameter
curve__coords
Input File Parameter
curve__values
Input File Parameter
curve__coords
Input File Parameter
curve__values

Definition at line 27 of file CreatePiecewiseLinearCurve.cpp.

29{
30 const bool read_from_file =
31 config.getConfigParameter<bool>("read_from_file", false);
32
33 std::vector<double> x;
34 std::vector<double> y;
35
36 if (read_from_file == true)
37 {
38 auto const coords_file_name =
40 config.getConfigParameter<std::string>("coords");
41
42 auto const values_file_name =
44 config.getConfigParameter<std::string>("values");
45
46 x = BaseLib::readDoublesFromBinaryFile(coords_file_name);
47
48 y = BaseLib::readDoublesFromBinaryFile(values_file_name);
49 }
50 else
51 {
52 x =
54 config.getConfigParameter<std::vector<double>>("coords");
55 y =
57 config.getConfigParameter<std::vector<double>>("values");
58 }
59
60 if (x.empty() || y.empty())
61 {
62 OGS_FATAL("The given coordinates or values vector is empty.");
63 }
64 if (x.size() != y.size())
65 {
67 "The given coordinates and values vector sizes are "
68 "different.");
69 }
70
71 return {std::move(x), std::move(y)};
72}
std::vector< double > readDoublesFromBinaryFile(const std::string &filename)

References BaseLib::ConfigTree::getConfigParameter(), OGS_FATAL, and BaseLib::readDoublesFromBinaryFile().

Referenced by createPiecewiseLinearCurve().

◆ readDoublesFromBinaryFile()

std::vector< double > MathLib::readDoublesFromBinaryFile ( const std::string & filename)

◆ setMatrix() [1/2]

void MathLib::setMatrix ( PETScMatrix & m,
Eigen::MatrixXd const & tmp )

Definition at line 48 of file UnifiedMatrixSetters.cpp.

49{
50 using IndexType = PETScMatrix::IndexType;
51
52 auto const rows = tmp.rows();
53 auto const cols = tmp.cols();
54
55 assert(rows == m.getNumberOfRows() && cols == m.getNumberOfColumns());
56
57 m.setZero();
58 std::vector<IndexType> row_idcs(rows);
59 std::vector<IndexType> col_idcs(cols);
60
61 std::iota(row_idcs.begin(), row_idcs.end(), 0);
62 std::iota(col_idcs.begin(), col_idcs.end(), 0);
63
64 // PETSc wants row-major
65 Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>
66 tmp_ = tmp;
67
68 m.add(row_idcs, col_idcs, tmp_);
69}
void setZero()
Set all entries to zero.
Definition PETScMatrix.h:95

References MathLib::PETScMatrix::add(), MathLib::PETScMatrix::getNumberOfColumns(), MathLib::PETScMatrix::getNumberOfRows(), and MathLib::PETScMatrix::setZero().

◆ setMatrix() [2/2]

void MathLib::setMatrix ( PETScMatrix & m,
std::initializer_list< double > values )

Definition at line 42 of file UnifiedMatrixSetters.cpp.

43{
44 m.setZero();
45 addToMatrix(m, values);
46}
void addToMatrix(PETScMatrix &m, std::initializer_list< double > values)

References addToMatrix(), and MathLib::PETScMatrix::setZero().

◆ setMatrixSparsity()

template<typename MATRIX , typename SPARSITY_PATTERN >
void MathLib::setMatrixSparsity ( MATRIX & matrix,
SPARSITY_PATTERN const & sparsity_pattern )

Sets the sparsity pattern of the underlying matrix. To allow partial specialization a SetMatrixSparsity template is instantiated, to which the matrix and the sparsity_pattern are passed.

Definition at line 31 of file SetMatrixSparsity.h.

32{
34 set_sparsity(matrix, sparsity_pattern);
35}

◆ setVector() [1/2]

void MathLib::setVector ( PETScVector & v,
MatrixVectorTraits< PETScVector >::Index const index,
double const value )

Definition at line 35 of file UnifiedMatrixSetters.cpp.

38{
39 v.set(index, value); // TODO handle negative indices
40}

References v.

◆ setVector() [2/2]

void MathLib::setVector ( PETScVector & v,
std::initializer_list< double > values )

Definition at line 26 of file UnifiedMatrixSetters.cpp.

27{
28 std::vector<double> const vals(values);
29 std::vector<PETScVector::IndexType> idcs(vals.size());
30 std::iota(idcs.begin(), idcs.end(), 0);
31
32 v.set(idcs, vals);
33}

References v.

Referenced by detail::applyKnownSolutions().

◆ SPECIALIZE_MATRIX_VECTOR_TRAITS() [1/2]

MathLib::SPECIALIZE_MATRIX_VECTOR_TRAITS ( PETScMatrix ,
PETScMatrix::IndexType  )

◆ SPECIALIZE_MATRIX_VECTOR_TRAITS() [2/2]

MathLib::SPECIALIZE_MATRIX_VECTOR_TRAITS ( PETScVector ,
PETScVector::IndexType  )

◆ sqrDist()

◆ sqrDist2d()

double MathLib::sqrDist2d ( MathLib::Point3d const & p0,
MathLib::Point3d const & p1 )
inline

Computes the squared distance between the orthogonal projection of the two points p0 and p1 onto the \(xy\)-plane.

Definition at line 123 of file Point3d.h.

124{
125 return (p0[0] - p1[0]) * (p0[0] - p1[0]) +
126 (p0[1] - p1[1]) * (p0[1] - p1[1]);
127}

Referenced by MeshLib::isPointInElementXY(), GeoLib::lineSegmentIntersect2d(), and MeshGeoToolsLib::snapPointToElementNode().

◆ toMatrix() [1/4]

template<typename Matrix >
Eigen::Map< Matrix > MathLib::toMatrix ( std::vector< double > & data,
Eigen::MatrixXd::Index rows,
Eigen::MatrixXd::Index cols )

Creates an Eigen mapped matrix from the given data vector.

Attention
The data vector must have the same storage order (row or column major) as the requested matrix type.

Definition at line 111 of file EigenMapTools.h.

114{
115 static_assert(Matrix::IsRowMajor || Matrix::IsVectorAtCompileTime,
116 "The default storage order in OGS is row major storage for "
117 "dense matrices.");
118 assert(Matrix::RowsAtCompileTime == Eigen::Dynamic ||
119 Matrix::RowsAtCompileTime == rows);
120 assert(Matrix::ColsAtCompileTime == Eigen::Dynamic ||
121 Matrix::ColsAtCompileTime == cols);
122 assert(static_cast<Eigen::MatrixXd::Index>(data.size()) == rows * cols);
123
124 return {data.data(), rows, cols};
125}

◆ toMatrix() [2/4]

Eigen::Map< Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > > MathLib::toMatrix ( std::vector< double > & data,
Eigen::MatrixXd::Index rows,
Eigen::MatrixXd::Index cols )
inline

Creates an Eigen mapped matrix from the given data vector.

This is a convenience method which makes the specification of dynamically allocated Eigen matrices as return type easier.

Definition at line 134 of file EigenMapTools.h.

137{
138 return toMatrix<
139 Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>>(
140 data, rows, cols);
141}
Eigen::Map< const Matrix > toMatrix(std::vector< double > const &data, Eigen::MatrixXd::Index rows, Eigen::MatrixXd::Index cols)

References toMatrix().

◆ toMatrix() [3/4]

template<typename Matrix >
Eigen::Map< const Matrix > MathLib::toMatrix ( std::vector< double > const & data,
Eigen::MatrixXd::Index rows,
Eigen::MatrixXd::Index cols )

Creates an Eigen mapped matrix from the given data vector.

Attention
The data vector must have the same storage order (row or column major) as the requested matrix type.

Definition at line 72 of file EigenMapTools.h.

75{
76 static_assert(Matrix::IsRowMajor || Matrix::IsVectorAtCompileTime,
77 "The default storage order in OGS is row major storage for "
78 "dense matrices.");
79 assert(Matrix::RowsAtCompileTime == Eigen::Dynamic ||
80 Matrix::RowsAtCompileTime == rows);
81 assert(Matrix::ColsAtCompileTime == Eigen::Dynamic ||
82 Matrix::ColsAtCompileTime == cols);
83 assert(static_cast<Eigen::MatrixXd::Index>(data.size()) == rows * cols);
84
85 return {data.data(), rows, cols};
86}

Referenced by ProcessLib::Assembly::MatrixElementCache< Dim >::addToCacheImpl(), ProcessLib::VectorMatrixAssembler::assemble(), ProcessLib::ComponentTransport::ComponentTransportLocalAssemblerInterface::assembleReactionEquation(), ProcessLib::CentralDifferencesJacobianAssembler::assembleWithJacobian(), ProcessLib::CompareJacobiansJacobianAssembler::assembleWithJacobian(), ProcessLib::ForwardDifferencesJacobianAssembler::assembleWithJacobian(), ProcessLib::HeatTransportBHE::HeatTransportBHELocalAssemblerBHE< ShapeFunction, BHEType >::assembleWithJacobian(), ProcessLib::HeatTransportBHE::HeatTransportBHELocalAssemblerSoil< ShapeFunction >::assembleWithJacobian(), ProcessLib::VectorMatrixAssembler::assembleWithJacobian(), NumLib::LocalLinearLeastSquaresExtrapolator::calculateResidualElement(), ProcessLib::ComponentTransport::LocalAssemblerData< ShapeFunction, GlobalDim >::computeSecondaryVariableConcrete(), NumLib::LocalLinearLeastSquaresExtrapolator::extrapolateElement(), ProcessLib::TES::TESLocalAssembler< ShapeFunction_, GlobalDim >::getIntPtDarcyVelocity(), toMatrix(), toMatrix(), ProcessLib::transposeInPlace(), ProcessLib::transposeInPlace(), and ProcessLib::transposeInPlace().

◆ toMatrix() [4/4]

Eigen::Map< const Eigen:: Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > > MathLib::toMatrix ( std::vector< double > const & data,
Eigen::MatrixXd::Index rows,
Eigen::MatrixXd::Index cols )
inline

Creates an Eigen mapped matrix from the given data vector.

This is a convenience method which makes the specification of dynamically allocated Eigen matrices as return type easier.

Definition at line 96 of file EigenMapTools.h.

99{
100 return toMatrix<
101 Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>>(
102 data, rows, cols);
103}

References toMatrix().

◆ toVector() [1/4]

Eigen::Map< Eigen::VectorXd > MathLib::toVector ( std::vector< double > & data)
inline

Creates an Eigen mapped vector from the given data vector.

This is a convenience method which makes the specification of dynamically allocated Eigen vectors as return type easier.

Definition at line 207 of file EigenMapTools.h.

208{
209 return {data.data(), static_cast<Eigen::VectorXd::Index>(data.size())};
210}

◆ toVector() [2/4]

template<typename Vector >
Eigen::Map< Vector > MathLib::toVector ( std::vector< double > & data,
Eigen::VectorXd::Index size )

Creates an Eigen mapped vector from the given data vector.

Definition at line 180 of file EigenMapTools.h.

182{
183 static_assert(Vector::IsVectorAtCompileTime, "A vector type is required.");
184 assert(Vector::SizeAtCompileTime == Eigen::Dynamic ||
185 Vector::SizeAtCompileTime == size);
186 assert(static_cast<Eigen::VectorXd::Index>(data.size()) == size);
187
188 return {data.data(), size};
189}

◆ toVector() [3/4]

Eigen::Map< const Eigen::VectorXd > MathLib::toVector ( std::vector< double > const & data)
inline

Creates an Eigen mapped vector from the given data vector.

This is a convenience method which makes the specification of dynamically allocated Eigen vectors as return type easier.

Definition at line 196 of file EigenMapTools.h.

198{
199 return {data.data(), static_cast<Eigen::VectorXd::Index>(data.size())};
200}

◆ toVector() [4/4]

template<typename Vector >
Eigen::Map< const Vector > MathLib::toVector ( std::vector< double > const & data,
Eigen::VectorXd::Index size )

Creates an Eigen mapped vector from the given data vector.

Definition at line 167 of file EigenMapTools.h.

169{
170 static_assert(Vector::IsVectorAtCompileTime, "A vector type is required.");
171 assert(Vector::SizeAtCompileTime == Eigen::Dynamic ||
172 Vector::SizeAtCompileTime == size);
173 assert(static_cast<Eigen::VectorXd::Index>(data.size()) == size);
174
175 return {data.data(), size};
176}

Referenced by ProcessLib::BoundaryConditionAndSourceTerm::Python::BcAndStLocalAssemblerImpl< BcOrStData, ShapeFunction, LowerOrderShapeFunction, GlobalDim >::assemble(), ProcessLib::RobinBoundaryConditionLocalAssembler< ShapeFunction, GlobalDim >::assemble(), ProcessLib::VectorMatrixAssembler::assemble(), ProcessLib::LiquidFlow::LiquidFlowLocalAssembler< ShapeFunction, GlobalDim >::assembleMatrixAndVector(), ProcessLib::ComponentTransport::ComponentTransportLocalAssemblerInterface::assembleReactionEquation(), ProcessLib::CentralDifferencesJacobianAssembler::assembleWithJacobian(), ProcessLib::CompareJacobiansJacobianAssembler::assembleWithJacobian(), ProcessLib::ForwardDifferencesJacobianAssembler::assembleWithJacobian(), ProcessLib::VectorMatrixAssembler::assembleWithJacobian(), anonymous_namespace{ParallelVectorMatrixAssembler.cpp}::assembleWithJacobianForStaggeredSchemeOneElement(), ProcessLib::LiquidFlow::LiquidFlowLocalAssembler< ShapeFunction, GlobalDim >::computeProjectedDarcyVelocity(), ProcessLib::LocalAssemblerInterface::computeSecondaryVariable(), MathLib::EigenVector::copyValues(), ProcessLib::ComponentTransport::createComponentTransportProcess(), ProcessLib::HT::createHTProcess(), ProcessLib::LiquidFlow::createLiquidFlowProcess(), ProcessLib::RichardsComponentTransport::createRichardsComponentTransportProcess(), ProcessLib::RichardsFlow::createRichardsFlowProcess(), ProcessLib::ThermalTwoPhaseFlowWithPP::createThermalTwoPhaseFlowWithPPProcess(), ProcessLib::TwoPhaseFlowWithPP::createTwoPhaseFlowWithPPProcess(), ProcessLib::TwoPhaseFlowWithPrho::createTwoPhaseFlowWithPrhoProcess(), ProcessLib::WellboreSimulator::createWellboreSimulatorProcess(), NumLib::LocalLinearLeastSquaresExtrapolator::extrapolateElement(), MaterialLib::Solids::Ehlers::SolidEhlers< DisplacementDim >::getInternalVariables(), ProcessLib::SteadyStateDiffusion::LocalAssemblerData< ShapeFunction, GlobalDim >::getIntPtDarcyVelocity(), ProcessLib::ComponentTransport::LocalAssemblerData< ShapeFunction, GlobalDim >::getIntPtMolarFlux(), NumLib::getLocalX(), ProcessLib::ComponentTransport::ComponentTransportLocalAssemblerInterface::initializeChemicalSystem(), ProcessLib::AnchorTerm< GlobalDim >::integrate(), ProcessLib::Assembly::LocalMatrixOutput::operator()(), ProcessLib::Assembly::LocalMatrixOutput::operator()(), ProcessLib::Deformation::CollectIntegrationPointDataForExtrapolation< InternalVariable >::operator()(), and ProcessLib::ComponentTransport::ComponentTransportLocalAssemblerInterface::setChemicalSystem().

Variable Documentation

◆ ORIGIN

MATHLIB_EXPORT const Point3d MathLib::ORIGIN {{{0.0, 0.0, 0.0}}}
extern

Definition at line 98 of file Point3d.h.

Referenced by MeshLib::getBulkElementPoint(), and getOrigin().

◆ p

◆ q

const double MathLib::q = 0.0734930431163619 / 6.
static

Definition at line 63 of file GaussLegendreTet.cpp.

Referenced by gaussPointInTriangle().

◆ r

const double MathLib::r = 0.0425460207770812 / 6.
static

Definition at line 64 of file GaussLegendreTet.cpp.

Referenced by addToMatrix().

◆ s

◆ t

◆ u

◆ v