3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
1p_richards/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/grid/yaspgrid.hh>
30#include <dune/geometry/quadraturerules.hh>
31#include <dune/geometry/referenceelements.hh>
32#include <dune/localfunctions/lagrange/pqkfactory.hh>
33
34#include <dumux/common/math.hh>
39
42
43#include "spatialparams_soil.hh"
44
45namespace Dumux {
46
47template <class TypeTag>
48class SoilProblem;
49
50namespace Properties {
51
52// Create new type tags
53namespace TTag {
54struct Soil { using InheritsFrom = std::tuple<Richards>; };
55struct SoilCC { using InheritsFrom = std::tuple<Soil, CCTpfaModel>; };
56struct SoilBox { using InheritsFrom = std::tuple<Soil, BoxModel>; };
57} // end namespace TTag
58
59// Set the grid type
60template<class TypeTag>
61struct Grid<TypeTag, TTag::Soil> { using type = Dune::YaspGrid<3, Dune::EquidistantOffsetCoordinates<GetPropType<TypeTag, Properties::Scalar>, 3> >; };
62
63template<class TypeTag>
64struct EnableGridGeometryCache<TypeTag, TTag::Soil> { static constexpr bool value = true; };
65template<class TypeTag>
66struct EnableGridVolumeVariablesCache<TypeTag, TTag::Soil> { static constexpr bool value = true; };
67template<class TypeTag>
68struct EnableGridFluxVariablesCache<TypeTag, TTag::Soil> { static constexpr bool value = true; };
69template<class TypeTag>
70struct SolutionDependentAdvection<TypeTag, TTag::Soil> { static constexpr bool value = false; };
71template<class TypeTag>
72struct SolutionDependentMolecularDiffusion<TypeTag, TTag::Soil> { static constexpr bool value = false; };
73template<class TypeTag>
74struct SolutionDependentHeatConduction<TypeTag, TTag::Soil> { static constexpr bool value = false; };
75
76// Set the problem property
77template<class TypeTag>
78struct Problem<TypeTag, TTag::Soil> { using type = SoilProblem<TypeTag>; };
79
80// Set the spatial parameters
81template<class TypeTag>
82struct SpatialParams<TypeTag, TTag::Soil>
83{
86};
87} // end namespace Properties
88
89
95template <class TypeTag>
96class SoilProblem : public PorousMediumFlowProblem<TypeTag>
97{
101 using GridView = typename GridGeometry::GridView;
102 using FVElementGeometry = typename GridGeometry::LocalView;
103 using SubControlVolume = typename GridGeometry::SubControlVolume;
104 using GlobalPosition = typename GridGeometry::GlobalCoordinate;
105 using Element = typename GridView::template Codim<0>::Entity;
113
114public:
115 SoilProblem(std::shared_ptr<const GridGeometry> gridGeometry,
116 std::shared_ptr<CouplingManager> couplingManager)
117 : ParentType(gridGeometry, "Soil")
118 , couplingManager_(couplingManager)
119 {
120 // read parameters from input file
121 name_ = getParam<std::string>("Vtk.OutputName") + "_" + getParamFromGroup<std::string>(this->paramGroup(), "Problem.Name");
122 initPressure_ = getParam<Scalar>("BoundaryConditions.InitialSoilPressure");
123 }
124
128 // \{
129
135 const std::string& name() const
136 { return name_; }
137
143 Scalar temperature() const
144 { return 273.15 + 10; } // in [K]
145
146 /*
147 * \brief Returns the reference pressure [Pa] of the non-wetting
148 * fluid phase within a finite volume.
149 *
150 * This problem assumes a constant reference pressure of 1 bar.
151 */
153 { return 1.0e5; }
154
155
156 // \}
157
161 // \{
162
169 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
170 {
171 BoundaryTypes values;
172 values.setAllNeumann();
173 return values;
174 }
175
176 // \}
177
181 // \{
182
193 void addPointSources(std::vector<PointSource>& pointSources) const
194 { pointSources = this->couplingManager().bulkPointSources(); }
195
214 template<class ElementVolumeVariables>
215 void pointSource(PointSource& source,
216 const Element &element,
217 const FVElementGeometry& fvGeometry,
218 const ElementVolumeVariables& elemVolVars,
219 const SubControlVolume &scv) const
220 {
221 // compute source at every integration point
222 const Scalar pressure3D = this->couplingManager().bulkPriVars(source.id())[Indices::pressureIdx];
223 const Scalar pressure1D = this->couplingManager().lowDimPriVars(source.id())[Indices::pressureIdx];
224
225 const auto& spatialParams = this->couplingManager().problem(Dune::index_constant<1>{}).spatialParams();
226 const auto lowDimElementIdx = this->couplingManager().pointSourceData(source.id()).lowDimElementIdx();
227 const Scalar Kr = spatialParams.Kr(lowDimElementIdx);
228 const Scalar rootRadius = spatialParams.radius(lowDimElementIdx);
229
230 // sink defined as radial flow Jr * density [m^2 s-1]* [kg m-3]
231 const auto density = 1000;
232 const Scalar sourceValue = 2* M_PI *rootRadius * Kr *(pressure1D - pressure3D)*density;
233 source = sourceValue*source.quadratureWeight()*source.integrationElement();
234
235 }
236
245 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
246 {
247 PrimaryVariables priVars({initPressure_});
248 priVars.setState(Indices::bothPhases);
249 return priVars;
250 }
251
254 void computeSourceIntegral(const SolutionVector& sol, const GridVariables& gridVars)
255 {
256 PrimaryVariables source(0.0);
257 for (const auto& element : elements(this->gridGeometry().gridView()))
258 {
259 auto fvGeometry = localView(this->gridGeometry());
260 fvGeometry.bindElement(element);
261
262 auto elemVolVars = localView(gridVars.curGridVolVars());
263 elemVolVars.bindElement(element, fvGeometry, sol);
264
265 for (auto&& scv : scvs(fvGeometry))
266 {
267 auto pointSources = this->scvPointSources(element, fvGeometry, elemVolVars, scv);
268 pointSources *= scv.volume()*elemVolVars[scv].extrusionFactor();
269 source += pointSources;
270 }
271 }
272
273 std::cout << "Global integrated source (soil): " << source << " (kg/s) / "
274 << source*3600*24*1000 << " (g/day)" << '\n';
275
276 }
277
279 const CouplingManager& couplingManager() const
280 { return *couplingManager_; }
281
282private:
283 Scalar initPressure_;
284
285 static constexpr Scalar eps_ = 1.5e-7;
286 std::string name_;
287
288 std::shared_ptr<CouplingManager> couplingManager_;
289};
290
291} // end namespace Dumux
292
293#endif
Define some often used mathematical functions.
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
Defines a type tag and some properties for models using the box scheme.
Properties for all models using cell-centered finite volume scheme with TPFA.
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
std::string density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:65
Base class for all finite-volume problems.
Definition: common/fvproblem.hh:50
NumEqVector scvPointSources(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolume &scv) const
Adds contribution of point sources for a specific sub control volume to the values....
Definition: common/fvproblem.hh:435
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
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
Definition: common/properties.hh:169
The type of the spatial parameters object.
Definition: common/properties.hh:221
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: 1p_richards/problem_soil.hh:193
Indices
Definition: 1p2c_richards2c/problem_soil.hh:136
void computeSourceIntegral(const SolutionVector &sol, const GridVariables &gridVars)
Definition: 1p_richards/problem_soil.hh:254
const std::string & name() const
The problem name.
Definition: 1p_richards/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: 1p_richards/problem_soil.hh:169
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluates the initial value for a control volume.
Definition: 1p_richards/problem_soil.hh:245
const CouplingManager & couplingManager() const
Get the coupling manager.
Definition: 1p2c_richards2c/problem_soil.hh:341
Scalar nonWettingReferencePressure() const
Definition: 1p_richards/problem_soil.hh:152
Scalar temperature() const
Returns the temperature within the domain [K].
Definition: 1p_richards/problem_soil.hh:143
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: 1p_richards/problem_soil.hh:215
SoilProblem(std::shared_ptr< const GridGeometry > gridGeometry, std::shared_ptr< CouplingManager > couplingManager)
Definition: 1p_richards/problem_soil.hh:115
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
Definition of the spatial parameters for the soil problem.
Definition: 1p2c_richards2c/spatialparams_soil.hh:42
Definition: 1p_richards/problem_soil.hh:55
std::tuple< Soil, CCTpfaModel > InheritsFrom
Definition: 1p_richards/problem_soil.hh:55
Definition: 1p_richards/problem_soil.hh:56
std::tuple< Soil, BoxModel > InheritsFrom
Definition: 1p_richards/problem_soil.hh:56
Declares all properties used in Dumux.
This model implements a variant of the Richards' equation for quasi-twophase flow.
Base class for all porous media problems.
Definition of the spatial parameters for the tissue problem.