3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
1p2c_richards2c/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
40
41#include "spatialparams_root.hh"
42
43namespace Dumux {
44// forward declaration
45template <class TypeTag> class RootProblem;
46
47namespace Properties {
48
49// Create new type tags
50namespace TTag {
51struct Root { using InheritsFrom = std::tuple<OnePNC, CCTpfaModel>; };
52} // end namespace TTag
53
54// Set the grid type
55template<class TypeTag>
56struct Grid<TypeTag, TTag::Root> { using type = Dune::FoamGrid<1, 3>; };
57
58template<class TypeTag>
59struct EnableGridGeometryCache<TypeTag, TTag::Root> { static constexpr bool value = true; };
60template<class TypeTag>
61struct EnableGridVolumeVariablesCache<TypeTag, TTag::Root> { static constexpr bool value = true; };
62template<class TypeTag>
63struct EnableGridFluxVariablesCache<TypeTag, TTag::Root> { static constexpr bool value = true; };
64template<class TypeTag>
65struct SolutionDependentAdvection<TypeTag, TTag::Root> { static constexpr bool value = false; };
66template<class TypeTag>
67struct SolutionDependentMolecularDiffusion<TypeTag, TTag::Root> { static constexpr bool value = false; };
68template<class TypeTag>
69struct SolutionDependentHeatConduction<TypeTag, TTag::Root> { static constexpr bool value = false; };
70
71// Set the problem property
72template<class TypeTag>
73struct Problem<TypeTag, TTag::Root> { using type = RootProblem<TypeTag>; };
74
75// Set the fluid system
76template<class TypeTag>
77struct FluidSystem<TypeTag, TTag::Root>
78{
82};
83
84// Set the spatial parameters
85template<class TypeTag>
86struct SpatialParams<TypeTag, TTag::Root>
87{
90};
91
92template<class TypeTag>
93struct UseMoles<TypeTag, TTag::Root> { static constexpr bool value = true; };
94
95} // end namespace Properties
96
101template <class TypeTag>
102class RootProblem : public PorousMediumFlowProblem<TypeTag>
103{
104 using ParentType = PorousMediumFlowProblem<TypeTag>;
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;
117 using Element = typename GridView::template Codim<0>::Entity;
120
122
123public:
125 enum Indices {
126 // Grid and world dimension
127 dim = GridView::dimension,
128 dimworld = GridView::dimensionworld,
129
132
135
137 };
138
139 template<class SpatialParams>
140 RootProblem(std::shared_ptr<const GridGeometry> gridGeometry,
141 std::shared_ptr<SpatialParams> spatialParams,
142 std::shared_ptr<CouplingManager> couplingManager)
144 , couplingManager_(couplingManager)
145 {
146 // read parameters from input file
147 name_ = getParam<std::string>("Vtk.OutputName") + "_" + getParamFromGroup<std::string>(this->paramGroup(), "Problem.Name");
148 transpirationRate_ = getParam<Scalar>("BoundaryConditions.TranspirationRate");
149 initPressure_ = getParam<Scalar>("BoundaryConditions.InitialRootPressure");
150 }
151
158 template<class ElementSolution>
159 Scalar extrusionFactor(const Element &element,
160 const SubControlVolume &scv,
161 const ElementSolution& elemSol) const
162 {
163 const auto eIdx = this->gridGeometry().elementMapper().index(element);
164 const auto radius = this->spatialParams().radius(eIdx);
165 return M_PI*radius*radius;
166 }
167
171 // \{
172
178 const std::string& name() const
179 { return name_; }
180
184 Scalar temperature() const
185 { return 273.15 + 10.0; }
186
187 // \}
191 // \{
192
199 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
200 {
201 BoundaryTypes values;
202 values.setAllNeumann();
203 return values;
204 }
205
213 PrimaryVariables dirichletAtPos(const GlobalPosition& globalPos) const
214 { return initialAtPos(globalPos); }
215
216
224 template<class ElementVolumeVariables, class ElementFluxVarsCache>
225 NeumannFluxes neumann(const Element& element,
226 const FVElementGeometry& fvGeometry,
227 const ElementVolumeVariables& elemVolvars,
228 const ElementFluxVarsCache& elemFluxVarsCache,
229 const SubControlVolumeFace& scvf) const
230 {
231 NeumannFluxes values(0.0);
232 if (scvf.center()[2] + eps_ > this->gridGeometry().bBoxMax()[2])
233 {
234 const auto& volVars = elemVolvars[scvf.insideScvIdx()];
235 const Scalar value = transpirationRate_ * volVars.molarDensity(liquidPhaseIdx)/volVars.density(liquidPhaseIdx);
236
237 values[conti0EqIdx] = value / volVars.extrusionFactor() / scvf.area();
238 // use upwind mole fraction to get outflow condition for the tracer
239 values[transportEqIdx] = values[conti0EqIdx] * volVars.moleFraction(liquidPhaseIdx, transportCompIdx);
240 }
241 return values;
242
243 }
244
245 // \}
246
250 // \{
251
262 void addPointSources(std::vector<PointSource>& pointSources) const
263 { pointSources = this->couplingManager().lowDimPointSources(); }
264
283 template<class ElementVolumeVariables>
284 void pointSource(PointSource& source,
285 const Element &element,
286 const FVElementGeometry& fvGeometry,
287 const ElementVolumeVariables& elemVolVars,
288 const SubControlVolume &scv) const
289 {
290 SourceValues sourceValues;
291
292 // compute source at every integration point
293 const auto priVars3D = this->couplingManager().bulkPriVars(source.id());
294 const auto priVars1D = this->couplingManager().lowDimPriVars(source.id());
295 const Scalar pressure3D = priVars3D[pressureIdx];
296 const Scalar pressure1D = priVars1D[pressureIdx];
297
298 const auto lowDimElementIdx = this->couplingManager().pointSourceData(source.id()).lowDimElementIdx();
299 const Scalar Kr = this->spatialParams().Kr(lowDimElementIdx);
300 const Scalar rootRadius = this->spatialParams().radius(lowDimElementIdx);
301
302 // sink defined as radial flow Jr * density [m^2 s-1]* [kg m-3]
303 const auto molarDensityH20 = 1000 / 0.018;
304 sourceValues[conti0EqIdx] = 2 * M_PI * rootRadius * Kr * (pressure3D - pressure1D) * molarDensityH20;
305
306 const Scalar x3D = priVars3D[transportCompIdx];
307 const Scalar x1D = priVars1D[transportCompIdx];
308
310 // compute correct upwind concentration
311 if (sourceValues[conti0EqIdx] > 0)
312 sourceValues[transportEqIdx] = sourceValues[conti0EqIdx]*x3D;
313 else
314 sourceValues[transportEqIdx] = sourceValues[conti0EqIdx]*x1D;
315
317 const auto molarDensityD20 = 1000 / 0.020;
318 sourceValues[transportEqIdx] += 2 * M_PI * rootRadius * 1.0e-8 * (x3D - x1D) * molarDensityD20;
319
320 sourceValues *= source.quadratureWeight()*source.integrationElement();
321 source = sourceValues;
322 }
323
330 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
331 { return PrimaryVariables({initPressure_, 0.0}); }
332
333 // \}
334
340 template<class VtkOutputModule>
342 {
343 vtk.addField(this->spatialParams().getRadii(), "radius");
344 }
345
347 const CouplingManager& couplingManager() const
348 { return *couplingManager_; }
349
350private:
351 Scalar transpirationRate_, initPressure_;
352
353 static constexpr Scalar eps_ = 1.5e-7;
354 std::string name_;
355
356 std::shared_ptr<CouplingManager> couplingManager_;
357};
358
359} // end namespace Dumux
360
361#endif
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
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 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 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
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: 1p2c_richards2c/problem_root.hh:341
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: 1p2c_richards2c/problem_root.hh:284
void addPointSources(std::vector< PointSource > &pointSources) const
Applies a vector of point sources which are possibly solution dependent.
Definition: 1p2c_richards2c/problem_root.hh:262
GetPropType< TypeTag, Properties::FluidSystem > FluidSystem
Definition: 1p2c_richards2c/problem_root.hh:124
RootProblem(std::shared_ptr< const GridGeometry > gridGeometry, std::shared_ptr< SpatialParams > spatialParams, std::shared_ptr< CouplingManager > couplingManager)
Definition: 1p2c_richards2c/problem_root.hh:140
Scalar temperature() const
Returns the temperature within the domain in [K].
Definition: 1p2c_richards2c/problem_root.hh:184
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: 1p2c_richards2c/problem_root.hh:199
const std::string & name() const
The problem name.
Definition: 1p2c_richards2c/problem_root.hh:178
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: 1p2c_richards2c/problem_root.hh:225
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: 1p2c_richards2c/problem_root.hh:159
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Dirichlet control volume.
Definition: 1p2c_richards2c/problem_root.hh:213
Indices
Definition: 1p2c_richards2c/problem_root.hh:125
@ dim
Definition: 1p2c_richards2c/problem_root.hh:127
@ liquidPhaseIdx
Definition: 1p2c_richards2c/problem_root.hh:136
@ conti0EqIdx
Definition: 1p2c_richards2c/problem_root.hh:133
@ dimworld
Definition: 1p2c_richards2c/problem_root.hh:128
@ pressureIdx
Definition: 1p2c_richards2c/problem_root.hh:130
@ transportCompIdx
Definition: 1p2c_richards2c/problem_root.hh:131
@ transportEqIdx
Definition: 1p2c_richards2c/problem_root.hh:134
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.
Adaption of the fully implicit model to the one-phase n-component flow model.
Base class for all porous media problems.
The spatial parameters class blood flow problem.