4 #ifndef DUNE_ALU2DGRID_FACTORY_HH
5 #define DUNE_ALU2DGRID_FACTORY_HH
9 #include <dune/common/array.hh>
10 #include <dune/common/mpihelper.hh>
12 #include <dune/geometry/referenceelements.hh>
23 template<
class Gr
idImp >
50 static const ALU2DSPACE ElementType elementType = Grid::elementType;
51 static const unsigned int numFaceCorners = 2;
53 typedef FieldVector< ctype, dimensionworld > VertexType;
54 typedef std::vector< unsigned int > ElementType;
55 typedef array< unsigned int, numFaceCorners > FaceType;
70 typedef std::vector< VertexType > VertexVector;
71 typedef std::vector< ElementType > ElementVector;
72 typedef std::vector< std::pair< FaceType, int > > BoundaryIdVector;
74 typedef std::map< FaceType, const DuneBoundaryProjectionType* > BoundaryProjectionMap;
75 typedef std::vector< const DuneBoundaryProjectionType* > BoundaryProjectionVector;
77 typedef std::pair< unsigned int, int > SubEntity;
78 typedef std::map< FaceType, SubEntity, FaceLess > FaceMap;
79 typedef std::vector< Transformation > FaceTransformationVector;
80 typedef std::map< FaceType, unsigned int, FaceLess > PeriodicNeighborMap;
83 void copyAndSort(
const std::vector<unsigned int>& vertices, FaceType& faceId)
const
85 std::vector<unsigned int> tmp( vertices );
86 std::sort( tmp.begin(), tmp.end() );
89 for(
size_t i = 0; i < faceId.size(); ++i ) faceId[ i ] = tmp[ i ];
118 const std::vector< unsigned int > &vertices );
132 const std::vector< unsigned int > &faceVertices,
141 virtual void insertBoundary (
const int element,
const int face,
const int id );
153 const std::vector< unsigned int > &vertices,
192 return Grid::getRealImplementation( entity ).getIndex();
198 return Grid::getRealImplementation( entity ).getIndex();
204 return intersection.boundarySegmentIndex();
210 return intersection.boundary() &&
220 Grid *
createGrid (
const bool addMissingBoundaries,
const std::string dgfName =
"" );
222 Grid *
createGrid (
const bool addMissingBoundaries,
bool temporary,
const std::string dgfName =
"" );
229 const std::string& filename,
230 std::istream& inFile,
231 BoundaryProjectionVector* bndProjections )
233 return ( temporary ) ?
234 new Grid( filename, inFile, globalProjection_, bndProjections, grdVerbose_ ) :
235 new Grid( filename, globalProjection_ , bndProjections, grdVerbose_ );
245 static void generateFace (
const ElementType &element,
const int f, FaceType &face );
246 void correctElementOrientation ();
247 typename FaceMap::const_iterator findPeriodicNeighbor(
const FaceMap &faceMap,
const FaceType &key )
const;
248 void reinsertBoundary (
const FaceMap &faceMap,
const typename FaceMap::const_iterator &pos,
const int id );
249 void recreateBoundaryIds (
const int defaultId = 1 );
251 VertexVector vertices_;
252 ElementVector elements_;
253 BoundaryIdVector boundaryIds_;
255 BoundaryProjectionMap boundaryProjections_;
256 unsigned int numFacesInserted_;
258 FaceTransformationVector faceTransformations_;
259 PeriodicNeighborMap periodicNeighborMap_;
264 template<
class Gr
idImp >
266 :
public std::binary_function< FaceType, FaceType, bool >
268 bool operator() (
const FaceType &a,
const FaceType &b )
const
270 for(
unsigned int i = 0; i < numFaceCorners; ++i )
272 if( a[ i ] != b[ i ] )
273 return (a[ i ] < b[ i ]);
309 this->setVerbosity( verbose );
344 this->setVerbosity( verbose );
380 this->setVerbosity( verbose );
388 template<
int dimw, ALUGr
idElementType eltype, ALUGr
idRefinementType refinementtype,
class Comm>
389 class GridFactory< ALUGrid<2, dimw, eltype, refinementtype, Comm > >
390 :
public ALU2dGridFactory< ALUGrid<2, dimw, eltype, refinementtype, Comm > >
393 typedef ALUGrid<2, dimw, eltype, refinementtype, Comm >
Grid;
417 this->setVerbosity( verbose );
426 template<
class Gr
idImp >
428 : globalProjection_ ( 0 ),
429 numFacesInserted_ ( 0 ),
435 template<
class Gr
idImp >
437 : globalProjection_ ( 0 ),
438 numFacesInserted_ ( 0 ),
444 template<
class Gr
idImp >
449 template<
class Gr
idImp >
452 return createGrid(
true,
true,
"" );
456 template<
class Gr
idImp >
458 ::createGrid (
const bool addMissingBoundaries,
const std::string dgfName )
460 return createGrid( addMissingBoundaries,
true, dgfName );
465 #endif // #ifdef ENABLE_ALUGRID
467 #endif // #ifndef DUNE_ALU2DGRID_FACTORY_HH