3 #ifndef DUNE_GRID_FILE_IO_DGFPARSER_DGFONED_HH
4 #define DUNE_GRID_FILE_IO_DGFPARSER_DGFONED_HH
14 #include <dune/common/exceptions.hh>
27 double getfirst ( std::vector< double > v )
76 generate( input, comm );
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 >
118 template<
int codim >
124 template<
class Entity >
127 return parameter< Entity::codimension >( entity );
131 template<
int codim >
134 return emptyParameters_;
144 template<
class GG,
class II >
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 );
220 #endif // #ifndef DUNE_GRID_FILE_IO_DGFPARSER_DGFONED_HH
Some simple static information for a given GridType.
Definition: io/file/dgfparser/dgfparser.hh:54
GridFamily::Traits::template Codim< cd >::Entity Entity
A type that is a model of a Dune::Entity<cd,dim,...>.
Definition: common/grid.hh:444
std::vector< double > & parameter(const Entity &entity)
Definition: dgfoned.hh:125
Wrapper class for entities.
Definition: common/entity.hh:56
bool haveBoundaryParameters() const
OneDGrid does not support boundary parameters.
Definition: dgfoned.hh:138
The dimension of the world the grid lives in.
Definition: common/grid.hh:406
size_t boundarySegmentIndex() const
index of the boundary segment within the macro grid
Definition: common/intersection.hh:259
static int refineStepsForHalf()
Definition: dgfoned.hh:44
int numParameters(const Entity &) const
OneDGrid does not support parameters, returns 0.
Definition: dgfoned.hh:112
The dimension of the grid.
Definition: common/grid.hh:400
std::vector< double > & parameter(const typename Grid::Codim< codim >::Entity &element)
return empty vector
Definition: dgfoned.hh:132
int boundaryId(const Dune::Intersection< GG, II > &intersection) const
Definition: dgfoned.hh:103
DGFGridFactory(std::istream &input, MPICommunicatorType comm=MPIHelper::getCommunicator())
constructor taking istream
Definition: dgfoned.hh:71
OneDGrid Grid
grid type
Definition: dgfoned.hh:64
std::string type
type of additional boundary parameters
Definition: parser.hh:23
static const int dimension
Definition: dgfgridfactory.hh:38
Grid abstract base classThis class is the base class for all grid implementations. Although no virtual functions are used we call it abstract since its methods do not contain an implementation but forward to the methods of the derived class via the Barton-Nackman trick.
Definition: common/grid.hh:386
DGFGridFactory(const std::string &filename, MPICommunicatorType comm=MPIHelper::getCommunicator())
constructor taking filename
Definition: dgfoned.hh:80
int numParameters() const
OneDGrid does not support parameters, returns 0.
Definition: dgfoned.hh:119
MPIHelper::MPICommunicator MPICommunicatorType
Definition: dgfgridfactory.hh:39
bool wasInserted(const Dune::Intersection< GG, II > &intersection) const
always returns false
Definition: dgfoned.hh:97
Intersection of a mesh entities of codimension 0 ("elements") with a "neighboring" element or with th...
Definition: albertagrid/dgfparser.hh:26
const DGFBoundaryParameter::type & boundaryParameter(const Dune::Intersection< GG, II > &intersection) const
return invalid default value
Definition: dgfoned.hh:145
One-dimensional adaptive grid.
Definition: onedgrid.hh:83
Grid * grid() const
get grid
Definition: dgfoned.hh:90
static const type & defaultValue()
default constructor
Definition: parser.hh:26
std::vector< double > & parameter(const Element &element)
Definition: dgfgridfactory.hh:129
MPIHelper::MPICommunicator MPICommunicatorType
MPI communicator type.
Definition: dgfoned.hh:68
static double refineWeight()
Definition: dgfoned.hh:49