3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
1p_richards/problem_root.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_ROOT_PROBLEM_HH
27#define DUMUX_ROOT_PROBLEM_HH
28
29#include <dune/foamgrid/foamgrid.hh>
30
34
38
41
42#include "spatialparams_root.hh"
43
44namespace Dumux {
45// forward declaration
46template <class TypeTag> class RootProblem;
47
48namespace Properties {
49
50// Create new type tags
51namespace TTag {
52struct Root { using InheritsFrom = std::tuple<OneP, CCTpfaModel>; };
53} // end namespace TTag
54
55// Set the grid type
56template<class TypeTag>
57struct Grid<TypeTag, TTag::Root> { using type = Dune::FoamGrid<1, 3>; };
58
59template<class TypeTag>
60struct EnableGridGeometryCache<TypeTag, TTag::Root> { static constexpr bool value = true; };
61template<class TypeTag>
62struct EnableGridVolumeVariablesCache<TypeTag, TTag::Root> { static constexpr bool value = true; };
63template<class TypeTag>
64struct EnableGridFluxVariablesCache<TypeTag, TTag::Root> { static constexpr bool value = true; };
65template<class TypeTag>
66struct SolutionDependentAdvection<TypeTag, TTag::Root> { static constexpr bool value = false; };
67template<class TypeTag>
68struct SolutionDependentMolecularDiffusion<TypeTag, TTag::Root> { static constexpr bool value = false; };
69template<class TypeTag>
70struct SolutionDependentHeatConduction<TypeTag, TTag::Root> { static constexpr bool value = false; };
71
72// Set the problem property
73template<class TypeTag>
74struct Problem<TypeTag, TTag::Root> { using type = RootProblem<TypeTag>; };
75
76// the fluid system
77template<class TypeTag>
78struct FluidSystem<TypeTag, TTag::Root>
79{
82};
83
84// Set the problem property
85template<class TypeTag>
86struct LocalResidual<TypeTag, TTag::Root> { using type = OnePIncompressibleLocalResidual<TypeTag>; };
87
88// Set the spatial parameters
89template<class TypeTag>
90struct SpatialParams<TypeTag, TTag::Root>
91{
94};
95} // end namespace Properties
96
101template <class TypeTag>
103{
112 using GridView = typename GridGeometry::GridView;
113 using FVElementGeometry = typename GridGeometry::LocalView;
114 using SubControlVolume = typename GridGeometry::SubControlVolume;
115 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
116 using GlobalPosition = typename GridGeometry::GlobalCoordinate;
119 using Element = typename GridView::template Codim<0>::Entity;
121
122public:
123
124 template<class SpatialParams>
125 RootProblem(std::shared_ptr<const GridGeometry> gridGeometry,
126 std::shared_ptr<SpatialParams> spatialParams,
127 std::shared_ptr<CouplingManager> couplingManager)
129 , couplingManager_(couplingManager)
130 {
131 // read parameters from input file
132 name_ = getParam<std::string>("Vtk.OutputName") + "_" + getParamFromGroup<std::string>(this->paramGroup(), "Problem.Name");
133 transpirationRate_ = getParam<Scalar>("BoundaryConditions.TranspirationRate");
134 }
135
142 template<class ElementSolution>
143 Scalar extrusionFactor(const Element &element,
144 const SubControlVolume &scv,
145 const ElementSolution& elemSol) const
146 {
147 const auto eIdx = this->gridGeometry().elementMapper().index(element);
148 const auto radius = this->spatialParams().radius(eIdx);
149 return M_PI*radius*radius;
150 }
151
155 // \{
156
162 const std::string& name() const
163 { return name_; }
164
168 Scalar temperature() const
169 { return 273.15 + 10.0; }
170
171 // \}
175 // \{
176
183 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
184 {
185 BoundaryTypes values;
186 values.setAllNeumann();
187 return values;
188 }
189
197 PrimaryVariables dirichletAtPos(const GlobalPosition& globalPos) const
198 { return initialAtPos(globalPos); }
199
200
208 template<class ElementVolumeVariables, class ElementFluxVarsCache>
209 NeumannFluxes neumann(const Element& element,
210 const FVElementGeometry& fvGeometry,
211 const ElementVolumeVariables& elemVolvars,
212 const ElementFluxVarsCache& elemFluxVarsCache,
213 const SubControlVolumeFace& scvf) const
214 {
215 NeumannFluxes values(0.0);
216 if (scvf.center()[2] + eps_ > this->gridGeometry().bBoxMax()[2])
217 {
218 const auto r = this->spatialParams().radius(scvf.insideScvIdx());
219 values[Indices::conti0EqIdx] = transpirationRate_/(M_PI*r*r)/scvf.area();
220 }
221 return values;
222
223 }
224
225 // \}
226
230 // \{
231
242 void addPointSources(std::vector<PointSource>& pointSources) const
243 { pointSources = this->couplingManager().lowDimPointSources(); }
244
263 template<class ElementVolumeVariables>
264 void pointSource(PointSource& source,
265 const Element &element,
266 const FVElementGeometry& fvGeometry,
267 const ElementVolumeVariables& elemVolVars,
268 const SubControlVolume &scv) const
269 {
270 // compute source at every integration point
271 const Scalar pressure3D = this->couplingManager().bulkPriVars(source.id())[Indices::pressureIdx];
272 const Scalar pressure1D = this->couplingManager().lowDimPriVars(source.id())[Indices::pressureIdx];
273
274 const auto lowDimElementIdx = this->couplingManager().pointSourceData(source.id()).lowDimElementIdx();
275 const Scalar Kr = this->spatialParams().Kr(lowDimElementIdx);
276 const Scalar rootRadius = this->spatialParams().radius(lowDimElementIdx);
277
278 // sink defined as radial flow Jr * density [m^2 s-1]* [kg m-3]
279 const auto density = 1000;
280 const Scalar sourceValue = 2* M_PI *rootRadius * Kr *(pressure3D - pressure1D)*density;
281 source = sourceValue*source.quadratureWeight()*source.integrationElement();
282 }
283
290 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
291 { return PrimaryVariables(0.0); }
292
293 // \}
294
297 void computeSourceIntegral(const SolutionVector& sol, const GridVariables& gridVars)
298 {
299 PrimaryVariables source(0.0);
300 for (const auto& element : elements(this->gridGeometry().gridView()))
301 {
302 auto fvGeometry = localView(this->gridGeometry());
303 fvGeometry.bindElement(element);
304
305 auto elemVolVars = localView(gridVars.curGridVolVars());
306 elemVolVars.bindElement(element, fvGeometry, sol);
307
308 for (auto&& scv : scvs(fvGeometry))
309 {
310 auto pointSources = this->scvPointSources(element, fvGeometry, elemVolVars, scv);
311 pointSources *= scv.volume()*elemVolVars[scv].extrusionFactor();
312 source += pointSources;
313 }
314 }
315
316 std::cout << "Global integrated source (root): " << source << " (kg/s) / "
317 << source*3600*24*1000 << " (g/day)" << '\n';
318 }
319
325 template<class VtkOutputModule>
327 {
328 vtk.addField(this->spatialParams().getRadii(), "radius");
329 }
330
332 const CouplingManager& couplingManager() const
333 { return *couplingManager_; }
334
335private:
336 Scalar transpirationRate_;
337
338 static constexpr Scalar eps_ = 1.5e-7;
339 std::string name_;
340
341 std::shared_ptr<CouplingManager> couplingManager_;
342};
343
344} // end namespace Dumux
345
346#endif
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
Properties for all models using cell-centered finite volume scheme with TPFA.
A much simpler (and thus potentially less buggy) version of pure water.
A liquid phase consisting of a single component.
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:91
Definition: common/properties.hh:169
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 VTK output module to simplify writing dumux simulation data to VTK format.
Definition: io/vtkoutputmodule.hh:66
void addField(const Vector &v, const std::string &name, FieldType fieldType=FieldType::automatic)
Definition: io/vtkoutputmodule.hh:161
A liquid phase consisting of a single component.
Definition: 1pliquid.hh:46
A liquid phase consisting of a two components, a main component and a conservative tracer component.
Definition: liquidphase2c.hh:46
Element-wise calculation of the residual and its derivatives for a single-phase, incompressible,...
Definition: 1p/incompressiblelocalresidual.hh:41
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
Exact solution 1D-3D.
Definition: 1p_richards/problem_root.hh:103
void addVtkOutputFields(VtkOutputModule &vtk) const
Adds additional VTK output data to the VTKWriter.
Definition: 1p_richards/problem_root.hh:326
const CouplingManager & couplingManager() const
Get the coupling manager.
Definition: 1p2c_richards2c/problem_root.hh:347
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_root.hh:264
void addPointSources(std::vector< PointSource > &pointSources) const
Applies a vector of point sources which are possibly solution dependent.
Definition: 1p_richards/problem_root.hh:242
void computeSourceIntegral(const SolutionVector &sol, const GridVariables &gridVars)
Definition: 1p_richards/problem_root.hh:297
RootProblem(std::shared_ptr< const GridGeometry > gridGeometry, std::shared_ptr< SpatialParams > spatialParams, std::shared_ptr< CouplingManager > couplingManager)
Definition: 1p_richards/problem_root.hh:125
Scalar temperature() const
Returns the temperature within the domain in [K].
Definition: 1p_richards/problem_root.hh:168
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluates the initial value for a control volume.
Definition: 1p2c_richards2c/problem_root.hh:330
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_root.hh:183
const std::string & name() const
The problem name.
Definition: 1p_richards/problem_root.hh:162
NeumannFluxes neumann(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolvars, const ElementFluxVarsCache &elemFluxVarsCache, const SubControlVolumeFace &scvf) const
Evaluates the boundary conditions for a Neumann boundary segment.
Definition: 1p_richards/problem_root.hh:209
Scalar extrusionFactor(const Element &element, const SubControlVolume &scv, const ElementSolution &elemSol) const
Returns how much the domain is extruded at a given sub-control volume.
Definition: 1p_richards/problem_root.hh:143
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Dirichlet control volume.
Definition: 1p_richards/problem_root.hh:197
Indices
Definition: 1p2c_richards2c/problem_root.hh:125
Definition: 1p2c_richards2c/problem_root.hh:51
std::tuple< OnePNC, CCTpfaModel > InheritsFrom
Definition: 1p2c_richards2c/problem_root.hh:51
Dune::FoamGrid< 1, 3 > type
Definition: 1p2c_richards2c/problem_root.hh:56
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: 1p2c_richards2c/problem_root.hh:79
Definition of the spatial parameters for the root xylem flow.
Definition: 1p2c_richards2c/spatialparams_root.hh:42
Declares all properties used in Dumux.
A single-phase, isothermal flow model using the fully implicit scheme.
Base class for all porous media problems.
Element-wise calculation of the residual and its derivatives for a single-phase, incompressible,...
The spatial parameters class blood flow problem.