3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
test/porousmediumflow/1p/implicit/network1d3d/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 *****************************************************************************/
26#ifndef DUMUX_ONEP_TUBES_TEST_PROBLEM_HH
27#define DUMUX_ONEP_TUBES_TEST_PROBLEM_HH
28
29#include <dune/localfunctions/lagrange/pqkfactory.hh>
30#include <dune/geometry/quadraturerules.hh>
31
32#if HAVE_DUNE_FOAMGRID
33#include <dune/foamgrid/foamgrid.hh>
34#endif
35
45
46#include "spatialparams.hh"
47
48namespace Dumux {
49
50template <class TypeTag>
51class TubesTestProblem;
52
53namespace Properties {
54
55// Create new type tags
56namespace TTag {
57struct TubesTest { using InheritsFrom = std::tuple<OneP>; };
58struct TubesTestCCTpfa { using InheritsFrom = std::tuple<TubesTest, CCTpfaModel>; };
59struct TubesTestBox { using InheritsFrom = std::tuple<TubesTest, BoxModel>; };
60} // end namespace TTag
61
62// Set the grid type
63#if HAVE_DUNE_FOAMGRID
64template<class TypeTag>
65struct Grid<TypeTag, TTag::TubesTest> { using type = Dune::FoamGrid<1, 3>; };
66#endif
67
68// Dumux 3.1 changes the property `FVGridGeometry` to `GridGeometry`.
69// For ensuring backward compatibility on the user side, it is necessary to
70// stick to the old name for the specializations, see the discussion in MR 1647.
71// Use diagnostic pragmas to prevent the emission of a warning message.
72// TODO after 3.1: Rename to GridGeometry, remove the pragmas and this comment.
73#pragma GCC diagnostic push
74#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
75// if we have pt scotch use the reordering dof mapper to optimally sort the dofs (cc)
76template<class TypeTag>
77struct FVGridGeometry<TypeTag, TTag::TubesTestCCTpfa>
78{
79private:
80 static constexpr bool enableCache = getPropValue<TypeTag, Properties::EnableGridGeometryCache>();
82
83 using ElementMapper = ReorderingDofMapper<GridView>;
84 using VertexMapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView>;
86public:
88};
89
90// if we have pt scotch use the reordering dof mapper to optimally sort the dofs (box)
91template<class TypeTag>
92struct FVGridGeometry<TypeTag, TTag::TubesTestBox>
93{
94private:
95 static constexpr bool enableCache = getPropValue<TypeTag, Properties::EnableGridGeometryCache>();
98
99 using ElementMapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView>;
100 using VertexMapper = ReorderingDofMapper<GridView>;
102public:
104};
105#pragma GCC diagnostic pop
106
107// Set the problem property
108template<class TypeTag>
109struct Problem<TypeTag, TTag::TubesTest> { using type = TubesTestProblem<TypeTag>; };
110
111// Set the spatial parameters
112template<class TypeTag>
113struct SpatialParams<TypeTag, TTag::TubesTest>
114{
118};
119
120// the fluid system
121template<class TypeTag>
122struct FluidSystem<TypeTag, TTag::TubesTest>
123{
126};
127} // end namespace Properties
128
134template <class TypeTag>
136{
140 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
141
142 // Grid and world dimension
143 static const int dim = GridView::dimension;
144 static const int dimWorld = GridView::dimensionworld;
145
147 enum {
148 // indices of the primary variables
149 conti0EqIdx = Indices::conti0EqIdx,
150 pressureIdx = Indices::pressureIdx
151 };
152
156 using Element = typename GridView::template Codim<0>::Entity;
159 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
160 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
161 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
162
164
165public:
166 TubesTestProblem(std::shared_ptr<const GridGeometry> gridGeometry)
168 {
169 name_ = getParam<std::string>("Problem.Name");
170
171 //get hMax_ of the grid
172 hMax_ = 0.0;
173 for (const auto& element : elements(gridGeometry->gridView()))
174 hMax_ = std::max(element.geometry().volume(), hMax_);
175 }
176
180 // \{
181
187 const std::string& name() const
188 {
189 return name_;
190 }
191
196 Scalar temperature() const
197 { return 273.15 + 37.0; } // Body temperature
198
208 template<class ElementSolution>
209 Scalar extrusionFactor(const Element &element,
210 const SubControlVolume &scv,
211 const ElementSolution& elemSol) const
212 {
213 const auto radius = this->spatialParams().radius(scv);
214 return M_PI*radius*radius;
215 }
216
217 // \}
221 // \{
222
229 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
230 {
231 BoundaryTypes bcTypes;
232 bcTypes.setAllDirichlet();
233 return bcTypes;
234 }
235
243 PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
244 {
245 return PrimaryVariables(0.0);
246 }
247
248 // \}
249
253 // \{
254
273 NumEqVector source(const Element &element,
274 const FVElementGeometry& fvGeometry,
275 const ElementVolumeVariables& elemVolVars,
276 const SubControlVolume &scv) const
277 {
278 NumEqVector source(0.0);
279
280 const auto& globalPos = scv.center();
281 const auto& volVars = elemVolVars[scv];
282 const auto K = this->spatialParams().permeability(element, scv, EmptyElementSolution{});
283
284 using std::sin;
285 if (globalPos[2] > 0.5 - eps_)
286 source[conti0EqIdx] = K/volVars.viscosity()*volVars.density()
287 *4.0*4.0*M_PI*M_PI*sin(4.0*M_PI*globalPos[2]);
288 else
289 // the "/3.0" stems from the coordindate transformations on the lower branches
290 source[conti0EqIdx] = K/volVars.viscosity()*volVars.density()
291 *4.0*4.0*M_PI*M_PI*sin(4.0*M_PI*globalPos[2])/3.0;
292
293 return source;
294 }
295
302 PrimaryVariables initialAtPos(const GlobalPosition& globalPos) const
303 {
304 return PrimaryVariables(0.0);
305 }
306
307 // \}
308
309 void outputL2Norm(const SolutionVector solution) const
310 {
311 // calculate the discrete L2-Norm
312 Scalar lTwoNorm = 0.0;
313
314 // get the Gaussian quadrature rule for intervals
315 const auto& quad = Dune::QuadratureRules<Scalar, dim>::rule(Dune::GeometryType(1), 1);
316
317 const auto& gg = this->gridGeometry();
318 for (const auto& element : elements(gg.gridView()))
319 {
320 const auto eIdx = gg.elementMapper().index(element);
321 const auto geometry = element.geometry();
322 for(auto&& qp : quad)
323 {
324 const auto globalPos = geometry.global(qp.position());
325 const Scalar pe = exactPressure_(globalPos);
326 const Scalar integrationElement = geometry.integrationElement(qp.position());
327 Scalar p = 0.0;
328 if (!isBox)
329 p = solution[eIdx][pressureIdx];
330 else
331 {
332 // do interpolation with ansatz functions
333 std::vector<Dune::FieldVector<Scalar, 1> > shapeValues;
334 const auto& localFiniteElement = feCache_.get(geometry.type());
335 localFiniteElement.localBasis().evaluateFunction(qp.position(), shapeValues);
336 for (unsigned int i = 0; i < shapeValues.size(); ++i)
337 p += shapeValues[i]*solution[gg.dofMapper().subIndex(element, i, dim)][pressureIdx];
338 }
339 lTwoNorm += (p - pe)*(p - pe)*qp.weight()*integrationElement;
340 }
341 }
342 lTwoNorm = std::sqrt(lTwoNorm);
343
344 // write the norm into a log file
345 std::ofstream logFile;
346 logFile.open(this->name() + ".log", std::ios::app);
347 logFile << "[ConvergenceTest] L2-norm(pressure) = " << lTwoNorm << " hMax = " << hMax_ << std::endl;
348 logFile.close();
349 }
350
351private:
352
353 Scalar exactPressure_(const GlobalPosition& globalPos) const
354 {
355 using std::sin;
356 return sin(4.0*M_PI*globalPos[2]);
357 }
358
359 static constexpr Scalar eps_ = 1e-8;
360 std::string name_;
361
362 Scalar hMax_;
363
364 typename Dune::PQkLocalFiniteElementCache<Scalar, Scalar, dim, 1> feCache_;
365};
366
367} // end namespace Dumux
368
369#endif
Element solution classes and factory functions.
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.
The available discretization methods in Dumux.
Setting constant fluid properties via the input file.
A liquid phase consisting of a single component.
An SCSG element mapper that sorts the indices in order to optimize the matrix sparsity pattern.
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
Dune::MultipleCodimMultipleGeomTypeMapper< GridView > ReorderingDofMapper
Definition: reorderingdofmapper.hh:191
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
Definition: defaultmappertraits.hh:35
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
The DUNE grid type.
Definition: common/properties.hh:57
UndefinedProperty type
Definition: common/properties.hh:57
Property to specify the type of a problem which has to be solved.
Definition: common/properties.hh:69
The type of the global finite volume geometry.
Definition: common/properties.hh:125
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
Base class for the finite volume geometry vector for box schemes This builds up the sub control volum...
Definition: discretization/box/fvgridgeometry.hh:73
The finite volume geometry (scvs and scvfs) for cell-centered TPFA models on a grid view This builds ...
Definition: discretization/cellcentered/tpfa/fvgridgeometry.hh:79
Definition: elementsolution.hh:33
A liquid phase consisting of a single component.
Definition: 1pliquid.hh:46
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 test problem for the 1p model: A pipe system with circular cross-section and a branching point embe...
Definition: test/porousmediumflow/1p/implicit/network1d3d/problem.hh:136
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Dirichlet control volume.
Definition: test/porousmediumflow/1p/implicit/network1d3d/problem.hh:243
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluates the initial value for a control volume.
Definition: test/porousmediumflow/1p/implicit/network1d3d/problem.hh:302
Scalar temperature() const
Returns the temperature within the domain in [K].
Definition: test/porousmediumflow/1p/implicit/network1d3d/problem.hh:196
BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
Specifies which kind of boundary condition should be used for which equation on a given boundary cont...
Definition: test/porousmediumflow/1p/implicit/network1d3d/problem.hh:229
Scalar extrusionFactor(const Element &element, const SubControlVolume &scv, const ElementSolution &elemSol) const
Returns how much the domain is extruded at a given sub-control volume.
Definition: test/porousmediumflow/1p/implicit/network1d3d/problem.hh:209
TubesTestProblem(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: test/porousmediumflow/1p/implicit/network1d3d/problem.hh:166
void outputL2Norm(const SolutionVector solution) const
Definition: test/porousmediumflow/1p/implicit/network1d3d/problem.hh:309
const std::string & name() const
The problem name.
Definition: test/porousmediumflow/1p/implicit/network1d3d/problem.hh:187
NumEqVector source(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolume &scv) const
Evaluates the source term for all phases within a given sub-control volume.
Definition: test/porousmediumflow/1p/implicit/network1d3d/problem.hh:273
Definition: test/porousmediumflow/1p/implicit/network1d3d/problem.hh:57
std::tuple< OneP > InheritsFrom
Definition: test/porousmediumflow/1p/implicit/network1d3d/problem.hh:57
Definition: test/porousmediumflow/1p/implicit/network1d3d/problem.hh:58
std::tuple< TubesTest, CCTpfaModel > InheritsFrom
Definition: test/porousmediumflow/1p/implicit/network1d3d/problem.hh:58
Definition: test/porousmediumflow/1p/implicit/network1d3d/problem.hh:59
std::tuple< TubesTest, BoxModel > InheritsFrom
Definition: test/porousmediumflow/1p/implicit/network1d3d/problem.hh:59
GetPropType< TypeTag, Properties::GridGeometry > GridGeometry
Definition: test/porousmediumflow/1p/implicit/network1d3d/problem.hh:115
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: test/porousmediumflow/1p/implicit/network1d3d/problem.hh:116
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: test/porousmediumflow/1p/implicit/network1d3d/problem.hh:124
A test problem for the 1p model: A pipe system with circular cross-section and a branching point embe...
Definition: porousmediumflow/1p/implicit/network1d3d/spatialparams.hh:43
Base class for all porous media problems.
A single-phase, isothermal flow model using the fully implicit scheme.
Definition of the spatial parameters for the MaxwellStefan problem.