3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
2ptracer/problem_tracer.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 *****************************************************************************/
24#ifndef DUMUX_TWOP_TRACER_TEST_PROBLEM_HH
25#define DUMUX_TWOP_TRACER_TEST_PROBLEM_HH
26
27#include <dune/grid/yaspgrid.hh>
28
33
35
36namespace Dumux {
41template <class TypeTag>
42class TwoPTracerTestProblem;
43
44namespace Properties {
45//Create new type tags
46namespace TTag {
47struct TwoPTracerTest { using InheritsFrom = std::tuple<Tracer>; };
48struct TwoPTracerTestTpfa { using InheritsFrom = std::tuple<TwoPTracerTest, CCTpfaModel>; };
49} // end namespace TTag
50
51// Set the grid type
52template<class TypeTag>
53struct Grid<TypeTag, TTag::TwoPTracerTest> { using type = Dune::YaspGrid<2>; };
54
55// Set the problem property
56template<class TypeTag>
57struct Problem<TypeTag, TTag::TwoPTracerTest> { using type = TwoPTracerTestProblem<TypeTag>; };
58
59// Set the spatial parameters
60template<class TypeTag>
61struct SpatialParams<TypeTag, TTag::TwoPTracerTest>
62{
66};
67
68// Define whether mole(true) or mass (false) fractions are used
69template<class TypeTag>
70struct UseMoles<TypeTag, TTag::TwoPTracerTest> { static constexpr bool value = false; };
71template<class TypeTag>
72struct SolutionDependentMolecularDiffusion<TypeTag, TTag::TwoPTracerTestTpfa> { static constexpr bool value = false; };
73
75template<class TypeTag>
76class TracerFluidSystem : public FluidSystems::Base<GetPropType<TypeTag, Properties::Scalar>,
77 TracerFluidSystem<TypeTag>>
78{
82 using Element = typename GridView::template Codim<0>::Entity;
83 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
84 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
85
86public:
88 static constexpr bool isTracerFluidSystem()
89 { return true; }
90
92 static constexpr int getMainComponent(int phaseIdx)
93 { return -1; }
94
96 static constexpr int numComponents = 1;
97
99 static std::string componentName(int compIdx)
100 { return "tracer_" + std::to_string(compIdx); }
101
103 static Scalar molarMass(unsigned int compIdx)
104 { return 0.300; }
105
108 static Scalar binaryDiffusionCoefficient(unsigned int compIdx,
109 const Problem& problem,
110 const Element& element,
111 const SubControlVolume& scv)
112 {
113 static const Scalar D = getParam<Scalar>("Problem.BinaryDiffusionCoefficient");
114 return D;
115 }
116};
117
118template<class TypeTag>
119struct FluidSystem<TypeTag, TTag::TwoPTracerTest> { using type = TracerFluidSystem<TypeTag>; };
120
121} // end namespace Properties
122
135template <class TypeTag>
137{
139
148
150 static constexpr bool useMoles = getPropValue<TypeTag, Properties::UseMoles>();
151
152 using Element = typename GridGeometry::GridView::template Codim<0>::Entity;
153 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
154
155public:
156 TwoPTracerTestProblem(std::shared_ptr<const GridGeometry> gridGeometry)
158 {
159 // stating in the console whether mole or mass fractions are used
160 if(useMoles)
161 std::cout<<"problem uses mole fractions" << '\n';
162 else
163 std::cout<<"problem uses mass fractions" << '\n';
164
165 stripeWidth_ = getParam<Scalar>("Problem.StripeWidth", 0.125);
166 }
167
171 // \{
172
179 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
180 {
181 BoundaryTypes values;
182 if (onLeftBoundary_(globalPos) || onRightBoundary_(globalPos))
183 values.setAllDirichlet();
184 else
185 values.setAllNeumann();
186 return values;
187 }
188 // \}
189
193 // \{
194
200 PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
201 {
202 PrimaryVariables initialValues(0.0);
203 return initialValues;
204 }
205
214 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
215 {
216 PrimaryVariables initialValues(0.0);
217
218 if (onStripe1_(globalPos) || onStripe2_(globalPos) || onStripe3_(globalPos))
219 {
220 if (useMoles)
221 initialValues = 1e-9;
222 else
223 initialValues = 1e-9*FluidSystem::molarMass(0)/this->spatialParams().fluidMolarMass(globalPos);
224 }
225 return initialValues;
226 }
227
228private:
229 static constexpr Scalar eps_ = 1e-6;
230 Scalar stripeWidth_;
231
232 bool onUpperBoundary_(const GlobalPosition &globalPos) const
233 {
234 return globalPos[1] > this->gridGeometry().bBoxMax()[1] - 0.1 - eps_;
235 }
236
237 bool onLeftBoundary_(const GlobalPosition &globalPos) const
238 {
239 return globalPos[0] < this->gridGeometry().bBoxMin()[0] + eps_;
240 }
241
242 bool onRightBoundary_(const GlobalPosition &globalPos) const
243 {
244 return globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_;
245 }
246
247 bool onStripe1_(const GlobalPosition &globalPos) const
248 {
249 const auto xMax = this->gridGeometry().bBoxMax()[0];
250 return (
251 ( (xMax /4.0 - stripeWidth_*0.5) < globalPos[0] + eps_ ) &&
252 ( (xMax/4.0 + stripeWidth_*0.5) > globalPos[0] + eps_ )
253 );
254 }
255
256 bool onStripe2_(const GlobalPosition &globalPos) const
257 {
258 const auto xMax = this->gridGeometry().bBoxMax()[0];
259 return (
260 ( (2.0 * xMax /4.0 - stripeWidth_*0.5) < globalPos[0] + eps_ ) &&
261 ( (2.0 * xMax/4.0 + stripeWidth_*0.5) > globalPos[0] + eps_ )
262 );
263 }
264
265 bool onStripe3_(const GlobalPosition &globalPos) const
266 {
267 const auto xMax = this->gridGeometry().bBoxMax()[0];
268 return (
269 ( (3.0 * xMax /4.0 - stripeWidth_*0.5) < globalPos[0] + eps_ ) &&
270 ( (3.0 * xMax/4.0 + stripeWidth_*0.5) > globalPos[0] + eps_ )
271 );
272 }
273
274};
275
276} //end namespace Dumux
277
278#endif
Properties for all models using cell-centered finite volume scheme with TPFA.
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
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition: common/fvproblem.hh:588
Property to specify the type of scalar values.
Definition: common/properties.hh:53
The DUNE grid type.
Definition: common/properties.hh:57
The type of the grid view according to the grid type.
Definition: common/properties.hh:63
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
specifies if the parameters for the diffusive fluxes depend on the solution
Definition: common/properties.hh:214
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
Fluid system base class.
Definition: fluidsystems/base.hh:45
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
GetPropType< TypeTag, Properties::SpatialParams > SpatialParams
Export spatial parameter type.
Definition: dumux/porousmediumflow/problem.hh:58
A simple fluid system with one tracer component.
Definition: 1ptracer/problem_tracer.hh:89
static constexpr int numComponents
The number of components.
Definition: 1ptracer/problem_tracer.hh:107
static Scalar binaryDiffusionCoefficient(unsigned int compIdx, const Problem &problem, const Element &element, const SubControlVolume &scv)
Definition: 2ptracer/problem_tracer.hh:108
static std::string componentName(int compIdx)
Human readable component name (index compIdx) (for vtk output)
Definition: 2ptracer/problem_tracer.hh:99
static constexpr bool isTracerFluidSystem()
If the fluid system only contains tracer components.
Definition: 2ptracer/problem_tracer.hh:88
static Scalar molarMass(unsigned int compIdx)
Molar mass in kg/mol of the component with index compIdx.
Definition: 2ptracer/problem_tracer.hh:103
static constexpr int getMainComponent(int phaseIdx)
No component is the main component.
Definition: 2ptracer/problem_tracer.hh:92
A 2p problem with multiple tracer bands in a porous groundwater reservoir with a lens.
Definition: 2ptracer/problem_tracer.hh:137
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluates the initial value for a control volume.
Definition: 2ptracer/problem_tracer.hh:214
BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
Specifies which kind of boundary condition should be used for which equation on a given boundary segm...
Definition: 2ptracer/problem_tracer.hh:179
TwoPTracerTestProblem(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: 2ptracer/problem_tracer.hh:156
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Dirichlet boundary segment.
Definition: 2ptracer/problem_tracer.hh:200
Definition: 2ptracer/problem_tracer.hh:47
std::tuple< Tracer > InheritsFrom
Definition: 2ptracer/problem_tracer.hh:47
Definition: 2ptracer/problem_tracer.hh:48
std::tuple< TwoPTracerTest, CCTpfaModel > InheritsFrom
Definition: 2ptracer/problem_tracer.hh:48
Dune::YaspGrid< 2 > type
Definition: 2ptracer/problem_tracer.hh:53
GetPropType< TypeTag, Properties::GridGeometry > GridGeometry
Definition: 2ptracer/problem_tracer.hh:63
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: 2ptracer/problem_tracer.hh:64
Definition of the spatial parameters for the tracer problem.
Definition: porousmediumflow/tracer/2ptracer/spatialparams_tracer.hh:41
Adaption of the fully implicit scheme to the tracer transport model.
Base class for all porous media problems.
Fluid system base class.
Definition of the spatial parameters for the tracer problem.