5#ifndef DUNE_GRID_IO_FILE_DGFPARSER_DGFUG_HH
6#define DUNE_GRID_IO_FILE_DGFPARSER_DGFUG_HH
20#include <dune/grid/common/intersection.hh>
24#include "dgfparser.hh"
25#include "blocks/gridparameter.hh"
37 struct UGGridParameterBlock
38 :
public GridParameterBlock
41 explicit UGGridParameterBlock ( std::istream &input );
44 bool noClosure ()
const {
return noClosure_; }
46 bool noCopy ()
const {
return noCopy_; }
48 size_t heapSize ()
const {
return heapSize_; }
62 struct DGFGridInfo< UGGrid< dim > >
81 struct DGFGridFactory< UGGrid< dim > >
84 typedef UGGrid< dim > Grid;
86 static const int dimension = dim;
91 explicit DGFGridFactory ( std::istream &input,
95 dgf_( rank( comm ), size( comm ) )
101 explicit DGFGridFactory (
const std::string &filename,
105 dgf_( rank( comm ), size( comm ) )
107 std::ifstream input( filename.c_str() );
109 DUNE_THROW( DGFException,
"Error: Macrofile " << filename <<
" not found" );
120 template<
class GG,
class II >
123 return factory_.wasInserted( intersection );
127 template<
class GG,
class II >
134 template<
int codim >
135 int numParameters ()
const
138 return dgf_.nofelparams;
139 else if( codim == dimension )
140 return dgf_.nofvtxparams;
146 template<
class Entity >
147 int numParameters (
const Entity & )
const
149 return numParameters< Entity::codimension >();
153 std::vector< double > ¶meter (
const typename Grid::template Codim< 0 >::Entity &element )
155 if( numParameters< 0 >() <= 0 )
158 "Calling DGFGridFactory::parameter is only allowed if there are parameters." );
160 return dgf_.elParams[ factory_.insertionIndex( element ) ];
164 std::vector< double > ¶meter (
const typename Grid::template Codim< dimension >::Entity &
vertex )
166 if( numParameters< dimension >() <= 0 )
169 "Calling DGFGridFactory::parameter is only allowed if there are parameters." );
171 return dgf_.vtxParams[ factory_.insertionIndex(
vertex ) ];
175 bool haveBoundaryParameters ()
const
177 return dgf_.haveBndParameters;
181 template<
class GG,
class II >
188 auto refElem = referenceElement< double, dimension >( entity.type() );
189 int corners = refElem.size( face, 1, dimension );
190 std::vector< unsigned int > bound( corners );
191 for(
int i = 0; i < corners; ++i )
193 const int k = refElem.subEntity( face, 1, i, dimension );
194 bound[ i ] = factory_.insertionIndex( entity.template subEntity< dimension >( k ) );
197 DuneGridFormatParser::facemap_t::key_type key( bound,
false );
198 const DuneGridFormatParser::facemap_t::const_iterator pos = dgf_.facemap.find( key );
199 if( pos != dgf_.facemap.end() )
200 return dgf_.facemap.find( key )->second.second;
207 void generate ( std::istream &input );
210 static int rank( MPICommunicatorType MPICOMM )
214 MPI_Comm_rank( MPICOMM, &rank );
220 static int size( MPICommunicatorType MPICOMM )
224 MPI_Comm_size( MPICOMM, &size );
230 GridFactory< UGGrid< dim > > factory_;
231 DuneGridFormatParser dgf_;
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition: intersection.hh:164
int indexInInside() const
Local index of codim 1 entity in the inside() entity where intersection is contained in.
Definition: intersection.hh:346
size_t boundarySegmentIndex() const
index of the boundary segment within the macro grid
Definition: intersection.hh:236
Entity inside() const
return Entity on the inside of this intersection. That is the Entity where we started this.
Definition: intersection.hh:250
GridImp::template Codim< 0 >::Entity Entity
Type of entity that this Intersection belongs to.
Definition: intersection.hh:192
MPI_Comm MPICommunicator
The type of the mpi communicator.
Definition: mpihelper.hh:190
static MPICommunicator getCommunicator()
get the default communicator
Definition: mpihelper.hh:198
A few common exception classes.
Implements a vector constructed from a given type representing a field and a compile-time given size.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
constexpr GeometryType vertex
GeometryType representing a vertex.
Definition: type.hh:506
Helpers for dealing with MPI.
Dune namespace.
Definition: alignedallocator.hh:13
static const type & defaultValue()
default constructor
Definition: parser.hh:28
std::string type
type of additional boundary parameters
Definition: parser.hh:25
static double refineWeight()
static int refineStepsForHalf()
number of globalRefine steps needed to refuce h by 0.5