version 3.8
numericepsilon.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3//
4// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_ASSEMBLY_NUMERIC_EPSILON_HH
13#define DUMUX_ASSEMBLY_NUMERIC_EPSILON_HH
14
15#include <dune/common/fvector.hh>
18
19namespace Dumux {
20
27template<class Scalar, int numEq>
29{
30 using NumEqVector = Dune::FieldVector<Scalar, numEq>;
31
32public:
33 explicit NumericEpsilon(const std::string& paramGroup = "")
34 {
35 // get epsilons from input file with invalid default
36 baseEps_ = getParamFromGroup<Scalar>(paramGroup, "Assembly.NumericDifference.BaseEpsilon", 1e-10);
37 magnitude_ = getParamFromGroup<NumEqVector>(paramGroup, "Assembly.NumericDifference.PriVarMagnitude", NumEqVector(-1));
38 }
39
45 Scalar operator() (Scalar priVar, int priVarIdx) const noexcept
46 {
47 return magnitude_[priVarIdx] > 0.0 ? baseEps_*magnitude_[priVarIdx]
48 : NumericDifferentiation::epsilon(priVar, baseEps_);
49 }
50
51private:
52 Scalar baseEps_;
53 NumEqVector magnitude_;
54};
55
56} // end namespace Dumux
57
58#endif
static Scalar epsilon(const Scalar value, const Scalar baseEps=1e-10)
Computes the epsilon used for numeric differentiation.
Definition: numericdifferentiation.hh:35
A helper class for local assemblers using numeric differentiation to determine the epsilon.
Definition: numericepsilon.hh:29
NumericEpsilon(const std::string &paramGroup="")
Definition: numericepsilon.hh:33
Scalar operator()(Scalar priVar, int priVarIdx) const noexcept
get the epsilon
Definition: numericepsilon.hh:45
typename NumEqVectorTraits< PrimaryVariables >::type NumEqVector
A vector with the same size as numbers of equations This is the default implementation and has to be ...
Definition: numeqvector.hh:34
Definition: adapt.hh:17
A class for numeric differentiation.
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.