/usr/include/dune/pdelab/gridfunctionspace/dunefunctionslfsindexcache.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 | // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_PDELAB_GRIDFUNCTIONSPACE_DUNEFUNCTIONSLFSINDEXCACHE_HH
#define DUNE_PDELAB_GRIDFUNCTIONSPACE_DUNEFUNCTIONSLFSINDEXCACHE_HH
#include <dune/pdelab/gridfunctionspace/lfsindexcache.hh>
#include <dune/pdelab/gridfunctionspace/dunefunctionsgridfunctionspace.hh>
namespace Dune {
namespace PDELab {
template<typename LFS, typename C>
class LFSIndexCacheBase<LFS,C,Experimental::DuneFunctionsCacheTag>
{
enum DOFFlags
{
DOF_NONCONSTRAINED = 0,
DOF_CONSTRAINED = 1<<0,
DOF_DIRICHLET = 1<<1
};
public:
using LocalFunctionSpace = LFS;
using GFS = typename LFS::Traits::GridFunctionSpace;;
using Ordering = typename GFS::Ordering;
using DOFIndex = typename Ordering::Traits::DOFIndex;
using DI = DOFIndex;
using ContainerIndex = typename Ordering::Traits::ContainerIndex;
using CI = ContainerIndex;
using size_type = std::size_t;
typedef std::vector<CI> CIVector;
typedef std::unordered_map<DI,CI> CIMap;
typedef std::unordered_map<const CI*,std::pair<size_type,bool> > InverseMap;
struct ConstraintsEntry
: public std::pair<const CI*,typename C::mapped_type::mapped_type>
{
typedef CI ContainerIndex;
typedef typename C::mapped_type::mapped_type Weight;
const ContainerIndex& containerIndex() const
{
return *(this->first);
}
const Weight& weight() const
{
return this->second;
}
};
//typedef std::pair<CI,typename C::mapped_type::mapped_type> ConstraintsEntry;
typedef std::vector<ConstraintsEntry> ConstraintsVector;
typedef typename ConstraintsVector::const_iterator ConstraintsIterator;
LFSIndexCacheBase(const LFS& lfs, const C& constraints, bool enable_constraints_caching)
: _lfs(lfs)
, _enable_constraints_caching(enable_constraints_caching)
, _container_indices(lfs.maxSize())
, _dof_flags(lfs.maxSize(),0)
, _constraints_iterators(lfs.maxSize())
, _inverse_cache_built(false)
, _gfs_constraints(constraints)
{
}
void update()
{}
DI dofIndex(size_type i) const
{
return _lfs.dofIndex(i);
}
CI containerIndex(size_type i) const
{
return _lfs.dofIndex(i);
}
CI containerIndex(const DI& i) const
{
return i;
}
bool isConstrained(size_type i) const
{
return _dof_flags[i] & DOF_CONSTRAINED;
}
bool isDirichletConstraint(size_type i) const
{
return _dof_flags[i] & DOF_DIRICHLET;
}
ConstraintsIterator constraintsBegin(size_type i) const
{
assert(isConstrained(i));
return _constraints_iterators[i].first;
}
ConstraintsIterator constraintsEnd(size_type i) const
{
assert(isConstrained(i));
return _constraints_iterators[i].second;
}
const LocalFunctionSpace& localFunctionSpace() const
{
return _lfs;
}
size_type size() const
{
return _lfs.size();
}
bool constraintsCachingEnabled() const
{
return _enable_constraints_caching;
}
private:
const LFS& _lfs;
const bool _enable_constraints_caching;
CIVector _container_indices;
std::vector<unsigned char> _dof_flags;
std::vector<std::pair<ConstraintsIterator,ConstraintsIterator> > _constraints_iterators;
mutable CIMap _container_index_map;
ConstraintsVector _constraints;
mutable bool _inverse_cache_built;
mutable InverseMap _inverse_map;
const C& _gfs_constraints;
};
template<typename LFS>
class LFSIndexCacheBase<LFS,EmptyTransformation,Experimental::DuneFunctionsCacheTag>
{
public:
using LocalFunctionSpace = LFS;
using GFS = typename LFS::Traits::GridFunctionSpace;
using Ordering = typename GFS::Ordering;
using DOFIndex = typename Ordering::Traits::DOFIndex;
using DI = DOFIndex;
using ContainerIndex = typename Ordering::Traits::ContainerIndex;
using CI = ContainerIndex;
using size_type = std::size_t;
struct ConstraintsEntry
: public std::pair<const CI*,double>
{
typedef CI ContainerIndex;
typedef double Weight;
const ContainerIndex& containerIndex() const
{
return *(this->first);
}
const Weight& weight() const
{
return this->second;
}
};
typedef std::vector<ConstraintsEntry> ConstraintsVector;
typedef typename ConstraintsVector::const_iterator ConstraintsIterator;
typedef std::vector<CI> CIVector;
typedef std::unordered_map<DI,CI> CIMap;
explicit LFSIndexCacheBase(const LFS& lfs)
: _lfs(lfs)
{}
template<typename C>
LFSIndexCacheBase(const LFS& lfs, const C& c, bool enable_constraints_caching)
: _lfs(lfs)
{}
DI dofIndex(size_type i) const
{
return _lfs.dofIndex(i);
}
CI containerIndex(size_type i) const
{
return _lfs.dofIndex(i);
}
CI containerIndex(const DI& i) const
{
return i;
}
bool isConstrained(size_type i) const
{
return false;
}
bool isDirichletConstraint(size_type i) const
{
return false;
}
ConstraintsIterator constraintsBegin(size_type i) const
{
return _constraints.begin();
}
ConstraintsIterator constraintsEnd(size_type i) const
{
return _constraints.end();
}
const LocalFunctionSpace& localFunctionSpace() const
{
return _lfs;
}
size_type size() const
{
return _lfs.size();
}
bool constraintsCachingEnabled() const
{
return false;
}
void update()
{}
private:
const LFS& _lfs;
CIVector _container_indices;
mutable CIMap _container_index_map;
const ConstraintsVector _constraints;
};
} // namespace PDELab
} // namespace Dune
#endif // DUNE_PDELAB_GRIDFUNCTIONSPACE_DUNEFUNCTIONSLFSINDEXCACHE_HH
|