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 Pore-network sub-problem for the coupled 1p2c_1p2c free-flow/pore-network-model test | ||
11 | */ | ||
12 | |||
13 | #ifndef DUMUX_TEST_MULTIDOMAIN_BOUNDARY_FREEFLOW_PORE_NETWORK_ONEPTWOC_PROBLEM_PNM_HH | ||
14 | #define DUMUX_TEST_MULTIDOMAIN_BOUNDARY_FREEFLOW_PORE_NETWORK_ONEPTWOC_PROBLEM_PNM_HH | ||
15 | |||
16 | #include <dumux/common/boundarytypes.hh> | ||
17 | #include <dumux/common/numeqvector.hh> | ||
18 | #include <dumux/common/properties.hh> | ||
19 | #include <dumux/common/parameters.hh> | ||
20 | #include <dumux/porousmediumflow/problem.hh> | ||
21 | |||
22 | namespace Dumux { | ||
23 | |||
24 | /*! | ||
25 | * \ingroup BoundaryTests | ||
26 | * \brief Pore-network sub-problem for the coupled 1p_1p free-flow/pore-network-model test | ||
27 | * A two-dimensional pore-network region coupled to a free-flow model. | ||
28 | */ | ||
29 | template <class TypeTag> | ||
30 | class PNMOnePNCProblem : public PorousMediumFlowProblem<TypeTag> | ||
31 | { | ||
32 | using ParentType = PorousMediumFlowProblem<TypeTag>; | ||
33 | using Scalar = GetPropType<TypeTag, Properties::Scalar>; | ||
34 | using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>; | ||
35 | using BoundaryTypes = Dumux::BoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>; | ||
36 | using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView; | ||
37 | using SubControlVolume = typename FVElementGeometry::SubControlVolume; | ||
38 | using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>; | ||
39 | using Element = typename GridGeometry::GridView::template Codim<0>::Entity; | ||
40 | using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices; | ||
41 | using CouplingManager = GetPropType<TypeTag, Properties::CouplingManager>; | ||
42 | |||
43 | using GlobalPosition = typename Element::Geometry::GlobalCoordinate; | ||
44 | |||
45 | public: | ||
46 | template<class SpatialParams> | ||
47 | 3 | PNMOnePNCProblem(std::shared_ptr<const GridGeometry> gridGeometry, | |
48 | std::shared_ptr<SpatialParams> spatialParams, | ||
49 | std::shared_ptr<CouplingManager> couplingManager) | ||
50 |
3/8✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
|
12 | : ParentType(gridGeometry, spatialParams, "PNM"), couplingManager_(couplingManager) |
51 | { | ||
52 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
3 | initialPressure_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.InitialPressure", 1e5); |
53 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
3 | initialMoleFraction_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.InitialMoleFraction", 2e-3); |
54 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
3 | onlyDiffusion_ = getParam<bool>("Problem.OnlyDiffusion", false); |
55 | #if !ISOTHERMAL | ||
56 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | initialTemperature_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.InitialTemperature", 273.15 + 20); |
57 | #endif | ||
58 | 3 | } | |
59 | |||
60 | /*! | ||
61 | * \name Simulation steering | ||
62 | */ | ||
63 | // \{ | ||
64 | |||
65 | /*! | ||
66 | * \name Problem parameters | ||
67 | */ | ||
68 | // \{ | ||
69 | |||
70 | 3 | const std::string& name() const | |
71 | { | ||
72 |
5/10✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 3 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 3 times.
✗ Branch 13 not taken.
|
6 | static const std::string problemName = getParam<std::string>("Vtk.OutputName") + "_" + getParamFromGroup<std::string>(this->paramGroup(), "Problem.Name"); |
73 | 3 | return problemName; | |
74 | } | ||
75 | |||
76 | // \} | ||
77 | |||
78 | /*! | ||
79 | * \name Boundary conditions | ||
80 | */ | ||
81 | // \{ | ||
82 | |||
83 | /*! | ||
84 | * \brief Specifies which kind of boundary condition should be used for | ||
85 | * which equation for a finite volume on the boundary. | ||
86 | */ | ||
87 | 266 | BoundaryTypes boundaryTypes(const Element& element, const SubControlVolume& scv) const | |
88 | { | ||
89 | 266 | BoundaryTypes bcTypes; | |
90 |
2/2✓ Branch 0 taken 133 times.
✓ Branch 1 taken 133 times.
|
266 | if (couplingManager().isCoupled(CouplingManager::poreNetworkIndex, CouplingManager::freeFlowMassIndex, scv)) |
91 | 266 | bcTypes.setAllCouplingNeumann(); | |
92 |
1/2✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
|
133 | else if (onLowerBoundary_(scv)) |
93 | { | ||
94 |
2/2✓ Branch 0 taken 40 times.
✓ Branch 1 taken 93 times.
|
133 | if (!onlyDiffusion_ ) |
95 | 219 | bcTypes.setAllDirichlet(); | |
96 | else | ||
97 | 219 | bcTypes.setAllNeumann(); | |
98 | #if !ISOTHERMAL | ||
99 | 47 | bcTypes.setDirichlet(Indices::temperatureIdx); | |
100 | #endif | ||
101 | } | ||
102 | |||
103 | 266 | return bcTypes; | |
104 | } | ||
105 | |||
106 | /*! | ||
107 | * \brief Evaluate the boundary conditions for a dirichlet | ||
108 | * control volume. | ||
109 | */ | ||
110 | 93 | PrimaryVariables dirichlet(const Element& element, | |
111 | const SubControlVolume& scv) const | ||
112 | { | ||
113 | 93 | return initialAtPos(scv.dofPosition()); | |
114 | } | ||
115 | |||
116 | // \} | ||
117 | |||
118 | /*! | ||
119 | * \name Volume terms | ||
120 | */ | ||
121 | // \{ | ||
122 | |||
123 | /*! | ||
124 | * \brief Evaluate the source term for all phases within a given | ||
125 | * sub-control-volume. | ||
126 | * | ||
127 | * This is the method for the case where the source term is | ||
128 | * potentially solution dependent and requires some quantities that | ||
129 | * are specific to the fully-implicit method. | ||
130 | * | ||
131 | * \param element The finite element | ||
132 | * \param fvGeometry The finite-volume geometry | ||
133 | * \param elemVolVars All volume variables for the element | ||
134 | * \param scv The sub control volume | ||
135 | * | ||
136 | * For this method, the return parameter stores the conserved quantity rate | ||
137 | * generated or annihilate per volume unit. Positive values mean | ||
138 | * that the conserved quantity is created, negative ones mean that it vanishes. | ||
139 | * E.g. for the mass balance that would be a mass rate in \f$ [ kg / (m^3 \cdot s)] \f$. | ||
140 | */ | ||
141 | template<class ElementVolumeVariables> | ||
142 | 5790 | PrimaryVariables source(const Element &element, | |
143 | const FVElementGeometry& fvGeometry, | ||
144 | const ElementVolumeVariables& elemVolVars, | ||
145 | const SubControlVolume &scv) const | ||
146 | { | ||
147 | 5790 | PrimaryVariables values(0.0); | |
148 | |||
149 |
2/2✓ Branch 0 taken 2895 times.
✓ Branch 1 taken 2895 times.
|
5790 | if (couplingManager().isCoupled(CouplingManager::poreNetworkIndex, CouplingManager::freeFlowMassIndex, scv)) |
150 | { | ||
151 | 2895 | const auto& massCouplingCondition = couplingManager().massCouplingCondition( | |
152 | CouplingManager::poreNetworkIndex, CouplingManager::freeFlowMassIndex, | ||
153 | fvGeometry, scv, elemVolVars | ||
154 | ); | ||
155 | 2895 | values[Indices::conti0EqIdx] = massCouplingCondition[Indices::conti0EqIdx]; | |
156 | 2895 | values[Indices::conti0EqIdx + 1] = massCouplingCondition[Indices::conti0EqIdx + 1]; | |
157 | #if !ISOTHERMAL | ||
158 | 1175 | values[Indices::energyEqIdx] = couplingManager().energyCouplingCondition( | |
159 | CouplingManager::poreNetworkIndex, | ||
160 | CouplingManager::freeFlowMassIndex, fvGeometry, | ||
161 | scv, | ||
162 | elemVolVars); | ||
163 | #endif | ||
164 | } | ||
165 | 5790 | values /= this->gridGeometry().poreVolume(scv.dofIndex()); | |
166 | |||
167 | 5790 | return values; | |
168 | } | ||
169 | |||
170 | /*! | ||
171 | * \brief Evaluate the initial value for a given global position. | ||
172 | * | ||
173 | * For this method, the \a priVars parameter stores primary | ||
174 | * variables. | ||
175 | */ | ||
176 | 99 | PrimaryVariables initialAtPos(const GlobalPosition& pos) const | |
177 | { | ||
178 | 50 | PrimaryVariables values(0.0); | |
179 | 99 | values[Indices::pressureIdx] = initialPressure_; | |
180 | 99 | values[Indices::conti0EqIdx + 1] = initialMoleFraction_; | |
181 | |||
182 | #if !ISOTHERMAL | ||
183 | 49 | values[Indices::temperatureIdx] = initialTemperature_; | |
184 | #endif | ||
185 | return values; | ||
186 | } | ||
187 | |||
188 | //! Set the coupling manager | ||
189 | void setCouplingManager(std::shared_ptr<CouplingManager> cm) | ||
190 | { couplingManager_ = cm; } | ||
191 | |||
192 | //! Get the coupling manager | ||
193 | 7231 | const CouplingManager& couplingManager() const | |
194 |
5/5✓ Branch 0 taken 2895 times.
✓ Branch 1 taken 2895 times.
✓ Branch 4 taken 133 times.
✓ Branch 5 taken 47 times.
✓ Branch 3 taken 86 times.
|
6056 | { return *couplingManager_; } |
195 | |||
196 | private: | ||
197 | 133 | bool onLowerBoundary_(const SubControlVolume& scv) const | |
198 |
1/2✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
|
133 | { return this->gridGeometry().poreLabel(scv.dofIndex()) == 2; } |
199 | |||
200 | Scalar initialPressure_; | ||
201 | Scalar initialMoleFraction_; | ||
202 | bool onlyDiffusion_; | ||
203 | #if !ISOTHERMAL | ||
204 | Scalar initialTemperature_; | ||
205 | #endif | ||
206 | std::shared_ptr<CouplingManager> couplingManager_; | ||
207 | }; | ||
208 | |||
209 | } // end namespace Dumux | ||
210 | |||
211 | #endif | ||
212 |