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;
92 typedef FieldVector< double, dimension > Point;
97 MPICommunicatorType comm = MPIHelper::getCommunicator() )
99 generate( input, comm );
103 MPICommunicatorType comm = MPIHelper::getCommunicator() )
105 std::ifstream input( filename.c_str() );
106 generate( input, comm );
111 delete boundaryDomainBlock_;
119 template <
class Intersection>
125 template <
class Intersection>
128 if( boundaryDomainBlock_->isactive() )
130 std::vector< Point > corners;
131 getCorners( intersection.
geometry(), corners );
132 const dgf::DomainData *data = boundaryDomainBlock_->contains( corners );
142 template<
int codim >
151 return boundaryDomainBlock_->hasParameter();
154 template<
class GG,
class II >
158 if( haveBoundaryParameters() )
160 std::vector< Point > corners;
161 getCorners( intersection.
geometry(), corners );
162 const dgf::DomainData *data = boundaryDomainBlock_->contains( corners );
172 template<
class Entity >
179 void generate( std::istream &gridin, MPICommunicatorType comm );
181 template<
class Geometry >
182 static void getCorners (
const Geometry &geometry, std::vector< Point > &corners )
184 corners.resize( geometry.
corners() );
185 for(
int i = 0; i < geometry.
corners(); ++i )
188 for(
int j = 0; j < dimension; ++j )
189 corners[ i ][ j ] = corner[ j ];
195 std::vector<double> emptyParam;
201 ::generate ( std::istream &gridin, MPICommunicatorType comm )
206 DUNE_THROW(
DGFException,
"YaspGrid can only be created from an interval block." );
209 DUNE_THROW(
DGFException,
"YaspGrid can only handle 1 interval block." );
211 if( intervalBlock.
dimw() != dim )
214 "Cannot read an interval of dimension " << intervalBlock.
dimw()
215 <<
" into a YaspGrid< " << dim <<
" >." );
220 FieldVector<double,dim> lang;
221 std::array<int,dim> anz;
222 for(
int i = 0; i < dim; ++i )
225 if(
std::abs( interval.p[ 0 ][ i ] ) > 1e-10 )
228 "YaspGrid cannot handle grids with non-zero left lower corner." );
231 lang[ i ] = interval.p[ 1 ][ i ] - interval.p[ 0 ][ i ];
232 anz[ i ] = interval.n[ i ];
237 std::bitset< dim > per;
239 for(
int k = 0; k < numTrafos; ++k )
243 bool identity =
true;
244 for(
int i = 0; i < dim; ++i )
245 for(
int j = 0; j < dim; ++j )
246 identity &= (
std::abs( (i == j ? 1.0 : 0.0) - trafo.matrix( i, j ) ) < 1e-10);
248 DUNE_THROW(
DGFException,
"YaspGrid can only handle shifts as periodic face transformations." );
252 for(
int i = 0; i < dim; ++i )
254 if(
std::abs( trafo.shift[ i ] ) < 1e-10 )
259 if( (numDirs != 1) || (
std::abs(
std::abs( trafo.shift[ dir ] ) - lang[ dir ] ) >= 1e-10) )
261 std::cerr <<
"Tranformation '" << trafo
262 <<
"' does not map boundaries on boundaries." << std::endl;
293 typedef FieldVector< double, dimension > Point;
298 MPICommunicatorType comm = MPIHelper::getCommunicator() )
300 generate( input, comm );
304 MPICommunicatorType comm = MPIHelper::getCommunicator() )
306 std::ifstream input( filename.c_str() );
307 generate( input, comm );
312 delete boundaryDomainBlock_;
320 template <
class Intersection>
326 template <
class Intersection>
329 if( boundaryDomainBlock_->isactive() )
331 std::vector< Point > corners;
332 getCorners( intersection.
geometry(), corners );
333 const dgf::DomainData *data = boundaryDomainBlock_->contains( corners );
343 template<
int codim >
352 return boundaryDomainBlock_->hasParameter();
355 template<
class GG,
class II >
359 if( haveBoundaryParameters() )
361 std::vector< Point > corners;
362 getCorners( intersection.
geometry(), corners );
363 const dgf::DomainData *data = boundaryDomainBlock_->contains( corners );
373 template<
class Entity >
380 void generate( std::istream &gridin, MPICommunicatorType comm );
382 template<
class Geometry >
383 static void getCorners (
const Geometry &geometry, std::vector< Point > &corners )
385 corners.resize( geometry.
corners() );
386 for(
int i = 0; i < geometry.
corners(); ++i )
389 for(
int j = 0; j < dimension; ++j )
390 corners[ i ][ j ] = corner[ j ];
396 std::vector<double> emptyParam;
402 ::generate ( std::istream &gridin, MPICommunicatorType comm )
407 DUNE_THROW(
DGFException,
"YaspGrid can only be created from an interval block." );
410 DUNE_THROW(
DGFException,
"YaspGrid can only handle 1 interval block." );
412 if( intervalBlock.
dimw() != dim )
415 "Cannot read an interval of dimension " 416 << intervalBlock.
dimw()
417 <<
" into a YaspGrid< " << dim <<
" >." );
422 FieldVector<double,dim> lower;
423 FieldVector<double,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 ];
434 std::bitset< dim > periodic;
436 for(
int k = 0; k < numTrafos; ++k )
440 bool identity =
true;
441 for(
int i = 0; i < dim; ++i )
442 for(
int j = 0; j < dim; ++j )
443 identity &= (
std::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(
std::abs( trafo.shift[ currentDir ] ) > 1e-10 )
460 std::cerr <<
"Tranformation '" << trafo
461 <<
"' does not map boundaries on boundaries." << std::endl;
465 periodic[ dir ] =
true;
473 ( lower, upper, anz, periodic, grdParam.
overlap(), comm );
485 #endif // #ifndef DUNE_DGFPARSERYASP_HH int corners() const
Return the number of corners of the reference element.
Definition: common/geometry.hh:142
int dimw() const
Definition: interval.hh:65
bool getnextentry(ENTRY &entry)
Definition: basic.hh:61
int boundaryId(const Intersection &intersection) const
Definition: dgfyasp.hh:327
int numParameters() const
Definition: dgfyasp.hh:344
~DGFGridFactory()
Definition: dgfyasp.hh:109
DGFGridFactory(const std::string &filename, MPICommunicatorType comm=MPIHelper::getCommunicator())
Definition: dgfyasp.hh:303
Definition: boundarydom.hh:20
bool wasInserted(const Intersection &intersection) const
Definition: dgfyasp.hh:321
int overlap() const
get dimension of world found in block
Definition: dgfyasp.hh:72
Intersection of a mesh entities of codimension 0 ("elements") with a "neighboring" element or with th...
Definition: albertagrid/dgfparser.hh:26
std::vector< double > & parameter(const Entity &entity)
Definition: dgfyasp.hh:173
Definition: periodicfacetrans.hh:97
bool isactive()
Definition: basic.hh:75
static int refineStepsForHalf()
Definition: dgfyasp.hh:480
YaspGrid< dim, EquidistantOffsetCoordinates< double, dim > > Grid
Definition: dgfyasp.hh:288
Wrapper class for geometries.
Definition: common/geometry.hh:65
Definition: interval.hh:23
static const type & defaultValue()
default constructor
Definition: parser.hh:26
static double refineWeight()
Definition: dgfyasp.hh:481
int numIntervals() const
Definition: interval.hh:60
Wrapper class for entities.
Definition: common/entity.hh:61
const BoundaryParameter & parameter() const
Definition: boundarydom.hh:52
DGFGridFactory(const std::string &filename, MPICommunicatorType comm=MPIHelper::getCommunicator())
Definition: dgfyasp.hh:102
static double refineWeight()
Definition: dgfyasp.hh:279
std::string type
type of additional boundary parameters
Definition: parser.hh:23
FieldVector< ctype, cdim > GlobalCoordinate
type of the global coordinates
Definition: common/geometry.hh:104
YaspGrid< dim > Grid
Definition: dgfyasp.hh:87
~DGFGridFactory()
Definition: dgfyasp.hh:310
Definition: periodicfacetrans.hh:21
bool findtoken(std::string token)
Definition: basic.cc:121
int _overlap
Definition: dgfyasp.hh:40
int numParameters() const
Definition: dgfyasp.hh:143
std::vector< double > & parameter(const Entity &entity)
Definition: dgfyasp.hh:374
int id() const
Definition: boundarydom.hh:40
YaspGridParameterBlock(std::istream &in)
constructor taking istream
Definition: dgfyasp.hh:44
Grid * grid() const
Definition: dgfyasp.hh:114
DGFGridFactory(std::istream &input, MPICommunicatorType comm=MPIHelper::getCommunicator())
Definition: dgfyasp.hh:96
DGFGridFactory(std::istream &input, MPICommunicatorType comm=MPIHelper::getCommunicator())
Definition: dgfyasp.hh:297
const AffineTransformation & transformation(int i) const
Definition: periodicfacetrans.hh:39
int boundaryId(const Intersection &intersection) const
Definition: dgfyasp.hh:126
GlobalCoordinate corner(int i) const
Obtain a corner of the geometry.
Definition: common/geometry.hh:156
MPIHelper::MPICommunicator MPICommunicatorType
Definition: dgfyasp.hh:89
void get(std::vector< std::vector< double > > &vtx, int &nofvtx, std::vector< std::vector< unsigned int > > &simplex, int &nofsimpl)
Definition: interval.hh:38
static int refineStepsForHalf()
Definition: dgfyasp.hh:278
const DGFBoundaryParameter::type & boundaryParameter(const Intersection< GG, II > &intersection) const
Definition: dgfyasp.hh:156
Grid * grid() const
Definition: dgfyasp.hh:315
bool haveBoundaryParameters() const
Definition: dgfyasp.hh:350
bool haveBoundaryParameters() const
Definition: dgfyasp.hh:149
const DGFBoundaryParameter::type & boundaryParameter(const Intersection< GG, II > &intersection) const
Definition: dgfyasp.hh:357
Include standard header files.
Definition: agrid.hh:59
int indexInInside() const
Local index of codim 1 entity in the inside() entity where intersection is contained in...
Definition: common/intersection.hh:393
Grid parameters for YaspGridThe YaspGridParameter class is in charge of passing parameters specific t...
Definition: dgfyasp.hh:36
[ provides Dune::Grid ]
Definition: yaspgrid.hh:56
int numTransformations() const
Definition: periodicfacetrans.hh:45
Container for equidistant coordinates in a YaspGrid with non-trivial origin.
Definition: coordinates.hh:124
Definition: boundarydom.hh:191
MPIHelper::MPICommunicator MPICommunicatorType
Definition: dgfyasp.hh:290
Common Grid parametersFor each grid implementation there is a set of parameters that can be passed vi...
Definition: gridparameter.hh:31
Some simple static information for a given GridType.
Definition: io/file/dgfparser/dgfparser.hh:54
void abs(const DofVectorPointer< int > &dofVector)
Definition: dofvector.hh:326
Geometry geometry() const
geometrical information about the intersection in global coordinates.
Definition: common/intersection.hh:373
The dimension of the grid.
Definition: common/grid.hh:402
bool wasInserted(const Intersection &intersection) const
Definition: dgfyasp.hh:120
Definition: interval.hh:20
exception class for IO errors in the DGF parser
Definition: dgfexception.hh:12