5#ifndef DUNE_DGFPARSERYASP_HH
6#define DUNE_DGFPARSERYASP_HH
18 template<
class Gr
idImp,
class IntersectionImp >
57 dwarn <<
"GridParameterBlock: found keyword `overlap' but no value, defaulting to `" <<
_overlap <<
"' !\n";
67 dwarn <<
"YaspGridParameterBlock: Parameter 'overlap' not specified, "
68 <<
"defaulting to '" <<
_overlap <<
"'." << std::endl;
86 template <
typename ctype,
int dim>
94 typedef FieldVector< ctype, dimension > Point;
101 generate( input, comm );
107 std::ifstream input( filename.c_str() );
109 DUNE_THROW(
DGFException,
"Error: Macrofile '" << filename <<
"' not found" );
110 generate( input, comm );
115 delete boundaryDomainBlock_;
123 template <
class Intersection>
129 template <
class Intersection>
132 if( boundaryDomainBlock_->isactive() )
134 std::vector< Point > corners;
135 getCorners( intersection.
geometry(), corners );
136 const dgf::DomainData *data = boundaryDomainBlock_->contains( corners );
146 template<
int codim >
155 return boundaryDomainBlock_->hasParameter();
158 template<
class GG,
class II >
164 std::vector< Point > corners;
165 getCorners( intersection.
geometry(), corners );
166 const dgf::DomainData *data = boundaryDomainBlock_->contains( corners );
176 template<
class Entity >
185 template<
class Geometry >
186 static void getCorners (
const Geometry &geometry, std::vector< Point > &corners )
188 corners.resize( geometry.
corners() );
189 for(
int i = 0; i < geometry.
corners(); ++i )
193 corners[ i ][ j ] = corner[ j ];
198 dgf::BoundaryDomBlock *boundaryDomainBlock_;
199 std::vector<double> emptyParam;
203 template<
typename ctype,
int dim >
204 inline void DGFGridFactory< YaspGrid< dim , EquidistantCoordinates<ctype, dim> > >
205 ::generate ( std::istream &gridin, MPICommunicatorType comm )
208 dgf::IntervalBlock intervalBlock( gridin );
210 if( !intervalBlock.isactive() )
211 DUNE_THROW( DGFException,
"YaspGrid can only be created from an interval block." );
213 if( intervalBlock.numIntervals() != 1 )
214 DUNE_THROW( DGFException,
"YaspGrid can only handle 1 interval block." );
216 if( intervalBlock.dimw() != dim )
218 DUNE_THROW( DGFException,
219 "Cannot read an interval of dimension " << intervalBlock.dimw()
220 <<
" into a YaspGrid< " << dim <<
" >." );
223 const dgf::IntervalBlock::Interval &interval = intervalBlock.get( 0 );
225 FieldVector<ctype, dim> lang;
226 std::array<int,dim> anz;
227 for(
int i = 0; i < dim; ++i )
230 if(
abs( interval.p[ 0 ][ i ] ) > 1e-10 )
232 DUNE_THROW( DGFException,
233 "YaspGrid cannot handle grids with non-zero left lower corner." );
236 lang[ i ] = interval.p[ 1 ][ i ] - interval.p[ 0 ][ i ];
237 anz[ i ] = interval.n[ i ];
241 dgf::PeriodicFaceTransformationBlock trafoBlock( gridin, dim );
242 std::bitset< dim > per;
243 const int numTrafos = trafoBlock.numTransformations();
244 for(
int k = 0; k < numTrafos; ++k )
246 const Transformation &trafo = trafoBlock.transformation( k );
248 bool identity =
true;
249 for(
int i = 0; i < dim; ++i )
250 for(
int j = 0; j < dim; ++j )
251 identity &= (
abs( (i == j ? 1.0 : 0.0) - trafo.matrix( i, j ) ) < 1e-10);
253 DUNE_THROW( DGFException,
"YaspGrid can only handle shifts as periodic face transformations." );
257 for(
int i = 0; i < dim; ++i )
259 if(
abs( trafo.shift[ i ] ) < 1e-10 )
264 if( (numDirs != 1) || (
abs(
abs( trafo.shift[ dir ] ) - lang[ dir ] ) >= 1e-10) )
266 std::cerr <<
"Tranformation '" << trafo
267 <<
"' does not map boundaries on boundaries." << std::endl;
274 dgf::YaspGridParameterBlock grdParam( gridin );
276 grid_ =
new YaspGrid< dim , EquidistantCoordinates<ctype, dim> >( lang, anz, per, grdParam.overlap(), comm );
278 boundaryDomainBlock_ =
new dgf::BoundaryDomBlock( gridin, dimension );
284 template <
typename ctype,
int dim>
292 typedef FieldVector< ctype, dimension > Point;
299 generate( input, comm );
305 std::ifstream input( filename.c_str() );
306 generate( input, comm );
311 delete boundaryDomainBlock_;
319 template <
class Intersection>
325 template <
class Intersection>
328 if( boundaryDomainBlock_->isactive() )
330 std::vector< Point > corners;
331 getCorners( intersection.
geometry(), corners );
332 const dgf::DomainData *data = boundaryDomainBlock_->contains( corners );
342 template<
int codim >
351 return boundaryDomainBlock_->hasParameter();
354 template<
class GG,
class II >
360 std::vector< Point > corners;
361 getCorners( intersection.
geometry(), corners );
362 const dgf::DomainData *data = boundaryDomainBlock_->contains( corners );
372 template<
class Entity >
381 template<
class Geometry >
382 static void getCorners (
const Geometry &geometry, std::vector< Point > &corners )
384 corners.resize( geometry.
corners() );
385 for(
int i = 0; i < geometry.
corners(); ++i )
389 corners[ i ][ j ] = corner[ j ];
394 dgf::BoundaryDomBlock *boundaryDomainBlock_;
395 std::vector<double> emptyParam;
399 template<
typename ctype,
int dim >
400 inline void DGFGridFactory< YaspGrid<dim, EquidistantOffsetCoordinates<ctype, dim> > >
401 ::generate ( std::istream &gridin, MPICommunicatorType comm )
404 dgf::IntervalBlock intervalBlock( gridin );
406 if( !intervalBlock.isactive() )
407 DUNE_THROW( DGFException,
"YaspGrid can only be created from an interval block." );
409 if( intervalBlock.numIntervals() != 1 )
410 DUNE_THROW( DGFException,
"YaspGrid can only handle 1 interval block." );
412 if( intervalBlock.dimw() != dim )
414 DUNE_THROW( DGFException,
415 "Cannot read an interval of dimension "
416 << intervalBlock.dimw()
417 <<
" into a YaspGrid< " << dim <<
" >." );
420 const dgf::IntervalBlock::Interval &interval = intervalBlock.get( 0 );
422 FieldVector<ctype, dim> lower;
423 FieldVector<ctype, dim> upper;
424 std::array<int,dim> anz;
425 for(
int i = 0; i < dim; ++i )
427 lower[ i ] = interval.p[ 0 ][ i ];
428 upper[ i ] = interval.p[ 1 ][ i ];
429 anz[ i ] = interval.n[ i ];
433 dgf::PeriodicFaceTransformationBlock trafoBlock( gridin, dim );
434 std::bitset< dim > periodic;
435 const int numTrafos = trafoBlock.numTransformations();
436 for(
int k = 0; k < numTrafos; ++k )
438 const Transformation &trafo = trafoBlock.transformation( k );
440 bool identity =
true;
441 for(
int i = 0; i < dim; ++i )
442 for(
int j = 0; j < dim; ++j )
443 identity &= (
abs( (i == j ? 1.0 : 0.0) - trafo.matrix( i, j ) ) < 1e-10);
445 DUNE_THROW( DGFException,
"YaspGrid can only handle shifts as periodic face transformations." );
449 for(
int currentDir = 0; currentDir < dim; ++currentDir )
451 if(
abs( trafo.shift[ currentDir ] ) > 1e-10 )
458 || (
abs(
abs( trafo.shift[ dir ] ) -
abs( upper[ dir ] - lower[ dir ] ) ) >= 1e-10) )
460 std::cerr <<
"Tranformation '" << trafo
461 <<
"' does not map boundaries on boundaries." << std::endl;
465 periodic[ dir ] =
true;
470 dgf::YaspGridParameterBlock grdParam( gridin );
472 grid_ =
new YaspGrid< dim, EquidistantOffsetCoordinates<ctype, dim> >
473 ( lower, upper, anz, periodic, grdParam.overlap(), comm );
475 boundaryDomainBlock_ =
new dgf::BoundaryDomBlock( gridin, dimension );
483 template<
class ctype,
int dim >
488 template<
typename In >
492 throw std::invalid_argument(
"Tensor product coordinates for YaspGrid are currently not supported via the DGFGridFactory" );
496 template <
typename Coordinates,
int dim>
Include standard header files.
Definition: agrid.hh:60
void abs(const DofVectorPointer< int > &dofVector)
Definition: dofvector.hh:328
ALBERTA AFF_TRAFO AffineTransformation
Definition: misc.hh:52
Definition: dgfgridfactory.hh:38
MPIHelper::MPICommunicator MPICommunicatorType
Definition: dgfgridfactory.hh:41
G Grid
Definition: dgfgridfactory.hh:39
static const int dimension
Definition: dgfgridfactory.hh:40
bool haveBoundaryParameters() const
Definition: dgfgridfactory.hh:151
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition: common/intersection.hh:164
Geometry geometry() const
geometrical information about the intersection in global coordinates.
Definition: common/intersection.hh:323
int indexInInside() const
Local index of codim 1 entity in the inside() entity where intersection is contained in.
Definition: common/intersection.hh:346
Wrapper class for entities.
Definition: common/entity.hh:66
Wrapper class for geometries.
Definition: common/geometry.hh:71
FieldVector< ctype, cdim > GlobalCoordinate
type of the global coordinates
Definition: common/geometry.hh:106
GlobalCoordinate corner(int i) const
Obtain a corner of the geometry.
Definition: common/geometry.hh:219
int corners() const
Return the number of corners of the reference element.
Definition: common/geometry.hh:205
static constexpr int dimension
The dimension of the grid.
Definition: common/grid.hh:387
bool findtoken(std ::string token)
Definition: basic.cc:123
bool getnextentry(ENTRY &entry)
Definition: basic.hh:63
Definition: boundarydom.hh:23
int id() const
Definition: boundarydom.hh:42
const BoundaryParameter & parameter() const
Definition: boundarydom.hh:54
Definition: boundarydom.hh:195
Common Grid parameters.
Definition: gridparameter.hh:35
exception class for IO errors in the DGF parser
Definition: dgfexception.hh:16
Some simple static information for a given GridType.
Definition: io/file/dgfparser/dgfparser.hh:56
Grid parameters for YaspGrid.
Definition: dgfyasp.hh:40
int _overlap
Definition: dgfyasp.hh:42
YaspGridParameterBlock(std::istream &in)
constructor taking istream
Definition: dgfyasp.hh:46
int overlap() const
get dimension of world found in block
Definition: dgfyasp.hh:74
DGFGridFactory(std::istream &input, MPICommunicatorType comm=MPIHelper::getCommunicator())
Definition: dgfyasp.hh:98
DGFGridFactory(const std::string &filename, MPICommunicatorType comm=MPIHelper::getCommunicator())
Definition: dgfyasp.hh:104
bool wasInserted(const Intersection &intersection) const
Definition: dgfyasp.hh:124
int numParameters() const
Definition: dgfyasp.hh:147
std::vector< double > & parameter(const Entity &)
Definition: dgfyasp.hh:177
MPIHelper::MPICommunicator MPICommunicatorType
Definition: dgfyasp.hh:91
const DGFBoundaryParameter::type & boundaryParameter(const Intersection< GG, II > &intersection) const
Definition: dgfyasp.hh:160
~DGFGridFactory()
Definition: dgfyasp.hh:113
bool haveBoundaryParameters() const
Definition: dgfyasp.hh:153
Grid * grid() const
Definition: dgfyasp.hh:118
YaspGrid< dim, EquidistantCoordinates< ctype, dim > > Grid
Definition: dgfyasp.hh:89
int boundaryId(const Intersection &intersection) const
Definition: dgfyasp.hh:130
const DGFBoundaryParameter::type & boundaryParameter(const Intersection< GG, II > &intersection) const
Definition: dgfyasp.hh:356
DGFGridFactory(const std::string &filename, MPICommunicatorType comm=MPIHelper::getCommunicator())
Definition: dgfyasp.hh:302
Grid * grid() const
Definition: dgfyasp.hh:314
int boundaryId(const Intersection &intersection) const
Definition: dgfyasp.hh:326
YaspGrid< dim, EquidistantOffsetCoordinates< ctype, dim > > Grid
Definition: dgfyasp.hh:287
bool wasInserted(const Intersection &intersection) const
Definition: dgfyasp.hh:320
std::vector< double > & parameter(const Entity &entity)
Definition: dgfyasp.hh:373
bool haveBoundaryParameters() const
Definition: dgfyasp.hh:349
MPIHelper::MPICommunicator MPICommunicatorType
Definition: dgfyasp.hh:289
DGFGridFactory(std::istream &input, MPICommunicatorType comm=MPIHelper::getCommunicator())
Definition: dgfyasp.hh:296
~DGFGridFactory()
Definition: dgfyasp.hh:309
int numParameters() const
Definition: dgfyasp.hh:343
Grid * grid()
Definition: dgfyasp.hh:490
DGFGridFactory(const In &)
Definition: dgfyasp.hh:489
static double refineWeight()
Definition: dgfyasp.hh:499
static int refineStepsForHalf()
Definition: dgfyasp.hh:498
static const type & defaultValue()
default constructor
Definition: parser.hh:28
std::string type
type of additional boundary parameters
Definition: parser.hh:25
[ provides Dune::Grid ]
Definition: yaspgrid.hh:163
Container for equidistant coordinates in a YaspGrid.
Definition: coordinates.hh:29
Container for equidistant coordinates in a YaspGrid with non-trivial origin.
Definition: coordinates.hh:131