3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
1p2c_1p2c/problem_darcy.hh
Go to the documentation of this file.
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 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
25#ifndef DUMUX_DARCY_SUBPROBLEM_HH
26#define DUMUX_DARCY_SUBPROBLEM_HH
27
28#include <dune/grid/yaspgrid.hh>
29
31
34
35#include "spatialparams.hh"
36
40
41namespace Dumux {
42template <class TypeTag>
43class DarcySubProblem;
44
45namespace Properties {
46// Create new type tags
47namespace TTag {
48struct DarcyOnePTwoC { using InheritsFrom = std::tuple<OnePNC, CCTpfaModel>; };
49} // end namespace TTag
50
51// Set the problem property
52template<class TypeTag>
53struct Problem<TypeTag, TTag::DarcyOnePTwoC> { using type = Dumux::DarcySubProblem<TypeTag>; };
54
55// The fluid system
56template<class TypeTag>
57struct FluidSystem<TypeTag, TTag::DarcyOnePTwoC>
58{
60 static constexpr auto phaseIdx = H2OAir::liquidPhaseIdx; // simulate the water phase
62};
63
64// Use moles
65template<class TypeTag>
66struct UseMoles<TypeTag, TTag::DarcyOnePTwoC> { static constexpr bool value = true; };
67
68// Do not replace one equation with a total mass balance
69template<class TypeTag>
70struct ReplaceCompEqIdx<TypeTag, TTag::DarcyOnePTwoC> { static constexpr int value = 3; };
71
73template<class TypeTag>
74struct EffectiveDiffusivityModel<TypeTag, TTag::DarcyOnePTwoC>
76
77// Set the grid type
78template<class TypeTag>
79struct Grid<TypeTag, TTag::DarcyOnePTwoC> { using type = Dune::YaspGrid<2>; };
80
81// Set the spatial paramaters type
82template<class TypeTag>
83struct SpatialParams<TypeTag, TTag::DarcyOnePTwoC>
84{
88};
89} // end namespace Dumux
90
91template <class TypeTag>
92class DarcySubProblem : public PorousMediumFlowProblem<TypeTag>
93{
94 using ParentType = PorousMediumFlowProblem<TypeTag>;
96 using GridView = typename GridGeometry::GridView;
101 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
102 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
103 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
104 using Element = typename GridView::template Codim<0>::Entity;
106
107 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
108
110 using TimeLoopPtr = std::shared_ptr<TimeLoop<Scalar>>;
111
112public:
113 DarcySubProblem(std::shared_ptr<const GridGeometry> gridGeometry,
114 std::shared_ptr<CouplingManager> couplingManager)
115 : ParentType(gridGeometry, "Darcy"), eps_(1e-7), couplingManager_(couplingManager)
116 {
117 problemName_ = getParam<std::string>("Vtk.OutputName") + "_" + getParamFromGroup<std::string>(this->paramGroup(), "Problem.Name");
118
119 // determine whether to simulate a vertical or horizontal flow configuration
120 verticalFlow_ = problemName_.find("vertical") != std::string::npos;
121 }
122
126 const std::string& name() const
127 {
128 return problemName_;
129 }
130
135 Scalar temperature() const
136 { return 273.15 + 10; } // 10°C
137 // \}
138
142 // \{
143
151 BoundaryTypes boundaryTypes(const Element& element, const SubControlVolumeFace& scvf) const
152 {
153 BoundaryTypes values;
154 values.setAllNeumann();
155
156 if (couplingManager().isCoupledEntity(CouplingManager::darcyIdx, scvf))
157 values.setAllCouplingNeumann();
158
159 if (verticalFlow_)
160 {
161 if (onLowerBoundary_(scvf.center()))
162 values.setAllDirichlet();
163 }
164
165 return values;
166 }
167
175 PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const
176 {
177 PrimaryVariables values(0.0);
178 values = initial(element);
179
180 if (verticalFlow_)
181 {
182 // Check if this a pure diffusion problem.
183 static const bool isDiffusionProblem = problemName_.find("diffusion") != std::string::npos;
184
185 Scalar bottomMoleFraction = 0.0;
186
187 if (isDiffusionProblem)
188 {
189 // For the diffusion problem, change the top mole fraction after some time
190 // in order to revert the concentration gradient.
191 if (time() >= 1e10)
192 bottomMoleFraction = 1e-3;
193 }
194
195 if(onLowerBoundary_(scvf.center()))
196 values[Indices::conti0EqIdx + 1] = bottomMoleFraction;
197 }
198
199 return values;
200 }
201
213 template<class ElementVolumeVariables, class ElementFluxVarsCache>
214 NumEqVector neumann(const Element& element,
215 const FVElementGeometry& fvGeometry,
216 const ElementVolumeVariables& elemVolVars,
217 const ElementFluxVarsCache& elemFluxVarsCache,
218 const SubControlVolumeFace& scvf) const
219 {
220 NumEqVector values(0.0);
221
222 if (couplingManager().isCoupledEntity(CouplingManager::darcyIdx, scvf))
223 values = couplingManager().couplingData().massCouplingCondition(element, fvGeometry, elemVolVars, scvf);
224
225 return values;
226 }
227
228 // \}
229
233 // \{
243 template<class ElementVolumeVariables>
244 NumEqVector source(const Element &element,
245 const FVElementGeometry& fvGeometry,
246 const ElementVolumeVariables& elemVolVars,
247 const SubControlVolume &scv) const
248 { return NumEqVector(0.0); }
249
250 // \}
251
260 PrimaryVariables initial(const Element &element) const
261 {
262 PrimaryVariables values(0.0);
263 values[Indices::pressureIdx] = 1e5;
264
265 return values;
266 }
267
268 // \}
269
271 const CouplingManager& couplingManager() const
272 { return *couplingManager_; }
273
277 void setTimeLoop(TimeLoopPtr timeLoop)
278 { timeLoop_ = timeLoop; }
279
283 Scalar time() const
284 { return timeLoop_->time(); }
285
286private:
287 bool onLeftBoundary_(const GlobalPosition &globalPos) const
288 { return globalPos[0] < this->gridGeometry().bBoxMin()[0] + eps_; }
289
290 bool onRightBoundary_(const GlobalPosition &globalPos) const
291 { return globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_; }
292
293 bool onLowerBoundary_(const GlobalPosition &globalPos) const
294 { return globalPos[1] < this->gridGeometry().bBoxMin()[1] + eps_; }
295
296 bool onUpperBoundary_(const GlobalPosition &globalPos) const
297 { return globalPos[1] > this->gridGeometry().bBoxMax()[1] - eps_; }
298
299 Scalar eps_;
300 std::string problemName_;
301 bool verticalFlow_;
302 std::shared_ptr<CouplingManager> couplingManager_;
303 TimeLoopPtr timeLoop_;
304};
305} // end namespace Dumux
306
307#endif //DUMUX_DARCY_SUBPROBLEM_HH
Properties for all models using cell-centered finite volume scheme with TPFA.
Relation for the saturation-dependent effective diffusion coefficient.
An adapter for multi-phase fluid systems to be used with (compositional) one-phase models.
A compositional two-phase fluid system with water and air as components in both, the liquid and the g...
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:149
Class to specify the type of a boundary.
Definition: common/boundarytypes.hh:38
Base class for all finite-volume problems.
Definition: common/fvproblem.hh:50
const std::string & paramGroup() const
The parameter group in which to retrieve runtime parameters.
Definition: common/fvproblem.hh:592
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition: common/fvproblem.hh:588
The DUNE grid type.
Definition: common/properties.hh:57
Property to specify the type of a problem which has to be solved.
Definition: common/properties.hh:69
Property whether to use moles or kg as amount unit for balance equations.
Definition: common/properties.hh:102
The type of the spatial parameters object.
Definition: common/properties.hh:221
The type of the fluid system to use.
Definition: common/properties.hh:223
Relation for the saturation-dependent effective diffusion coefficient.
Definition: diffusivityconstanttortuosity.hh:49
An adapter for multi-phase fluid systems to be used with (compositional) one-phase models.
Definition: 1padapter.hh:46
A compositional two-phase fluid system with water and air as components in both, the liquid and the g...
Definition: h2oair.hh:75
Definition: multidomain/couplingmanager.hh:46
Base class for all fully implicit porous media problems.
Definition: dumux/porousmediumflow/problem.hh:39
Definition: 1p_2p/problem_darcy.hh:79
Scalar time() const
Returns the time.
Definition: 1p2c_1p2c/problem_darcy.hh:283
const CouplingManager & couplingManager() const
Get the coupling manager.
Definition: 1p2c_1p2c/diffusionlawcomparison/problem_darcy.hh:266
PrimaryVariables initial(const Element &element) const
Evaluates the initial value for a control volume.
Definition: 1p2c_1p2c/diffusionlawcomparison/problem_darcy.hh:254
DarcySubProblem(std::shared_ptr< const GridGeometry > gridGeometry, std::shared_ptr< CouplingManager > couplingManager)
Definition: 1p2c_1p2c/problem_darcy.hh:113
void setTimeLoop(TimeLoopPtr timeLoop)
Sets the time loop pointer.
Definition: 1p2c_1p2c/problem_darcy.hh:277
NumEqVector neumann(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const ElementFluxVarsCache &elemFluxVarsCache, const SubControlVolumeFace &scvf) const
Evaluates the boundary conditions for a Neumann control volume.
Definition: 1p2c_1p2c/problem_darcy.hh:214
PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const
Evaluates the boundary conditions for a Dirichlet control volume.
Definition: 1p2c_1p2c/problem_darcy.hh:175
Scalar temperature() const
Returns the temperature within the domain in [K].
Definition: 1p2c_1p2c/problem_darcy.hh:135
BoundaryTypes boundaryTypes(const Element &element, const SubControlVolumeFace &scvf) const
Specifies which kind of boundary condition should be used for which equation on a given boundary cont...
Definition: 1p2c_1p2c/problem_darcy.hh:151
const std::string & name() const
The problem name.
Definition: 1p2c_1p2c/problem_darcy.hh:126
NumEqVector source(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolume &scv) const
Evaluates the source term for all phases within a given sub control volume.
Definition: 1p2c_1p2c/problem_darcy.hh:244
Definition: 1p2c_1p2c/diffusionlawcomparison/problem_darcy.hh:57
std::tuple< OnePNC, CCTpfaModel > InheritsFrom
Definition: 1p2c_1p2c/diffusionlawcomparison/problem_darcy.hh:57
Dune::YaspGrid< 2 > type
Definition: 1p2c_1p2c/diffusionlawcomparison/problem_darcy.hh:88
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: 1p2c_1p2c/diffusionlawcomparison/problem_darcy.hh:99
GetPropType< TypeTag, Properties::GridGeometry > GridGeometry
Definition: 1p2c_1p2c/diffusionlawcomparison/problem_darcy.hh:98
The spatial parameters class for the test problem using the 1p cc model.
Definition: multidomain/boundary/stokesdarcy/1p2c_1p2c/spatialparams.hh:41
Adaption of the fully implicit model to the one-phase n-component flow model.
Base class for all porous media problems.
Definition of the spatial parameters for the MaxwellStefan problem.