3 #ifndef DUNE_DGF_GRIDFACTORY_HH
4 #define DUNE_DGF_GRIDFACTORY_HH
12 #include <dune/common/parallel/mpihelper.hh>
26 template <
class Gr
idImp,
class IntersectionImp >
42 typedef typename Grid::template Codim< 0 >::Entity Element;
44 typedef typename Grid::template Codim< dimension >::Entity Vertex;
51 DUNE_THROW(
DGFException,
"DGF factories using old MacroGrid implementation"
52 "don't support creation from std::istream." );
57 : macroGrid_( filename.c_str(), comm )
59 grid_ = macroGrid_.template createGrid< Grid >();
63 const size_t nofElements = macroGrid_.
elements.size();
64 for(
size_t i = 0; i < nofElements; ++i )
66 std::vector< double > coord;
69 const size_t nofCorners = macroGrid_.
elements[i].size();
70 for (
size_t k=0; k<nofCorners; ++k)
73 p/=
double(nofCorners);
75 elInsertOrder_.insert( std::make_pair( p, i ) );
81 const size_t nofVertices = macroGrid_.
vtx.size();
82 for(
size_t i = 0; i < nofVertices; ++i )
84 std::vector< double > coord;
88 p[ k ] = macroGrid_.
vtx[i][k];
90 vtxInsertOrder_.insert( std::make_pair( p, i ) );
100 template <
class Intersection>
106 template <
class Intersection>
109 return intersection.boundaryId();
112 template<
int codim >
123 template <
class Entity >
126 return numParameters< Entity::codimension >();
131 const typename Element::Geometry &geo = element.geometry();
132 DomainType coord( geo.corner( 0 ) );
133 for(
int i = 1; i < geo.corners(); ++i )
134 coord += geo.corner( i );
135 coord /= double( geo.corners() );
137 InsertOrderIterator it = elInsertOrder_.find( coord );
138 if( it != elInsertOrder_.end() )
139 return macroGrid_.
elParams[ it->second ];
146 const typename Vertex::Geometry &geo = vertex.geometry();
147 DomainType coord( geo.corner( 0 ) );
149 InsertOrderIterator it = vtxInsertOrder_.find( coord );
150 if( it != vtxInsertOrder_.end() )
151 return macroGrid_.
vtxParams[ it->second ];
161 template<
class GG,
class II >
169 typedef FieldVector<typename Grid::ctype,Grid::dimensionworld> DomainType;
172 bool operator() (
const DomainType &a,
const DomainType &b )
const
175 const DomainType c = a - b;
176 const double eps = 1e-8;
188 typedef std::map< DomainType, size_t, Compare > InsertOrderMap;
189 typedef typename InsertOrderMap::const_iterator InsertOrderIterator;
191 MacroGrid macroGrid_;
193 InsertOrderMap elInsertOrder_;
194 InsertOrderMap vtxInsertOrder_;
195 std::vector<double> emptyParam;