3#ifndef DUNE_DGF_GRIDFACTORY_HH 
    4#define DUNE_DGF_GRIDFACTORY_HH 
   13#include <dune/grid/io/file/dgfparser/dgfexception.hh> 
   14#include <dune/grid/io/file/dgfparser/macrogrid.hh> 
   16#include <dune/grid/io/file/dgfparser/parser.hh> 
   17#include <dune/grid/common/intersection.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;
 
   47    explicit DGFGridFactory ( std::istream &input,
 
   51      DUNE_THROW( DGFException, 
"DGF factories using old MacroGrid implementation" 
   52                  "don't support creation from std::istream." );
 
   55    explicit DGFGridFactory ( 
const std::string &filename,
 
   57      : macroGrid_( filename.c_str(), comm )
 
   59      grid_ = macroGrid_.template createGrid< Grid >();
 
   61      if( macroGrid_.nofelparams > 0 )
 
   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)
 
   72              p[j]+=macroGrid_.vtx[macroGrid_.elements[i][k]][j];
 
   73          p/=
double(nofCorners);
 
   75          elInsertOrder_.insert( std::make_pair( p, i ) );
 
   79      if( macroGrid_.nofvtxparams > 0 )
 
   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>
 
  101    bool wasInserted(
const Intersection &intersection)
 const 
  103      return intersection.boundary();
 
  106    template <
class Intersection>
 
  107    int boundaryId(
const Intersection &intersection)
 const 
  109      return intersection.boundaryId();
 
  112    template< 
int codim >
 
  113    int numParameters ()
 const 
  116        return macroGrid_.nofelparams;
 
  117      else if( codim == dimension )
 
  118        return macroGrid_.nofvtxparams;
 
  123    template < 
class Entity >
 
  124    int numParameters ( 
const Entity & )
 const 
  126      return numParameters< Entity::codimension >();
 
  129    std::vector<double>& parameter(
const Element &element)
 
  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 ];
 
  144    std::vector<double>& parameter(
const Vertex &vertex)
 
  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 ];
 
  156    bool haveBoundaryParameters ()
 const 
  161    template< 
class GG, 
class II >
 
  163    boundaryParameter ( 
const Intersection< GG, II > & intersection )
 const 
  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;
 
@ dimension
The size of this vector.
Definition: fvector.hh:101
 
@ dimension
The dimension of the grid.
Definition: grid.hh:402
 
MPI_Comm MPICommunicator
The type of the mpi communicator.
Definition: mpihelper.hh:173
 
static MPICommunicator getCommunicator()
get the default communicator
Definition: mpihelper.hh:181
 
#define DUNE_DEPRECATED
Mark some entity as deprecated.
Definition: deprecated.hh:84
 
#define DUNE_THROW(E, m)
Definition: exceptions.hh:243
 
Helpers for dealing with MPI.
 
Dune namespace.
Definition: alignment.hh:10
 
static const type & defaultValue()
default constructor
Definition: parser.hh:26
 
std::string type
type of additional boundary parameters
Definition: parser.hh:23