1 #ifndef DUNE_GRID_IO_FILE_DGFPARSER_DGFUG_HH
2 #define DUNE_GRID_IO_FILE_DGFPARSER_DGFUG_HH
11 #include <dune/common/exceptions.hh>
12 #include <dune/common/fvector.hh>
13 #include <dune/common/mpihelper.hh>
77 struct DGFGridFactory< UGGrid< dim > >
80 typedef UGGrid< dim >
Grid;
91 dgf_( rank( comm ), size( comm ) )
101 dgf_( rank( comm ), size( comm ) )
103 std::ifstream input( filename.c_str() );
105 DUNE_THROW( DGFException,
"Error: Macrofile " << filename <<
" not found" );
116 template<
class GG,
template<
class >
class II >
119 return factory_.wasInserted( intersection );
123 template <
class GG,
template<
class >
class II >
130 template<
int codim >
134 return dgf_.nofelparams;
136 return dgf_.nofvtxparams;
142 template<
class Entity >
145 return numParameters< Entity::codimension >();
149 std::vector< double > &
parameter (
const typename Grid::template Codim< 0 >::Entity &element )
151 if( numParameters< 0 >() <= 0 )
153 DUNE_THROW( InvalidStateException,
154 "Calling DGFGridFactory::parameter is only allowed if there are parameters." );
156 return dgf_.elParams[ factory_.insertionIndex( element ) ];
160 std::vector< double > &
parameter (
const typename Grid::template Codim< dimension >::Entity &
vertex )
162 if( numParameters< dimension >() <= 0 )
164 DUNE_THROW( InvalidStateException,
165 "Calling DGFGridFactory::parameter is only allowed if there are parameters." );
167 return dgf_.vtxParams[ factory_.insertionIndex( vertex ) ];
173 return dgf_.haveBndParameters;
177 template <
class GG,
template<
class >
class II >
185 const GenericReferenceElement< double, dimension > &refElem
186 = GenericReferenceElements< double, dimension >::general( entity.type() );
187 int corners = refElem.size( face, 1,
dimension );
188 std::vector< unsigned int > bound( corners );
189 for(
int i = 0; i < corners; ++i )
191 const int k = refElem.subEntity( face, 1, i,
dimension );
192 bound[ i ] = factory_.insertionIndex( *entity.template subEntity< dimension >( k ) );
195 DuneGridFormatParser::facemap_t::key_type key( bound,
false );
196 const DuneGridFormatParser::facemap_t::const_iterator pos = dgf_.facemap.find( key );
197 if( pos != dgf_.facemap.end() )
198 return dgf_.facemap.find( key )->second.second;
205 void generate ( std::istream &input );
212 MPI_Comm_rank( MPICOMM, &rank );
222 MPI_Comm_size( MPICOMM, &size );
228 GridFactory< UGGrid< dim > > factory_;
229 DuneGridFormatParser dgf_;
231 #endif // #if ENABLE_UG
235 #endif // #ifndef DUNE_GRID_IO_FILE_DGFPARSER_DGFUG_HH