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-FileCopyrightText: 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/numeqvector.hh> | ||
18 | #include <dumux/common/properties.hh> | ||
19 | #include <dumux/common/parameters.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<GetPropType<TypeTag, Properties::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 | 3 | DarcySubProblem(std::shared_ptr<const GridGeometry> gridGeometry, | |
49 | std::shared_ptr<CouplingManager> couplingManager) | ||
50 |
3/6✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 9 taken 3 times.
✗ Branch 10 not taken.
|
9 | : ParentType(gridGeometry, "Darcy"), eps_(1e-7), couplingManager_(couplingManager) |
51 | { | ||
52 |
3/6✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
|
6 | problemName_ = getParam<std::string>("Vtk.OutputName") |
53 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
3 | + "_" + getParamFromGroup<std::string>(this->paramGroup(), "Problem.Name"); |
54 | |||
55 | // determine whether to simulate a vertical or horizontal flow configuration | ||
56 | 3 | verticalFlow_ = problemName_.find("vertical") != std::string::npos; | |
57 | 3 | } | |
58 | |||
59 | /*! | ||
60 | * \brief The problem name. | ||
61 | */ | ||
62 | 3 | const std::string& name() const | |
63 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
3 | { return problemName_; } |
64 | |||
65 | /*! | ||
66 | * \name Boundary conditions | ||
67 | */ | ||
68 | // \{ | ||
69 | |||
70 | /*! | ||
71 | * \brief Specifies which kind of boundary condition should be | ||
72 | * used for which equation on a given boundary control volume. | ||
73 | * | ||
74 | * \param element The element | ||
75 | * \param scvf The boundary sub control volume face | ||
76 | */ | ||
77 | 19056 | BoundaryTypes boundaryTypes(const Element &element, const SubControlVolumeFace &scvf) const | |
78 | { | ||
79 | 19056 | BoundaryTypes values; | |
80 | 19056 | values.setAllNeumann(); | |
81 | |||
82 | 19056 | if (couplingManager().isCoupled(CouplingManager::porousMediumIndex, CouplingManager::freeFlowMassIndex, scvf)) | |
83 | values.setAllCouplingNeumann(); | ||
84 | |||
85 |
2/2✓ Branch 0 taken 18160 times.
✓ Branch 1 taken 896 times.
|
19056 | if (verticalFlow_) |
86 | { | ||
87 | 896 | if (onLowerBoundary_(scvf.center())) | |
88 | values.setAllDirichlet(); | ||
89 | } | ||
90 | |||
91 | 19056 | return values; | |
92 | } | ||
93 | |||
94 | /*! | ||
95 | * \brief Evaluates the boundary conditions for a Dirichlet control volume. | ||
96 | * | ||
97 | * \param element The element for which the Dirichlet boundary condition is set | ||
98 | * \param scvf The boundary sub-control-volume-face | ||
99 | */ | ||
100 | 60 | PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const | |
101 |
1/2✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
|
60 | { return initial(element); } |
102 | |||
103 | /*! | ||
104 | * \brief Evaluates the boundary conditions for a Neumann control volume. | ||
105 | * | ||
106 | * \param element The element for which the Neumann boundary condition is set | ||
107 | * \param fvGeometry The fvGeometry | ||
108 | * \param elemVolVars The element volume variables | ||
109 | * \param elemFluxVarsCache Flux variables caches for all faces in stencil | ||
110 | * \param scvf The boundary sub control volume face | ||
111 | */ | ||
112 | template<class ElementVolumeVariables, class ElementFluxVarsCache> | ||
113 | 12076 | NumEqVector neumann(const Element& element, | |
114 | const FVElementGeometry& fvGeometry, | ||
115 | const ElementVolumeVariables& elemVolVars, | ||
116 | const ElementFluxVarsCache& elemFluxVarsCache, | ||
117 | const SubControlVolumeFace& scvf) const | ||
118 | { | ||
119 | 12076 | NumEqVector values(0.0); | |
120 | |||
121 |
2/2✓ Branch 1 taken 5480 times.
✓ Branch 2 taken 6596 times.
|
12076 | if (couplingManager().isCoupled(CouplingManager::porousMediumIndex, CouplingManager::freeFlowMassIndex, scvf)) |
122 | 5480 | values[Indices::conti0EqIdx] = couplingManager().massCouplingCondition( | |
123 | CouplingManager::porousMediumIndex, CouplingManager::freeFlowMassIndex, | ||
124 | fvGeometry, scvf, elemVolVars | ||
125 | ); | ||
126 | |||
127 | 12076 | return values; | |
128 | } | ||
129 | |||
130 | // \} | ||
131 | |||
132 | /*! | ||
133 | * \brief Evaluates the initial value for a control volume. | ||
134 | * \param element The element | ||
135 | */ | ||
136 | 460 | PrimaryVariables initial(const Element &element) const | |
137 | { | ||
138 | 460 | PrimaryVariables values(0.0); | |
139 |
1/2✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
|
460 | values = initialPressure_; |
140 | return values; | ||
141 | } | ||
142 | |||
143 | // \} | ||
144 | |||
145 | //! Get the coupling manager | ||
146 | 36612 | const CouplingManager& couplingManager() const | |
147 | 36612 | { return *couplingManager_; } | |
148 | |||
149 | private: | ||
150 | |||
151 |
2/2✓ Branch 0 taken 716 times.
✓ Branch 1 taken 180 times.
|
896 | bool onLowerBoundary_(const GlobalPosition &globalPos) const |
152 |
2/2✓ Branch 0 taken 716 times.
✓ Branch 1 taken 180 times.
|
896 | { return globalPos[1] < this->gridGeometry().bBoxMin()[1] + eps_; } |
153 | |||
154 | Scalar eps_; | ||
155 | std::shared_ptr<CouplingManager> couplingManager_; | ||
156 | std::string problemName_; | ||
157 | bool verticalFlow_; | ||
158 | Scalar initialPressure_; | ||
159 | }; | ||
160 | |||
161 | } // end namespace Dumux | ||
162 | |||
163 | #endif | ||
164 |