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 )
72 MPICommunicatorType comm = MPIHelper::getCommunicator() )
76 generate( input, comm );
81 MPICommunicatorType comm = MPIHelper::getCommunicator() )
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 >
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 );
220 #endif // #ifndef DUNE_GRID_FILE_IO_DGFPARSER_DGFONED_HH
Intersection of a mesh entities of codimension 0 ("elements") with a "neighboring" element or with th...
Definition: albertagrid/dgfparser.hh:26
Grid * grid() const
get grid
Definition: dgfoned.hh:90
The dimension of the world the grid lives in.
Definition: common/grid.hh:408
MPIHelper::MPICommunicator MPICommunicatorType
MPI communicator type.
Definition: dgfoned.hh:68
One-dimensional adaptive grid.
Definition: onedgrid.hh:84
Wrapper class for entities.
Definition: common/entity.hh:61
int numParameters(const Entity &) const
OneDGrid does not support parameters, returns 0.
Definition: dgfoned.hh:112
size_t boundarySegmentIndex() const
index of the boundary segment within the macro grid
Definition: common/intersection.hh:260
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
static double refineWeight()
Definition: dgfoned.hh:49
bool haveBoundaryParameters() const
OneDGrid does not support boundary parameters.
Definition: dgfoned.hh:138
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
std::vector< double > & parameter(const Element &element)
Definition: dgfgridfactory.hh:129
static const int dimension
Definition: dgfgridfactory.hh:38
GridFamily::Traits::template Codim< cd >::Entity Entity
A type that is a model of a Dune::Entity.
Definition: common/grid.hh:446
Some simple static information for a given GridType.
Definition: io/file/dgfparser/dgfparser.hh:54
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 int refineStepsForHalf()
Definition: dgfoned.hh:44
bool wasInserted(const Dune::Intersection< GG, II > &intersection) const
always returns false
Definition: dgfoned.hh:97
static const type & defaultValue()
default constructor
Definition: parser.hh:26
The dimension of the grid.
Definition: common/grid.hh:402
Include standard header files.
Definition: agrid.hh:59
const DGFBoundaryParameter::type & boundaryParameter(const Dune::Intersection< GG, II > &intersection) const
return invalid default value
Definition: dgfoned.hh:145
std::vector< double > & parameter(const Entity &entity)
Definition: dgfoned.hh:125