3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
test/porousmediumflow/richardsnc/implicit/problem.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 *****************************************************************************/
27#ifndef DUMUX_RICHARDS_NC_WELL_TRACER_PROBLEM_HH
28#define DUMUX_RICHARDS_NC_WELL_TRACER_PROBLEM_HH
29
30#include <dune/grid/yaspgrid.hh>
31
36
37#include "spatialparams.hh"
38
39namespace Dumux {
40
47template <class TypeTag>
48class RichardsWellTracerProblem;
49
50
51// Specify the properties for the lens problem
52namespace Properties {
53// Create new type tags
54namespace TTag {
55struct RichardsWellTracer { using InheritsFrom = std::tuple<RichardsNC>; };
56struct RichardsWellTracerBox { using InheritsFrom = std::tuple<RichardsWellTracer, BoxModel>; };
57struct RichardsWellTracerCC { using InheritsFrom = std::tuple<RichardsWellTracer, CCTpfaModel>; };
58} // end namespace TTag
59
60// Use 2d YaspGrid
61template<class TypeTag>
62struct Grid<TypeTag, TTag::RichardsWellTracer> { using type = Dune::YaspGrid<2>; };
63
64// Set the physical problem to be solved
65template<class TypeTag>
66struct Problem<TypeTag, TTag::RichardsWellTracer> { using type = RichardsWellTracerProblem<TypeTag>; };
67
68// Set the spatial parameters
69template<class TypeTag>
70struct SpatialParams<TypeTag, TTag::RichardsWellTracer>
71{
75};
76
77// Set the physical problem to be solved
78template<class TypeTag>
79struct PointSource<TypeTag, TTag::RichardsWellTracer> { using type = SolDependentPointSource<TypeTag>; };
80} // end namespace Properties
81
108template <class TypeTag>
110{
115 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
116 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
117 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
127 enum {
128 pressureIdx = Indices::pressureIdx,
129 compIdx = Indices::compMainIdx + 1,
130 liquidPhaseIdx = FluidSystem::liquidPhaseIdx,
131 dimWorld = GridView::dimensionworld
132 };
133 using Element = typename GridView::template Codim<0>::Entity;
134 using GlobalPosition = typename SubControlVolume::GlobalPosition;
135
136public:
137 RichardsWellTracerProblem(std::shared_ptr<const GridGeometry> gridGeometry)
139 {
140 name_ = getParam<std::string>("Problem.Name");
141 contaminantMoleFraction_ = getParam<Scalar>("Problem.ContaminantMoleFraction");
142 pumpRate_ = getParam<Scalar>("Problem.PumpRate"); // in kg/s
143
144 // for initial conditions
145 const Scalar sw = 0.4; // start with 80% saturation on top
146 using MaterialLaw = typename ParentType::SpatialParams::MaterialLaw;
147 pcTop_ = MaterialLaw::pc(this->spatialParams().materialLawParamsAtPos(this->gridGeometry().bBoxMax()), sw);
148
149 // for post time step mass balance
150 accumulatedSource_ = 0.0;
151 }
152
153 void printTracerMass(const SolutionVector& curSol,
154 const GridVariables& gridVariables,
155 const Scalar timeStepSize)
156
157 {
158 // compute the mass in the entire domain to make sure the tracer is conserved
159 Scalar tracerMass = 0.0;
160
161 // bulk elements
162 for (const auto& element : elements(this->gridGeometry().gridView()))
163 {
164 auto fvGeometry = localView(this->gridGeometry());
165 fvGeometry.bindElement(element);
166
167 auto elemVolVars = localView(gridVariables.curGridVolVars());
168 elemVolVars.bindElement(element, fvGeometry, curSol);
169
170 for (auto&& scv : scvs(fvGeometry))
171 {
172 const auto& volVars = elemVolVars[scv];
173 tracerMass += volVars.massFraction(liquidPhaseIdx, compIdx)*volVars.density(liquidPhaseIdx)
174 * scv.volume() * volVars.saturation(liquidPhaseIdx) * volVars.porosity() * volVars.extrusionFactor();
175
176 accumulatedSource_ += this->scvPointSources(element, fvGeometry, elemVolVars, scv)[compIdx]
177 * scv.volume() * volVars.extrusionFactor()
178 * FluidSystem::molarMass(compIdx)
179 * timeStepSize;
180 }
181 }
182
183 std::cout << "\033[1;33m" << "The domain contains " << tracerMass*1e9 << " µg tracer, "
184 << accumulatedSource_*1e9 << " µg ("<< int(std::round(-accumulatedSource_/(tracerMass - accumulatedSource_)*100))
185 <<"%) was already extracted (balanced: "
186 << (tracerMass - accumulatedSource_)*1e9 << " µg)\033[0m" << '\n';
187
188 }
189
193 // \{
194
200 const std::string& name() const
201 { return name_; }
202
208 Scalar temperature() const
209 { return 273.15 + 10; }; // -> 10°C
210
218 { return 1.0e5; };
219
220 // \}
221
225 // \{
226
233 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
234 {
235 BoundaryTypes bcTypes;
236 if (onLeftBoundary_(globalPos) || onRightBoundary_(globalPos))
237 bcTypes.setAllDirichlet();
238 else
239 bcTypes.setAllNeumann();
240 return bcTypes;
241 }
242
250 PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
251 { return initial_(globalPos); }
252
261 NumEqVector neumannAtPos(const GlobalPosition &globalPos) const
262 { return NumEqVector(0.0); }
263
267 // \{
268
281 void addPointSources(std::vector<PointSource>& pointSources) const
282 {
283 auto globalPos = this->gridGeometry().bBoxMax()-this->gridGeometry().bBoxMin();
284 globalPos *= 0.5;
286 pointSources.emplace_back(globalPos,
287 [this](const Problem &problem,
288 const Element &element,
289 const FVElementGeometry &fvGeometry,
290 const ElementVolumeVariables &elemVolVars,
291 const SubControlVolume &scv)
292 {
293 const auto& volVars = elemVolVars[scv];
296 const Scalar value = pumpRate_*volVars.molarDensity(liquidPhaseIdx)/volVars.density(liquidPhaseIdx)*volVars.saturation(liquidPhaseIdx);
297 return PrimaryVariables({-value, -value*volVars.moleFraction(liquidPhaseIdx, compIdx)});
298 });
299 }
300
309 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
310 { return initial_(globalPos); };
311
312 // \}
313
314private:
315 PrimaryVariables initial_(const GlobalPosition &globalPos) const
316 {
317 const auto xTracer = [&,this]()
318 {
319 const GlobalPosition contaminationPos({0.2*this->gridGeometry().bBoxMax()[0], 0.5*this->gridGeometry().bBoxMax()[1]});
320 if ((globalPos - contaminationPos).two_norm() < 0.1*(this->gridGeometry().bBoxMax()-this->gridGeometry().bBoxMin()).two_norm() + eps_)
321 return contaminantMoleFraction_;
322 else
323 return 0.0;
324 }();
325
326 PrimaryVariables values(0.0);
328 values[pressureIdx] = (nonWettingReferencePressure() - pcTop_)
329 - 9.81*1000*(globalPos[dimWorld-1] - this->gridGeometry().bBoxMax()[dimWorld-1]);
330 values[compIdx] = xTracer;
331 return values;
332 }
333
334 bool onLeftBoundary_(const GlobalPosition &globalPos) const
335 {
336 return globalPos[0] < this->gridGeometry().bBoxMin()[0] + eps_;
337 }
338
339 bool onRightBoundary_(const GlobalPosition &globalPos) const
340 {
341 return globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_;
342 }
343
344 bool onLowerBoundary_(const GlobalPosition &globalPos) const
345 {
346 return globalPos[1] < this->gridGeometry().bBoxMin()[1] + eps_;
347 }
348
349 bool onUpperBoundary_(const GlobalPosition &globalPos) const
350 {
351 return globalPos[1] > this->gridGeometry().bBoxMax()[1] - eps_;
352 }
353
354 static constexpr Scalar eps_ = 1.5e-7;
355 std::string name_;
356 Scalar contaminantMoleFraction_;
357 Scalar pumpRate_;
358 Scalar pcTop_;
359 Scalar accumulatedSource_;
360};
361
362} // end namespace Dumux
363
364#endif
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
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 GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition: common/fvproblem.hh:588
A point source class for time dependent point sources.
Definition: pointsource.hh:213
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 defining the type of point source used.
Definition: common/properties.hh:71
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
A water infiltration problem with a low-permeability lens embedded into a high-permeability domain wh...
Definition: test/porousmediumflow/richardsnc/implicit/problem.hh:110
NumEqVector neumannAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Neumann boundary segment.
Definition: test/porousmediumflow/richardsnc/implicit/problem.hh:261
Scalar temperature() const
Returns the temperature [K] within a finite volume.
Definition: test/porousmediumflow/richardsnc/implicit/problem.hh:208
void printTracerMass(const SolutionVector &curSol, const GridVariables &gridVariables, const Scalar timeStepSize)
Definition: test/porousmediumflow/richardsnc/implicit/problem.hh:153
void addPointSources(std::vector< PointSource > &pointSources) const
Applies a vector of point sources which are possibly solution dependent.
Definition: test/porousmediumflow/richardsnc/implicit/problem.hh:281
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Dirichlet boundary segment.
Definition: test/porousmediumflow/richardsnc/implicit/problem.hh:250
const std::string & name() const
The problem name.
Definition: test/porousmediumflow/richardsnc/implicit/problem.hh:200
Scalar nonWettingReferencePressure() const
Returns the reference pressure [Pa] of the non-wetting fluid phase within a finite volume.
Definition: test/porousmediumflow/richardsnc/implicit/problem.hh:217
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluates the initial values for a control volume.
Definition: test/porousmediumflow/richardsnc/implicit/problem.hh:309
RichardsWellTracerProblem(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: test/porousmediumflow/richardsnc/implicit/problem.hh:137
BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
Specifies which kind of boundary condition should be used for which equation on a given boundary segm...
Definition: test/porousmediumflow/richardsnc/implicit/problem.hh:233
Definition: test/porousmediumflow/richardsnc/implicit/problem.hh:55
std::tuple< RichardsNC > InheritsFrom
Definition: test/porousmediumflow/richardsnc/implicit/problem.hh:55
Definition: test/porousmediumflow/richardsnc/implicit/problem.hh:56
std::tuple< RichardsWellTracer, BoxModel > InheritsFrom
Definition: test/porousmediumflow/richardsnc/implicit/problem.hh:56
Definition: test/porousmediumflow/richardsnc/implicit/problem.hh:57
std::tuple< RichardsWellTracer, CCTpfaModel > InheritsFrom
Definition: test/porousmediumflow/richardsnc/implicit/problem.hh:57
Dune::YaspGrid< 2 > type
Definition: test/porousmediumflow/richardsnc/implicit/problem.hh:62
GetPropType< TypeTag, Properties::GridGeometry > GridGeometry
Definition: test/porousmediumflow/richardsnc/implicit/problem.hh:72
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: test/porousmediumflow/richardsnc/implicit/problem.hh:73
The spatial parameters for the RichardsWellTracerProblem.
Definition: porousmediumflow/richardsnc/implicit/spatialparams.hh:48
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 MaxwellStefan problem.