3#ifndef DUNE_ALBERTA_DGFPARSER_HH
4#define DUNE_ALBERTA_DGFPARSER_HH
8#include <dune/grid/albertagrid.hh>
11#include <dune/grid/io/file/dgfparser/dgfparser.hh>
12#include <dune/grid/io/file/dgfparser/blocks/projection.hh>
14#include <dune/grid/common/intersection.hh>
15#include <dune/grid/io/file/dgfparser/parser.hh>
25 template<
class Gr
idImp,
class IntersectionImp >
33 template<
int dim,
int dimworld >
34 struct DGFGridFactory< AlbertaGrid< dim, dimworld > >
36 typedef AlbertaGrid<dim,dimworld> Grid;
39 typedef typename Grid::template Codim<0>::Entity Element;
40 typedef typename Grid::template Codim<dimension>::Entity Vertex;
43 explicit DGFGridFactory ( std::istream &input,
45 explicit DGFGridFactory (
const std::string &filename,
53 template<
class Intersection >
54 bool wasInserted (
const Intersection &intersection )
const
56 return factory_.wasInserted( intersection );
59 template<
class Intersection >
60 int boundaryId (
const Intersection &intersection )
const
62 return Grid::getRealImplementation( intersection ).boundaryId();
66 bool haveBoundaryParameters ()
const
68 return dgf_.haveBndParameters;
71 template <
class GG,
class II >
73 boundaryParameter (
const Intersection< GG, II > & intersection )
const
77 const int face = intersection.indexInInside();
79 const ReferenceElement< double, dimension > & refElem =
81 int corners = refElem.size( face, 1, dimension );
82 std :: vector< unsigned int > bound( corners );
83 for(
int i=0; i < corners; ++i )
85 const int k = refElem.subEntity( face, 1, i, dimension );
86 bound[ i ] = factory_.insertionIndex( entity.template subEntity< dimension >( k ) );
89 DuneGridFormatParser::facemap_t::key_type key( bound,
false );
90 const DuneGridFormatParser::facemap_t::const_iterator pos = dgf_.facemap.find( key );
91 if( pos != dgf_.facemap.end() )
92 return dgf_.facemap.find( key )->second.second;
98 int numParameters ()
const
101 return dgf_.nofelparams;
102 else if( codim == dimension )
103 return dgf_.nofvtxparams;
108 std::vector< double > ¶meter (
const Element &element )
110 if( numParameters< 0 >() <= 0 )
113 "Calling DGFGridFactory::parameter is only allowed if there are parameters." );
115 return dgf_.elParams[ factory_.insertionIndex( element ) ];
118 std::vector< double > ¶meter (
const Vertex &vertex )
120 if( numParameters< dimension >() <= 0 )
123 "Calling DGFGridFactory::parameter is only allowed if there are parameters." );
125 return dgf_.vtxParams[ factory_.insertionIndex( vertex ) ];
129 bool generate( std::istream &input );
132 GridFactory factory_;
133 DuneGridFormatParser dgf_;
141 template<
int dim,
int dimworld >
142 struct DGFGridInfo< AlbertaGrid< dim, dimworld > >
160 template<
int dim,
int dimworld >
161 inline DGFGridFactory< AlbertaGrid< dim, dimworld > >
162 ::DGFGridFactory ( std::istream &input, MPICommunicatorType comm )
168 DUNE_THROW(DGFException,
"Error resetting input stream." );
173 template<
int dim,
int dimworld >
174 inline DGFGridFactory< AlbertaGrid< dim, dimworld > >
175 ::DGFGridFactory (
const std::string &filename, MPICommunicatorType comm )
178 std::ifstream input( filename.c_str() );
180 DUNE_THROW( DGFException,
"Macrofile " << filename <<
" not found." );
181 if( !generate( input ) )
specialization of the generic GridFactory for AlbertaGrid
@ 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:162
GridImp::template Codim< 0 >::Entity Entity
Type of entity that this Intersection belongs to.
Definition: intersection.hh:186
MPI_Comm MPICommunicator
The type of the mpi communicator.
Definition: mpihelper.hh:173
static MPICommunicator getCommunicator()
get the default communicator
Definition: mpihelper.hh:181
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
Dune namespace.
Definition: alignment.hh:11
static const type & defaultValue()
default constructor
Definition: parser.hh:26
std::string type
type of additional boundary parameters
Definition: parser.hh:23
static double refineWeight()
static int refineStepsForHalf()
number of globalRefine steps needed to refuce h by 0.5
static const ReferenceElement< ctype, dim > & general(const GeometryType &type)
get general reference elements
Definition: referenceelements.hh:758