GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/multidomain/boundary/stokesdarcy/1p3c_1p3c/problem_darcy.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 22 25 88.0%
Functions: 3 5 60.0%
Branches: 23 38 60.5%

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 BoundaryTests
10 * \brief A Darcy test problem using Maxwell-Stefan diffusion.
11 */
12
13 #ifndef DUMUX_DARCY_SUBPROBLEM_ONEPTHREEC_HH
14 #define DUMUX_DARCY_SUBPROBLEM_ONEPTHREEC_HH
15
16 #include <dumux/common/boundarytypes.hh>
17 #include <dumux/common/numeqvector.hh>
18
19 #include <dumux/multidomain/boundary/stokesdarcy/couplingdata.hh>
20 #include <dumux/flux/maxwellstefanslaw.hh>
21
22 #include <dumux/material/fluidmatrixinteractions/diffusivityconstanttortuosity.hh>
23 #include <dumux/porousmediumflow/problem.hh>
24
25 #include "../1p2c_1p2c/spatialparams.hh"
26
27 namespace Dumux {
28
29 template <class TypeTag>
30 class DarcySubProblem;
31
32 template <class TypeTag>
33 class DarcySubProblem : public PorousMediumFlowProblem<TypeTag>
34 {
35 using ParentType = PorousMediumFlowProblem<TypeTag>;
36 using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView;
37 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
38 using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
39 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
40 using NumEqVector = Dumux::NumEqVector<PrimaryVariables>;
41 using BoundaryTypes = Dumux::BoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>;
42 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
43 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
44 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
45 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
46 using DiffusionCoefficientAveragingType = typename StokesDarcyCouplingOptions::DiffusionCoefficientAveragingType;
47
48 // copy some indices for convenience
49 using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
50 enum {
51 // grid and world dimension
52 dim = GridView::dimension,
53 dimworld = GridView::dimensionworld,
54
55 // primary variable indices
56 conti0EqIdx = Indices::conti0EqIdx,
57 pressureIdx = Indices::pressureIdx,
58 };
59
60 using Element = typename GridView::template Codim<0>::Entity;
61 using GlobalPosition = Dune::FieldVector<Scalar, dimworld>;
62
63 using CouplingManager = GetPropType<TypeTag, Properties::CouplingManager>;
64
65 public:
66 1 DarcySubProblem(std::shared_ptr<const GridGeometry> gridGeometry,
67 std::shared_ptr<CouplingManager> couplingManager)
68
5/16
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
3 : ParentType(gridGeometry, "Darcy"), eps_(1e-7), couplingManager_(couplingManager)
69 {
70
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 pressure_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.Pressure");
71
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 initialMoleFractionN2_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.InitialMoleFractionN2");
72
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 initialMoleFractionCO2_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.InitialMoleFractionCO2");
73 1 }
74
75 /*!
76 * \name Boundary conditions
77 */
78 // \{
79
80 /*!
81 * \brief Specifies which kind of boundary condition should be
82 * used for which equation on a given boundary control volume.
83 *
84 * \param element The element
85 * \param scvf The boundary sub control volume face
86 */
87 27664 BoundaryTypes boundaryTypes(const Element &element, const SubControlVolumeFace &scvf) const
88 {
89 27664 BoundaryTypes values;
90 27664 values.setAllNeumann();
91
92
2/2
✓ Branch 0 taken 11440 times.
✓ Branch 1 taken 16224 times.
27664 if (couplingManager().isCoupledEntity(CouplingManager::darcyIdx, scvf))
93 values.setAllCouplingNeumann();
94
95
96 27664 return values;
97 }
98
99 /*!
100 * \brief Evaluates the boundary conditions for a Neumann control volume.
101 *
102 * \param element The element for which the Neumann boundary condition is set
103 * \param fvGeometry The fvGeometry
104 * \param elemVolVars The element volume variables
105 * \param elemFluxVarsCache Flux variables caches for all faces in stencil
106 * \param scvf The boundary sub control volume face
107 *
108 * For this method, the \a values variable stores primary variables.
109 */
110 template<class ElementVolumeVariables, class ElementFluxVarsCache>
111 23504 NumEqVector neumann(const Element& element,
112 const FVElementGeometry& fvGeometry,
113 const ElementVolumeVariables& elemVolVars,
114 const ElementFluxVarsCache& elemFluxVarsCache,
115 const SubControlVolumeFace& scvf) const
116 {
117 23504 NumEqVector values(0.0);
118
119
2/2
✓ Branch 0 taken 10400 times.
✓ Branch 1 taken 13104 times.
23504 if (couplingManager().isCoupledEntity(couplingManager().darcyIdx, scvf))
120 10400 values = couplingManager().couplingData().massCouplingCondition(element, fvGeometry, elemVolVars, scvf, DiffusionCoefficientAveragingType::harmonic);
121
122 23504 return values;
123 }
124
125 // \}
126
127 /*!
128 * \name Volume terms
129 */
130 // \{
131 /*!
132 * \brief Evaluates the source term for all phases within a given
133 * sub control volume.
134 *
135 * \param element The element for which the source term is set
136 * \param fvGeometry The fvGeometry
137 * \param elemVolVars The element volume variables
138 * \param scv The sub control volume
139 */
140 template<class ElementVolumeVariables>
141 NumEqVector source(const Element &element,
142 const FVElementGeometry& fvGeometry,
143 const ElementVolumeVariables& elemVolVars,
144 const SubControlVolume &scv) const
145 89440 { return NumEqVector(0.0); }
146
147 // \}
148
149 /*!
150 * \brief Evaluates the initial value for a control volume.
151 *
152 * For this method, the \a priVars parameter stores primary
153 * variables.
154 */
155 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
156 {
157 400 PrimaryVariables values(0.0);
158 400 values[pressureIdx] = pressure_;
159 400 values[conti0EqIdx + 1] = initialMoleFractionN2_;
160 800 values[conti0EqIdx + 2] = initialMoleFractionCO2_;
161
162 return values;
163 }
164
165 // \}
166
167 //! Get the coupling manager
168 const CouplingManager& couplingManager() const
169
10/10
✓ Branch 0 taken 10400 times.
✓ Branch 1 taken 13104 times.
✓ Branch 2 taken 10400 times.
✓ Branch 3 taken 13104 times.
✓ Branch 4 taken 10400 times.
✓ Branch 5 taken 13104 times.
✓ Branch 8 taken 11440 times.
✓ Branch 9 taken 16224 times.
✓ Branch 10 taken 11440 times.
✓ Branch 11 taken 16224 times.
125840 { return *couplingManager_; }
170
171 private:
172 bool onLeftBoundary_(const GlobalPosition &globalPos) const
173 { return globalPos[0] < this->gridGeometry().bBoxMin()[0] + eps_; }
174
175 bool onRightBoundary_(const GlobalPosition &globalPos) const
176 { return globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_; }
177
178 bool onLowerBoundary_(const GlobalPosition &globalPos) const
179 { return globalPos[1] < this->gridGeometry().bBoxMin()[1] + eps_; }
180
181 bool onUpperBoundary_(const GlobalPosition &globalPos) const
182 { return globalPos[1] > this->gridGeometry().bBoxMax()[1] - eps_; }
183
184 Scalar eps_;
185 Scalar pressure_;
186 Scalar initialMoleFractionN2_;
187 Scalar initialMoleFractionCO2_;
188
189
190 std::shared_ptr<CouplingManager> couplingManager_;
191 };
192 } // end namespace Dumux
193
194 #endif
195