5#ifndef DUNE_DGF_GRIDFACTORY_HH
6#define DUNE_DGF_GRIDFACTORY_HH
14#include <dune/common/parallel/mpihelper.hh>
28 template <
class Gr
idImp,
class IntersectionImp >
44 typedef typename Grid::template Codim< 0 >::Entity Element;
46 typedef typename Grid::template Codim< dimension >::Entity Vertex;
52 : macroGrid_( filename.c_str(), comm )
54 grid_ = macroGrid_.template createGrid< Grid >();
58 const size_t nofElements = macroGrid_.
elements.size();
59 for(
size_t i = 0; i < nofElements; ++i )
61 std::vector< double > coord;
64 const size_t nofCorners = macroGrid_.
elements[i].size();
65 for (
size_t k=0; k<nofCorners; ++k)
66 for (
int j=0; j<DomainType::dimension; ++j)
68 p/=
double(nofCorners);
70 elInsertOrder_.insert( std::make_pair( p, i ) );
76 const size_t nofVertices = macroGrid_.
vtx.size();
77 for(
size_t i = 0; i < nofVertices; ++i )
79 std::vector< double > coord;
82 for(
int k = 0; k < DomainType::dimension; ++k )
83 p[ k ] = macroGrid_.
vtx[i][k];
85 vtxInsertOrder_.insert( std::make_pair( p, i ) );
95 template <
class Intersection>
101 template <
class Intersection>
107 template<
int codim >
118 template <
class Entity >
121 return numParameters< Entity::codimension >();
126 const typename Element::Geometry &geo = element.geometry();
127 DomainType coord( geo.corner( 0 ) );
128 for(
int i = 1; i < geo.corners(); ++i )
129 coord += geo.corner( i );
130 coord /= double( geo.corners() );
132 InsertOrderIterator it = elInsertOrder_.find( coord );
133 if( it != elInsertOrder_.end() )
134 return macroGrid_.
elParams[ it->second ];
141 const typename Vertex::Geometry &geo =
vertex.geometry();
142 DomainType coord( geo.corner( 0 ) );
144 InsertOrderIterator it = vtxInsertOrder_.find( coord );
145 if( it != vtxInsertOrder_.end() )
146 return macroGrid_.
vtxParams[ it->second ];
156 template<
class GG,
class II >
164 typedef FieldVector<typename Grid::ctype,Grid::dimensionworld> DomainType;
167 bool operator() (
const DomainType &a,
const DomainType &b )
const
170 const DomainType c = a - b;
171 const double eps = 1e-8;
173 for(
int i = 0; i < DomainType::dimension; ++i )
183 typedef std::map< DomainType, size_t, Compare > InsertOrderMap;
184 typedef typename InsertOrderMap::const_iterator InsertOrderIterator;
186 MacroGrid macroGrid_;
188 InsertOrderMap elInsertOrder_;
189 InsertOrderMap vtxInsertOrder_;
190 std::vector<double> emptyParam;
Include standard header files.
Definition: agrid.hh:60
@ vertex
Definition: common.hh:133
Definition: dgfgridfactory.hh:38
int numParameters() const
Definition: dgfgridfactory.hh:108
int boundaryId(const Intersection &intersection) const
Definition: dgfgridfactory.hh:102
const DGFBoundaryParameter::type & boundaryParameter(const Intersection< GG, II > &intersection) const
Definition: dgfgridfactory.hh:158
std::vector< double > & parameter(const Vertex &vertex)
Definition: dgfgridfactory.hh:139
MPIHelper::MPICommunicator MPICommunicatorType
Definition: dgfgridfactory.hh:41
int numParameters(const Entity &) const
Definition: dgfgridfactory.hh:119
bool wasInserted(const Intersection &intersection) const
Definition: dgfgridfactory.hh:96
DGFGridFactory(const std::string &filename, MPICommunicatorType comm=MPIHelper::getCommunicator())
Definition: dgfgridfactory.hh:50
G Grid
Definition: dgfgridfactory.hh:39
static const int dimension
Definition: dgfgridfactory.hh:40
Grid * grid()
Definition: dgfgridfactory.hh:90
std::vector< double > & parameter(const Element &element)
Definition: dgfgridfactory.hh:124
bool haveBoundaryParameters() const
Definition: dgfgridfactory.hh:151
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition: common/intersection.hh:164
bool boundary() const
Return true if intersection is with interior or exterior boundary (see the cases above)
Definition: common/intersection.hh:216
int indexInInside() const
Local index of codim 1 entity in the inside() entity where intersection is contained in.
Definition: common/intersection.hh:346
Wrapper class for entities.
Definition: common/entity.hh:66
static constexpr int dimension
The dimension of the grid.
Definition: common/grid.hh:387
static const type & defaultValue()
default constructor
Definition: parser.hh:28
std::string type
type of additional boundary parameters
Definition: parser.hh:25
int nofvtxparams
Definition: parser.hh:163
std::vector< std::vector< double > > vtxParams
Definition: parser.hh:165
int nofelparams
Definition: parser.hh:163
std::vector< std::vector< double > > elParams
Definition: parser.hh:165
std::vector< std::vector< double > > vtx
Definition: parser.hh:125
std ::vector< std ::vector< unsigned int > > elements
Definition: parser.hh:134