/usr/include/dune/grid/common/scsgmapper.hh is in libdune-grid-dev 2.4.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 | // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_GRID_COMMON_SCSGMAPPER_HH
#define DUNE_GRID_COMMON_SCSGMAPPER_HH
#include <iostream>
#include "mapper.hh"
#include <dune/grid/common/grid.hh>
/**
* @file
* @brief Mapper classes are used to attach data to a grid
* @author Peter Bastian
*/
namespace Dune
{
/**
* @addtogroup Mapper
*
* @{
*/
/** @brief Implementation class for a single codim and single geometry type mapper.
*
* In this implementation of a mapper the entity set used as domain for the map consists
* of the entities of a given codimension c for all entities in the given index set. The index
* set may only contain entities of a single geometry type, otherwise an exception is thrown. This
* version is usually not used directly but is used to implement versions for leafwise and levelwise
* entity sets.
*
* \tparam GV A Dune grid view type
*
* \tparam c A valid codimension
*/
template <typename GV, int c>
class SingleCodimSingleGeomTypeMapper :
public Mapper<typename GV::Grid,SingleCodimSingleGeomTypeMapper<GV,c>, typename GV::IndexSet::IndexType >
{
public:
/** \brief Number type used for indices */
typedef typename GV::IndexSet::IndexType Index;
/** @brief Construct mapper from grid and one of its index sets.
\param gridView A Dune GridView object.
*/
SingleCodimSingleGeomTypeMapper (const GV& gridView)
: is(gridView.indexSet())
{
// check that grid has only a single geometry type
if (is.types(c).size() != 1)
DUNE_THROW(GridError, "mapper treats only a single codim and a single geometry type");
}
/** @brief Map entity to array index.
\param e Reference to codim cc entity, where cc is the template parameter of the function.
\return An index in the range 0 ... Max number of entities in set - 1.
*/
template<class EntityType>
Index DUNE_DEPRECATED_MSG("Will be removed after dune-grid-2.4. Use method 'index' instead!") map (const EntityType& e) const
{
static_assert(EntityType::codimension == c, "Entity of wrong codim passed to SingleCodimSingleGeomTypeMapper");
return is.index(e);
}
/** @brief Map entity to array index.
\param e Reference to codim cc entity, where cc is the template parameter of the function.
\return An index in the range 0 ... Max number of entities in set - 1.
*/
template<class EntityType>
Index index (const EntityType& e) const
{
static_assert(EntityType::codimension == c, "Entity of wrong codim passed to SingleCodimSingleGeomTypeMapper");
return is.index(e);
}
/** @brief Map subentity of codim 0 entity to array index.
\param e Reference to codim 0 entity.
\param i Number of the subentity of e, where cc is the template parameter of the function.
\param codim Codimension of the subentity of e
\return An index in the range 0 ... Max number of entities in set - 1.
*/
Index DUNE_DEPRECATED_MSG("Will be removed after dune-grid-2.4. Use method 'subIndex' instead!") map (const typename GV::template Codim<0>::Entity& e,
int i, unsigned int codim) const
{
if (codim != c)
DUNE_THROW(GridError, "Id of wrong codim requested from SingleCodimSingleGeomTypeMapper");
return is.subIndex(e,i,codim);
}
/** @brief Map subentity of codim 0 entity to array index.
\param e Reference to codim 0 entity.
\param i Number of the subentity of e, where cc is the template parameter of the function.
\param codim Codimension of the subentity of e
\return An index in the range 0 ... Max number of entities in set - 1.
*/
Index subIndex (const typename GV::template Codim<0>::Entity& e,
int i, unsigned int codim) const
{
if (codim != c)
DUNE_THROW(GridError, "Id of wrong codim requested from SingleCodimSingleGeomTypeMapper");
return is.subIndex(e,i,codim);
}
/** @brief Return total number of entities in the entity set managed by the mapper.
This number can be used to allocate a vector of data elements associated with the
entities of the set. In the parallel case this number is per process (i.e. it
may be different in different processes).
\return Size of the entity set.
*/
int size () const
{
return is.size(c);
}
/** @brief Returns true if the entity is contained in the index set
\param e Reference to entity
\param result integer reference where corresponding index is stored if true
\return true if entity is in entity set of the mapper
*/
template<class EntityType>
bool contains (const EntityType& e, Index& result) const
{
result = index(e);
return true;
}
/** @brief Returns true if the entity is contained in the index set
\param e Reference to codim 0 entity
\param i subentity number
\param cc subentity codim
\param result integer reference where corresponding index is stored if true
\return true if entity is in entity set of the mapper
*/
bool contains (const typename GV::template Codim<0>::Entity& e, int i, int cc, Index& result) const
{
result = subIndex(e,i,cc);
return true;
}
/** @brief Recalculates map after mesh adaptation
*/
void update ()
{ // nothing to do here
}
private:
const typename GV::IndexSet& is;
};
/** @} */
/**
* @addtogroup Mapper
*
* @{
*/
/** @brief Single codim and single geometry type mapper for leaf entities.
This mapper uses all leaf entities of a certain codimension as its entity set. It is
assumed (and checked) that the given grid contains only entities of a single geometry type.
Template parameters are:
* \tparam G A Dune grid type.
* \tparam c A valid codimension.
*/
template <typename G, int c>
class LeafSingleCodimSingleGeomTypeMapper : public SingleCodimSingleGeomTypeMapper<typename G::LeafGridView,c> {
public:
/** \brief The constructor
* \param grid A reference to a grid.
*/
LeafSingleCodimSingleGeomTypeMapper (const G& grid)
: SingleCodimSingleGeomTypeMapper<typename G::LeafGridView,c>(grid.leafGridView())
{}
};
/** @brief Single codim and single geometry type mapper for entities of one level.
This mapper uses all entities of a certain codimension on a given level as its entity set. It is
assumed (and checked) that the given grid contains only entities of a single geometry type.
Template parameters are:
* \tparam G A Dune grid type.
* \tparam c A valid codimension.
*/
template <typename G, int c>
class LevelSingleCodimSingleGeomTypeMapper : public SingleCodimSingleGeomTypeMapper<typename G::LevelGridView,c> {
public:
/* @brief The constructor
@param grid A reference to a grid.
@param level A valid level of the grid.
*/
LevelSingleCodimSingleGeomTypeMapper (const G& grid, int level)
: SingleCodimSingleGeomTypeMapper<typename G::LevelGridView,c>(grid.levelGridView(level))
{}
};
/** @} */
}
#endif
|