3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
test/porousmediumflow/2p/implicit/adaptive/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_LENSPROBLEM_ADAPTIVE_HH
27#define DUMUX_LENSPROBLEM_ADAPTIVE_HH
28
29#include "../incompressible/problem.hh"
30
31#include <dumux/io/container.hh>
32
33namespace Dumux {
34
40template <class TypeTag >
42{
45 using Element = typename GridView::template Codim<0>::Entity;
46 using Vertex = typename GridView::template Codim<GridView::dimensionworld>::Entity;
50
51 static constexpr bool isBox = GridGeometry::discMethod == DiscretizationMethod::box;
52
53public:
54 TwoPTestProblemAdaptive(std::shared_ptr<const GridGeometry> gridGeometry)
56 {
57 if(!isBox)
58 initialValues_ = readFileToContainer<std::vector<PrimaryVariables>>("initialsolutioncc.txt");
59 else
60 initialValues_ = readFileToContainer<std::vector<PrimaryVariables>>("initialsolutionbox.txt");
61 }
62
66 PrimaryVariables initial(const Element& element) const
67 {
68 const auto delta = 0.0625;
69 unsigned int cellsX = this->gridGeometry().bBoxMax()[0]/delta;
70 const auto globalPos = element.geometry().center();
71
72 // the input data corresponds to a uniform grid with discretization length deltaX_
73 unsigned int dataIdx = std::trunc(globalPos[1]/delta) * cellsX + std::trunc(globalPos[0]/delta);
74 return initialValues_[dataIdx];
75 }
76
80 PrimaryVariables initial(const Vertex& vertex) const
81 {
82 const auto delta = 0.0625;
83 unsigned int verticesX = this->gridGeometry().bBoxMax()[0]/delta + 1;
84 const auto globalPos = vertex.geometry().center();
85
86 // the input data corresponds to a uniform grid with discretization length deltaX_
87 unsigned int dataIdx = std::trunc(globalPos[1]/delta) * verticesX + std::trunc(globalPos[0]/delta);
88 return initialValues_[dataIdx];
89 }
90
91private:
92 std::vector<PrimaryVariables> initialValues_;
93};
94
95} // end namespace Dumux
96
97#endif
Free functions to write and read a sequence container to and from a file.
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
Soil contamination problem where DNAPL infiltrates a fully water saturated medium.
Definition: test/porousmediumflow/2p/implicit/adaptive/problem.hh:42
TwoPTestProblemAdaptive(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: test/porousmediumflow/2p/implicit/adaptive/problem.hh:54
PrimaryVariables initial(const Vertex &vertex) const
Evaluates the initial value for a vertex for vertex-centered models.
Definition: test/porousmediumflow/2p/implicit/adaptive/problem.hh:80
PrimaryVariables initial(const Element &element) const
Evaluates the initial value for an element for cell-centered models.
Definition: test/porousmediumflow/2p/implicit/adaptive/problem.hh:66
The incompressible 2p-boxdfm test problem.
Definition: test/porousmediumflow/2p/implicit/incompressible/problem.hh:112