5#ifndef DUNE_GRID_IO_FILE_DGFPARSER_DGFUG_HH
6#define DUNE_GRID_IO_FILE_DGFPARSER_DGFUG_HH
15#include <dune/common/exceptions.hh>
16#include <dune/common/fvector.hh>
17#include <dune/common/parallel/mpihelper.hh>
20#include <dune-grid-config.hh>
21#include <dune/grid/common/intersection.hh>
25#include "dgfparser.hh"
26#include "blocks/gridparameter.hh"
38 struct UGGridParameterBlock
39 :
public GridParameterBlock
42 explicit UGGridParameterBlock ( std::istream &input );
45 bool noClosure ()
const {
return noClosure_; }
47 bool noCopy ()
const {
return noCopy_; }
49 size_t heapSize ()
const {
return heapSize_; }
63 struct DGFGridInfo< UGGrid< dim > >
82 struct DGFGridFactory< UGGrid< dim > >
85 typedef UGGrid< dim > Grid;
87 static const int dimension = dim;
89 typedef MPIHelper::MPICommunicator MPICommunicatorType;
92 explicit DGFGridFactory ( std::istream &input,
93 MPICommunicatorType comm = MPIHelper::getCommunicator() )
96 dgf_( rank( comm ), size( comm ) )
102 explicit DGFGridFactory (
const std::string &filename,
103 MPICommunicatorType comm = MPIHelper::getCommunicator() )
106 dgf_( rank( comm ), size( comm ) )
108 std::ifstream input( filename.c_str() );
110 DUNE_THROW( DGFException,
"Error: Macrofile " << filename <<
" not found" );
121 template<
class GG,
class II >
124 return factory_.wasInserted( intersection );
128 template<
class GG,
class II >
135 template<
int codim >
136 int numParameters ()
const
139 return dgf_.nofelparams;
140 else if( codim == dimension )
141 return dgf_.nofvtxparams;
147 template<
class Entity >
148 int numParameters (
const Entity & )
const
150 return numParameters< Entity::codimension >();
154 std::vector< double > ¶meter (
const typename Grid::template Codim< 0 >::Entity &element )
156 if( numParameters< 0 >() <= 0 )
158 DUNE_THROW( InvalidStateException,
159 "Calling DGFGridFactory::parameter is only allowed if there are parameters." );
161 return dgf_.elParams[ factory_.insertionIndex( element ) ];
165 std::vector< double > ¶meter (
const typename Grid::template Codim< dimension >::Entity &vertex )
167 if( numParameters< dimension >() <= 0 )
169 DUNE_THROW( InvalidStateException,
170 "Calling DGFGridFactory::parameter is only allowed if there are parameters." );
172 return dgf_.vtxParams[ factory_.insertionIndex( vertex ) ];
176 bool haveBoundaryParameters ()
const
178 return dgf_.haveBndParameters;
182 template<
class GG,
class II >
189 auto refElem = referenceElement< double, dimension >( entity.type() );
190 int corners = refElem.size( face, 1, dimension );
191 std::vector< unsigned int > bound( corners );
192 for(
int i = 0; i < corners; ++i )
194 const int k = refElem.subEntity( face, 1, i, dimension );
195 bound[ i ] = factory_.insertionIndex( entity.template subEntity< dimension >( k ) );
198 DuneGridFormatParser::facemap_t::key_type key( bound,
false );
199 const DuneGridFormatParser::facemap_t::const_iterator pos = dgf_.facemap.find( key );
200 if( pos != dgf_.facemap.end() )
201 return dgf_.facemap.find( key )->second.second;
208 void generate ( std::istream &input );
211 static int rank( MPICommunicatorType MPICOMM )
215 MPI_Comm_rank( MPICOMM, &rank );
221 static int size( MPICommunicatorType MPICOMM )
225 MPI_Comm_size( MPICOMM, &size );
231 GridFactory< UGGrid< dim > > factory_;
232 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:351
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
Include standard header files.
Definition: agrid.hh:60
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