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 simple Darcy test problem (cell-centered finite volume method). | ||
11 | */ | ||
12 | |||
13 | #ifndef DUMUX_DARCY_SUBPROBLEM_HH | ||
14 | #define DUMUX_DARCY_SUBPROBLEM_HH | ||
15 | |||
16 | #include <dumux/common/boundarytypes.hh> | ||
17 | #include <dumux/common/properties.hh> | ||
18 | #include <dumux/common/parameters.hh> | ||
19 | #include <dumux/common/numeqvector.hh> | ||
20 | |||
21 | #include <dumux/porousmediumflow/problem.hh> | ||
22 | |||
23 | namespace Dumux { | ||
24 | |||
25 | template <class TypeTag> | ||
26 | class DarcySubProblem : public PorousMediumFlowProblem<TypeTag> | ||
27 | { | ||
28 | using ParentType = PorousMediumFlowProblem<TypeTag>; | ||
29 | using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView; | ||
30 | using Scalar = GetPropType<TypeTag, Properties::Scalar>; | ||
31 | using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>; | ||
32 | using NumEqVector = Dumux::NumEqVector<PrimaryVariables>; | ||
33 | using BoundaryTypes = Dumux::BoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>; | ||
34 | using VolumeVariables = GetPropType<TypeTag, Properties::VolumeVariables>; | ||
35 | using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView; | ||
36 | using SubControlVolume = typename FVElementGeometry::SubControlVolume; | ||
37 | using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace; | ||
38 | using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>; | ||
39 | |||
40 | using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices; | ||
41 | |||
42 | using Element = typename GridView::template Codim<0>::Entity; | ||
43 | using GlobalPosition = typename Element::Geometry::GlobalCoordinate; | ||
44 | |||
45 | using CouplingManager = GetPropType<TypeTag, Properties::CouplingManager>; | ||
46 | |||
47 | public: | ||
48 | 2 | DarcySubProblem(std::shared_ptr<const GridGeometry> gridGeometry, | |
49 | std::shared_ptr<CouplingManager> couplingManager) | ||
50 |
6/18✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✓ Branch 17 taken 2 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
|
6 | : ParentType(gridGeometry, "Darcy"), eps_(1e-7), couplingManager_(couplingManager) |
51 | { | ||
52 |
9/26✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 2 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 2 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 2 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 2 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
|
4 | problemName_ = getParam<std::string>("Vtk.OutputName") + "_" + getParamFromGroup<std::string>(this->paramGroup(), "Problem.Name"); |
53 | |||
54 | // determine whether to simulate a vertical or horizontal flow configuration | ||
55 | 2 | verticalFlow_ = problemName_.find("vertical") != std::string::npos; | |
56 | 2 | } | |
57 | |||
58 | /*! | ||
59 | * \brief The problem name. | ||
60 | */ | ||
61 | const std::string& name() const | ||
62 | { | ||
63 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | return problemName_; |
64 | } | ||
65 | |||
66 | /*! | ||
67 | * \name Boundary conditions | ||
68 | */ | ||
69 | // \{ | ||
70 | |||
71 | /*! | ||
72 | * \brief Specifies which kind of boundary condition should be | ||
73 | * used for which equation on a given boundary control volume. | ||
74 | * | ||
75 | * \param element The element | ||
76 | * \param scvf The boundary sub control volume face | ||
77 | */ | ||
78 | 2272 | BoundaryTypes boundaryTypes(const Element &element, const SubControlVolumeFace &scvf) const | |
79 | { | ||
80 |
2/2✓ Branch 0 taken 800 times.
✓ Branch 1 taken 1472 times.
|
2272 | BoundaryTypes values; |
81 | 2272 | values.setAllNeumann(); | |
82 | |||
83 |
2/2✓ Branch 0 taken 800 times.
✓ Branch 1 taken 1472 times.
|
2272 | if (couplingManager().isCoupledEntity(CouplingManager::darcyIdx, scvf)) |
84 | values.setAllCouplingNeumann(); | ||
85 | |||
86 |
2/2✓ Branch 0 taken 1136 times.
✓ Branch 1 taken 1136 times.
|
2272 | if (verticalFlow_) |
87 | { | ||
88 |
2/2✓ Branch 0 taken 240 times.
✓ Branch 1 taken 896 times.
|
1136 | if (onLowerBoundary_(scvf.center())) |
89 | values.setAllDirichlet(); | ||
90 | } | ||
91 | |||
92 | 2272 | return values; | |
93 | } | ||
94 | |||
95 | /*! | ||
96 | * \brief Evaluates the boundary conditions for a Dirichlet control volume. | ||
97 | * | ||
98 | * \param element The element for which the Dirichlet boundary condition is set | ||
99 | * \param scvf The boundary subcontrolvolumeface | ||
100 | * | ||
101 | * For this method, the \a values parameter stores primary variables. | ||
102 | */ | ||
103 | ✗ | PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const | |
104 | { | ||
105 | 80 | return initial(element); | |
106 | } | ||
107 | |||
108 | /*! | ||
109 | * \brief Evaluates the boundary conditions for a Neumann control volume. | ||
110 | * | ||
111 | * \param element The element for which the Neumann boundary condition is set | ||
112 | * \param fvGeometry The fvGeometry | ||
113 | * \param elemVolVars The element volume variables | ||
114 | * \param elemFluxVarsCache Flux variables caches for all faces in stencil | ||
115 | * \param scvf The boundary sub control volume face | ||
116 | * | ||
117 | * For this method, the \a values variable stores primary variables. | ||
118 | */ | ||
119 | template<class ElementVolumeVariables, class ElementFluxVarsCache> | ||
120 | ✗ | NumEqVector neumann(const Element& element, | |
121 | const FVElementGeometry& fvGeometry, | ||
122 | const ElementVolumeVariables& elemVolVars, | ||
123 | const ElementFluxVarsCache& elemFluxVarsCache, | ||
124 | const SubControlVolumeFace& scvf) const | ||
125 | { | ||
126 | ✗ | NumEqVector values(0.0); | |
127 | |||
128 | ✗ | if (couplingManager().isCoupledEntity(CouplingManager::darcyIdx, scvf)) | |
129 | ✗ | values[Indices::conti0EqIdx] = couplingManager().couplingData().massCouplingCondition(element, fvGeometry, elemVolVars, scvf); | |
130 | |||
131 | ✗ | return values; | |
132 | } | ||
133 | |||
134 | // \} | ||
135 | |||
136 | /*! | ||
137 | * \name Volume terms | ||
138 | */ | ||
139 | // \{ | ||
140 | /*! | ||
141 | * \brief Evaluates the source term for all phases within a given | ||
142 | * sub control volume. | ||
143 | * | ||
144 | * \param element The element for which the source term is set | ||
145 | * \param fvGeometry The fvGeometry | ||
146 | * \param elemVolVars The element volume variables | ||
147 | * \param scv The sub control volume | ||
148 | */ | ||
149 | template<class ElementVolumeVariables> | ||
150 | ✗ | NumEqVector source(const Element &element, | |
151 | const FVElementGeometry& fvGeometry, | ||
152 | const ElementVolumeVariables& elemVolVars, | ||
153 | const SubControlVolume &scv) const | ||
154 |
1/4✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3520 times.
|
3520 | { return NumEqVector(0.0); } |
155 | |||
156 | // \} | ||
157 | |||
158 | /*! | ||
159 | * \brief Evaluates the initial value for a control volume. | ||
160 | * | ||
161 | * \param element The element | ||
162 | * | ||
163 | * For this method, the \a priVars parameter stores primary | ||
164 | * variables. | ||
165 | */ | ||
166 | ✗ | PrimaryVariables initial(const Element &element) const | |
167 | { | ||
168 | 80 | return PrimaryVariables(0.0); | |
169 | } | ||
170 | |||
171 | // \} | ||
172 | |||
173 | //! Get the coupling manager | ||
174 | const CouplingManager& couplingManager() const | ||
175 |
4/12✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 800 times.
✓ Branch 11 taken 1472 times.
✓ Branch 12 taken 800 times.
✓ Branch 13 taken 1472 times.
|
4544 | { return *couplingManager_; } |
176 | |||
177 | private: | ||
178 | |||
179 | bool onLowerBoundary_(const GlobalPosition &globalPos) const | ||
180 |
10/10✓ Branch 0 taken 240 times.
✓ Branch 1 taken 896 times.
✓ Branch 2 taken 240 times.
✓ Branch 3 taken 896 times.
✓ Branch 4 taken 240 times.
✓ Branch 5 taken 896 times.
✓ Branch 6 taken 240 times.
✓ Branch 7 taken 896 times.
✓ Branch 8 taken 240 times.
✓ Branch 9 taken 896 times.
|
5680 | { return globalPos[1] < this->gridGeometry().bBoxMin()[1] + eps_; } |
181 | |||
182 | Scalar eps_; | ||
183 | std::shared_ptr<CouplingManager> couplingManager_; | ||
184 | std::string problemName_; | ||
185 | bool verticalFlow_; | ||
186 | }; | ||
187 | |||
188 | } // end namespace Dumux | ||
189 | |||
190 | #endif | ||
191 |