/usr/include/dune/pdelab/ordering/utility.hh is in libdune-pdelab-dev 2.5.0~20170124g7cf9f47a-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 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | // -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=8 sw=2 sts=2:
#ifndef DUNE_PDELAB_ORDERING_UTILITY_HH
#define DUNE_PDELAB_ORDERING_UTILITY_HH
#include <vector>
#include <bitset>
#include <dune/pdelab/common/dofindex.hh>
#include <dune/pdelab/common/globaldofindex.hh>
#include <dune/pdelab/ordering/transformations.hh>
namespace Dune {
namespace PDELab {
//! \addtogroup Ordering
//! \{
//! Index merging algorithm for global orderings.
struct MergeMode
{
enum type {
lexicographic, //!< Lexicographically ordered ([i1,i2],[j1,j2] -> [i1,i2,j1,j2]).
interleaved //!< Indices are interleaved according to a user-supplied pattern ([i1,i2],[j1,j2] -> [i1,j1,i2,j2]).
};
};
#ifndef DOXYGEN
namespace ordering {
// This is an implementation detail of the composite orderings, no need to confuse our users!
struct update_direct_children
: public TypeTree::DirectChildrenVisitor
, public TypeTree::DynamicTraversal
{
template<typename GFS, typename Child, typename TreePath, typename ChildIndex>
void afterChild(const GFS& gfs, Child& child, TreePath tp, ChildIndex childIndex) const
{
child.update();
}
};
} // end namespace ordering
#endif // DOXYGEN
struct DefaultDOFIndexAccessor
{
template<typename DOFIndex, typename SizeType, typename IndexType>
static typename std::enable_if<
std::is_integral<IndexType>::value
>::type
store(DOFIndex& dof_index, const GeometryType& gt, SizeType entity_index, IndexType tree_index)
{
dof_index.clear();
dof_index.entityIndex()[0] = GlobalGeometryTypeIndex::index(gt);
dof_index.entityIndex()[1] = entity_index;
dof_index.treeIndex().push_back(tree_index);
}
template<typename DOFIndex, typename SizeType, typename IndexType>
static typename std::enable_if<
!std::is_integral<IndexType>::value
>::type
store(DOFIndex& dof_index, const GeometryType& gt, SizeType entity_index, IndexType tree_index)
{
dof_index.entityIndex()[0] = GlobalGeometryTypeIndex::index(gt);
dof_index.entityIndex()[1] = entity_index;
dof_index.treeIndex() = tree_index;
}
template<typename DOFIndex, typename SizeType, typename IndexType>
static typename std::enable_if<
std::is_integral<IndexType>::value
>::type
store(DOFIndex& dof_index, SizeType gt_index, SizeType entity_index, IndexType tree_index)
{
dof_index.clear();
dof_index.entityIndex()[0] = gt_index;
dof_index.entityIndex()[1] = entity_index;
dof_index.treeIndex().push_back(tree_index);
}
template<typename DOFIndex, typename SizeType, typename IndexType>
static typename std::enable_if<
!std::is_integral<IndexType>::value
>::type
store(DOFIndex& dof_index, SizeType gt_index, SizeType entity_index, IndexType tree_index)
{
dof_index.entityIndex()[0] = gt_index;
dof_index.entityIndex()[1] = entity_index;
dof_index.treeIndex() = tree_index;
}
struct GeometryIndex
{
template<typename Index>
static std::size_t geometryType(const Index& geometry_index)
{
return geometry_index[0];
}
template<typename Index>
static std::size_t entityIndex(const Index& geometry_index)
{
return geometry_index[1];
}
template<typename Index, typename SizeType>
static void store(Index& index, const GeometryType& gt, SizeType entity_index)
{
index[0] = GlobalGeometryTypeIndex::index(gt);
index[1] = entity_index;
}
};
template<typename DOFIndex>
static std::size_t geometryType(const DOFIndex& dof_index)
{
return GeometryIndex::geometryType(dof_index.entityIndex());
}
template<typename DOFIndex>
static std::size_t entityIndex(const DOFIndex& dof_index)
{
return GeometryIndex::entityIndex(dof_index.entityIndex());
}
};
struct SimpleDOFIndexAccessor
{
template<typename DOFIndex, typename SizeType>
static void store(DOFIndex& dof_index, const GeometryType& gt, SizeType entity_index, SizeType tree_index)
{
dof_index = entity_index;
}
};
template<typename DI, typename CI>
struct SimpleOrderingTraits
{
typedef DI DOFIndex;
typedef CI ContainerIndex;
typedef std::size_t SizeType;
typedef DefaultDOFIndexAccessor DOFIndexAccessor;
};
template<typename SizeType_, typename CI>
struct SimpleOrderingTraits<SimpleDOFIndex<SizeType_>,CI>
{
typedef SimpleDOFIndex<SizeType_> DOFIndex;
typedef CI ContainerIndex;
typedef SizeType_ SizeType;
typedef SimpleDOFIndexAccessor DOFIndexAccessor;
};
template<typename DI, typename CI>
struct OrderingTraits
: public SimpleOrderingTraits<DI,CI>
{
// The maximum dimension supported (length of bitsets)
// 32 dimensions should probably be fine for now... ;-)
static const std::size_t max_dim = 32;
typedef std::bitset<max_dim> CodimFlag;
typedef typename DI::TreeIndex TreeIndex;
typedef typename DI::View DOFIndexView;
typedef typename DI::View::TreeIndex TreeIndexView;
typedef typename DI::size_type SizeType;
typedef typename DI::size_type size_type;
};
template<typename ES, typename DI, typename CI>
struct LocalOrderingTraits
: public OrderingTraits<DI,
CI
>
{
using EntitySet = ES;
using GridView = typename ES::GridView;
};
template<typename ES, typename DI, typename CI>
struct GridViewOrderingTraits
: public LocalOrderingTraits<ES,DI,CI>
{
typedef typename DI::EntityIndex EntityIndex;
typedef typename DI::View::EntityIndex EntityIndexView;
};
template<typename DI, typename CI>
class VirtualOrderingBase
{
public:
typedef OrderingTraits<DI,CI> Traits;
VirtualOrderingBase() {}
virtual void map_index_dynamic(typename Traits::DOFIndexView di, typename Traits::ContainerIndex& ci) const = 0;
};
template<typename child_type>
struct extract_child_bases
: public TypeTree::DirectChildrenVisitor
, public TypeTree::DynamicTraversal
{
template<typename Node, typename Child, typename TreePath, typename ChildIndex>
void afterChild(const Node& node, Child& child, TreePath tp, ChildIndex child_index)
{
extract_child(node,child,child_index);
}
template<typename Node, typename Child, typename ChildIndex>
typename std::enable_if<Node::has_dynamic_ordering_children>::type
extract_child(const Node& node, Child& child, ChildIndex child_index)
{
_children[child_index] = &child;
}
template<typename Node, typename Child, typename ChildIndex>
typename std::enable_if<!Node::has_dynamic_ordering_children>::type
extract_child(const Node& node, Child& child, ChildIndex child_index)
{
}
extract_child_bases(std::vector<child_type*>& children)
: _children(children)
{}
private:
std::vector<child_type*>& _children;
};
//! Dummy iterator type over DOF indices.
/**
* This dummy iterator is used to support omitting the calculation
* of DOFIndex values in the per-entity index lookup methods of
* orderings. By defining all operations performed on the DOFIndex
* iterator and its value by this methods as no-ops, we can reuse the
* combined implementation mapping both DOFIndex and ContainerIndex for
* the (much more common) case of only having to map the ContainerIndex
* values.
*/
struct DummyDOFIndexIterator
{
typedef std::size_t size_type;
DummyDOFIndexIterator& operator++()
{
return *this;
}
DummyDOFIndexIterator& operator+=(size_type i)
{
return *this;
}
DummyDOFIndexIterator& operator*()
{
return *this;
}
DummyDOFIndexIterator* operator->()
{
return this;
}
DummyDOFIndexIterator& treeIndex()
{
return *this;
}
bool operator==(const DummyDOFIndexIterator& r) const
{
return true;
}
bool operator!=(const DummyDOFIndexIterator& r) const
{
return !operator==(r);
}
void push_back(size_type i)
{}
};
//! \} group Ordering
} // namespace PDELab
} // namespace Dune
#endif // DUNE_PDELAB_ORDERING_UTILITY_HH
|