/usr/include/dune/pdelab/backend/istl/vector.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 | // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_PDELAB_BACKEND_ISTL_VECTOR_HH
#define DUNE_PDELAB_BACKEND_ISTL_VECTOR_HH
// this is here for backwards compatibility and deprecation warnings, remove after 2.5.0
#include "ensureistlinclude.hh"
#include <dune/common/fvector.hh>
#include <dune/istl/bvector.hh>
#include <dune/typetree/typetree.hh>
#include <dune/pdelab/backend/interface.hh>
#include <dune/pdelab/backend/common/tags.hh>
#include <dune/pdelab/backend/common/uncachedvectorview.hh>
#include <dune/pdelab/backend/istl/descriptors.hh>
#include <dune/pdelab/backend/istl/vectorhelpers.hh>
#include <dune/pdelab/backend/istl/vectoriterator.hh>
#include <dune/pdelab/gridfunctionspace/gridfunctionspace.hh>
#include <dune/pdelab/gridfunctionspace/lfsindexcache.hh>
#include <dune/pdelab/gridfunctionspace/tags.hh>
namespace Dune {
namespace PDELab {
namespace ISTL {
template<typename GFS, typename C>
class BlockVector
: public Backend::impl::Wrapper<C>
{
friend Backend::impl::Wrapper<C>;
public:
typedef typename C::field_type ElementType;
typedef ElementType E;
typedef C Container;
typedef GFS GridFunctionSpace;
typedef typename Container::field_type field_type;
typedef typename Container::block_type block_type;
typedef typename Container::size_type size_type;
typedef typename GFS::Ordering::Traits::ContainerIndex ContainerIndex;
typedef ISTL::vector_iterator<C> iterator;
typedef ISTL::vector_iterator<const C> const_iterator;
template<typename LFSCache>
using LocalView = UncachedVectorView<BlockVector,LFSCache>;
template<typename LFSCache>
using ConstLocalView = ConstUncachedVectorView<const BlockVector,LFSCache>;
BlockVector(const BlockVector& rhs)
: _gfs(rhs._gfs)
, _container(std::make_shared<Container>(_gfs.ordering().blockCount()))
{
ISTL::dispatch_vector_allocation(_gfs.ordering(),*_container,typename GFS::Ordering::ContainerAllocationTag());
(*_container) = rhs.native();
}
BlockVector (const GFS& gfs, Backend::attached_container = Backend::attached_container())
: _gfs(gfs)
, _container(std::make_shared<Container>(gfs.ordering().blockCount()))
{
ISTL::dispatch_vector_allocation(gfs.ordering(),*_container,typename GFS::Ordering::ContainerAllocationTag());
}
//! Creates an BlockVector without allocating an underlying ISTL vector.
BlockVector(const GFS& gfs, Backend::unattached_container)
: _gfs(gfs)
{}
/** \brief Constructs an BlockVector for an explicitly given vector object
*
* \param gfs GridFunctionSpace that determines the size and the blocking of the vector
* \param container The actual ISTL container class
*/
BlockVector (const GFS& gfs, Container& container)
: _gfs(gfs)
, _container(stackobject_to_shared_ptr(container))
{
_container->resize(gfs.ordering().blockCount());
ISTL::dispatch_vector_allocation(gfs.ordering(),*_container,typename GFS::Ordering::ContainerAllocationTag());
}
BlockVector (const GFS& gfs, const E& e)
: _gfs(gfs)
, _container(std::make_shared<Container>(gfs.ordering().blockCount()))
{
ISTL::dispatch_vector_allocation(gfs.ordering(),*_container,typename GFS::Ordering::ContainerAllocationTag());
(*_container)=e;
}
void detach()
{
_container.reset();
}
void attach(std::shared_ptr<Container> container)
{
_container = container;
}
bool attached() const
{
return bool(_container);
}
const std::shared_ptr<Container>& storage() const
{
return _container;
}
size_type N() const
{
return _container->N();
}
BlockVector& operator= (const BlockVector& r)
{
if (this == &r)
return *this;
if (attached())
{
(*_container) = r.native();
}
else
{
_container = std::make_shared<Container>(r.native());
}
return *this;
}
BlockVector& operator= (const E& e)
{
(*_container)=e;
return *this;
}
BlockVector& operator*= (const E& e)
{
(*_container)*=e;
return *this;
}
BlockVector& operator+= (const E& e)
{
(*_container)+=e;
return *this;
}
BlockVector& operator+= (const BlockVector& e)
{
(*_container)+= e.native();
return *this;
}
BlockVector& operator-= (const BlockVector& e)
{
(*_container)-= e.native();
return *this;
}
block_type& block(std::size_t i)
{
return (*_container)[i];
}
const block_type& block(std::size_t i) const
{
return (*_container)[i];
}
E& operator[](const ContainerIndex& ci)
{
return ISTL::access_vector_element(ISTL::container_tag(*_container),*_container,ci,ci.size()-1);
}
const E& operator[](const ContainerIndex& ci) const
{
return ISTL::access_vector_element(ISTL::container_tag(*_container),*_container,ci,ci.size()-1);
}
typename Dune::template FieldTraits<E>::real_type two_norm() const
{
return _container->two_norm();
}
typename Dune::template FieldTraits<E>::real_type one_norm() const
{
return _container->one_norm();
}
typename Dune::template FieldTraits<E>::real_type infinity_norm() const
{
return _container->infinity_norm();
}
E operator*(const BlockVector& y) const
{
return (*_container)*y.native();
}
E dot(const BlockVector& y) const
{
return _container->dot(y.native());
}
BlockVector& axpy(const E& a, const BlockVector& y)
{
_container->axpy(a, y.native());
return *this;
}
private:
// for debugging and AMG access
Container& native ()
{
return *_container;
}
const Container& native () const
{
return *_container;
}
public:
operator Container&()
{
return *_container;
}
operator const Container&() const
{
return *_container;
}
iterator begin()
{
return iterator(*_container,false);
}
const_iterator begin() const
{
return const_iterator(*_container,false);
}
iterator end()
{
return iterator(*_container,true);
}
const_iterator end() const
{
return const_iterator(*_container,true);
}
size_t flatsize() const
{
return _container->dim();
}
const GFS& gridFunctionSpace() const
{
return _gfs;
}
private:
const GFS& _gfs;
std::shared_ptr<Container> _container;
};
#ifndef DOXYGEN
// helper struct invoking the GFS tree -> ISTL vector reduction
template<typename GFS, typename E>
struct BlockVectorSelectorHelper
{
typedef typename TypeTree::AccumulateType<
GFS,
ISTL::vector_creation_policy<E>
>::type vector_descriptor;
typedef BlockVector<GFS,typename vector_descriptor::vector_type> Type;
};
#endif // DOXYGEN
// can't have the closing of the namespace inside the #ifndef DOXYGEN block
} // namespace ISTL
#ifndef DOXYGEN
namespace Backend {
namespace impl {
template<Dune::PDELab::ISTL::Blocking blocking, std::size_t block_size, typename GFS, typename E>
struct BackendVectorSelectorHelper<ISTL::VectorBackend<blocking,block_size>, GFS, E>
: public ISTL::BlockVectorSelectorHelper<GFS,E>
{};
} // namespace impl
} // namespace Backend
#endif // DOXYGEN
} // namespace PDELab
} // namespace Dune
#endif // DUNE_PDELAB_BACKEND_ISTL_VECTOR_HH
|