3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
porousmediumflow/tracer/1ptracer/spatialparams_1p.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 *****************************************************************************/
25#ifndef DUMUX_INCOMPRESSIBLE_ONEP_TEST_SPATIAL_PARAMS_HH
26#define DUMUX_INCOMPRESSIBLE_ONEP_TEST_SPATIAL_PARAMS_HH
27
28#include <random>
31
32namespace Dumux {
33
38template<class GridGeometry, class Scalar>
39class OnePTestSpatialParams
40: public FVSpatialParamsOneP<GridGeometry, Scalar,
41 OnePTestSpatialParams<GridGeometry, Scalar>>
42{
43 using GridView = typename GridGeometry::GridView;
44 using FVElementGeometry = typename GridGeometry::LocalView;
45 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
46 using Element = typename GridView::template Codim<0>::Entity;
47 using ParentType = FVSpatialParamsOneP<GridGeometry, Scalar,
48 OnePTestSpatialParams<GridGeometry, Scalar>>;
49
50 static constexpr int dimWorld = GridView::dimensionworld;
51 using GlobalPosition = typename SubControlVolume::GlobalPosition;
52
53public:
54 using PermeabilityType = Scalar;
55 OnePTestSpatialParams(std::shared_ptr<const GridGeometry> gridGeometry)
56 : ParentType(gridGeometry), K_(gridGeometry->gridView().size(0), 0.0)
57 {
58 permeability_ = getParam<Scalar>("SpatialParams.Permeability");
59 permeabilityLens_ = getParam<Scalar>("SpatialParams.PermeabilityLens");
60
61 lensLowerLeft_ = getParam<GlobalPosition>("SpatialParams.LensLowerLeft");
62 lensUpperRight_ =getParam<GlobalPosition>("SpatialParams.LensUpperRight");
63
64 // generate random fields
65 std::mt19937 rand(0);
66 std::lognormal_distribution<Scalar> K(std::log(permeability_), std::log(permeability_)*0.1);
67 std::lognormal_distribution<Scalar> KLens(std::log(permeabilityLens_), std::log(permeabilityLens_)*0.1);
68 for (const auto& element : elements(gridGeometry->gridView()))
69 {
70 const auto eIdx = gridGeometry->elementMapper().index(element);
71 const auto globalPos = element.geometry().center();
72 K_[eIdx] = isInLens_(globalPos) ? KLens(rand) : K(rand);
73 }
74 }
75
84 template<class ElementSolution>
85 const PermeabilityType& permeability(const Element& element,
86 const SubControlVolume& scv,
87 const ElementSolution& elemSol) const
88 {
89 return K_[scv.dofIndex()];
90
91 // if (isInLens_(scv.dofPosition()))
92 // return permeabilityLens_;
93 // else
94 // return permeability_;
95 }
96
102 Scalar porosityAtPos(const GlobalPosition &globalPos) const
103 { return 0.2; }
104
106 const std::vector<Scalar>& getKField() const
107 { return K_; }
108
109private:
110 bool isInLens_(const GlobalPosition &globalPos) const
111 {
112 for (int i = 0; i < dimWorld; ++i) {
113 if (globalPos[i] < lensLowerLeft_[i] + eps_ || globalPos[i] > lensUpperRight_[i] - eps_)
114 return false;
115 }
116 return true;
117 }
118
119 GlobalPosition lensLowerLeft_;
120 GlobalPosition lensUpperRight_;
121
122 Scalar permeability_, permeabilityLens_;
123
124 std::vector<Scalar> K_;
125
126 static constexpr Scalar eps_ = 1.5e-7;
127};
128
129} // end namespace Dumux
130
131#endif
The base class for spatial parameters of one-phase problems using a fully implicit discretization met...
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
The base class for spatial parameters of one-phase problems using a fully implicit discretization met...
Definition: fv1p.hh:77
FVSpatialParamsOneP(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: fv1p.hh:91
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition: fv1p.hh:334
Scalar PermeabilityType
Definition: multidomain/boundary/darcydarcy/1p_1p/spatialparams.hh:74
const PermeabilityType & permeability(const Element &element, const SubControlVolume &scv, const ElementSolution &elemSol) const
Function for defining the (intrinsic) permeability .
Definition: porousmediumflow/tracer/1ptracer/spatialparams_1p.hh:85
const std::vector< Scalar > & getKField() const
Reference to the k field.
Definition: porousmediumflow/tracer/1ptracer/spatialparams_1p.hh:106
Scalar porosityAtPos(const GlobalPosition &globalPos) const
Function for defining the porosity which is possibly solution dependent.
Definition: porousmediumflow/tracer/1ptracer/spatialparams_1p.hh:102
OnePTestSpatialParams(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: porousmediumflow/tracer/1ptracer/spatialparams_1p.hh:55
Defines a type tag and some properties for models using the box scheme.