3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
porousmediumflow/1p/implicit/isothermal/spatialparams.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_1P_TEST_SPATIALPARAMS_HH
27#define DUMUX_1P_TEST_SPATIALPARAMS_HH
28
32
33namespace Dumux {
34
40template<class GridGeometry, class Scalar>
41class OnePTestSpatialParams
42: public FVSpatialParamsOneP<GridGeometry, Scalar,
43 OnePTestSpatialParams<GridGeometry, Scalar>>
44{
45 using GridView = typename GridGeometry::GridView;
46 using FVElementGeometry = typename GridGeometry::LocalView;
47 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
48 using IndexSet = typename GridView::IndexSet;
49 using ParentType = FVSpatialParamsOneP<GridGeometry, Scalar,
50 OnePTestSpatialParams<GridGeometry, Scalar>>;
51
52 enum {
53 dim=GridView::dimension,
54 dimWorld=GridView::dimensionworld
55 };
56
57 using Element = typename GridView::template Codim<0>::Entity;
58 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
59
60public:
61 // export permeability type
62 using PermeabilityType = Scalar;
63
64 OnePTestSpatialParams(std::shared_ptr<const GridGeometry> gridGeometry)
66 randomPermeability_(gridGeometry->gridView().size(dim), 0.0),
67 indexSet_(gridGeometry->gridView().indexSet())
68 {
69 randomField_ = getParam<bool>("SpatialParams.RandomField", false);
70 permeability_ = getParam<Scalar>("SpatialParams.Permeability");
71 if(!randomField_)
72 permeabilityLens_ = getParam<Scalar>("SpatialParams.PermeabilityLens");
73 else
75
76 lensLowerLeft_ = getParam<GlobalPosition>("SpatialParams.LensLowerLeft");
77 lensUpperRight_ = getParam<GlobalPosition>("SpatialParams.LensUpperRight");
78 }
79
88 template<class ElementSolution>
89 PermeabilityType permeability(const Element& element,
90 const SubControlVolume& scv,
91 const ElementSolution& elemSol) const
92 {
93 if (isInLens_(scv.dofPosition()))
94 {
95 if(randomField_)
96 return randomPermeability_[indexSet_.index(element)];
97 else
98 return permeabilityLens_;
99 }
100 else
101 return permeability_;
102 }
103
108 Scalar porosityAtPos(const GlobalPosition& globalPos) const
109 { return 0.4; }
110
116 void initRandomField(const GridGeometry& gg)
117 {
118 const auto& gridView = gg.gridView();
119 const auto& elementMapper = gg.elementMapper();
120 const auto gStatControlFile = getParam<std::string>("Gstat.ControlFile");
121 const auto gStatInputFile = getParam<std::string>("Gstat.InputFile");
122 const auto outputFilePrefix = getParam<std::string>("Gstat.OutputFilePrefix");
123
124 // create random permeability object
125 using RandomField = GstatRandomField<GridView, Scalar>;
126 RandomField randomPermeabilityField(gridView, elementMapper);
127 randomPermeabilityField.create(gStatControlFile,
128 gStatInputFile,
129 outputFilePrefix + ".dat",
130 RandomField::FieldType::log10,
131 true);
132 randomPermeability_.resize(gridView.size(dim), 0.0);
133
134 // copy vector from the temporary gstat object
135 randomPermeability_ = randomPermeabilityField.data();
136 }
137
139 const std::vector<Scalar>& getPermField() const
140 { return randomPermeability_; }
141
142private:
143 bool isInLens_(const GlobalPosition &globalPos) const
144 {
145 for (int i = 0; i < dimWorld; ++i) {
146 if (globalPos[i] < lensLowerLeft_[i] + eps_ || globalPos[i] > lensUpperRight_[i] - eps_)
147 return false;
148 }
149 return true;
150 }
151
152 bool randomField_;
153 GlobalPosition lensLowerLeft_;
154 GlobalPosition lensUpperRight_;
155
156 Scalar permeability_, permeabilityLens_;
157 std::vector<Scalar> randomPermeability_;
158
159 const IndexSet& indexSet_;
160 static constexpr Scalar eps_ = 1.5e-7;
161};
162
163} // end namespace
164
165#endif
The base class for spatial parameters of one-phase problems using a fully implicit discretization met...
Creating random fields using gstat.
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
Creating random fields using gstat.
Definition: gstatrandomfield.hh:49
Scalar PermeabilityType
Definition: multidomain/boundary/darcydarcy/1p_1p/spatialparams.hh:74
PermeabilityType permeability(const Element &element, const SubControlVolume &scv, const ElementSolution &elemSol) const
Function for defining the (intrinsic) permeability .
Definition: porousmediumflow/1p/implicit/isothermal/spatialparams.hh:89
const std::vector< Scalar > & getPermField() const
get the permeability field for output
Definition: porousmediumflow/1p/implicit/isothermal/spatialparams.hh:139
Scalar porosityAtPos(const GlobalPosition &globalPos) const
Defines the porosity in [-].
Definition: porousmediumflow/1p/implicit/isothermal/spatialparams.hh:108
OnePTestSpatialParams(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: porousmediumflow/1p/implicit/isothermal/spatialparams.hh:64
void initRandomField(const GridGeometry &gg)
This method allows the generation of a statistical field using gstat.
Definition: porousmediumflow/1p/implicit/isothermal/spatialparams.hh:116
Defines a type tag and some properties for models using the box scheme.