3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
1p2c_richards2c/problem_soil.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 *****************************************************************************/
26#ifndef DUMUX_TISSUE_PROBLEM_HH
27#define DUMUX_TISSUE_PROBLEM_HH
28
29#include <dune/geometry/quadraturerules.hh>
30#include <dune/geometry/referenceelements.hh>
31#include <dune/grid/yaspgrid.hh>
32#include <dune/grid/uggrid.hh>
33#include <dune/localfunctions/lagrange/pqkfactory.hh>
34
35#include <dumux/common/math.hh>
39
45
46#include "spatialparams_soil.hh"
47
48namespace Dumux {
49
50template <class TypeTag>
51class SoilProblem;
52
53namespace Properties {
54
55// Create new type tags
56namespace TTag {
57struct Soil { using InheritsFrom = std::tuple<RichardsNC, CCTpfaModel>; };
58} // end namespace TTag
59
60// Set the grid type
61#if HAVE_UG
62template<class TypeTag>
63struct Grid<TypeTag, TTag::Soil> { using type = Dune::UGGrid<3>; };
64#else
65template<class TypeTag>
66struct Grid<TypeTag, TTag::Soil> { using type = Dune::YaspGrid<3, Dune::EquidistantOffsetCoordinates<double, 3>>; };
67#endif
68
69template<class TypeTag>
70struct EnableGridGeometryCache<TypeTag, TTag::Soil> { static constexpr bool value = true; };
71template<class TypeTag>
72struct EnableGridVolumeVariablesCache<TypeTag, TTag::Soil> { static constexpr bool value = true; };
73template<class TypeTag>
74struct EnableGridFluxVariablesCache<TypeTag, TTag::Soil> { static constexpr bool value = true; };
75template<class TypeTag>
76struct SolutionDependentAdvection<TypeTag, TTag::Soil> { static constexpr bool value = false; };
77template<class TypeTag>
78struct SolutionDependentMolecularDiffusion<TypeTag, TTag::Soil> { static constexpr bool value = false; };
79template<class TypeTag>
80struct SolutionDependentHeatConduction<TypeTag, TTag::Soil> { static constexpr bool value = false; };
81
82// Set the problem property
83template<class TypeTag>
84struct Problem<TypeTag, TTag::Soil> { using type = SoilProblem<TypeTag>; };
85
86// Set the spatial parameters
87template<class TypeTag>
88struct SpatialParams<TypeTag, TTag::Soil>
89{
92};
93
94// Set the fluid system
95template<class TypeTag>
96struct FluidSystem<TypeTag, TTag::Soil>
97{
101};
102
103template<class TypeTag>
104struct UseMoles<TypeTag, TTag::Soil> { static constexpr bool value = true; };
105
106} // end namespace Properties
107
108
114template <class TypeTag>
115class SoilProblem : public PorousMediumFlowProblem<TypeTag>
116{
117 using ParentType = PorousMediumFlowProblem<TypeTag>;
120 using FVElementGeometry = typename GridGeometry::LocalView;
121 using SubControlVolume = typename GridGeometry::SubControlVolume;
122 using GridView = typename GridGeometry::GridView;
123 using GlobalPosition = typename GridGeometry::GlobalCoordinate;
130 using Element = typename GridView::template Codim<0>::Entity;
131
133
134public:
136 enum Indices {
137 // world dimension
138 dim = GridView::dimension,
139 dimWorld = GridView::dimensionworld,
140
143
146
147 liquidPhaseIdx = FluidSystem::liquidPhaseIdx
148 };
149
150 SoilProblem(std::shared_ptr<const GridGeometry> gridGeometry,
151 std::shared_ptr<CouplingManager> couplingManager)
152 : ParentType(gridGeometry, "Soil")
153 , couplingManager_(couplingManager)
154 {
155 //read parameters from input file
156 name_ = getParam<std::string>("Vtk.OutputName") + "_" + getParamFromGroup<std::string>(this->paramGroup(), "Problem.Name");
157 contaminantMoleFraction_ = getParam<Scalar>("Problem.ContaminantMoleFraction");
158
159 // for initial conditions
160 const Scalar sw = getParam<Scalar>("Problem.InitTopSaturation", 0.3); // start with 30% saturation on top
162 pcTop_ = MaterialLaw::pc(this->spatialParams().materialLawParamsAtPos(gridGeometry->bBoxMax()), sw);
163 }
164
168 // \{
169
175 const std::string& name() const
176 { return name_; }
177
183 Scalar temperature() const
184 { return 273.15 + 10; } // in [K]
185
186 /*
187 * \brief Returns the reference pressure [Pa] of the non-wetting
188 * fluid phase within a finite volume.
189 *
190 * This problem assumes a constant reference pressure of 1 bar.
191 */
193 { return 1.0e5; }
194
195
196 // \}
197
201 // \{
202
209 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
210 {
211 BoundaryTypes values;
212 values.setAllNeumann();
213 return values;
214 }
215
223 PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
224 { return initialAtPos(globalPos); }
225
226 // \}
227
231 // \{
232
243 void addPointSources(std::vector<PointSource>& pointSources) const
244 { pointSources = this->couplingManager().bulkPointSources(); }
245
264 template<class ElementVolumeVariables>
265 void pointSource(PointSource& source,
266 const Element &element,
267 const FVElementGeometry& fvGeometry,
268 const ElementVolumeVariables& elemVolVars,
269 const SubControlVolume &scv) const
270 {
271 NumEqVector sourceValues;
272
273 // compute source at every integration point
274 const auto priVars3D = this->couplingManager().bulkPriVars(source.id());
275 const auto priVars1D = this->couplingManager().lowDimPriVars(source.id());
276 const Scalar pressure3D = priVars3D[pressureIdx];
277 const Scalar pressure1D = priVars1D[pressureIdx];
278
279 const auto& spatialParams = this->couplingManager().problem(Dune::index_constant<1>{}).spatialParams();
280 const auto lowDimElementIdx = this->couplingManager().pointSourceData(source.id()).lowDimElementIdx();
281 const Scalar Kr = spatialParams.Kr(lowDimElementIdx);
282 const Scalar rootRadius = spatialParams.radius(lowDimElementIdx);
283
284 // sink defined as radial flow Jr * density [m^2 s-1]* [kg m-3]
285 const auto molarDensityH20 = 1000 / 0.018;
286 sourceValues[conti0EqIdx] = 2 * M_PI * rootRadius * Kr * (pressure1D - pressure3D) * molarDensityH20;
287
288 const Scalar x3D = priVars3D[transportCompIdx];
289 const Scalar x1D = priVars1D[transportCompIdx];
290
292 // compute correct upwind concentration
293 if (sourceValues[conti0EqIdx] > 0)
294 sourceValues[transportEqIdx] = sourceValues[conti0EqIdx]*x1D;
295 else
296 sourceValues[transportEqIdx] = sourceValues[conti0EqIdx]*x3D;
297
299 const auto molarDensityD20 = 1000 / 0.020;
300 sourceValues[transportEqIdx] += 2 * M_PI * rootRadius * 1.0e-8 * (x1D - x3D) * molarDensityD20;
301
302 sourceValues *= source.quadratureWeight()*source.integrationElement();
303 source = sourceValues;
304 }
305
314 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
315 {
316 const auto& gg = this->gridGeometry();
317 static const Scalar extend = 0.15*(gg.bBoxMax()[0]-gg.bBoxMin()[0]);
318 const auto xTracer = [&]()
319 {
320 auto contaminationPos = gg.bBoxMax()-gg.bBoxMin();
321 contaminationPos[0] *= 0.26;
322 contaminationPos[1] *= 0.56;
323 contaminationPos[2] *= 0.26;
324 contaminationPos += gg.bBoxMin();
325
326 if ((globalPos - contaminationPos).infinity_norm() < extend + eps_)
327 return contaminantMoleFraction_;
328 else
329 return 0.0;
330 }();
331
332 PrimaryVariables priVars(0.0);
334 priVars[pressureIdx] = (nonWettingReferencePressure() - pcTop_)
335 -9.81*1000*(globalPos[dimWorld-1] - gg.bBoxMax()[dimWorld-1]);
336 priVars[transportCompIdx] = xTracer;
337 return priVars;
338 }
339
341 const CouplingManager& couplingManager() const
342 { return *couplingManager_; }
343
344private:
345 Scalar pcTop_, contaminantMoleFraction_;
346
347 static constexpr Scalar eps_ = 1.5e-7;
348 std::string name_;
349
350 std::shared_ptr<CouplingManager> couplingManager_;
351};
352
353} // end namespace Dumux
354
355#endif
Define some often used mathematical functions.
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
Properties for all models using cell-centered finite volume scheme with TPFA.
Setting constant fluid properties via the input file.
A much simpler (and thus potentially less buggy) version of pure water.
A liquid phase consisting of a two components, a main component and a conservative tracer component.
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
NumEqVector source(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolume &scv) const
Evaluate the source term for all phases within a given sub-control-volume.
Definition: common/fvproblem.hh:327
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition: common/fvproblem.hh:588
A point source base class.
Definition: pointsource.hh:49
The DUNE grid type.
Definition: common/properties.hh:57
UndefinedProperty 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
Definition: common/properties.hh:169
If disabled, the volume variables are not stored (reduces memory, but is slower)
Definition: common/properties.hh:178
specifies if data on flux vars should be saved (faster, but more memory consuming)
Definition: common/properties.hh:188
specifies if the parameters for the advective fluxes depend on the solution
Definition: common/properties.hh:210
specifies if the parameters for the diffusive fluxes depend on the solution
Definition: common/properties.hh:214
specifies if the parameters for the heat conduction fluxes depend on the solution
Definition: common/properties.hh:218
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
A component which returns run time specified values for all fluid properties.
Definition: constant.hh:58
A liquid phase consisting of a two components, a main component and a conservative tracer component.
Definition: liquidphase2c.hh:46
Definition: multidomain/couplingmanager.hh:46
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 of a problem, for the 1p2c problem: Component transport of oxygen in interstitial fluid.
Definition: 1p_richards/problem_soil.hh:97
void addPointSources(std::vector< PointSource > &pointSources) const
Applies a vector of point sources which are possibly solution dependent.
Definition: 1p2c_richards2c/problem_soil.hh:243
Indices
Definition: 1p2c_richards2c/problem_soil.hh:136
@ dim
Definition: 1p2c_richards2c/problem_soil.hh:138
@ transportEqIdx
Definition: 1p2c_richards2c/problem_soil.hh:145
@ liquidPhaseIdx
Definition: 1p2c_richards2c/problem_soil.hh:147
@ transportCompIdx
Definition: 1p2c_richards2c/problem_soil.hh:142
@ conti0EqIdx
Definition: 1p2c_richards2c/problem_soil.hh:144
@ dimWorld
Definition: 1p2c_richards2c/problem_soil.hh:139
@ pressureIdx
Definition: 1p2c_richards2c/problem_soil.hh:141
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Dirichlet boundary segment.
Definition: 1p2c_richards2c/problem_soil.hh:223
const std::string & name() const
The problem name.
Definition: 1p2c_richards2c/problem_soil.hh:175
GetPropType< TypeTag, Properties::FluidSystem > FluidSystem
Definition: 1p2c_richards2c/problem_soil.hh:135
BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
Specifies which kind of boundary condition should be used for which equation on a given boundary segm...
Definition: 1p2c_richards2c/problem_soil.hh:209
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluates the initial value for a control volume.
Definition: 1p2c_richards2c/problem_soil.hh:314
const CouplingManager & couplingManager() const
Get the coupling manager.
Definition: 1p2c_richards2c/problem_soil.hh:341
Scalar nonWettingReferencePressure() const
Definition: 1p2c_richards2c/problem_soil.hh:192
Scalar temperature() const
Returns the temperature within the domain [K].
Definition: 1p2c_richards2c/problem_soil.hh:183
void pointSource(PointSource &source, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolume &scv) const
Evaluates the point sources (added by addPointSources) for all phases within a given sub control volu...
Definition: 1p2c_richards2c/problem_soil.hh:265
SoilProblem(std::shared_ptr< const GridGeometry > gridGeometry, std::shared_ptr< CouplingManager > couplingManager)
Definition: 1p2c_richards2c/problem_soil.hh:150
Definition: 1p2c_richards2c/problem_soil.hh:57
std::tuple< RichardsNC, CCTpfaModel > InheritsFrom
Definition: 1p2c_richards2c/problem_soil.hh:57
Dune::YaspGrid< 3, Dune::EquidistantOffsetCoordinates< double, 3 > > type
Definition: 1p2c_richards2c/problem_soil.hh:66
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: 1p2c_richards2c/problem_soil.hh:98
Definition of the spatial parameters for the soil problem.
Definition: 1p2c_richards2c/spatialparams_soil.hh:42
Declares all properties used in Dumux.
Base class for all models which use the Richards, n-component fully implicit model.
Base class for all porous media problems.
Definition of the spatial parameters for the tissue problem.