3 #ifndef DUNE_DGFPARSERYASP_HH 4 #define DUNE_DGFPARSERYASP_HH 16 template<
class Gr
idImp,
class IntersectionImp >
55 dwarn <<
"GridParameterBlock: found keyword `overlap' but no value, defaulting to `" << _overlap <<
"' !\n";
65 dwarn <<
"YaspGridParameterBlock: Parameter 'overlap' not specified, " 66 <<
"defaulting to '" << _overlap <<
"'." << std::endl;
84 template <
typename ctype,
int dim>
92 typedef FieldVector< ctype, dimension > Point;
97 MPICommunicatorType comm = MPIHelper::getCommunicator() )
99 generate( input, comm );
103 MPICommunicatorType comm = MPIHelper::getCommunicator() )
105 std::ifstream input( filename.c_str() );
107 DUNE_THROW(
DGFException,
"Error: Macrofile '" << filename <<
"' not found" );
108 generate( input, comm );
113 delete boundaryDomainBlock_;
121 template <
class Intersection>
127 template <
class Intersection>
130 if( boundaryDomainBlock_->isactive() )
132 std::vector< Point > corners;
133 getCorners( intersection.
geometry(), corners );
134 const dgf::DomainData *data = boundaryDomainBlock_->contains( corners );
144 template<
int codim >
153 return boundaryDomainBlock_->hasParameter();
156 template<
class GG,
class II >
160 if( haveBoundaryParameters() )
162 std::vector< Point > corners;
163 getCorners( intersection.
geometry(), corners );
164 const dgf::DomainData *data = boundaryDomainBlock_->contains( corners );
174 template<
class Entity >
181 void generate( std::istream &gridin, MPICommunicatorType comm );
183 template<
class Geometry >
184 static void getCorners (
const Geometry &geometry, std::vector< Point > &corners )
186 corners.resize( geometry.
corners() );
187 for(
int i = 0; i < geometry.
corners(); ++i )
190 for(
int j = 0; j < dimension; ++j )
191 corners[ i ][ j ] = corner[ j ];
197 std::vector<double> emptyParam;
201 template<
typename ctype,
int dim >
203 ::generate ( std::istream &gridin, MPICommunicatorType comm )
209 DUNE_THROW(
DGFException,
"YaspGrid can only be created from an interval block." );
212 DUNE_THROW(
DGFException,
"YaspGrid can only handle 1 interval block." );
214 if( intervalBlock.
dimw() != dim )
217 "Cannot read an interval of dimension " << intervalBlock.
dimw()
218 <<
" into a YaspGrid< " << dim <<
" >." );
223 FieldVector<ctype, dim> lang;
224 std::array<int,dim> anz;
225 for(
int i = 0; i < dim; ++i )
228 if(
abs( interval.p[ 0 ][ i ] ) > 1e-10 )
231 "YaspGrid cannot handle grids with non-zero left lower corner." );
234 lang[ i ] = interval.p[ 1 ][ i ] - interval.p[ 0 ][ i ];
235 anz[ i ] = interval.n[ i ];
240 std::bitset< dim > per;
242 for(
int k = 0; k < numTrafos; ++k )
246 bool identity =
true;
247 for(
int i = 0; i < dim; ++i )
248 for(
int j = 0; j < dim; ++j )
249 identity &= (
abs( (i == j ? 1.0 : 0.0) - trafo.matrix( i, j ) ) < 1e-10);
251 DUNE_THROW(
DGFException,
"YaspGrid can only handle shifts as periodic face transformations." );
255 for(
int i = 0; i < dim; ++i )
257 if(
abs( trafo.shift[ i ] ) < 1e-10 )
262 if( (numDirs != 1) || (
abs(
abs( trafo.shift[ dir ] ) - lang[ dir ] ) >= 1e-10) )
264 std::cerr <<
"Tranformation '" << trafo
265 <<
"' does not map boundaries on boundaries." << std::endl;
279 template <
typename ctype,
int dim>
288 template <
typename ctype,
int dim>
296 typedef FieldVector< ctype, dimension > Point;
301 MPICommunicatorType comm = MPIHelper::getCommunicator() )
303 generate( input, comm );
307 MPICommunicatorType comm = MPIHelper::getCommunicator() )
309 std::ifstream input( filename.c_str() );
310 generate( input, comm );
315 delete boundaryDomainBlock_;
323 template <
class Intersection>
329 template <
class Intersection>
332 if( boundaryDomainBlock_->isactive() )
334 std::vector< Point > corners;
335 getCorners( intersection.
geometry(), corners );
336 const dgf::DomainData *data = boundaryDomainBlock_->contains( corners );
346 template<
int codim >
355 return boundaryDomainBlock_->hasParameter();
358 template<
class GG,
class II >
362 if( haveBoundaryParameters() )
364 std::vector< Point > corners;
365 getCorners( intersection.
geometry(), corners );
366 const dgf::DomainData *data = boundaryDomainBlock_->contains( corners );
376 template<
class Entity >
383 void generate( std::istream &gridin, MPICommunicatorType comm );
385 template<
class Geometry >
386 static void getCorners (
const Geometry &geometry, std::vector< Point > &corners )
388 corners.resize( geometry.
corners() );
389 for(
int i = 0; i < geometry.
corners(); ++i )
392 for(
int j = 0; j < dimension; ++j )
393 corners[ i ][ j ] = corner[ j ];
399 std::vector<double> emptyParam;
403 template<
typename ctype,
int dim >
405 ::generate ( std::istream &gridin, MPICommunicatorType comm )
411 DUNE_THROW(
DGFException,
"YaspGrid can only be created from an interval block." );
414 DUNE_THROW(
DGFException,
"YaspGrid can only handle 1 interval block." );
416 if( intervalBlock.
dimw() != dim )
419 "Cannot read an interval of dimension " 420 << intervalBlock.
dimw()
421 <<
" into a YaspGrid< " << dim <<
" >." );
426 FieldVector<ctype, dim> lower;
427 FieldVector<ctype, dim> upper;
428 std::array<int,dim> anz;
429 for(
int i = 0; i < dim; ++i )
431 lower[ i ] = interval.p[ 0 ][ i ];
432 upper[ i ] = interval.p[ 1 ][ i ];
433 anz[ i ] = interval.n[ i ];
438 std::bitset< dim > periodic;
440 for(
int k = 0; k < numTrafos; ++k )
444 bool identity =
true;
445 for(
int i = 0; i < dim; ++i )
446 for(
int j = 0; j < dim; ++j )
447 identity &= (
abs( (i == j ? 1.0 : 0.0) - trafo.matrix( i, j ) ) < 1e-10);
449 DUNE_THROW(
DGFException,
"YaspGrid can only handle shifts as periodic face transformations." );
453 for(
int currentDir = 0; currentDir < dim; ++currentDir )
455 if(
abs( trafo.shift[ currentDir ] ) > 1e-10 )
462 || (
abs(
abs( trafo.shift[ dir ] ) -
abs( upper[ dir ] - lower[ dir ] ) ) >= 1e-10) )
464 std::cerr <<
"Tranformation '" << trafo
465 <<
"' does not map boundaries on boundaries." << std::endl;
469 periodic[ dir ] =
true;
477 ( lower, upper, anz, periodic, grdParam.
overlap(), comm );
482 template <
typename ctype,
int dim>
489 #endif // #ifndef DUNE_DGFPARSERYASP_HH DGFGridFactory(const std::string &filename, MPICommunicatorType comm=MPIHelper::getCommunicator())
Definition: dgfyasp.hh:306
Include standard header files.
Definition: agrid.hh:58
~DGFGridFactory()
Definition: dgfyasp.hh:111
YaspGridParameterBlock(std::istream &in)
constructor taking istream
Definition: dgfyasp.hh:44
YaspGrid< dim, EquidistantOffsetCoordinates< ctype, dim > > Grid
Definition: dgfyasp.hh:291
int boundaryId(const Intersection &intersection) const
Definition: dgfyasp.hh:330
Definition: interval.hh:19
bool getnextentry(ENTRY &entry)
Definition: basic.hh:61
std::string type
type of additional boundary parameters
Definition: parser.hh:23
YaspGrid< dim, EquidistantCoordinates< ctype, dim > > Grid
Definition: dgfyasp.hh:87
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition: albertagrid/dgfparser.hh:26
Some simple static information for a given GridType.
Definition: io/file/dgfparser/dgfparser.hh:50
Definition: periodicfacetrans.hh:21
const BoundaryParameter & parameter() const
Definition: boundarydom.hh:52
Common Grid parametersFor each grid implementation there is a set of parameters that can be passed vi...
Definition: gridparameter.hh:31
Grid parameters for YaspGridThe YaspGridParameter class is in charge of passing parameters specific t...
Definition: dgfyasp.hh:36
bool findtoken(std ::string token)
Definition: basic.cc:121
void get(std::vector< std::vector< double > > &vtx, int &nofvtx, std::vector< std::vector< unsigned int > > &simplex, int &nofsimpl)
Definition: interval.hh:59
bool isactive()
Definition: basic.hh:75
int boundaryId(const Intersection &intersection) const
Definition: dgfyasp.hh:128
[ provides Dune::Grid ]
Definition: yaspgrid.hh:58
Container for equidistant coordinates in a YaspGrid.
Definition: coordinates.hh:26
bool haveBoundaryParameters() const
Definition: dgfyasp.hh:151
exception class for IO errors in the DGF parser
Definition: dgfexception.hh:12
Definition: periodicfacetrans.hh:97
Definition: interval.hh:22
DGFGridFactory(std::istream &input, MPICommunicatorType comm=MPIHelper::getCommunicator())
Definition: dgfyasp.hh:300
int numIntervals() const
Definition: interval.hh:81
Wrapper class for entities.
Definition: common/entity.hh:63
static double refineWeight()
Definition: dgfyasp.hh:485
const AffineTransformation & transformation(int i) const
Definition: periodicfacetrans.hh:39
int indexInInside() const
Local index of codim 1 entity in the inside() entity where intersection is contained in...
Definition: common/intersection.hh:356
DGFGridFactory(const std::string &filename, MPICommunicatorType comm=MPIHelper::getCommunicator())
Definition: dgfyasp.hh:102
void abs(const DofVectorPointer< int > &dofVector)
Definition: dofvector.hh:326
Grid * grid() const
Definition: dgfyasp.hh:318
std::vector< double > & parameter(const Entity &entity)
Definition: dgfyasp.hh:377
Grid * grid() const
Definition: dgfyasp.hh:116
Definition: boundarydom.hh:20
Geometry geometry() const
geometrical information about the intersection in global coordinates.
Definition: common/intersection.hh:333
static double refineWeight()
Definition: dgfyasp.hh:282
static int refineStepsForHalf()
Definition: dgfyasp.hh:281
Container for equidistant coordinates in a YaspGrid with non-trivial origin.
Definition: coordinates.hh:124
int corners() const
Return the number of corners of the reference element.
Definition: common/geometry.hh:139
Wrapper class for geometries.
Definition: common/geometry.hh:66
const DGFBoundaryParameter::type & boundaryParameter(const Intersection< GG, II > &intersection) const
Definition: dgfyasp.hh:360
Definition: boundarydom.hh:191
DGFGridFactory(std::istream &input, MPICommunicatorType comm=MPIHelper::getCommunicator())
Definition: dgfyasp.hh:96
FieldVector< ctype, cdim > GlobalCoordinate
type of the global coordinates
Definition: common/geometry.hh:101
bool haveBoundaryParameters() const
Definition: dgfyasp.hh:353
static int refineStepsForHalf()
Definition: dgfyasp.hh:484
int id() const
Definition: boundarydom.hh:40
int numParameters() const
Definition: dgfyasp.hh:145
int numParameters() const
Definition: dgfyasp.hh:347
std::vector< double > & parameter(const Entity &entity)
Definition: dgfyasp.hh:175
bool wasInserted(const Intersection &intersection) const
Definition: dgfyasp.hh:122
int overlap() const
get dimension of world found in block
Definition: dgfyasp.hh:72
The dimension of the grid.
Definition: common/grid.hh:387
static const type & defaultValue()
default constructor
Definition: parser.hh:26
int _overlap
Definition: dgfyasp.hh:40
int dimw() const
Definition: interval.hh:86
GlobalCoordinate corner(int i) const
Obtain a corner of the geometry.
Definition: common/geometry.hh:153
const DGFBoundaryParameter::type & boundaryParameter(const Intersection< GG, II > &intersection) const
Definition: dgfyasp.hh:158
MPIHelper::MPICommunicator MPICommunicatorType
Definition: dgfyasp.hh:293
~DGFGridFactory()
Definition: dgfyasp.hh:313
int numTransformations() const
Definition: periodicfacetrans.hh:45
bool wasInserted(const Intersection &intersection) const
Definition: dgfyasp.hh:324
MPIHelper::MPICommunicator MPICommunicatorType
Definition: dgfyasp.hh:89