27 #ifndef EWOMS_DGF_GRID_MANAGER_HH 28 #define EWOMS_DGF_GRID_MANAGER_HH 30 #include <dune/grid/io/file/dgfparser/dgfparser.hh> 31 #include <dune/grid/common/mcmgmapper.hh> 39 #include <type_traits> 43 namespace Properties {
55 template <
class TypeTag>
59 typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
61 typedef typename GET_PROP_TYPE(TypeTag, Grid) Grid;
64 typedef std::unique_ptr< Grid > GridPointer;
73 "The file name of the DGF file to load");
75 "The number of global refinements of the grid " 76 "executed after it was loaded");
85 const std::string dgfFileName =
EWOMS_GET_PARAM(TypeTag, std::string, GridFile);
86 unsigned numRefinments =
EWOMS_GET_PARAM(TypeTag,
unsigned, GridGlobalRefinements);
90 Dune::GridPtr< Grid > dgfPointer( dgfFileName );
93 addFractures_( dgfPointer );
96 gridPtr_.reset( dgfPointer.release() );
99 if (numRefinments > 0)
100 gridPtr_->globalRefine(static_cast<int>(numRefinments));
102 this->finalizeInit_();
109 {
return *gridPtr_; }
115 {
return *gridPtr_; }
125 { gridPtr_->loadBalance(); }
133 {
return fractureMapper_; }
141 {
return fractureMapper_; }
144 void addFractures_(Dune::GridPtr<Grid>& dgfPointer)
146 typedef typename Grid::LevelGridView GridView;
147 typedef Dune::MultipleCodimMultipleGeomTypeMapper<GridView, Dune::MCMGVertexLayout> ElementMapper;
150 if (dgfPointer.nofParameters(static_cast<int>(Grid::dimension)) == 0)
153 GridView
gridView = dgfPointer->levelGridView(0);
154 const unsigned edgeCodim = Grid::dimension - 1;
157 ElementMapper elementMapper(
gridView);
158 auto eIt =
gridView.template begin<0>();
159 const auto eEndIt =
gridView.template end<0>();
160 for (; eIt != eEndIt; ++eIt) {
161 const auto& element = *eIt;
162 const auto& refElem =
163 Dune::ReferenceElements<Scalar, Grid::dimension>::general(element.type());
165 const int edges = refElem.size( edgeCodim );
166 for (
int edge = 0; edge < edges; ++edge) {
167 const int vertices = refElem.size(edge, edgeCodim, Grid::dimension);
168 std::vector<unsigned> vertexIndices;
169 vertexIndices.reserve(Grid::dimension);
170 for (
int vx = 0; vx < vertices; ++vx) {
172 const int localVx = refElem.subEntity(edge, edgeCodim, vx, Grid::dimension);
175 const auto vertex = element.template subEntity<Grid::dimension>(localVx);
178 if (dgfPointer.parameters( vertex )[ 0 ] > 0)
179 vertexIndices.push_back(
180 static_cast<unsigned>(elementMapper.subIndex(element,
181 static_cast<int>(localVx),
185 if (static_cast<int>(vertexIndices.size()) == Grid::dimension)
192 GridPointer gridPtr_;
193 FractureMapper fractureMapper_;
const FractureMapper & fractureMapper() const
Returns the fracture mapper.
Definition: dgfgridmanager.hh:140
Grid & grid()
Returns a reference to the grid.
Definition: dgfgridmanager.hh:108
Stores the topology of fractures.
Definition: baseauxiliarymodule.hh:37
Provides the base class for most (all?) grid managers.
Stores the topology of fractures.
Definition: fracturemapper.hh:42
const GridView & gridView() const
Returns a reference to the grid view to be used.
Definition: basegridmanager.hh:79
Provides the base class for most (all?) grid managers.
Definition: basegridmanager.hh:58
#define EWOMS_REGISTER_PARAM(TypeTag, ParamType, ParamName, Description)
Register a run-time parameter.
Definition: parametersystem.hh:68
This file provides the infrastructure to retrieve run-time parameters.
void loadBalance()
Distributes the grid on all processes of a parallel computation.
Definition: dgfgridmanager.hh:124
FractureMapper & fractureMapper()
Returns the fracture mapper.
Definition: dgfgridmanager.hh:132
Provides a grid manager which reads Dune Grid Format (DGF) files.
Definition: dgfgridmanager.hh:56
#define EWOMS_GET_PARAM(TypeTag, ParamType, ParamName)
Retrieve a runtime parameter.
Definition: parametersystem.hh:99
void addFractureEdge(unsigned vertexIdx1, unsigned vertexIdx2)
Marks an edge as having a fracture.
Definition: fracturemapper.hh:74
Provides the magic behind the eWoms property system.
static void registerParameters()
Register all run-time parameters for the grid manager.
Definition: dgfgridmanager.hh:70
const Grid & grid() const
Returns a reference to the grid.
Definition: dgfgridmanager.hh:114
DgfGridManager(Simulator &simulator)
Load the grid from the file.
Definition: dgfgridmanager.hh:82
Manages the initializing and running of time dependent problems.
Definition: simulator.hh:75
#define NEW_PROP_TAG(PTagName)
Define a property tag.
Definition: propertysystem.hh:247