GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/porousmediumflow/1pnc/dispersion/spatialparams.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 17 29 58.6%
Functions: 1 6 16.7%
Branches: 20 72 27.8%

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 OnePNCTests
10 * \brief Definition of the spatial parameters for the 1pnc problems.
11 */
12
13 #ifndef DUMUX_1PNC_TEST_SPATIAL_PARAMS_HH
14 #define DUMUX_1PNC_TEST_SPATIAL_PARAMS_HH
15
16 #include <dune/common/exceptions.hh>
17 #include <dumux/porousmediumflow/properties.hh>
18 #include <dumux/porousmediumflow/fvspatialparams1p.hh>
19
20 namespace Dumux {
21
22 /*!
23 * \ingroup OnePNCTests
24 * \brief Definition of the spatial parameters for the 1pnc test problems.
25 */
26 template<class GridGeometry, class Scalar>
27 class OnePNCTestSpatialParams
28 : public FVPorousMediumFlowSpatialParamsOneP<GridGeometry, Scalar,
29 OnePNCTestSpatialParams<GridGeometry, Scalar>>
30 {
31 using GridView = typename GridGeometry::GridView;
32 using FVElementGeometry = typename GridGeometry::LocalView;
33 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
34 using Element = typename GridView::template Codim<0>::Entity;
35 using ParentType = FVPorousMediumFlowSpatialParamsOneP<GridGeometry, Scalar,
36 OnePNCTestSpatialParams<GridGeometry, Scalar>>;
37
38 static const int dimWorld = GridView::dimensionworld;
39 using GlobalPosition = typename Dune::FieldVector<Scalar, dimWorld>;
40
41 public:
42 // export permeability type
43 using PermeabilityType = Scalar;
44 using DimWorldMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
45
46 6 OnePNCTestSpatialParams(std::shared_ptr<const GridGeometry> gridGeometry)
47
4/14
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 6 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
18 : ParentType(gridGeometry)
48 {
49 6 permeability_ = 1e-10;
50 6 porosity_ = 0.4;
51
1/2
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
6 alphaL_ = getParam<Scalar>("Problem.AlphaL");
52
1/2
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
6 alphaT_ = getParam<Scalar>("Problem.AlphaT");
53
2/4
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
6 dispersionTensorCoefficients_ = getParam<std::vector<Scalar>>("Problem.DispersionTensor");
54
55
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 4 times.
12 if (dispersionTensorCoefficients_.size() > 1)
56 {
57
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (dispersionTensorCoefficients_.size() != (dimWorld*dimWorld))
58 DUNE_THROW(Dune::InvalidStateException, "For anisotropic dispersion tensors, please list all entries (dim x dim).");
59
60 int k = 0;
61
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2 times.
6 for (int i = 0; i < dimWorld; i++)
62 {
63
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 for (int j = 0; j < dimWorld; j++)
64 {
65 24 dispersionTensor_[i][j] = dispersionTensorCoefficients_[k];
66 8 k++;
67 }
68 }
69 }
70 else
71 {
72
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (dispersionTensorCoefficients_.size() != 1)
73 DUNE_THROW(Dune::InvalidStateException, "For isotropic dispersion tensors, please one scalar value.");
74
75
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 for (int i = 0; i < dimWorld; i++)
76 24 dispersionTensor_[i][i] = dispersionTensorCoefficients_[0];
77 }
78 6 }
79
80 /*!
81 * \brief Defines the intrinsic permeability \f$\mathrm{[m^2]}\f$.
82 *
83 * \param globalPos The global position
84 */
85 PermeabilityType permeabilityAtPos(const GlobalPosition& globalPos) const
86 { return permeability_; }
87
88 /*!
89 * \brief Defines the porosity \f$\mathrm{[-]}\f$.
90 *
91 * \param globalPos The global position
92 */
93 Scalar porosityAtPos(const GlobalPosition& globalPos) const
94 { return porosity_; }
95
96 /*!
97 * \brief Returns the temperature within the domain [K].
98 *
99 * \param globalPos The global position
100 */
101 Scalar temperatureAtPos(const GlobalPosition& globalPos) const
102 { return 273.15 + 20; } // in [K]
103
104 /*!
105 * \brief Defines the dispersion tensor \f$\mathrm{[-]}\f$.
106 *
107 * \param globalPos The global position
108 */
109 std::array<Scalar, 2> dispersionAlphas(const GlobalPosition& globalPos, int phaseIdx = 0, int compIdx = 0) const
110 { return { alphaL_, alphaT_ }; }
111
112 /*!
113 * \brief Defines the dispersion tensor \f$\mathrm{[-]}\f$.
114 *
115 * \param globalPos The global position
116 */
117 const DimWorldMatrix &dispersionTensor(const GlobalPosition& globalPos, int phaseIdx = 0, int compIdx = 0) const
118 { return dispersionTensor_; }
119
120 private:
121 Scalar permeability_;
122 Scalar porosity_;
123 Scalar alphaL_;
124 Scalar alphaT_;
125 std::vector<Scalar> dispersionTensorCoefficients_;
126 DimWorldMatrix dispersionTensor_;
127 };
128
129 } // end namespace Dumux
130
131 #endif
132