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;
48 MPICommunicatorType comm = MPIHelper::getCommunicator() ) DUNE_DEPRECATED
51 DUNE_THROW(
DGFException,
"DGF factories using old MacroGrid implementation"
52 "don't support creation from std::istream." );
56 MPICommunicatorType comm = MPIHelper::getCommunicator() ) DUNE_DEPRECATED
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)
71 for (
int j=0; j<DomainType::dimension; ++j)
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;
87 for(
int k = 0; k < DomainType::dimension; ++k )
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 >
117 else if( codim == dimension )
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;
178 for(
int i = 0; i < DomainType::dimension; ++i )
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;
static const type & defaultValue()
default constructor
Definition: parser.hh:26
static const int dimension
Definition: dgfgridfactory.hh:38
int numParameters() const
Definition: dgfgridfactory.hh:113
std::vector< std::vector< double > > vtxParams
Definition: parser.hh:163
bool boundary() const
Return true if intersection is with interior or exterior boundary (see the cases above) ...
Definition: common/intersection.hh:218
DGFGridFactory(std::istream &input, MPICommunicatorType comm=MPIHelper::getCommunicator())
Definition: dgfgridfactory.hh:47
int numParameters(const Entity &) const
Definition: dgfgridfactory.hh:124
MPIHelper::MPICommunicator MPICommunicatorType
Definition: dgfgridfactory.hh:39
Include standard header files.
Definition: agrid.hh:59
bool wasInserted(const Intersection &intersection) const
Definition: dgfgridfactory.hh:101
int boundaryId(const Intersection &intersection) const
Definition: dgfgridfactory.hh:107
std::vector< std::vector< unsigned int > > elements
Definition: parser.hh:132
std::vector< std::vector< double > > elParams
Definition: parser.hh:163
int nofvtxparams
Definition: parser.hh:161
bool haveBoundaryParameters() const
Definition: dgfgridfactory.hh:156
The dimension of the grid.
Definition: common/grid.hh:402
exception class for IO errors in the DGF parser
Definition: dgfexception.hh:12
DGFGridFactory(const std::string &filename, MPICommunicatorType comm=MPIHelper::getCommunicator())
Definition: dgfgridfactory.hh:55
std::vector< std::vector< double > > vtx
Definition: parser.hh:123
Intersection of a mesh entities of codimension 0 ("elements") with a "neighboring" element or with th...
Definition: albertagrid/dgfparser.hh:26
std::vector< double > & parameter(const Vertex &vertex)
Definition: dgfgridfactory.hh:144
std::string type
type of additional boundary parameters
Definition: parser.hh:23
Definition: common.hh:179
int nofelparams
Definition: parser.hh:161
G Grid
Definition: dgfgridfactory.hh:37
Grid * grid()
Definition: dgfgridfactory.hh:95
std::vector< double > & parameter(const Element &element)
Definition: dgfgridfactory.hh:129
const DGFBoundaryParameter::type & boundaryParameter(const Intersection< GG, II > &intersection) const
Definition: dgfgridfactory.hh:163
Wrapper class for entities.
Definition: common/entity.hh:61