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() );
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;
203 ::generate ( std::istream &gridin, MPICommunicatorType comm )
208 DUNE_THROW(
DGFException,
"YaspGrid can only be created from an interval block." );
211 DUNE_THROW(
DGFException,
"YaspGrid can only handle 1 interval block." );
213 if( intervalBlock.
dimw() != dim )
216 "Cannot read an interval of dimension " << intervalBlock.
dimw()
217 <<
" into a YaspGrid< " << dim <<
" >." );
222 FieldVector<double,dim> lang;
223 std::array<int,dim> anz;
224 for(
int i = 0; i < dim; ++i )
227 if(
std::abs( interval.p[ 0 ][ i ] ) > 1e-10 )
230 "YaspGrid cannot handle grids with non-zero left lower corner." );
233 lang[ i ] = interval.p[ 1 ][ i ] - interval.p[ 0 ][ i ];
234 anz[ i ] = interval.n[ i ];
239 std::bitset< dim > per;
241 for(
int k = 0; k < numTrafos; ++k )
245 bool identity =
true;
246 for(
int i = 0; i < dim; ++i )
247 for(
int j = 0; j < dim; ++j )
248 identity &= (
std::abs( (i == j ? 1.0 : 0.0) - trafo.matrix( i, j ) ) < 1e-10);
250 DUNE_THROW(
DGFException,
"YaspGrid can only handle shifts as periodic face transformations." );
254 for(
int i = 0; i < dim; ++i )
256 if(
std::abs( trafo.shift[ i ] ) < 1e-10 )
261 if( (numDirs != 1) || (
std::abs(
std::abs( trafo.shift[ dir ] ) - lang[ dir ] ) >= 1e-10) )
263 std::cerr <<
"Tranformation '" << trafo
264 <<
"' does not map boundaries on boundaries." << std::endl;
295 typedef FieldVector< double, dimension > Point;
300 MPICommunicatorType comm = MPIHelper::getCommunicator() )
302 generate( input, comm );
306 MPICommunicatorType comm = MPIHelper::getCommunicator() )
308 std::ifstream input( filename.c_str() );
309 generate( input, comm );
314 delete boundaryDomainBlock_;
322 template <
class Intersection>
328 template <
class Intersection>
331 if( boundaryDomainBlock_->isactive() )
333 std::vector< Point > corners;
334 getCorners( intersection.
geometry(), corners );
335 const dgf::DomainData *data = boundaryDomainBlock_->contains( corners );
345 template<
int codim >
354 return boundaryDomainBlock_->hasParameter();
357 template<
class GG,
class II >
361 if( haveBoundaryParameters() )
363 std::vector< Point > corners;
364 getCorners( intersection.
geometry(), corners );
365 const dgf::DomainData *data = boundaryDomainBlock_->contains( corners );
375 template<
class Entity >
382 void generate( std::istream &gridin, MPICommunicatorType comm );
384 template<
class Geometry >
385 static void getCorners (
const Geometry &geometry, std::vector< Point > &corners )
387 corners.resize( geometry.
corners() );
388 for(
int i = 0; i < geometry.
corners(); ++i )
391 for(
int j = 0; j < dimension; ++j )
392 corners[ i ][ j ] = corner[ j ];
398 std::vector<double> emptyParam;
404 ::generate ( std::istream &gridin, MPICommunicatorType comm )
409 DUNE_THROW(
DGFException,
"YaspGrid can only be created from an interval block." );
412 DUNE_THROW(
DGFException,
"YaspGrid can only handle 1 interval block." );
414 if( intervalBlock.
dimw() != dim )
417 "Cannot read an interval of dimension " 418 << intervalBlock.
dimw()
419 <<
" into a YaspGrid< " << dim <<
" >." );
424 FieldVector<double,dim> lower;
425 FieldVector<double,dim> upper;
426 std::array<int,dim> anz;
427 for(
int i = 0; i < dim; ++i )
429 lower[ i ] = interval.p[ 0 ][ i ];
430 upper[ i ] = interval.p[ 1 ][ i ];
431 anz[ i ] = interval.n[ i ];
436 std::bitset< dim > periodic;
438 for(
int k = 0; k < numTrafos; ++k )
442 bool identity =
true;
443 for(
int i = 0; i < dim; ++i )
444 for(
int j = 0; j < dim; ++j )
445 identity &= (
std::abs( (i == j ? 1.0 : 0.0) - trafo.matrix( i, j ) ) < 1e-10);
447 DUNE_THROW(
DGFException,
"YaspGrid can only handle shifts as periodic face transformations." );
451 for(
int currentDir = 0; currentDir < dim; ++currentDir )
453 if(
std::abs( trafo.shift[ currentDir ] ) > 1e-10 )
462 std::cerr <<
"Tranformation '" << trafo
463 <<
"' does not map boundaries on boundaries." << std::endl;
467 periodic[ dir ] =
true;
475 ( lower, upper, anz, periodic, grdParam.
overlap(), comm );
487 #endif // #ifndef DUNE_DGFPARSERYASP_HH bool wasInserted(const Intersection &intersection) const
Definition: dgfyasp.hh:323
int numParameters() const
Definition: dgfyasp.hh:346
DGFGridFactory(std::istream &input, MPICommunicatorType comm=MPIHelper::getCommunicator())
Definition: dgfyasp.hh:96
DGFGridFactory(std::istream &input, MPICommunicatorType comm=MPIHelper::getCommunicator())
Definition: dgfyasp.hh:299
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition: albertagrid/dgfparser.hh:26
DGFGridFactory(const std::string &filename, MPICommunicatorType comm=MPIHelper::getCommunicator())
Definition: dgfyasp.hh:305
int indexInInside() const
Local index of codim 1 entity in the inside() entity where intersection is contained in...
Definition: common/intersection.hh:374
Geometry geometry() const
geometrical information about the intersection in global coordinates.
Definition: common/intersection.hh:351
bool findtoken(std ::string token)
Definition: basic.cc:121
Common Grid parametersFor each grid implementation there is a set of parameters that can be passed vi...
Definition: gridparameter.hh:31
bool getnextentry(ENTRY &entry)
Definition: basic.hh:61
MPIHelper::MPICommunicator MPICommunicatorType
Definition: dgfyasp.hh:292
Definition: interval.hh:22
GlobalCoordinate corner(int i) const
Obtain a corner of the geometry.
Definition: common/geometry.hh:148
YaspGrid< dim, EquidistantOffsetCoordinates< double, dim > > Grid
Definition: dgfyasp.hh:290
bool isactive()
Definition: basic.hh:75
void abs(const DofVectorPointer< int > &dofVector)
Definition: dofvector.hh:326
const DGFBoundaryParameter::type & boundaryParameter(const Intersection< GG, II > &intersection) const
Definition: dgfyasp.hh:158
bool haveBoundaryParameters() const
Definition: dgfyasp.hh:352
static int refineStepsForHalf()
Definition: dgfyasp.hh:482
int numTransformations() const
Definition: periodicfacetrans.hh:45
~DGFGridFactory()
Definition: dgfyasp.hh:111
int boundaryId(const Intersection &intersection) const
Definition: dgfyasp.hh:128
const BoundaryParameter & parameter() const
Definition: boundarydom.hh:52
int overlap() const
get dimension of world found in block
Definition: dgfyasp.hh:72
int numParameters() const
Definition: dgfyasp.hh:145
std::vector< double > & parameter(const Entity &entity)
Definition: dgfyasp.hh:175
bool wasInserted(const Intersection &intersection) const
Definition: dgfyasp.hh:122
DGFGridFactory(const std::string &filename, MPICommunicatorType comm=MPIHelper::getCommunicator())
Definition: dgfyasp.hh:102
int corners() const
Return the number of corners of the reference element.
Definition: common/geometry.hh:134
int dimw() const
Definition: interval.hh:86
int boundaryId(const Intersection &intersection) const
Definition: dgfyasp.hh:329
int numIntervals() const
Definition: interval.hh:81
Grid parameters for YaspGridThe YaspGridParameter class is in charge of passing parameters specific t...
Definition: dgfyasp.hh:36
Container for equidistant coordinates in a YaspGrid with non-trivial origin.
Definition: coordinates.hh:124
static int refineStepsForHalf()
Definition: dgfyasp.hh:280
static double refineWeight()
Definition: dgfyasp.hh:281
const DGFBoundaryParameter::type & boundaryParameter(const Intersection< GG, II > &intersection) const
Definition: dgfyasp.hh:359
Definition: periodicfacetrans.hh:21
std::string type
type of additional boundary parameters
Definition: parser.hh:23
int _overlap
Definition: dgfyasp.hh:40
Include standard header files.
Definition: agrid.hh:59
~DGFGridFactory()
Definition: dgfyasp.hh:312
FieldVector< ctype, cdim > GlobalCoordinate
type of the global coordinates
Definition: common/geometry.hh:96
MPIHelper::MPICommunicator MPICommunicatorType
Definition: dgfyasp.hh:89
Wrapper class for geometries.
Definition: common/geometry.hh:65
void get(std::vector< std::vector< double > > &vtx, int &nofvtx, std::vector< std::vector< unsigned int > > &simplex, int &nofsimpl)
Definition: interval.hh:59
[ provides Dune::Grid ]
Definition: yaspgrid.hh:56
exception class for IO errors in the DGF parser
Definition: dgfexception.hh:12
Definition: periodicfacetrans.hh:97
Wrapper class for entities.
Definition: common/entity.hh:64
std::vector< double > & parameter(const Entity &entity)
Definition: dgfyasp.hh:376
Definition: boundarydom.hh:20
Some simple static information for a given GridType.
Definition: io/file/dgfparser/dgfparser.hh:54
bool haveBoundaryParameters() const
Definition: dgfyasp.hh:151
YaspGrid< dim > Grid
Definition: dgfyasp.hh:87
static double refineWeight()
Definition: dgfyasp.hh:483
Definition: boundarydom.hh:191
static const type & defaultValue()
default constructor
Definition: parser.hh:26
The dimension of the grid.
Definition: common/grid.hh:387
const AffineTransformation & transformation(int i) const
Definition: periodicfacetrans.hh:39
Grid * grid() const
Definition: dgfyasp.hh:317
YaspGridParameterBlock(std::istream &in)
constructor taking istream
Definition: dgfyasp.hh:44
int id() const
Definition: boundarydom.hh:40
Grid * grid() const
Definition: dgfyasp.hh:116
Definition: interval.hh:19