25 #ifndef EWOMS_DGF_GRID_MANAGER_HH
26 #define EWOMS_DGF_GRID_MANAGER_HH
28 #include <dune/grid/io/file/dgfparser/dgfparser.hh>
36 #include <type_traits>
40 namespace Properties {
52 template <
class TypeTag>
56 typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
58 typedef typename GET_PROP_TYPE(TypeTag, Grid) Grid;
61 typedef std::unique_ptr< Grid > GridPointer;
70 "The file name of the DGF file to load");
72 "The number of global refinements of the grid "
73 "executed after it was loaded");
80 : ParentType(simulator)
82 const std::string dgfFileName =
EWOMS_GET_PARAM(TypeTag, std::string, GridFile);
83 unsigned numRefinments =
EWOMS_GET_PARAM(TypeTag,
unsigned, GridGlobalRefinements);
87 Dune::GridPtr< Grid > dgfPointer( dgfFileName );
93 gridPtr_.reset( dgfPointer.release() );
96 if (numRefinments > 0)
97 gridPtr_->globalRefine(numRefinments);
106 {
return *gridPtr_; }
112 {
return *gridPtr_; }
122 { gridPtr_->loadBalance(); }
130 {
return fractureMapper_; }
138 {
return fractureMapper_; }
144 if( dgfPointer.nofParameters(
int(Grid::dimension) ) > 0 )
146 typedef typename Grid::LevelGridView GridView;
147 #if DUNE_VERSION_NEWER(DUNE_GRID,2,3)
148 GridView
gridView = dgfPointer->levelGridView( 0 );
150 GridView gridView = dgfPointer->levelView( 0 );
154 typedef Dune::MultipleCodimMultipleGeomTypeMapper<GridView,
155 Dune::MCMGVertexLayout> ElementMapper;
157 const int edgeCodim = Grid::dimension - 1;
159 ElementMapper elementMapper( gridView );
160 const auto endIt = gridView.template end< 0 > ();
161 for(
auto eIt = gridView.template begin< 0 >(); eIt != endIt; ++eIt )
163 const auto& element = *eIt;
164 #if DUNE_VERSION_NEWER(DUNE_GRID,2,3)
165 const auto& refElem =
166 Dune::ReferenceElements< Scalar, Grid::dimension >::general( element.type() );
168 const auto& refElem =
169 Dune::GenericReferenceElements< Scalar, Grid::dimension >::general( element.type() );
172 const int edges = refElem.size( edgeCodim );
173 for(
int edge = 0; edge < edges; ++edge )
175 const int vertices = refElem.size( edge, edgeCodim, Grid::dimension );
176 std::vector< int > vertexIndices;
177 vertexIndices.reserve( Grid::dimension );
178 for(
int vx = 0; vx<vertices; ++vx )
181 const int localVx = refElem.subEntity( edge, edgeCodim, vx, Grid::dimension );
183 #if DUNE_VERSION_NEWER(DUNE_GRID,2,4)
185 const auto vertex = element.template subEntity< Grid::dimension >( localVx );
188 const auto vertexPtr = element.template subEntity< Grid::dimension >( localVx );
189 const auto& vertex = *vertexPtr ;
193 if( dgfPointer.parameters( vertex )[ 0 ] > 0 )
195 #if DUNE_VERSION_NEWER(DUNE_GRID, 2,4)
196 vertexIndices.push_back( elementMapper.subIndex( element, localVx, Grid::dimension ) );
198 vertexIndices.push_back( elementMapper.map( element, localVx, Grid::dimension ) );
203 if(
int(vertexIndices.size()) == Grid::dimension )
205 fractureMapper_.
addFractureEdge(vertexIndices[ 0 ], vertexIndices[ 1 ] );
213 GridPointer gridPtr_;
214 FractureMapper fractureMapper_;
Provides a grid manager which reads Dune Grid Format (DGF) files.
Definition: dgfgridmanager.hh:53
void finalizeInit_()
Definition: basegridmanager.hh:84
static void registerParameters()
Register all run-time parameters for the grid manager.
Definition: dgfgridmanager.hh:67
const Grid & grid() const
Returns a reference to the grid.
Definition: dgfgridmanager.hh:111
void loadBalance()
Distributes the grid on all processes of a parallel computation.
Definition: dgfgridmanager.hh:121
Stores the topology of fractures.
Definition: fracturemapper.hh:40
void addFractureEdge(int vertexIdx1, int vertexIdx2)
Marks an edge as having a fracture.
Definition: fracturemapper.hh:72
NEW_PROP_TAG(Grid)
The type of the DUNE grid.
Stores the topology of fractures.
This file provides the infrastructure to retrieve run-time parameters.
Provides the base class for most (all?) grid managers.
Definition: basegridmanager.hh:51
void addFractures_(Dune::GridPtr< Grid > &dgfPointer)
Definition: dgfgridmanager.hh:141
FractureMapper & fractureMapper()
Returns the fracture mapper.
Definition: dgfgridmanager.hh:129
Manages the initializing and running of time dependent problems.
Definition: simulator.hh:73
GridView & gridView()
Returns a reference to the grid view to be used.
Definition: basegridmanager.hh:66
Definition: baseauxiliarymodule.hh:35
#define EWOMS_REGISTER_PARAM(TypeTag, ParamType, ParamName, Description)
Register a run-time parameter.
Definition: parametersystem.hh:64
Grid & grid()
Returns a reference to the grid.
Definition: dgfgridmanager.hh:105
DgfGridManager(Simulator &simulator)
Load the grid from the file.
Definition: dgfgridmanager.hh:79
Provides the magic behind the eWoms property system.
Provides the base class for most (all?) grid managers.
const FractureMapper & fractureMapper() const
Returns the fracture mapper.
Definition: dgfgridmanager.hh:137
#define EWOMS_GET_PARAM(TypeTag, ParamType, ParamName)
Retrieve a runtime parameter.
Definition: parametersystem.hh:95