GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/porousmediumflow/2pnc/surfactant/spatialparams.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 22 32 68.8%
Functions: 2 8 25.0%
Branches: 12 28 42.9%

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 TwoPNCTests
10 * \brief Definition of the spatial parameters for a surfactant model.
11 */
12 #ifndef DUMUX_TEST_2P3C_SURFACTANT_SPATIALPARAMS_HH
13 #define DUMUX_TEST_2P3C_SURFACTANT_SPATIALPARAMS_HH
14
15 #include <algorithm>
16
17 #include <dune/common/fmatrix.hh>
18
19 #include <dumux/porousmediumflow/fvspatialparamsmp.hh>
20 #include <dumux/discretization/evalgradients.hh>
21
22 #include "materiallaw.hh"
23
24 namespace Dumux {
25 /*!
26 * \ingroup TwoPNCTests
27 * \brief Definition of the spatial parameters for a surfactant model.
28 */
29 template<class GridGeometry, class Scalar>
30
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 class TestSurfactantSpatialParams
31 : public FVPorousMediumFlowSpatialParamsMP<GridGeometry, Scalar,
32 TestSurfactantSpatialParams<GridGeometry, Scalar>>
33 {
34 using ParentType = FVPorousMediumFlowSpatialParamsMP<
35 GridGeometry, Scalar, TestSurfactantSpatialParams<GridGeometry, Scalar>
36 >;
37
38 using GridView = typename GridGeometry::GridView;
39 using Element = typename GridView::template Codim<0>::Entity;
40 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
41
42 using FVElementGeometry = typename GridGeometry::LocalView;
43 using SubControlVolume = typename GridGeometry::SubControlVolume;
44
45 static constexpr int dimWorld = GridView::dimensionworld;
46 static constexpr int surfactantCompIdx = 2;
47
48 using MaterialLaw = FluidMatrix::SurfactantPcKrSw<Scalar>;
49
50 public:
51 using PermeabilityType = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
52
53 1 TestSurfactantSpatialParams(std::shared_ptr<const GridGeometry> gridGeometry)
54
2/8
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
1 : ParentType(gridGeometry)
55 {
56
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 sMinKr_ = getParam<Scalar>("SpatialParams.Smin");
57
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 sMaxKr_ = getParam<Scalar>("SpatialParams.Smax");
58
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 srwSurf_ = getParam<Scalar>("SpatialParams.SrwSurf");
59
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 sroSurf_ = getParam<Scalar>("SpatialParams.SroSurf");
60 1 }
61
62 /*!
63 * \brief Defines the porosity \f$[-]\f$ of the spatial parameters
64 * \param globalPos The global position
65 */
66 Scalar porosityAtPos(const GlobalPosition& globalPos) const
67 {
68 return 0.18;
69 }
70
71 /*!
72 * \brief Returns the hydraulic conductivity \f$[m^2]\f$
73 */
74 PermeabilityType permeability(const Element& element) const
75 {
76
4/4
✓ Branch 0 taken 42294 times.
✓ Branch 1 taken 42294 times.
✓ Branch 2 taken 42294 times.
✓ Branch 3 taken 42294 times.
169176 return 1e-13;
77 }
78
79 /*!
80 * \brief Returns the temperature in the domain at the given position
81 * \param globalPos The position in global coordinates where the temperature should be specified.
82 */
83 Scalar temperatureAtPos(const GlobalPosition& globalPos) const
84 {
85 return 300.0;
86 }
87
88 template<class ElementSolution>
89 PermeabilityType permeability(const Element& element,
90 const SubControlVolume& scv,
91 const ElementSolution& elemSol) const
92 {
93 27207726 return permeability(element);
94 }
95
96 void setMaxSurfactantConcentration (Scalar c)
97 {
98
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 maxConcentration_ = c;
99 }
100
101 template<class ElementSolution>
102 18138484 auto fluidMatrixInteraction(const Element& element,
103 const SubControlVolume& scv,
104 const ElementSolution& elemSol) const
105 {
106 18138484 const auto& priVars = elemSol[scv.localDofIndex()];
107 18138484 const Scalar f = priVars[surfactantCompIdx];
108 18138484 const auto& gg = this->gridGeometry();
109
110 36276968 const auto gradP = evalGradients(
111 element, element.geometry(), gg, elemSol, scv.dofPosition(), true
112 18138484 )[0];
113
114 18138484 const Scalar gradPNorm = gradP.two_norm();
115
116 using std::cos;
117 18138484 const Scalar sigma =
118 18138484 0.5 * 0.03 * (1 - 1e-3) * cos(f * M_PI / maxConcentration_) +
119 0.5 * 0.03 * (1 + 1e-3);
120
121 72553936 const Scalar Ncv = permeability(element, scv, elemSol) * gradPNorm / sigma;
122 18138484 return MaterialLaw(Ncv, sMinKr_, sMaxKr_, srwSurf_, sroSurf_);
123 }
124
125 /*!
126 * \brief Function for defining which phase is to be considered as the wetting phase.
127 * \param globalPos The position of the center of the element
128 * \return The wetting phase index
129 */
130 template<class FluidSystem>
131 int wettingPhaseAtPos(const GlobalPosition& globalPos) const
132 {
133 return 0;
134 }
135
136 private:
137 Scalar maxConcentration_;
138 Scalar sMinKr_, sMaxKr_, srwSurf_, sroSurf_;
139 };
140
141 } // end namespace Dumux
142
143 #endif
144