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 );
222 #endif // #ifndef DUNE_GRID_FILE_IO_DGFPARSER_DGFONED_HH One-dimensional adaptive grid.
Definition: onedgrid.hh:96
static constexpr int dimensionworld
The dimension of the world the grid lives in.
Definition: common/grid.hh:390
OneDGrid Grid
grid type
Definition: dgfoned.hh:66
bool wasInserted(const Dune::Intersection< GG, II > &intersection) const
always returns false
Definition: dgfoned.hh:99
std::vector< double > & parameter(const Element &element)
Definition: dgfgridfactory.hh:124
std::vector< double > & parameter([[maybe_unused]] const typename Grid::Codim< codim >::Entity &element)
return empty vector
Definition: dgfoned.hh:134
int numParameters() const
OneDGrid does not support parameters, returns 0.
Definition: dgfoned.hh:121
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:375
std::vector< double > & parameter(const Entity &entity)
Definition: dgfoned.hh:127
static double refineWeight()
Definition: dgfoned.hh:51
Some simple static information for a given GridType.
Definition: io/file/dgfparser/dgfparser.hh:55
size_t boundarySegmentIndex() const
index of the boundary segment within the macro grid
Definition: common/intersection.hh:236
MPIHelper::MPICommunicator MPICommunicatorType
Definition: dgfgridfactory.hh:41
int boundaryId(const Dune::Intersection< GG, II > &intersection) const
Definition: dgfoned.hh:105
DGFGridFactory(const std::string &filename, MPICommunicatorType comm=MPIHelper::getCommunicator())
constructor taking filename
Definition: dgfoned.hh:82
std::string type
type of additional boundary parameters
Definition: parser.hh:25
MPIHelper::MPICommunicator MPICommunicatorType
MPI communicator type.
Definition: dgfoned.hh:70
Include standard header files.
Definition: agrid.hh:59
Grid * grid() const
get grid
Definition: dgfoned.hh:92
const DGFBoundaryParameter::type & boundaryParameter([[maybe_unused]] const Dune::Intersection< GG, II > &intersection) const
return invalid default value
Definition: dgfoned.hh:147
DGFGridFactory(std::istream &input, MPICommunicatorType comm=MPIHelper::getCommunicator())
constructor taking istream
Definition: dgfoned.hh:73
static constexpr int dimension
The dimension of the grid.
Definition: common/grid.hh:387
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition: albertagrid/dgfparser.hh:28
static const type & defaultValue()
default constructor
Definition: parser.hh:28
Wrapper class for entities.
Definition: common/entity.hh:65
static int refineStepsForHalf()
Definition: dgfoned.hh:46
static const int dimension
Definition: dgfgridfactory.hh:40
GridFamily::Traits::template Codim< cd >::Entity Entity
A type that is a model of a Dune::Entity<cd,dim,...>.
Definition: common/grid.hh:419
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