GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/assembly/numericepsilon.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 8 8 100.0%
Functions: 13 16 81.2%
Branches: 5 6 83.3%

Line Branch Exec Source
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 //
7 /*!
8 * \file
9 * \ingroup Assembly
10 * \brief An adapter class for local assemblers using numeric differentiation
11 */
12 #ifndef DUMUX_ASSEMBLY_NUMERIC_EPSILON_HH
13 #define DUMUX_ASSEMBLY_NUMERIC_EPSILON_HH
14
15 #include <dune/common/fvector.hh>
16 #include <dumux/common/parameters.hh>
17 #include <dumux/common/numericdifferentiation.hh>
18
19 namespace Dumux {
20
21 /*!
22 * \ingroup Assembly
23 * \brief A helper class for local assemblers using numeric differentiation to determine the epsilon
24 * \tparam Scalar the scalar type
25 * \tparam numEq the number of primary variables / equations
26 */
27 template<class Scalar, int numEq>
28 class NumericEpsilon
29 {
30 using NumEqVector = Dune::FieldVector<Scalar, numEq>;
31
32 public:
33 1612 explicit NumericEpsilon(const std::string& paramGroup = "")
34 1612 {
35 // get epsilons from input file with invalid default
36 1612 baseEps_ = getParamFromGroup<Scalar>(paramGroup, "Assembly.NumericDifference.BaseEpsilon", 1e-10);
37 3224 magnitude_ = getParamFromGroup<NumEqVector>(paramGroup, "Assembly.NumericDifference.PriVarMagnitude", NumEqVector(-1));
38 1612 }
39
40 /*!
41 * \brief get the epsilon
42 * \note If no user input was specified -> try to estimate magnitude from primary variable value
43 * else -> use given magnitude for the primary variable times the base epsilon (default 1e-10)
44 */
45 194179235 Scalar operator() (Scalar priVar, int priVarIdx) const noexcept
46 {
47
4/4
✓ Branch 0 taken 755280 times.
✓ Branch 1 taken 124530857 times.
✓ Branch 2 taken 755280 times.
✓ Branch 3 taken 124530857 times.
388358470 return magnitude_[priVarIdx] > 0.0 ? baseEps_*magnitude_[priVarIdx]
48
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124530857 times.
187255167 : NumericDifferentiation::epsilon(priVar, baseEps_);
49 }
50
51 private:
52 Scalar baseEps_;
53 NumEqVector magnitude_;
54 };
55
56 } // end namespace Dumux
57
58 #endif
59