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;
50 : macroGrid_( filename.c_str(), comm )
52 grid_ = macroGrid_.template createGrid< Grid >();
56 const size_t nofElements = macroGrid_.
elements.size();
57 for(
size_t i = 0; i < nofElements; ++i )
59 std::vector< double > coord;
62 const size_t nofCorners = macroGrid_.
elements[i].size();
63 for (
size_t k=0; k<nofCorners; ++k)
64 for (
int j=0; j<DomainType::dimension; ++j)
66 p/=
double(nofCorners);
68 elInsertOrder_.insert( std::make_pair( p, i ) );
74 const size_t nofVertices = macroGrid_.
vtx.size();
75 for(
size_t i = 0; i < nofVertices; ++i )
77 std::vector< double > coord;
80 for(
int k = 0; k < DomainType::dimension; ++k )
81 p[ k ] = macroGrid_.
vtx[i][k];
83 vtxInsertOrder_.insert( std::make_pair( p, i ) );
93 template <
class Intersection>
99 template <
class Intersection>
105 template<
int codim >
116 template <
class Entity >
119 return numParameters< Entity::codimension >();
124 const typename Element::Geometry &geo = element.geometry();
125 DomainType coord( geo.corner( 0 ) );
126 for(
int i = 1; i < geo.corners(); ++i )
127 coord += geo.corner( i );
128 coord /= double( geo.corners() );
130 InsertOrderIterator it = elInsertOrder_.find( coord );
131 if( it != elInsertOrder_.end() )
132 return macroGrid_.
elParams[ it->second ];
139 const typename Vertex::Geometry &geo = vertex.geometry();
140 DomainType coord( geo.corner( 0 ) );
142 InsertOrderIterator it = vtxInsertOrder_.find( coord );
143 if( it != vtxInsertOrder_.end() )
144 return macroGrid_.
vtxParams[ it->second ];
154 template<
class GG,
class II >
162 typedef FieldVector<typename Grid::ctype,Grid::dimensionworld> DomainType;
165 bool operator() (
const DomainType &a,
const DomainType &b )
const
168 const DomainType c = a - b;
169 const double eps = 1e-8;
171 for(
int i = 0; i < DomainType::dimension; ++i )
181 typedef std::map< DomainType, size_t, Compare > InsertOrderMap;
182 typedef typename InsertOrderMap::const_iterator InsertOrderIterator;
184 MacroGrid macroGrid_;
186 InsertOrderMap elInsertOrder_;
187 InsertOrderMap vtxInsertOrder_;
188 std::vector<double> emptyParam;
Include standard header files.
Definition: agrid.hh:58
Definition: dgfgridfactory.hh:36
int numParameters() const
Definition: dgfgridfactory.hh:106
int boundaryId(const Intersection &intersection) const
Definition: dgfgridfactory.hh:100
const DGFBoundaryParameter::type & boundaryParameter(const Intersection< GG, II > &intersection) const
Definition: dgfgridfactory.hh:156
std::vector< double > & parameter(const Vertex &vertex)
Definition: dgfgridfactory.hh:137
MPIHelper::MPICommunicator MPICommunicatorType
Definition: dgfgridfactory.hh:39
int numParameters(const Entity &) const
Definition: dgfgridfactory.hh:117
bool wasInserted(const Intersection &intersection) const
Definition: dgfgridfactory.hh:94
DGFGridFactory(const std::string &filename, MPICommunicatorType comm=MPIHelper::getCommunicator())
Definition: dgfgridfactory.hh:48
G Grid
Definition: dgfgridfactory.hh:37
static const int dimension
Definition: dgfgridfactory.hh:38
Grid * grid()
Definition: dgfgridfactory.hh:88
std::vector< double > & parameter(const Element &element)
Definition: dgfgridfactory.hh:122
bool haveBoundaryParameters() const
Definition: dgfgridfactory.hh:149
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition: common/intersection.hh:162
bool boundary() const
Return true if intersection is with interior or exterior boundary (see the cases above)
Definition: common/intersection.hh:214
int indexInInside() const
Local index of codim 1 entity in the inside() entity where intersection is contained in.
Definition: common/intersection.hh:344
Wrapper class for entities.
Definition: common/entity.hh:64
@ dimension
The dimension of the grid.
Definition: common/grid.hh:386
static const type & defaultValue()
default constructor
Definition: parser.hh:26
std::string type
type of additional boundary parameters
Definition: parser.hh:23
int nofvtxparams
Definition: parser.hh:161
std::vector< std::vector< double > > vtxParams
Definition: parser.hh:163
int nofelparams
Definition: parser.hh:161
std::vector< std::vector< double > > elParams
Definition: parser.hh:163
std::vector< std::vector< double > > vtx
Definition: parser.hh:123
std ::vector< std ::vector< unsigned int > > elements
Definition: parser.hh:132