3#ifndef DUNE_GRID_FILE_IO_DGFPARSER_DGFONED_HH 
    4#define DUNE_GRID_FILE_IO_DGFPARSER_DGFONED_HH 
   17#include <dune/grid/common/intersection.hh> 
   21#include "dgfparser.hh" 
   27  double getfirst ( std::vector< double > v )
 
   42  struct DGFGridInfo< OneDGrid >
 
   61  struct DGFGridFactory< OneDGrid >
 
   64    typedef OneDGrid Grid;
 
   71    explicit DGFGridFactory ( std::istream &input,
 
   76      generate( input, comm );
 
   80    explicit DGFGridFactory ( 
const std::string &filename,
 
   85      std::ifstream input( filename.c_str() );
 
   86      generate( input, comm );
 
   96    template< 
class GG, 
class II >
 
  102    template< 
class GG, 
class II >
 
  111    template< 
class Entity >
 
  112    int numParameters ( 
const Entity & )
 const 
  118    template< 
int codim >
 
  119    int numParameters ()
 const 
  124    template< 
class Entity >
 
  125    std::vector< double >& parameter ( 
const Entity &entity )
 
  127      return parameter< Entity::codimension >( entity );
 
  131    template< 
int codim >
 
  134      return emptyParameters_;
 
  138    bool haveBoundaryParameters ()
 const 
  144    template< 
class GG, 
class II >
 
  152    void generate ( std::istream &input, MPICommunicatorType comm );
 
  155    std::vector< double > emptyParameters_;
 
  163  inline void DGFGridFactory< OneDGrid >::generate ( std::istream &input, MPICommunicatorType comm )
 
  166    dgf::IntervalBlock intervalBlock( input );
 
  170    dgf::VertexBlock vertexBlock( input, dimensionworld );
 
  173    if( !( vertexBlock.isactive() || intervalBlock.isactive() ))
 
  174      DUNE_THROW( DGFException, 
"No readable block found" );
 
  176    std::vector< std::vector< double > > vertices;
 
  179    if( vertexBlock.isactive() )
 
  182      std::vector< std::vector< double > > parameter;
 
  183      vertexBlock.get( vertices, parameter, nparameter );
 
  186        std::cerr << 
"Warning: vertex parameters will be ignored" << std::endl;
 
  190    if ( intervalBlock.isactive() )
 
  192      if( intervalBlock.dimw() != dimensionworld )
 
  194        DUNE_THROW( DGFException, 
"Error: wrong coordinate dimension in interval block \ 
  195                                   (got "                                                                                         << intervalBlock.dimw() << 
", expected " << dimensionworld << 
")" );
 
  198      int nintervals = intervalBlock.numIntervals();
 
  199      for( 
int i = 0; i < nintervals; ++i )
 
  200        intervalBlock.getVtx( i, vertices );
 
  204    std::vector< double > vtx( vertices.size() );
 
  205    transform( vertices.begin(), vertices.end(), vtx.begin(), getfirst );
 
  208    std::sort( vtx.begin(), vtx.end() );
 
  209    std::vector< double >::iterator it = std::unique( vtx.begin(), vtx.end() );
 
  210    vtx.erase( it, vtx.end() );
 
  211    if( vertices.size() != vtx.size() )
 
  212      std::cerr << 
"Warning: removed duplicate vertices" << std::endl;
 
  215    grid_ = 
new OneDGrid( vtx );
 
@ dimensionworld
The dimension of the world the grid lives in.
Definition: grid.hh:408
 
@ dimension
The dimension of the grid.
Definition: grid.hh:402
 
Intersection of a mesh entities of codimension 0 ("elements") with a "neighboring" element or with th...
Definition: intersection.hh:161
 
size_t boundarySegmentIndex() const
index of the boundary segment within the macro grid
Definition: intersection.hh:260
 
MPI_Comm MPICommunicator
The type of the mpi communicator.
Definition: mpihelper.hh:173
 
static MPICommunicator getCommunicator()
get the default communicator
Definition: mpihelper.hh:181
 
A few common exception classes.
 
#define DUNE_THROW(E, m)
Definition: exceptions.hh:243
 
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
 
static double refineWeight()
 
static int refineStepsForHalf()
number of globalRefine steps needed to refuce h by 0.5
 
GridFamily::Traits::template Codim< cd >::Entity Entity
A type that is a model of a Dune::Entity<cd,dim,...>.
Definition: grid.hh:446