5#ifndef DUNE_ALBERTA_DGFPARSER_HH
6#define DUNE_ALBERTA_DGFPARSER_HH
10#include <dune/grid/albertagrid.hh>
13#include <dune/grid/io/file/dgfparser/dgfparser.hh>
14#include <dune/grid/io/file/dgfparser/blocks/projection.hh>
16#include <dune/grid/common/intersection.hh>
17#include <dune/grid/io/file/dgfparser/parser.hh>
27 template<
class Gr
idImp,
class IntersectionImp >
35 template<
int dim,
int dimworld >
36 struct DGFGridFactory< AlbertaGrid< dim, dimworld > >
38 typedef AlbertaGrid<dim,dimworld> Grid;
41 typedef typename Grid::template Codim<0>::Entity Element;
42 typedef typename Grid::template Codim<dimension>::Entity Vertex;
45 explicit DGFGridFactory ( std::istream &input,
47 explicit DGFGridFactory (
const std::string &filename,
55 template<
class Intersection >
56 bool wasInserted (
const Intersection &intersection )
const
58 return factory_.wasInserted( intersection );
61 template<
class Intersection >
62 int boundaryId (
const Intersection &intersection )
const
64 return intersection.impl().boundaryId();
68 bool haveBoundaryParameters ()
const
70 return dgf_.haveBndParameters;
73 template <
class GG,
class II >
75 boundaryParameter (
const Intersection< GG, II > & intersection )
const
79 const int face = intersection.indexInInside();
81 auto refElem = referenceElement< double, dimension >( entity.type() );
82 int corners = refElem.size( face, 1, dimension );
83 std :: vector< unsigned int > bound( corners );
84 for(
int i=0; i < corners; ++i )
86 const int k = refElem.subEntity( face, 1, i, dimension );
87 bound[ i ] = factory_.insertionIndex( entity.template subEntity< dimension >( k ) );
90 DuneGridFormatParser::facemap_t::key_type key( bound,
false );
91 const DuneGridFormatParser::facemap_t::const_iterator pos = dgf_.facemap.find( key );
92 if( pos != dgf_.facemap.end() )
93 return dgf_.facemap.find( key )->second.second;
99 int numParameters ()
const
102 return dgf_.nofelparams;
103 else if( codim == dimension )
104 return dgf_.nofvtxparams;
109 std::vector< double > ¶meter (
const Element &element )
111 if( numParameters< 0 >() <= 0 )
114 "Calling DGFGridFactory::parameter is only allowed if there are parameters." );
116 return dgf_.elParams[ factory_.insertionIndex( element ) ];
119 std::vector< double > ¶meter (
const Vertex &
vertex )
121 if( numParameters< dimension >() <= 0 )
124 "Calling DGFGridFactory::parameter is only allowed if there are parameters." );
126 return dgf_.vtxParams[ factory_.insertionIndex(
vertex ) ];
130 bool generate( std::istream &input );
133 GridFactory factory_;
134 DuneGridFormatParser dgf_;
142 template<
int dim,
int dimworld >
143 struct DGFGridInfo< AlbertaGrid< dim, dimworld > >
161 template<
int dim,
int dimworld >
162 inline DGFGridFactory< AlbertaGrid< dim, dimworld > >
163 ::DGFGridFactory ( std::istream &input, MPICommunicatorType )
169 DUNE_THROW(DGFException,
"Error resetting input stream." );
174 template<
int dim,
int dimworld >
175 inline DGFGridFactory< AlbertaGrid< dim, dimworld > >
176 ::DGFGridFactory (
const std::string &filename, MPICommunicatorType )
179 std::ifstream input( filename.c_str() );
181 DUNE_THROW( DGFException,
"Macrofile " << filename <<
" not found." );
182 if( !generate( input ) )
specialization of the generic GridFactory for AlbertaGrid
static constexpr int dimension
The dimension of the grid.
Definition: grid.hh:387
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition: intersection.hh:164
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:192
static MPICommunicator getCommunicator()
get the default communicator
Definition: mpihelper.hh:200
#define DUNE_THROW(E,...)
Definition: exceptions.hh:312
constexpr GeometryType vertex
GeometryType representing a vertex.
Definition: type.hh:492
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