5#ifndef DUNE_GRID_FILE_IO_DGFPARSER_DGFONED_HH
6#define DUNE_GRID_FILE_IO_DGFPARSER_DGFONED_HH
16#include <dune/common/exceptions.hh>
29 double getfirst ( std::vector< double > v )
78 generate( input, comm );
87 std::ifstream input( filename.c_str() );
88 generate( input, comm );
98 template<
class GG,
class II >
104 template<
class GG,
class II >
113 template<
class Entity >
120 template<
int codim >
126 template<
class Entity >
129 return parameter< Entity::codimension >( entity );
133 template<
int codim >
136 return emptyParameters_;
146 template<
class GG,
class II >
157 std::vector< double > emptyParameters_;
165 inline void DGFGridFactory< OneDGrid >::generate ( std::istream &input, [[maybe_unused]] MPICommunicatorType comm )
168 dgf::IntervalBlock intervalBlock( input );
172 dgf::VertexBlock vertexBlock( input, dimensionworld );
175 if( !( vertexBlock.isactive() || intervalBlock.isactive() ))
176 DUNE_THROW( DGFException,
"No readable block found" );
178 std::vector< std::vector< double > > vertices;
181 if( vertexBlock.isactive() )
184 std::vector< std::vector< double > >
parameter;
185 vertexBlock.get( vertices,
parameter, nparameter );
188 std::cerr <<
"Warning: vertex parameters will be ignored" << std::endl;
192 if ( intervalBlock.isactive() )
194 if( intervalBlock.dimw() != dimensionworld )
196 DUNE_THROW( DGFException,
"Error: wrong coordinate dimension in interval block \
197 (got " << intervalBlock.dimw() <<
", expected " << dimensionworld <<
")" );
200 int nintervals = intervalBlock.numIntervals();
201 for(
int i = 0; i < nintervals; ++i )
202 intervalBlock.getVtx( i, vertices );
206 std::vector< double > vtx( vertices.size() );
207 transform( vertices.begin(), vertices.end(), vtx.begin(), getfirst );
210 std::sort( vtx.begin(), vtx.end() );
211 std::vector< double >::iterator it = std::unique( vtx.begin(), vtx.end() );
212 vtx.erase( it, vtx.end() );
213 if( vertices.size() != vtx.size() )
214 std::cerr <<
"Warning: removed duplicate vertices" << std::endl;
217 grid_ =
new OneDGrid( vtx );
Include standard header files.
Definition: agrid.hh:60
Definition: dgfgridfactory.hh:38
MPIHelper::MPICommunicator MPICommunicatorType
Definition: dgfgridfactory.hh:41
static const int dimension
Definition: dgfgridfactory.hh:40
std::vector< double > & parameter(const Element &element)
Definition: dgfgridfactory.hh:124
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition: common/intersection.hh:164
size_t boundarySegmentIndex() const
index of the boundary segment within the macro grid
Definition: common/intersection.hh:236
Wrapper class for entities.
Definition: common/entity.hh:66
Grid abstract base class.
Definition: common/grid.hh:375
static constexpr int dimension
The dimension of the grid.
Definition: common/grid.hh:387
static constexpr int dimensionworld
The dimension of the world the grid lives in.
Definition: common/grid.hh:390
GridFamily::Traits::template Codim< cd >::Entity Entity
A type that is a model of a Dune::Entity<cd,dim,...>.
Definition: common/grid.hh:419
static double refineWeight()
Definition: dgfoned.hh:51
static int refineStepsForHalf()
Definition: dgfoned.hh:46
OneDGrid Grid
grid type
Definition: dgfoned.hh:66
std::vector< double > & parameter(const typename Grid::Codim< codim >::Entity &element)
return empty vector
Definition: dgfoned.hh:134
MPIHelper::MPICommunicator MPICommunicatorType
MPI communicator type.
Definition: dgfoned.hh:70
const DGFBoundaryParameter::type & boundaryParameter(const Dune::Intersection< GG, II > &intersection) const
return invalid default value
Definition: dgfoned.hh:147
std::vector< double > & parameter(const Entity &entity)
Definition: dgfoned.hh:127
int boundaryId(const Dune::Intersection< GG, II > &intersection) const
Definition: dgfoned.hh:105
Grid * grid() const
get grid
Definition: dgfoned.hh:92
bool haveBoundaryParameters() const
OneDGrid does not support boundary parameters.
Definition: dgfoned.hh:140
int numParameters(const Entity &) const
OneDGrid does not support parameters, returns 0.
Definition: dgfoned.hh:114
DGFGridFactory(const std::string &filename, MPICommunicatorType comm=MPIHelper::getCommunicator())
constructor taking filename
Definition: dgfoned.hh:82
DGFGridFactory(std::istream &input, MPICommunicatorType comm=MPIHelper::getCommunicator())
constructor taking istream
Definition: dgfoned.hh:73
int numParameters() const
OneDGrid does not support parameters, returns 0.
Definition: dgfoned.hh:121
bool wasInserted(const Dune::Intersection< GG, II > &intersection) const
always returns false
Definition: dgfoned.hh:99
Some simple static information for a given GridType.
Definition: io/file/dgfparser/dgfparser.hh:56
static const type & defaultValue()
default constructor
Definition: parser.hh:28
std::string type
type of additional boundary parameters
Definition: parser.hh:25
One-dimensional adaptive grid.
Definition: onedgrid.hh:94