opm-simulators
Toggle main menu visibility
Loading...
Searching...
No Matches
unstructuredgridvanguard.hh
Go to the documentation of this file.
1
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil;
2
// c-basic-offset: 4 -*- vi: set et ts=4 sw=4 sts=4:
3
/*
4
This file is part of the Open Porous Media project (OPM).
5
OPM is free software: you can redistribute it and/or
6
modify it under the terms of the GNU General Public
7
License as published by the Free Software Foundation,
8
either version 2 of the License, or (at your option) any
9
later version. OPM is distributed in the hope that it will
10
be useful, but WITHOUT ANY WARRANTY; without even the
11
implied warranty of MERCHANTABILITY or FITNESS FOR A
12
PARTICULAR PURPOSE. See the GNU General Public License
13
for more details. You should have received a copy of the
14
GNU General Public License along with OPM. If not, see
15
<http://www.gnu.org/licenses/>. Consult the COPYING file
16
in the top-level source directory of this module for the
17
precise wording of the license and the list of copyright
18
holders.
19
*/
24
#ifndef EWOMS_UNSTRUCTURED_GRID_VANGUARD_HH
25
#define EWOMS_UNSTRUCTURED_GRID_VANGUARD_HH
26
27
#include <dune/grid/io/file/dgfparser/gridptr.hh>
28
29
#include <
opm/models/io/basevanguard.hh
>
30
#include <
opm/models/utils/parametersystem.hpp
>
31
#include <
opm/models/utils/propertysystem.hh
>
32
33
#ifdef HAVE_OPM_GRID
34
#include <opm/grid/UnstructuredGrid.h>
35
#include <string>
36
#endif
37
38
namespace
Opm
{
39
44
template
<
class
TypeTag>
45
class
UnstructuredGridVanguard
:
public
BaseVanguard<TypeTag>
46
{
47
using
ParentType = BaseVanguard<TypeTag>;
48
using
Scalar =
GetPropType<TypeTag, Properties::Scalar>
;
49
using
Simulator =
GetPropType<TypeTag, Properties::Simulator>
;
50
using
Grid =
GetPropType<TypeTag, Properties::Grid>
;
51
52
using
GridPointer = Dune::GridPtr<Grid>;
53
54
public
:
59
static
void
registerParameters
() {
60
Parameters::Register<Parameters::GridGlobalRefinements>
61
(
"The number of global refinements of the grid "
62
"executed after it was loaded"
);
63
Parameters::Register<Parameters::GridFile>
64
(
"The file name of the file to load"
);
65
}
66
70
explicit
UnstructuredGridVanguard
(Simulator& simulator)
71
: ParentType(simulator)
72
{
73
#ifdef HAVE_OPM_GRID
74
const
std::string gridFileName =
Parameters::Get<Parameters::GridFile>
();
75
const
int
numRefinments =
Parameters::Get<Parameters::GridGlobalRefinements>
();
76
77
UnstructuredGrid* ugrid = read_grid(gridFileName.c_str());
78
if
(ugrid ==
nullptr
) {
79
throw
std::runtime_error(
"RuntimeError: UnstructuredGridVanguard could not read grid file: "
+
80
gridFileName +
". Are you sure the filename is correct?"
);
81
}
82
ugPtr_.reset(std::move(ugrid));
83
//GridPointer polygrid(new Grid(*ugPtr));
84
gridPtr_ =
new
Grid(*ugPtr_);
//std::move(polygrid);
85
if
(numRefinments > 0) {
86
gridPtr_->globalRefine(numRefinments);
87
}
88
this->finalizeInit_();
89
#endif
90
}
91
95
Grid&
grid
()
96
{
return
*gridPtr_; }
97
102
const
Grid&
grid
()
const
103
{
return
*gridPtr_; }
104
105
private
:
106
GridPointer gridPtr_;
107
typename
Grid::UnstructuredGridPtr ugPtr_;
108
};
109
110
}
// namespace Opm
111
112
#endif
basevanguard.hh
Provides the base class for most (all?) simulator vanguards.
Opm::UnstructuredGridVanguard::registerParameters
static void registerParameters()
Register all run-time parameters for the unstructured grid simulator vanguard.
Definition
unstructuredgridvanguard.hh:59
Opm::UnstructuredGridVanguard::grid
const Grid & grid() const
Return a constant reference to the grid object.
Definition
unstructuredgridvanguard.hh:102
Opm::UnstructuredGridVanguard::UnstructuredGridVanguard
UnstructuredGridVanguard(Simulator &simulator)
Load the grid from the file.
Definition
unstructuredgridvanguard.hh:70
Opm::UnstructuredGridVanguard::grid
Grid & grid()
Return a reference to the grid object.
Definition
unstructuredgridvanguard.hh:95
Opm
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition
blackoilbioeffectsmodules.hh:43
Opm::GetPropType
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
parametersystem.hpp
This file provides the infrastructure to retrieve run-time parameters.
Opm::Parameters::Register
void Register(const char *usageString)
Register a run-time parameter.
Definition
parametersystem.hpp:292
Opm::Parameters::Get
auto Get(bool errorIfNotRegistered=true)
Retrieve a runtime parameter.
Definition
parametersystem.hpp:187
propertysystem.hh
The Opm property system, traits with inheritance.
opm
models
io
unstructuredgridvanguard.hh
Generated by
1.17.0