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 );
Include standard header files.
Definition: agrid.hh:59
Definition: dgfgridfactory.hh:36
MPIHelper::MPICommunicator MPICommunicatorType
Definition: dgfgridfactory.hh:39
std::vector< double > & parameter(const Element &element)
Definition: dgfgridfactory.hh:129
static const int dimension
Definition: dgfgridfactory.hh:38
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition: common/intersection.hh:162
size_t boundarySegmentIndex() const
index of the boundary segment within the macro grid
Definition: common/intersection.hh:246
Wrapper class for entities.
Definition: common/entity.hh:64
Grid abstract base class.
Definition: common/grid.hh:373
@ dimensionworld
The dimension of the world the grid lives in.
Definition: common/grid.hh:393
@ dimension
The dimension of the grid.
Definition: common/grid.hh:387
GridFamily::Traits::template Codim< cd >::Entity Entity
A type that is a model of a Dune::Entity<cd,dim,...>.
Definition: common/grid.hh:423
static double refineWeight()
Definition: dgfoned.hh:49
static int refineStepsForHalf()
Definition: dgfoned.hh:44
std::vector< double > & parameter(const Entity &entity)
Definition: dgfoned.hh:125
OneDGrid Grid
grid type
Definition: dgfoned.hh:64
const DGFBoundaryParameter::type & boundaryParameter(const Dune::Intersection< GG, II > &intersection) const
return invalid default value
Definition: dgfoned.hh:145
MPIHelper::MPICommunicator MPICommunicatorType
MPI communicator type.
Definition: dgfoned.hh:68
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
bool haveBoundaryParameters() const
OneDGrid does not support boundary parameters.
Definition: dgfoned.hh:138
Grid * grid() const
get grid
Definition: dgfoned.hh:90
int numParameters(const Entity &) const
OneDGrid does not support parameters, returns 0.
Definition: dgfoned.hh:112
DGFGridFactory(const std::string &filename, MPICommunicatorType comm=MPIHelper::getCommunicator())
constructor taking filename
Definition: dgfoned.hh:80
DGFGridFactory(std::istream &input, MPICommunicatorType comm=MPIHelper::getCommunicator())
constructor taking istream
Definition: dgfoned.hh:71
int numParameters() const
OneDGrid does not support parameters, returns 0.
Definition: dgfoned.hh:119
bool wasInserted(const Dune::Intersection< GG, II > &intersection) const
always returns false
Definition: dgfoned.hh:97
Some simple static information for a given GridType.
Definition: io/file/dgfparser/dgfparser.hh:54
static const type & defaultValue()
default constructor
Definition: parser.hh:26
std::string type
type of additional boundary parameters
Definition: parser.hh:23
One-dimensional adaptive grid.
Definition: onedgrid.hh:92