3 #ifndef DUNE_GRID_IO_FILE_DGFPARSER_DGFUG_HH
4 #define DUNE_GRID_IO_FILE_DGFPARSER_DGFUG_HH
13 #include <dune/common/exceptions.hh>
14 #include <dune/common/fvector.hh>
15 #include <dune/common/parallel/mpihelper.hh>
22 #include "dgfparser.hh"
79 struct DGFGridFactory< UGGrid< dim > >
82 typedef UGGrid< dim >
Grid;
93 dgf_( rank( comm ), size( comm ) )
103 dgf_( rank( comm ), size( comm ) )
105 std::ifstream input( filename.c_str() );
107 DUNE_THROW( DGFException,
"Error: Macrofile " << filename <<
" not found" );
118 template<
class GG,
class II >
121 return factory_.wasInserted( intersection );
125 template<
class GG,
class II >
132 template<
int codim >
136 return dgf_.nofelparams;
138 return dgf_.nofvtxparams;
144 template<
class Entity >
147 return numParameters< Entity::codimension >();
151 std::vector< double > &
parameter (
const typename Grid::template Codim< 0 >::Entity &element )
153 if( numParameters< 0 >() <= 0 )
155 DUNE_THROW( InvalidStateException,
156 "Calling DGFGridFactory::parameter is only allowed if there are parameters." );
158 return dgf_.elParams[ factory_.insertionIndex( element ) ];
162 std::vector< double > &
parameter (
const typename Grid::template Codim< dimension >::Entity &
vertex )
164 if( numParameters< dimension >() <= 0 )
166 DUNE_THROW( InvalidStateException,
167 "Calling DGFGridFactory::parameter is only allowed if there are parameters." );
169 return dgf_.vtxParams[ factory_.insertionIndex( vertex ) ];
175 return dgf_.haveBndParameters;
179 template<
class GG,
class II >
187 const ReferenceElement< double, dimension > &refElem
188 = ReferenceElements< double, dimension >::general( 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 );
214 MPI_Comm_rank( MPICOMM, &rank );
224 MPI_Comm_size( MPICOMM, &size );
230 GridFactory< UGGrid< dim > > factory_;
231 DuneGridFormatParser dgf_;
233 #endif // #if ENABLE_UG
237 #endif // #ifndef DUNE_GRID_IO_FILE_DGFPARSER_DGFUG_HH