opm-simulators
Loading...
Searching...
No Matches
structuredgridvanguard.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 This file is part of the Open Porous Media project (OPM).
5
6 OPM 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 2 of the License, or
9 (at your option) any later version.
10
11 OPM 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 OPM. If not, see <http://www.gnu.org/licenses/>.
18
19 Consult the COPYING file in the top-level source directory of this
20 module for the precise wording of the license and the list of
21 copyright holders.
22*/
27#ifndef EWOMS_STRUCTURED_GRID_VANGUARD_HH
28#define EWOMS_STRUCTURED_GRID_VANGUARD_HH
29
30#include <dune/common/fvector.hh>
31#include <dune/common/version.hh>
32
33#include <dune/grid/yaspgrid.hh>
34#include <dune/grid/io/file/dgfparser/dgfyasp.hh>
35
37
42
43#if HAVE_DUNE_ALUGRID
44#include <dune/alugrid/grid.hh>
45#include <dune/alugrid/dgf.hh>
46#endif
47
48#include <memory>
49#include <sstream>
50
51namespace Opm {
52
53template <class TypeTag>
55
56} // namespace Opm
57
58namespace Opm::Properties {
59
60namespace TTag {
61
63
64} // namespace TTag
65
66// GRIDDIM is only set by the finger problem
67#ifndef GRIDDIM
68static constexpr int dim = 2;
69#else
70static constexpr int dim = GRIDDIM;
71#endif
72
73// set the Grid and Vanguard properties
74#if HAVE_DUNE_ALUGRID
75template<class TypeTag>
76struct Grid<TypeTag, TTag::StructuredGridVanguard>
77{ using type = Dune::ALUGrid< dim, dim, Dune::cube, Dune::nonconforming >; };
78#else
79template<class TypeTag>
81{ using type = Dune::YaspGrid< dim >; };
82#endif
83
84template<class TypeTag>
87
88} // namespace Opm::Properties
89
90namespace Opm {
91
97template <class TypeTag>
98class StructuredGridVanguard : public BaseVanguard<TypeTag>
99{
100 using ParentType = BaseVanguard<TypeTag>;
104
105 using GridPointer = std::unique_ptr<Grid>;
106
107 static constexpr int dim = Grid::dimension;
108
109public:
113 static void registerParameters()
114 {
116 ("The number of global refinements of the grid "
117 "executed after it was loaded");
119 ("The size of the domain in x direction");
121 ("The number of intervalls in x direction");
122 if constexpr (dim > 1) {
124 ("The size of the domain in y direction");
126 ("The number of intervalls in y direction");
127 }
128 if constexpr (dim > 2) {
130 ("The size of the domain in z direction");
132 ("The number of intervalls in z direction");
133 }
134 }
135
139 explicit StructuredGridVanguard(Simulator& simulator)
140 : ParentType(simulator)
141 {
142 Dune::FieldVector<int, dim> cellRes;
143
144 using GridScalar = double;
145 Dune::FieldVector<GridScalar, dim> upperRight;
146 Dune::FieldVector<GridScalar, dim> lowerLeft( 0 );
147
150
153 if constexpr (dim == 3) {
156 }
157
158 std::stringstream dgffile;
159 dgffile << "DGF" << '\n'
160 << "INTERVAL" << '\n'
161 << lowerLeft << '\n'
162 << upperRight << '\n'
163 << cellRes << '\n'
164 << "#" << '\n'
165 << "GridParameter" << '\n'
166 << "overlap 1" << '\n'
167 << "#" << '\n'
168 << "Simplex" << '\n'
169 << "#" << '\n';
170
171 // use DGF parser to create a grid from interval block
172 gridPtr_.reset(Dune::GridPtr<Grid>(dgffile).release());
173
174 const int numRefinements = Parameters::Get<Parameters::GridGlobalRefinements>();
175 gridPtr_->globalRefine(numRefinements);
176
177 this->finalizeInit_();
178 }
179
183 Grid& grid()
184 { return *gridPtr_; }
185
189 const Grid& grid() const
190 { return *gridPtr_; }
191
192private:
193 GridPointer gridPtr_;
194};
195
196} // namespace Opm
197
198#endif
Provides the base class for most (all?) simulator vanguards.
Defines some fundamental parameters for all models.
Defines a type tags and some fundamental properties all models.
Helper class for grid instantiation of the lens problem.
Definition structuredgridvanguard.hh:99
StructuredGridVanguard(Simulator &simulator)
Create the grid for the lens problem.
Definition structuredgridvanguard.hh:139
static void registerParameters()
Register all run-time parameters for the structured grid simulator vanguard.
Definition structuredgridvanguard.hh:113
const Grid & grid() const
Return a constant reference to the grid object.
Definition structuredgridvanguard.hh:189
Grid & grid()
Return a reference to the grid object.
Definition structuredgridvanguard.hh:183
The generic type tag for problems using the immiscible multi-phase model.
Definition blackoilmodel.hh:81
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilbioeffectsmodules.hh:43
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:233
This file provides the infrastructure to retrieve run-time parameters.
void Register(const char *usageString)
Register a run-time parameter.
Definition parametersystem.hpp:292
auto Get(bool errorIfNotRegistered=true)
Retrieve a runtime parameter.
Definition parametersystem.hpp:187
The Opm property system, traits with inheritance.
The type of the DUNE grid.
Definition basicproperties.hh:100
Definition structuredgridvanguard.hh:62
Property which provides a Vanguard (manages grids).
Definition basicproperties.hh:96