27#ifndef EWOMS_DGF_GRID_VANGUARD_HH
28#define EWOMS_DGF_GRID_VANGUARD_HH
30#include <dune/grid/io/file/dgfparser/dgfparser.hh>
31#include <dune/grid/common/mcmgmapper.hh>
48template <
class TypeTag>
57 using GridPointer = std::unique_ptr<Grid>;
65 Parameters::Register<Parameters::GridFile>
66 (
"The file name of the DGF file to load");
67 Parameters::Register<Parameters::GridGlobalRefinements>
68 (
"The number of global refinements of the grid "
69 "executed after it was loaded");
78 const std::string dgfFileName = Parameters::Get<Parameters::GridFile>();
79 const unsigned numRefinments = Parameters::Get<Parameters::GridGlobalRefinements>();
83 Dune::GridPtr<Grid> dgfPointer(dgfFileName);
89 gridPtr_.reset(dgfPointer.release());
92 if (numRefinments > 0) {
93 gridPtr_->globalRefine(
static_cast<int>(numRefinments));
103 {
return *gridPtr_; }
109 {
return *gridPtr_; }
119 { gridPtr_->loadBalance(); }
127 {
return fractureMapper_; }
135 {
return fractureMapper_; }
140 using LevelGridView =
typename Grid::LevelGridView;
143 if (dgfPointer.nofParameters(
static_cast<int>(Grid::dimension)) == 0) {
147 LevelGridView
gridView = dgfPointer->levelGridView(0);
148 const unsigned edgeCodim = Grid::dimension - 1;
150 using VertexMapper = Dune::MultipleCodimMultipleGeomTypeMapper<LevelGridView>;
151 VertexMapper vertexMapper(
gridView, Dune::mcmgVertexLayout());
154 for (
const auto& element: elements(
gridView)) {
155 const auto& refElem =
156 Dune::ReferenceElements<Scalar, Grid::dimension>::general(element.type());
158 const int edges = refElem.size(edgeCodim);
159 for (
int edge = 0; edge < edges; ++edge) {
160 const int vertices = refElem.size(edge, edgeCodim, Grid::dimension);
161 std::vector<unsigned> vertexIndices;
162 vertexIndices.reserve(Grid::dimension);
163 for (
int vx = 0; vx < vertices; ++vx) {
165 const int localVx = refElem.subEntity(edge, edgeCodim, vx, Grid::dimension);
168 const auto vertex = element.template subEntity<Grid::dimension>(localVx);
171 if (dgfPointer.parameters(vertex)[0] > 0) {
172 vertexIndices.push_back(
173 static_cast<unsigned>(vertexMapper.subIndex(element,
174 static_cast<int>(localVx),
179 if (
static_cast<int>(vertexIndices.size()) == Grid::dimension) {
187 GridPointer gridPtr_;
Provides the base class for most (all?) simulator vanguards.
Definition: basevanguard.hh:50
const GridView & gridView() const
Returns a reference to the grid view to be used.
Definition: basevanguard.hh:70
void finalizeInit_()
Definition: basevanguard.hh:127
Provides a simulator vanguard which creates a grid by parsing a Dune Grid Format (DGF) file.
Definition: dgfvanguard.hh:50
static void registerParameters()
Register all run-time parameters for the DGF simulator vanguard.
Definition: dgfvanguard.hh:63
FractureMapper & fractureMapper()
Returns the fracture mapper.
Definition: dgfvanguard.hh:126
const FractureMapper & fractureMapper() const
Returns the fracture mapper.
Definition: dgfvanguard.hh:134
DgfVanguard(Simulator &simulator)
Load the grid from the file.
Definition: dgfvanguard.hh:75
void loadBalance()
Distributes the grid on all processes of a parallel computation.
Definition: dgfvanguard.hh:118
const Grid & grid() const
Returns a reference to the grid.
Definition: dgfvanguard.hh:108
Grid & grid()
Returns a reference to the grid.
Definition: dgfvanguard.hh:102
void addFractures_(Dune::GridPtr< Grid > &dgfPointer)
Definition: dgfvanguard.hh:138
Stores the topology of fractures.
Definition: fracturemapper.hh:41
void addFractureEdge(unsigned vertexIdx1, unsigned vertexIdx2)
Marks an edge as having a fracture.
Definition: fracturemapper.hh:66
Definition: blackoilboundaryratevector.hh:39
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.
The Opm property system, traits with inheritance.