6#include <dune/grid/common/intersection.hh>
16 template<
class Gr
idImp,
class IntersectionImp >
24 template<
int dim,
int dimworld,
class ctype >
25 struct DGFGridFactory< SGrid< dim, dimworld, ctype > >
27 typedef SGrid< dim, dimworld, ctype > Grid;
34 typedef FieldVector< double, dimension > Point;
36 typedef dgf::BoundaryDomBlock BoundaryDomainBlock;
39 explicit DGFGridFactory ( std::istream &input,
42 generate( input, comm );
45 explicit DGFGridFactory (
const std::string &filename,
48 std::ifstream input( filename.c_str() );
49 generate( input, comm );
57 template<
class Intersection >
58 bool wasInserted (
const Intersection &intersection )
const
63 template<
class Intersection >
64 int boundaryId (
const Intersection &intersection )
const
66 if( boundaryDomainBlock_->isactive() )
68 std::vector< Point > corners;
69 getCorners( intersection.geometry(), corners );
70 const dgf::DomainData *data = boundaryDomainBlock_->contains( corners );
74 return intersection.indexInInside();
77 return intersection.indexInInside();
81 int numParameters ()
const
87 bool haveBoundaryParameters ()
const
89 return boundaryDomainBlock_->isactive();
92 template<
class GG,
class II >
94 boundaryParameter (
const Intersection< GG, II > & intersection )
const
96 if( haveBoundaryParameters() )
98 std::vector< Point > corners;
99 getCorners( intersection.geometry(), corners );
100 const dgf::DomainData *data = boundaryDomainBlock_->contains( corners );
102 return data->parameter();
111 template<
class Entity >
112 std::vector< double > ¶meter (
const Entity &entity )
118 void generate( std::istream &gridin, MPICommunicatorType comm );
120 template<
class Geometry >
121 static void getCorners (
const Geometry &geometry, std::vector< Point > &corners )
123 corners.resize( geometry.corners() );
124 for(
int i = 0; i < geometry.corners(); ++i )
127 for(
int j = 0; j < dimension; ++j )
128 corners[ i ][ j ] = corner[ j ];
133 dgf::BoundaryDomBlock *boundaryDomainBlock_;
134 std::vector< double > emptyParam;
139 template<
int dim,
int dimworld,
class ctype >
140 inline void DGFGridFactory< SGrid< dim, dimworld, ctype > >
141 ::generate ( std::istream &gridin, MPICommunicatorType comm )
143 dgf::IntervalBlock intervalBlock( gridin );
145 if( !intervalBlock.isactive() )
146 DUNE_THROW( DGFException,
"SGrid can only be created from an interval block." );
148 if( intervalBlock.numIntervals() != 1 )
149 DUNE_THROW( DGFException,
"SGrid can only handle 1 interval block." );
151 if( intervalBlock.dimw() != dim )
154 "Cannot read an interval of dimension " << intervalBlock.dimw()
155 <<
"into a SGrid< " << dim <<
", " << dimworld <<
" >." );
158 const dgf::IntervalBlock::Interval &interval = intervalBlock.get( 0 );
160 FieldVector< double, dimension > lower, upper;
162 for(
int i = 0; i < dimension; ++i )
164 lower[ i ] = interval.p[ 0 ][ i ];
165 upper[ i ] = interval.p[ 1 ][ i ];
166 anz[ i ] = interval.n[ i ];
169 grid_ =
new Grid( anz, lower, upper );
171 boundaryDomainBlock_ =
new dgf::BoundaryDomBlock( gridin, dimension );
176 template<
int dim,
int dimworld,
class ctype >
177 struct DGFGridInfo< SGrid< dim, dimworld, ctype > >
186 return 1.0 / double( 1 << dim );
FieldVector< ctype, cdim > GlobalCoordinate
type of the global coordinates
Definition: geometry.hh:104
@ dimension
The dimension of the grid.
Definition: grid.hh:402
MPI_Comm MPICommunicator
The type of the mpi communicator.
Definition: mpihelper.hh:173
static MPICommunicator getCommunicator()
get the default communicator
Definition: mpihelper.hh:181
#define DUNE_THROW(E, m)
Definition: exceptions.hh:243
Dune namespace.
Definition: alignment.hh:10
static const type & defaultValue()
default constructor
Definition: parser.hh:26
std::string type
type of additional boundary parameters
Definition: parser.hh:23
static double refineWeight()
static int refineStepsForHalf()
number of globalRefine steps needed to refuce h by 0.5