27#ifndef DUMUX_RICHARDS_NC_WELL_TRACER_PROBLEM_HH
28#define DUMUX_RICHARDS_NC_WELL_TRACER_PROBLEM_HH
30#include <dune/grid/yaspgrid.hh>
47template <
class TypeTag>
48class RichardsWellTracerProblem;
61template<
class TypeTag>
62struct Grid<TypeTag, TTag::RichardsWellTracer> {
using type = Dune::YaspGrid<2>; };
65template<
class TypeTag>
69template<
class TypeTag>
78template<
class TypeTag>
108template <
class TypeTag>
117 using SubControlVolume =
typename FVElementGeometry::SubControlVolume;
128 pressureIdx = Indices::pressureIdx,
129 compIdx = Indices::compMainIdx + 1,
130 liquidPhaseIdx = FluidSystem::liquidPhaseIdx,
131 dimWorld = GridView::dimensionworld
133 using Element =
typename GridView::template Codim<0>::Entity;
134 using GlobalPosition =
typename SubControlVolume::GlobalPosition;
140 name_ = getParam<std::string>(
"Problem.Name");
141 contaminantMoleFraction_ = getParam<Scalar>(
"Problem.ContaminantMoleFraction");
142 pumpRate_ = getParam<Scalar>(
"Problem.PumpRate");
145 const Scalar sw = 0.4;
146 using MaterialLaw =
typename ParentType::SpatialParams::MaterialLaw;
150 accumulatedSource_ = 0.0;
154 const GridVariables& gridVariables,
155 const Scalar timeStepSize)
159 Scalar tracerMass = 0.0;
162 for (
const auto& element : elements(this->
gridGeometry().gridView()))
165 fvGeometry.bindElement(element);
167 auto elemVolVars =
localView(gridVariables.curGridVolVars());
168 elemVolVars.bindElement(element, fvGeometry, curSol);
170 for (
auto&& scv : scvs(fvGeometry))
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();
176 accumulatedSource_ += this->
scvPointSources(element, fvGeometry, elemVolVars, scv)[compIdx]
177 * scv.volume() * volVars.extrusionFactor()
178 * FluidSystem::molarMass(compIdx)
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';
200 const std::string&
name()
const
209 {
return 273.15 + 10; };
235 BoundaryTypes bcTypes;
236 if (onLeftBoundary_(globalPos) || onRightBoundary_(globalPos))
237 bcTypes.setAllDirichlet();
239 bcTypes.setAllNeumann();
251 {
return initial_(globalPos); }
262 {
return NumEqVector(0.0); }
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)
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)});
310 {
return initial_(globalPos); };
315 PrimaryVariables initial_(
const GlobalPosition &globalPos)
const
317 const auto xTracer = [&,
this]()
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_;
326 PrimaryVariables values(0.0);
329 - 9.81*1000*(globalPos[dimWorld-1] - this->
gridGeometry().bBoxMax()[dimWorld-1]);
330 values[compIdx] = xTracer;
334 bool onLeftBoundary_(
const GlobalPosition &globalPos)
const
336 return globalPos[0] < this->
gridGeometry().bBoxMin()[0] + eps_;
339 bool onRightBoundary_(
const GlobalPosition &globalPos)
const
341 return globalPos[0] > this->
gridGeometry().bBoxMax()[0] - eps_;
344 bool onLowerBoundary_(
const GlobalPosition &globalPos)
const
346 return globalPos[1] < this->
gridGeometry().bBoxMin()[1] + eps_;
349 bool onUpperBoundary_(
const GlobalPosition &globalPos)
const
351 return globalPos[1] > this->
gridGeometry().bBoxMax()[1] - eps_;
354 static constexpr Scalar eps_ = 1.5e-7;
356 Scalar contaminantMoleFraction_;
359 Scalar accumulatedSource_;
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.