3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
1p2c_2p2c/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_DARCY2P2C_SUBPROBLEM_HH
26#define DUMUX_DARCY2P2C_SUBPROBLEM_HH
27
28#include <dune/grid/yaspgrid.hh>
29
32
35
37
38#include "spatialparams.hh"
39
40namespace Dumux {
41template <class TypeTag>
42class DarcySubProblem;
43
44namespace Properties {
45// Create new type tags
46namespace TTag {
47#if !NONISOTHERMAL
48struct DarcyTwoPTwoC { using InheritsFrom = std::tuple<TwoPTwoC, CCTpfaModel>; };
49#else
50struct DarcyTwoPTwoC { using InheritsFrom = std::tuple<TwoPTwoCNI, CCTpfaModel>; };
51#endif
52} // end namespace TTag
53
54// Set the problem property
55template<class TypeTag>
56struct Problem<TypeTag, TTag::DarcyTwoPTwoC> { using type = Dumux::DarcySubProblem<TypeTag>; };
57
58// the fluid system
59template<class TypeTag>
60struct FluidSystem<TypeTag, TTag::DarcyTwoPTwoC> { using type = FluidSystems::H2OAir<GetPropType<TypeTag, Properties::Scalar>>; };
61
63template<class TypeTag>
64struct Formulation<TypeTag, TTag::DarcyTwoPTwoC>
65{ static constexpr auto value = TwoPFormulation::p1s0; };
66
68template<class TypeTag>
69struct ReplaceCompEqIdx<TypeTag, TTag::DarcyTwoPTwoC> { static constexpr int value = 3; };
70
71// Set the grid type
72template<class TypeTag>
73struct Grid<TypeTag, TTag::DarcyTwoPTwoC> { using type = Dune::YaspGrid<2, Dune::TensorProductCoordinates<GetPropType<TypeTag, Properties::Scalar>, 2> >; };
74
75template<class TypeTag>
76struct UseMoles<TypeTag, TTag::DarcyTwoPTwoC> { static constexpr bool value = true; };
77
78template<class TypeTag>
79struct SpatialParams<TypeTag, TTag::DarcyTwoPTwoC>
80{
84};
85
86} // end namespace Properties
87
88template <class TypeTag>
89class DarcySubProblem : public PorousMediumFlowProblem<TypeTag>
90{
91 using ParentType = PorousMediumFlowProblem<TypeTag>;
98 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
99 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
100 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
103 using ElementVolumeVariables = typename GridVariables::GridVolumeVariables::LocalView;
104 using ElementFluxVariablesCache = typename GridVariables::GridFluxVariablesCache::LocalView;
105
107
108 // copy some indices for convenience
110 enum {
111 // primary variable indices
112 conti0EqIdx = Indices::conti0EqIdx,
113 contiWEqIdx = Indices::conti0EqIdx + FluidSystem::H2OIdx,
114 contiNEqIdx = Indices::conti0EqIdx + FluidSystem::AirIdx,
115 pressureIdx = Indices::pressureIdx,
116 switchIdx = Indices::switchIdx
117 };
118
119 using Element = typename GridView::template Codim<0>::Entity;
120 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
121
122 using CouplingManager = GetPropType<TypeTag, Properties::CouplingManager>;
123
124 using DiffusionCoefficientAveragingType = typename StokesDarcyCouplingOptions::DiffusionCoefficientAveragingType;
125
126public:
127 DarcySubProblem(std::shared_ptr<const GridGeometry> gridGeometry,
128 std::shared_ptr<CouplingManager> couplingManager)
129 : ParentType(gridGeometry, "Darcy"), eps_(1e-7), couplingManager_(couplingManager)
130 {
131 pressure_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.Pressure");
132 initialSw_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.Saturation");
133 temperature_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.Temperature");
134 initialPhasePresence_ = getParamFromGroup<int>(this->paramGroup(), "Problem.InitPhasePresence");
135
136 diffCoeffAvgType_ = StokesDarcyCouplingOptions::stringToEnum(DiffusionCoefficientAveragingType{},
137 getParamFromGroup<std::string>(this->paramGroup(), "Problem.InterfaceDiffusionCoefficientAvg"));
138 problemName_ = getParam<std::string>("Vtk.OutputName") + "_" + getParamFromGroup<std::string>(this->paramGroup(), "Problem.Name");
139 }
140
144 const std::string& name() const
145 {
146 return problemName_;
147 }
148
152 // \{
153
154 template<class SolutionVector, class GridVariables>
155 void printWaterMass(const SolutionVector& curSol,
156 const GridVariables& gridVariables,
157 const Scalar timeStepSize)
158
159 {
160 // compute the mass in the entire domain
161 Scalar massWater = 0.0;
162
163 // bulk elements
164 for (const auto& element : elements(this->gridGeometry().gridView()))
165 {
166 auto fvGeometry = localView(this->gridGeometry());
167 fvGeometry.bindElement(element);
168
169 auto elemVolVars = localView(gridVariables.curGridVolVars());
170 elemVolVars.bindElement(element, fvGeometry, curSol);
171
172 for (auto&& scv : scvs(fvGeometry))
173 {
174 const auto& volVars = elemVolVars[scv];
175 for(int phaseIdx = 0; phaseIdx < FluidSystem::numPhases; ++phaseIdx)
176 {
177 massWater += volVars.massFraction(phaseIdx, FluidSystem::H2OIdx)*volVars.density(phaseIdx)
178 * scv.volume() * volVars.saturation(phaseIdx) * volVars.porosity() * volVars.extrusionFactor();
179 }
180 }
181 }
182
183 std::cout << std::setprecision(15) << "mass of water is: " << massWater << std::endl;
184 }
185
190 { return false; }
191
195 // \{
196
197 bool shouldWriteOutput() const //define output
198 { return true; }
199
203 Scalar temperature() const
204 { return temperature_; }
205 // \}
206
210 // \{
218 BoundaryTypes boundaryTypes(const Element &element, const SubControlVolumeFace &scvf) const
219 {
220 BoundaryTypes values;
221 values.setAllNeumann();
222
223 if (couplingManager().isCoupledEntity(CouplingManager::darcyIdx, scvf))
224 values.setAllCouplingNeumann();
225
226 return values;
227 }
228
237 PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const
238 {
239 PrimaryVariables values(0.0);
240 values = initialAtPos(scvf.center());
241
242 return values;
243 }
244
254 NumEqVector neumann(const Element& element,
255 const FVElementGeometry& fvGeometry,
256 const ElementVolumeVariables& elemVolVars,
257 const ElementFluxVariablesCache& elemFluxVarsCache,
258 const SubControlVolumeFace& scvf) const
259 {
260 NumEqVector values(0.0);
261
262 if (couplingManager().isCoupledEntity(CouplingManager::darcyIdx, scvf))
263 {
264#if !NONISOTHERMAL
265 values = couplingManager().couplingData().massCouplingCondition(element, fvGeometry, elemVolVars, scvf, diffCoeffAvgType_);
266#else
267 const auto massFlux = couplingManager().couplingData().massCouplingCondition(element, fvGeometry, elemVolVars, scvf, diffCoeffAvgType_);
268
269 for(int i = 0; i< massFlux.size(); ++i)
270 values[i] = massFlux[i];
271
272 values[Indices::energyEqIdx] = couplingManager().couplingData().energyCouplingCondition(element, fvGeometry, elemVolVars, scvf, diffCoeffAvgType_);
273#endif
274 }
275
276 return values;
277 }
278
279 // \}
280
284 // \{
299 NumEqVector source(const Element &element,
300 const FVElementGeometry& fvGeometry,
301 const ElementVolumeVariables& elemVolVars,
302 const SubControlVolume &scv) const
303 { return NumEqVector(0.0); }
304
305 // \}
306
313 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
314 {
315 PrimaryVariables values(0.0);
316 values.setState(initialPhasePresence_);
317
318 values[pressureIdx] = pressure_ + 1000. * this->spatialParams().gravity(globalPos)[1] * (globalPos[1] - this->gridGeometry().bBoxMax()[1]);
319 values[switchIdx] = initialSw_;
320
321#if NONISOTHERMAL
322 values[Indices::temperatureIdx] = temperature_;
323#endif
324 return values;
325 }
326
327 // \}
328
330 const CouplingManager& couplingManager() const
331 { return *couplingManager_; }
332
333private:
334 bool onLeftBoundary_(const GlobalPosition &globalPos) const
335 { return globalPos[0] < this->gridGeometry().bBoxMin()[0] + eps_; }
336
337 bool onRightBoundary_(const GlobalPosition &globalPos) const
338 { return globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_; }
339
340 bool onLowerBoundary_(const GlobalPosition &globalPos) const
341 { return globalPos[1] < this->gridGeometry().bBoxMin()[1] + eps_; }
342
343 bool onUpperBoundary_(const GlobalPosition &globalPos) const
344 { return globalPos[1] > this->gridGeometry().bBoxMax()[1] - eps_; }
345
346 Scalar pressure_;
347 Scalar initialSw_;
348 Scalar temperature_;
349 int initialPhasePresence_;
350 std::string problemName_;
351 Scalar eps_;
352
353 std::shared_ptr<CouplingManager> couplingManager_;
354 DiffusionCoefficientAveragingType diffCoeffAvgType_;
355};
356} // end namespace Dumux
357
358#endif //DUMUX_DARCY2P2C_SUBPROBLEM_HH
Properties for all models using cell-centered finite volume scheme with TPFA.
A compositional two-phase fluid system with water and air as components in both, the liquid and the g...
@ p1s0
first phase saturation and second phase pressure as primary variables
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:38
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 component balance index that should be replaced by the total mass/mole balance.
Definition: common/properties.hh:104
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
The formulation of the model.
Definition: common/properties.hh:237
A compositional two-phase fluid system with water and air as components in both, the liquid and the g...
Definition: h2oair.hh:75
DiffusionCoefficientAveragingType
Defines which kind of averanging of diffusion coefficiencients (moleculat diffusion or thermal conduc...
Definition: couplingdata.hh:52
static DiffusionCoefficientAveragingType stringToEnum(DiffusionCoefficientAveragingType, const std::string &diffusionCoefficientAveragingType)
Convenience function to convert user input given as std::string to the corresponding enum class used ...
Definition: couplingdata.hh:60
Base class for all fully implicit porous media problems.
Definition: dumux/porousmediumflow/problem.hh:39
SpatialParams & spatialParams()
Returns the spatial parameters object.
Definition: dumux/porousmediumflow/problem.hh:146
Definition: 1p_2p/problem_darcy.hh:79
void printWaterMass(const SolutionVector &curSol, const GridVariables &gridVariables, const Scalar timeStepSize)
Definition: 1p2c_2p2c/problem_darcy.hh:155
bool shouldWriteOutput() const
Definition: 1p2c_2p2c/problem_darcy.hh:197
const CouplingManager & couplingManager() const
Get the coupling manager.
Definition: 1p2c_1p2c/diffusionlawcomparison/problem_darcy.hh:266
bool shouldWriteRestartFile() const
Returns true if a restart file should be written to disk.
Definition: 1p2c_2p2c/problem_darcy.hh:189
DarcySubProblem(std::shared_ptr< const GridGeometry > gridGeometry, std::shared_ptr< CouplingManager > couplingManager)
Definition: 1p2c_2p2c/problem_darcy.hh:127
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluates the initial value for a control volume.
Definition: 1p2c_2p2c/problem_darcy.hh:313
PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const
Evaluates the boundary conditions for a Dirichlet control volume.
Definition: 1p2c_2p2c/problem_darcy.hh:237
NumEqVector neumann(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const ElementFluxVariablesCache &elemFluxVarsCache, const SubControlVolumeFace &scvf) const
Evaluates the boundary conditions for a Neumann control volume.
Definition: 1p2c_2p2c/problem_darcy.hh:254
Scalar temperature() const
Returns the temperature within the domain in [K].
Definition: 1p2c_2p2c/problem_darcy.hh:203
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_2p2c/problem_darcy.hh:218
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_2p2c/problem_darcy.hh:299
const std::string & name() const
The problem name.
Definition: 1p2c_2p2c/problem_darcy.hh:144
Definition: 1p2c_2p2c/problem_darcy.hh:48
std::tuple< TwoPTwoC, CCTpfaModel > InheritsFrom
Definition: 1p2c_2p2c/problem_darcy.hh:48
Dune::YaspGrid< 2, Dune::TensorProductCoordinates< GetPropType< TypeTag, Properties::Scalar >, 2 > > type
Definition: 1p2c_2p2c/problem_darcy.hh:73
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: 1p2c_2p2c/problem_darcy.hh:82
GetPropType< TypeTag, Properties::GridGeometry > GridGeometry
Definition: 1p2c_2p2c/problem_darcy.hh:81
The spatial parameters class for the test problem using the 1p cc model.
Definition: multidomain/boundary/stokesdarcy/1p2c_2p2c/spatialparams.hh:44
Adaption of the fully implicit scheme to the two-phase two-component fully implicit model.
Base class for all porous media problems.
Definition of the spatial parameters for the MaxwellStefan problem.