1 #ifndef DUNE_SPGRID_DOMAIN_HH 2 #define DUNE_SPGRID_DOMAIN_HH 3 4 #include <dune/grid/spgrid/cube.hh> 5 #include <dune/grid/spgrid/topology.hh> 6 #include <dune/grid/spgrid/refinement.hh> 7 8 /** \file 9 * \author Martin Nolte 10 * \brief description of computational domain 11 */ 12 13 namespace Dune 14 { 15 16 // SPDomain 17 // -------- 18 19 /** \class SPDomain 20 * \brief description of the computational domain 21 * 22 * \tparam ct coordinate type (e.g., double) 23 * \tparam dim dimension of the domain 24 */ 25 template< class ct, int dim > 26 class SPDomain 27 { 28 typedef SPDomain< ct, dim > This; 29 30 public: 31 typedef SPCube< ct, dim > Cube; 32 typedef SPTopology< dim > Topology; 33 34 /** \brief coordinate type */ 35 typedef typename Cube::ctype ctype; 36 37 /** \brief dimension of the domain */ 38 static const int dimension = Cube::dimension; 39 40 /** \brief type of global vectors, i.e., vectors within the domain */ 41 typedef typename Cube::GlobalVector GlobalVector; 42 43 /** \brief constructor 44 * 45 * \param[in] a one corner of the domain 46 * \param[in] b the opposite corner of the domain 47 * 48 * \note The only restriction on the given corners is that they are 49 * opposite to each other. 50 * It is not guaranteed, that one of the corners will be returned 51 * by the method origin. 52 */ 53 SPDomain ( const GlobalVector &a, const GlobalVector &b ); 54 55 /** \todo please doc me */ 56 SPDomain ( const std::vector< Cube > &cubes, const Topology &topology ); 57 58 /** \todo please doc me */ cube() const59 const Cube &cube () const { return cube_; } 60 61 /** \todo please doc me */ topology() const62 const Topology &topology () const { return topology_; } 63 64 /** \brief determine whether the domain contains a point x 65 * 66 * \param[in] x point to consider 67 * 68 * \returns true, if x is contained in the domain 69 */ contains(const GlobalVector & x) const70 bool contains ( const GlobalVector &x ) const { return cube().contains( x ); } 71 72 /** \brief obtain a domain modelling the unit cube 73 * 74 * \returns a domain modelling \f$[0,1]^{dim}\f$ 75 */ 76 static This unitCube (); 77 78 private: 79 Cube cube_; 80 Topology topology_; 81 }; 82 83 84 85 // Implementation of SPDomain 86 // -------------------------- 87 88 template< class ct, int dim > 89 inline SPDomain< ct, dim > SPDomain(const GlobalVector & a,const GlobalVector & b)90 ::SPDomain ( const GlobalVector &a, const GlobalVector &b ) 91 : cube_( a, b ), 92 topology_() 93 {} 94 95 96 template< class ct, int dim > 97 inline SPDomain< ct, dim > SPDomain(const std::vector<Cube> & cubes,const Topology & topology)98 ::SPDomain ( const std::vector< Cube > &cubes, const Topology &topology ) 99 : cube_( cubes[ 0 ] ), 100 topology_( topology ) 101 {} 102 103 104 template< class ct, int dim > 105 inline typename SPDomain< ct, dim >::This unitCube()106 SPDomain< ct, dim >::unitCube () 107 { 108 GlobalVector a, b; 109 for( int i = 0; i < dimension; ++i ) 110 { 111 a = ctype( 0 ); 112 b = ctype( 1 ); 113 } 114 return This( a, b ); 115 } 116 117 } // namespace Dune 118 119 #endif // #ifndef DUNE_SPGRID_DOMAIN_HH 120