3#ifndef DUNE_PDELAB_BACKEND_ISTL_VECTOR_HH
4#define DUNE_PDELAB_BACKEND_ISTL_VECTOR_HH
6#include <dune/common/fvector.hh>
7#include <dune/common/shared_ptr.hh>
8#include <dune/istl/bvector.hh>
9#include <dune/typetree/typetree.hh>
10#include <dune/functions/backends/istlvectorbackend.hh>
27 template<
typename GFS,
typename C>
29 :
public Backend::impl::Wrapper<C>
32 friend Backend::impl::Wrapper<C>;
51 template<
typename LFSCache>
54 template<
typename LFSCache>
57 template<
typename LFSCache>
60 template<
typename LFSCache>
65 , _container(
std::make_shared<
Container>(_gfs->ordering().blockCount()))
68 (*_container) = rhs.native();
73 , _container(
std::move(rhs._container))
95 , _container(stackobject_to_shared_ptr(container))
140 auto b = Functions::istlVectorBackend(*_container);
143 b.resize(size_provider);
151 template<
typename LFSCache>
154 return &((*this)[lfs_cache.containerIndex(0)]);
157 template<
typename LFSCache>
160 return &((*this)[lfs_cache.containerIndex(0)]);
163 void attach(std::shared_ptr<Container> container)
165 _container = container;
170 return bool(_container);
173 const std::shared_ptr<Container>&
storage()
const
180 return _container->N();
189 (*_container) = r.native();
193 _container = std::make_shared<Container>(r.native());
219 (*_container)+= e.native();
225 (*_container)-= e.native();
231 return (*_container)[i];
236 return (*_container)[i];
241 return ISTL::access_vector_element(
ISTL::container_tag(*_container),*_container,ci,ci.size()-1);
246 return ISTL::access_vector_element(
ISTL::container_tag(*_container),*_container,ci,ci.size()-1);
249 typename Dune::template FieldTraits<E>::real_type
two_norm2()
const
251 return _container->two_norm2();
254 typename Dune::template FieldTraits<E>::real_type
two_norm()
const
256 return _container->two_norm();
259 typename Dune::template FieldTraits<E>::real_type
one_norm()
const
261 return _container->one_norm();
266 return _container->infinity_norm();
271 return (*_container)*y.native();
276 return _container->dot(y.native());
281 _container->axpy(a, y.native());
334 return _container->dim();
348 std::shared_ptr<const GFS> _gfs;
349 std::shared_ptr<Container> _container;
355 template<
typename GFS,
typename E>
356 struct BlockVectorSelectorHelper
359 typedef typename TypeTree::AccumulateType<
361 ISTL::vector_creation_policy<E>
362 >::type vector_descriptor;
364 typedef BlockVector<GFS,typename vector_descriptor::vector_type> Type;
378 template<Dune::PDELab::ISTL::Blocking blocking, std::
size_t block_size,
typename GFS,
typename E>
379 struct BackendVectorSelectorHelper<ISTL::VectorBackend<blocking,block_size>, GFS, E>
380 :
public ISTL::BlockVectorSelectorHelper<GFS,E>
@ Outer2Inner
indices are ordered from outer to inner container: {outer,...,inner}
For backward compatibility – Do not use this!
Definition: adaptivity.hh:28
tags::container< T >::type container_tag(const T &)
Gets instance of container tag associated with T.
Definition: backend/istl/tags.hh:234
Definition: aliasedvectorview.hh:18
Definition: aliasedvectorview.hh:128
Tag for requesting a vector or matrix container without a pre-attached underlying object.
Definition: backend/common/tags.hh:24
Tag for requesting a vector or matrix container with a pre-attached underlying object.
Definition: backend/common/tags.hh:28
Definition: uncachedvectorview.hh:18
Definition: uncachedvectorview.hh:149
Definition: istl/vector.hh:30
const value_type * data(const LFSCache &lfs_cache) const
Definition: istl/vector.hh:158
C::field_type ElementType
Definition: istl/vector.hh:35
const std::shared_ptr< Container > & storage() const
Definition: istl/vector.hh:173
block_type & block(std::size_t i)
Definition: istl/vector.hh:229
BlockVector(std::shared_ptr< const GFS > gfs, Container &container)
Constructs an BlockVector for an explicitly given vector object.
Definition: istl/vector.hh:93
BlockVector(const BlockVector &rhs)
Definition: istl/vector.hh:63
Dune::template FieldTraits< E >::real_type one_norm() const
Definition: istl/vector.hh:259
void detach()
Definition: istl/vector.hh:146
size_t flatsize() const
Definition: istl/vector.hh:332
const block_type & block(std::size_t i) const
Definition: istl/vector.hh:234
BlockVector(const GFS &gfs, Container &container)
Constructs an BlockVector for an explicitly given vector object.
Definition: istl/vector.hh:122
BlockVector & operator-=(const BlockVector &e)
Definition: istl/vector.hh:223
GFS::Ordering::Traits::ContainerIndex ContainerIndex
Definition: istl/vector.hh:45
ElementType E
Definition: istl/vector.hh:36
std::shared_ptr< const GFS > gridFunctionSpaceStorage() const
Definition: istl/vector.hh:342
BlockVector(const GFS &gfs, Backend::attached_container tag=Backend::attached_container())
Definition: istl/vector.hh:108
const_iterator begin() const
Definition: istl/vector.hh:316
BlockVector(std::shared_ptr< const GFS > gfs, Backend::unattached_container)
Creates an BlockVector without allocating an underlying ISTL vector.
Definition: istl/vector.hh:84
iterator end()
Definition: istl/vector.hh:321
size_type N() const
Definition: istl/vector.hh:178
C Container
Definition: istl/vector.hh:37
bool attached() const
Definition: istl/vector.hh:168
Dune::template FieldTraits< E >::real_type two_norm() const
Definition: istl/vector.hh:254
E dot(const BlockVector &y) const
Definition: istl/vector.hh:274
ISTL::vector_iterator< C > iterator
Definition: istl/vector.hh:47
BlockVector(std::shared_ptr< const GFS > gfs, Backend::attached_container=Backend::attached_container())
Definition: istl/vector.hh:76
void resize()
Resize container for a given function space ordering.
Definition: istl/vector.hh:137
value_type * data(const LFSCache &lfs_cache)
Definition: istl/vector.hh:152
BlockVector(std::shared_ptr< const GFS > gfs, const E &e)
Definition: istl/vector.hh:100
const E & operator[](const ContainerIndex &ci) const
Definition: istl/vector.hh:244
Dune::template FieldTraits< E >::real_type two_norm2() const
Definition: istl/vector.hh:249
BlockVector & operator+=(const E &e)
Definition: istl/vector.hh:211
ISTL::vector_iterator< const C > const_iterator
Definition: istl/vector.hh:48
const GFS & gridFunctionSpace() const
Definition: istl/vector.hh:337
GFS GridFunctionSpace
Definition: istl/vector.hh:38
iterator begin()
Definition: istl/vector.hh:310
Container::field_type field_type
Definition: istl/vector.hh:39
BlockVector & operator=(const BlockVector &r)
Definition: istl/vector.hh:183
Container::block_type block_type
Definition: istl/vector.hh:40
E operator*(const BlockVector &y) const
Definition: istl/vector.hh:269
BlockVector & axpy(const E &a, const BlockVector &y)
Definition: istl/vector.hh:279
BlockVector(BlockVector &&rhs)
Definition: istl/vector.hh:71
BlockVector(const GFS &gfs, const E &e)
Definition: istl/vector.hh:126
E value_type
Definition: istl/vector.hh:43
BlockVector(const GFS &gfs, Backend::unattached_container tag)
Creates an BlockVector without allocating an underlying ISTL vector.
Definition: istl/vector.hh:113
BlockVector & operator*=(const E &e)
Definition: istl/vector.hh:204
void attach(std::shared_ptr< Container > container)
Definition: istl/vector.hh:163
Dune::template FieldTraits< E >::real_type infinity_norm() const
Definition: istl/vector.hh:264
E & operator[](const ContainerIndex &ci)
Definition: istl/vector.hh:239
Container::size_type size_type
Definition: istl/vector.hh:41
const_iterator end() const
Definition: istl/vector.hh:327
Definition: vectoriterator.hh:113
Adapter to create a size provider from an ordering.
Definition: ordering/utility.hh:363
Various tags for influencing backend behavior.