/usr/include/dune/grid/common/gridview.hh is in libdune-grid-dev 2.5.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_GRIDVIEW_HH
#define DUNE_GRIDVIEW_HH
#include <dune/common/iteratorrange.hh>
#include <dune/geometry/type.hh>
#include <dune/grid/common/datahandleif.hh>
#include <dune/grid/common/rangegenerators.hh>
namespace Dune
{
template< int, int, class, class >
class GridDefaultImplementation;
/** \addtogroup GIGridView
* @{
* Though a DUNE grid is hierarchic, one often only needs access to
* a certain subset of the entities in the grid, e.g., all entities
* on a given level or the leaf entities in the hierarchy.
* These views are provided by an
* implementation of GridView. Each grid exports a LevelGridView and
* a LeafGridView, corresponding to the two different subsets (views)
* described above.
*
* A grid view provides the following functionality:
* - The index set for the required subset can be accessed by the indexSet()
* method.
* - A pair of begin() / end() methods provide iterators for each
* codimension.
* - A pair of ibegin() / iend() methods return suitable intersection
* iterators for a given entity of codimension 0 in the subset.
* - For parallel computations, a suitable communicate() method is provided.
* - The underlying grid can be accessed through the grid() method.
* .
*
* The default GridViews can be obtained from the grid by calling one of the
* levelGridView() or leafGridView() methods which are provided as both
* free functions and member functions of the Grid interface class.
*/
/** \brief Grid view abstract base class
*
* Interface class for a view on grids. Grids return two types of view,
* a view of the leaf grid and of a level grid, which both satisfy
* the same interface. Through the view the user has access to the
* iterators, the intersections and the index set.
*
* The interface is implemented using the engine concept.
*
*/
template< class ViewTraits >
class GridView
{
typedef GridView< ViewTraits > ThisType;
#if DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
public:
#else
protected:
#endif
// type of underlying implementation, for internal use only
typedef typename ViewTraits :: GridViewImp Implementation;
public:
typedef typename ViewTraits :: GridViewImp GridViewImp;
/** \brief Traits class */
typedef ViewTraits Traits;
/** \brief type of the grid */
typedef typename Traits :: Grid Grid;
/** \brief type of the index set */
typedef typename Traits :: IndexSet IndexSet;
/** \brief type of the intersection */
typedef typename Traits :: Intersection Intersection;
/** \brief type of the intersection iterator */
typedef typename Traits :: IntersectionIterator IntersectionIterator;
/** \brief type of the collective communication */
typedef typename Traits :: CollectiveCommunication CollectiveCommunication;
/** \brief A struct that collects all associated types of one implementation
from the Traits class.
*/
template< int cd >
struct Codim {
/** \brief type of iterator returned by the grid view */
typedef typename Traits :: template Codim<cd> :: Iterator Iterator;
/** \brief type of corresponding entity */
typedef typename Traits :: template Codim<cd> :: Entity Entity;
/** \brief type of the geometry implementation */
typedef typename Traits :: template Codim<cd> :: Geometry Geometry;
/** \brief type of the implementation for local geometries */
typedef typename Traits :: template Codim<cd> :: LocalGeometry LocalGeometry;
/** \brief Define types needed to iterate over entities of a given partition type */
template< PartitionIteratorType pit >
struct Partition
{
/** \brief iterator over a given codim and partition type */
typedef typename Traits :: template Codim< cd >
:: template Partition< pit > :: Iterator Iterator;
};
}; //: public Traits :: template Codim<cd> {};
enum {
/** \brief Export if this grid view is conforming */
conforming = Traits :: conforming
};
/** \brief type used for coordinates in grid */
typedef typename Grid::ctype ctype;
enum { //! \brief The dimension of the grid
dimension = Grid :: dimension
};
enum { //! \brief The dimension of the world the grid lives in
dimensionworld = Grid :: dimensionworld
};
public:
//===========================================================
/** @name Interface for the implementor
*/
//@{
//===========================================================
/** \brief constructor (engine concept) */
GridView ( const Implementation &imp )
: impl_( imp )
{}
//@}
/** \brief Copy constructor */
GridView ( const ThisType &other )
: impl_( other.impl_ )
{}
/** \brief assignment operator */
ThisType &operator= ( const ThisType &other )
{
impl_ = other.impl_;
return *this;
}
public:
/** \brief obtain a const reference to the underlying hierarchic grid */
const Grid &grid () const
{
return impl().grid();
}
/** \brief obtain the index set
*
* The lifetime of the returned index set is bound to the lifetime of the
* grid view. Keep a copy of the grid view to prevent the index set from
* becoming a dangling reference.
*/
const IndexSet &indexSet () const
{
return impl().indexSet();
}
/** \brief obtain number of entities in a given codimension */
int size ( int codim ) const
{
return impl().size( codim );
}
/** \brief obtain number of entities with a given geometry type */
int size ( const GeometryType &type ) const
{
return impl().size( type );
}
/** @brief Return true if the given entity is contained in this grid view
* @todo Currently we call the implementation on the IndexSet. This may lead to suboptimal efficiency.
*
* \note If the input element e is not an element of the grid, then
* the result of contains() is undefined.
*/
template<class EntityType>
bool contains (const EntityType& e) const
{
return impl().indexSet().contains(e);
}
/** \brief obtain begin iterator for this view */
template< int cd >
typename Codim< cd > :: Iterator begin () const
{
return impl().template begin<cd>();
}
/** \brief obtain end iterator for this view */
template< int cd >
typename Codim< cd > :: Iterator end () const
{
return impl().template end<cd>();
}
/** \brief obtain begin iterator for this view */
template< int cd , PartitionIteratorType pitype >
typename Codim< cd > :: template Partition< pitype > :: Iterator
begin () const
{
return impl().template begin<cd,pitype>();
}
/** \brief obtain end iterator for this view */
template< int cd, PartitionIteratorType pitype >
typename Codim< cd > :: template Partition< pitype > :: Iterator
end () const
{
return impl().template end<cd,pitype>();
}
/** \brief obtain begin intersection iterator with respect to this view */
IntersectionIterator
ibegin ( const typename Codim< 0 > :: Entity &entity ) const
{
return impl().ibegin(entity);
}
/** \brief obtain end intersection iterator with respect to this view */
IntersectionIterator
iend ( const typename Codim< 0 > :: Entity &entity ) const
{
return impl().iend(entity);
}
/** \brief obtain collective communication object */
const CollectiveCommunication &comm () const
{
return impl().comm();
}
/** \brief Return size of the overlap region for a given codim on the grid view. */
int overlapSize(int codim) const
{
return impl().overlapSize(codim);
}
/** \brief Return size of the ghost region for a given codim on the grid view. */
int ghostSize(int codim) const
{
return impl().ghostSize(codim);
}
/** \brief Communicate data on this view */
template< class DataHandleImp, class DataType >
void communicate ( CommDataHandleIF< DataHandleImp, DataType > &data,
InterfaceType iftype,
CommunicationDirection dir ) const
{
impl().communicate(data,iftype,dir);
}
#if DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
public:
#else
protected:
// give the GridDefaultImplementation class access to the realImp
friend class GridDefaultImplementation< Grid::dimension, Grid::dimensionworld, typename Grid::ctype, typename Grid::GridFamily >;
#endif
//! return reference to the real implementation
Implementation &impl () { return impl_; }
//! return reference to the real implementation
const Implementation &impl () const { return impl_; }
protected:
Implementation impl_;
};
} // namespace Dune
#endif // #ifndef DUNE_GRIDVIEW_HH
|