1#ifndef DUNE_SPGRID_CUBE_HH
2#define DUNE_SPGRID_CUBE_HH
4#include <dune/common/fvector.hh>
14 template<
class ct,
int dim >
79 template<
class ct,
int dim >
82 for(
int i = 0; i < dimension; ++i )
83 origin_[ i ] = width_[ i ] = 0;
87 template<
class ct,
int dim >
91 for(
int i = 0; i < dimension; ++i )
93 origin_[ i ] =
std::min( a[ i ], b[ i ] );
94 width_[ i ] =
std::max( a[ i ], b[ i ] ) - origin_[ i ];
99 template<
class ct,
int dim >
107 template<
class ct,
int dim >
115 template<
class ct,
int dim >
118 bool contains =
true;
119 for(
int i = 0; i < dimension; ++i )
121 const ctype y = x[ i ] - origin()[ i ];
122 contains &= ((y >= 0) && (y <= width()[ i ]));
128 template<
class ct,
int dim >
133 for(
int i = 0; i < dimension; ++i )
146 template<
class char_type,
class traits,
class ct,
int dim >
147 inline std::basic_ostream< char_type, traits > &
148 operator<< ( std::basic_ostream< char_type, traits > &out,
152 typename Cube::GlobalVector a = cube.
origin();
153 typename Cube::GlobalVector b = a + cube.
width();
154 for(
int i = 0; i < Cube::dimension; ++i )
155 out << (i > 0 ?
"x[" :
"[") << a[ i ] <<
"," << b[ i ] <<
"]";
160 template<
class char_type,
class traits,
class ct,
int dim >
161 inline std::basic_istream< char_type, traits > &
166 typename Cube::GlobalVector a;
167 typename Cube::GlobalVector b;
168 for(
int i = 0; i < Cube::dimension; ++i )
172 in >>
match(
'[' ) >> a[ i ] >>
match(
',' ) >> b[ i ] >>
match(
']' );
Dune::SPMultiIndex< dim > min(const Dune::SPMultiIndex< dim > &a, const Dune::SPMultiIndex< dim > &b)
Definition: multiindex.hh:294
Dune::SPMultiIndex< dim > max(const Dune::SPMultiIndex< dim > &a, const Dune::SPMultiIndex< dim > &b)
Definition: multiindex.hh:305
Definition: iostream.hh:7
std::basic_ostream< char_type, traits > & operator<<(std::basic_ostream< char_type, traits > &out, const SPCube< ct, dim > &cube)
Definition: cube.hh:148
std::basic_istream< char_type, traits > & operator>>(std::basic_istream< char_type, traits > &in, SPCube< ct, dim > &cube)
Definition: cube.hh:162
iostream::Match< typename iostream::MatchTraits< T >::Type > match(const T &value)
Definition: iostream.hh:87
const GlobalVector & origin() const
obtain lower left corner
Definition: cube.hh:101
bool contains(const GlobalVector &x) const
determine whether the cube contains a point x
Definition: cube.hh:116
static This unitCube()
obtain a domain modelling the unit cube
Definition: cube.hh:130
const GlobalVector & width() const
obtain width
Definition: cube.hh:109
ct ctype
coordinate type
Definition: cube.hh:21
FieldVector< ctype, dimension > GlobalVector
type of global vectors, i.e., vectors within the domain
Definition: cube.hh:27
static const int dimension
dimension of the domain
Definition: cube.hh:24
SPCube()
default constructor
Definition: cube.hh:80