Loading [MathJax]/extensions/tex2jax.js
3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
test/porousmediumflow/2p/implicit/cornerpoint/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 *****************************************************************************/
24#ifndef DUMUX_TWOP_CORNERPOINT_TEST_PROBLEM_HH
25#define DUMUX_TWOP_CORNERPOINT_TEST_PROBLEM_HH
26
27#if HAVE_OPM_GRID
28#include <opm/grid/CpGrid.hpp>
29
31
36
40
41#include "spatialparams.hh"
42
43namespace Dumux {
44// forward declarations
45template<class TypeTag> class TwoPCornerPointTestProblem;
46
47namespace Properties {
48// Create new type tags
49namespace TTag {
50struct TwoPCornerPoint { using InheritsFrom = std::tuple<CCTpfaModel, TwoP>; };
51} // end namespace TTag
52
53// Set the grid type
54template<class TypeTag>
55struct Grid<TypeTag, TTag::TwoPCornerPoint> { using type = Dune::CpGrid; };
56
57// Set the problem type
58template<class TypeTag>
59struct Problem<TypeTag, TTag::TwoPCornerPoint> { using type = TwoPCornerPointTestProblem<TypeTag>; };
60
61// the local residual containing the analytic derivative methods
62template<class TypeTag>
63struct LocalResidual<TypeTag, TTag::TwoPCornerPoint> { using type = TwoPIncompressibleLocalResidual<TypeTag>; };
64
65// Set the fluid system
66template<class TypeTag>
67struct FluidSystem<TypeTag, TTag::TwoPCornerPoint>
68{
69 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
70 using WettingPhase = FluidSystems::OnePLiquid<Scalar, Components::SimpleH2O<Scalar> >;
71 using NonwettingPhase = FluidSystems::OnePLiquid<Scalar, Components::Trichloroethene<Scalar> >;
72 using type = FluidSystems::TwoPImmiscible<Scalar, WettingPhase, NonwettingPhase>;
73};
74
75// Set the spatial parameters
76template<class TypeTag>
77struct SpatialParams<TypeTag, TTag::TwoPCornerPoint>
78{
79private:
80 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
81 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
82public:
83 using type = TwoPCornerPointTestSpatialParams<GridGeometry, Scalar>;
84};
85
86// Enable caching
87template<class TypeTag>
88struct EnableGridVolumeVariablesCache<TypeTag, TTag::TwoPCornerPoint> { static constexpr bool value = false; };
89template<class TypeTag>
90struct EnableGridFluxVariablesCache<TypeTag, TTag::TwoPCornerPoint> { static constexpr bool value = false; };
91template<class TypeTag>
92struct EnableGridGeometryCache<TypeTag, TTag::TwoPCornerPoint> { static constexpr bool value = false; };
93} // end namespace Properties
94
99template<class TypeTag>
100class TwoPCornerPointTestProblem : public PorousMediumFlowProblem<TypeTag>
101{
102 using ParentType = PorousMediumFlowProblem<TypeTag>;
103 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
104 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
105 using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
106 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
107 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
108 using GridView = typename GridGeometry::GridView;
109 using Element = typename GridView::template Codim<0>::Entity;
110 using FVElementGeometry = typename GridGeometry::LocalView;
111 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
112 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
113 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
114 using BoundaryTypes = GetPropType<TypeTag, Properties::BoundaryTypes>;
115 using NumEqVector = GetPropType<TypeTag, Properties::NumEqVector>;
117 enum { dimWorld = GridView::dimensionworld };
118
119public:
120 TwoPCornerPointTestProblem(std::shared_ptr<const GridGeometry> gridGeometry,
121 std::shared_ptr<typename ParentType::SpatialParams> spatialParams)
122 : ParentType(gridGeometry, spatialParams)
123 {
124 gravity_ = {0, 0, 9.81};
125 injectionElement_ = getParam<int>("Problem.InjectionElement");
126 injectionRate_ = getParam<Scalar>("Problem.InjectionRate");
127 }
128
136 BoundaryTypes boundaryTypes(const Element &element,
137 const SubControlVolumeFace &scvf) const
138 {
139 BoundaryTypes bcTypes;
140
141 // set no-flux on top and bottom, hydrostatic on the rest
142 // use the scvf normal to decide
143 const auto& normal = scvf.unitOuterNormal();
144 using std::abs;
145 if (abs(normal[dimWorld-1]) > 0.5)
146 bcTypes.setAllNeumann();
147 else
148 bcTypes.setAllDirichlet();
149
150 return bcTypes;
151 }
152
160 PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
161 {
162 return initialAtPos(globalPos);
163 }
164
175 NumEqVector neumannAtPos(const GlobalPosition &globalPos) const
176 {
177 return NumEqVector(0.0);
178 }
179
181 NumEqVector source(const Element &element,
182 const FVElementGeometry& fvGeometry,
183 const ElementVolumeVariables& elemVolVars,
184 const SubControlVolume &scv) const
185 {
186 NumEqVector values(0.0);
187
188 int eIdx = this->gridGeometry().gridView().indexSet().index(element);
189 if (eIdx == injectionElement_)
190 values[FluidSystem::phase1Idx] = injectionRate_/element.geometry().volume();
191
192 return values;
193 }
194
195 const GlobalPosition& gravity() const
196 {
197 return gravity_;
198 }
199
207 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
208 {
209 PrimaryVariables values;
210
211 // hydrostatic pressure
212 Scalar densityW = 1000;
213 values[Indices::pressureIdx] = 1e5 + densityW*(this->spatialParams().gravity(globalPos)*globalPos);
214 values[Indices::saturationIdx] = 0.0;
215
216 return values;
217 }
218
226 Scalar temperature() const
227 {
228 return 293.15;
229 }
230
236 template<class VTKWriter>
237 void addFieldsToWriter(VTKWriter& vtk)
238 {
239 const auto numElements = this->gridGeometry().gridView().size(0);
240
241 permX_.resize(numElements);
242 permZ_.resize(numElements);
243
244 vtk.addField(permX_, "PERMX [mD]");
245 vtk.addField(permZ_, "PERMZ [mD]");
246
247 const auto& gridView = this->gridGeometry().gridView();
248 for (const auto& element : elements(gridView))
249 {
250 const auto eIdx = this->gridGeometry().elementMapper().index(element);
251
252 // transfer output to mD = 9.86923e-16 m^2
253 permX_[eIdx] = this->spatialParams().permeabilityX(eIdx)/9.86923e-16;
254 permZ_[eIdx] = this->spatialParams().permeabilityZ(eIdx)/9.86923e-16;
255 }
256 }
257
258private:
259 GlobalPosition gravity_;
260 int injectionElement_;
261 Scalar injectionRate_;
262 std::vector<Scalar> permX_, permZ_;
263};
264
265} // end namespace Dumux
266
267#else
268#warning "The opm-grid module is needed to use this class!"
269#endif
270
271#endif
Properties for all models using cell-centered finite volume scheme with TPFA.
A much simpler (and thus potentially less buggy) version of pure water.
A simple implementation of Trichloroethene (TCE), a DNAPL.
A liquid phase consisting of a single component.
A fluid system for two-phase models assuming immiscibility and thermodynamic equilibrium.
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
Property tag Indices
Definition: porousmediumflow/sequential/properties.hh:59
std::string temperature() noexcept
I/O name of temperature for equilibrium models.
Definition: name.hh:51
UndefinedProperty type
Definition: common/properties.hh:57
UndefinedProperty type
Definition: common/properties.hh:69
UndefinedProperty type
Definition: common/properties.hh:91
UndefinedProperty type
Definition: common/properties.hh:221
UndefinedProperty type
Definition: common/properties.hh:223
Adaption of the fully implicit scheme to the two-phase flow model.
Base class for all porous media problems.
Element-wise calculation of the residual and its derivatives for a two-phase, incompressible test pro...