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>
26 template<
typename GFS,
typename C>
28 :
public Backend::impl::Wrapper<C>
31 friend Backend::impl::Wrapper<C>;
50 template<
typename LFSCache>
53 template<
typename LFSCache>
56 template<
typename LFSCache>
59 template<
typename LFSCache>
64 , _container(std::make_shared<
Container>(_gfs->ordering().blockCount()))
66 ISTL::dispatch_vector_allocation(_gfs->ordering(),*_container,
typename GFS::Ordering::ContainerAllocationTag());
67 (*_container) = rhs.native();
72 , _container(std::move(rhs._container))
77 , _container(std::make_shared<
Container>(gfs->ordering().blockCount()))
79 ISTL::dispatch_vector_allocation(gfs->ordering(),*_container,
typename GFS::Ordering::ContainerAllocationTag());
94 , _container(stackobject_to_shared_ptr(container))
96 _container->resize(gfs->ordering().blockCount());
97 ISTL::dispatch_vector_allocation(gfs->ordering(),*_container,
typename GFS::Ordering::ContainerAllocationTag());
102 , _container(std::make_shared<
Container>(gfs->ordering().blockCount()))
104 ISTL::dispatch_vector_allocation(gfs->ordering(),*_container,
typename GFS::Ordering::ContainerAllocationTag());
135 template<
typename LFSCache>
138 return &((*this)[lfs_cache.containerIndex(0)]);
141 template<
typename LFSCache>
144 return &((*this)[lfs_cache.containerIndex(0)]);
147 void attach(std::shared_ptr<Container> container)
149 _container = container;
154 return bool(_container);
157 const std::shared_ptr<Container>&
storage()
const
164 return _container->N();
173 (*_container) = r.native();
177 _container = std::make_shared<Container>(r.native());
203 (*_container)+=
e.native();
209 (*_container)-=
e.native();
215 return (*_container)[i];
220 return (*_container)[i];
225 return ISTL::access_vector_element(
ISTL::container_tag(*_container),*_container,ci,ci.size()-1);
230 return ISTL::access_vector_element(
ISTL::container_tag(*_container),*_container,ci,ci.size()-1);
233 typename Dune::template FieldTraits<E>::real_type
two_norm2()
const
235 return _container->two_norm2();
238 typename Dune::template FieldTraits<E>::real_type
two_norm()
const
240 return _container->two_norm();
243 typename Dune::template FieldTraits<E>::real_type
one_norm()
const
245 return _container->one_norm();
250 return _container->infinity_norm();
255 return (*_container)*y.native();
260 return _container->dot(y.native());
265 _container->axpy(a, y.native());
318 return _container->dim();
332 std::shared_ptr<const GFS> _gfs;
333 std::shared_ptr<Container> _container;
339 template<
typename GFS,
typename E>
340 struct BlockVectorSelectorHelper
343 typedef typename TypeTree::AccumulateType<
345 ISTL::vector_creation_policy<E>
346 >::type vector_descriptor;
348 typedef BlockVector<GFS,typename vector_descriptor::vector_type> Type;
362 template<Dune::PDELab::ISTL::Blocking blocking, std::
size_t block_size,
typename GFS,
typename E>
363 struct BackendVectorSelectorHelper<ISTL::VectorBackend<blocking,block_size>, GFS, E>
364 :
public ISTL::BlockVectorSelectorHelper<GFS,E>
const Entity & e
Definition: localfunctionspace.hh:121
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:29
Dune::template FieldTraits< E >::real_type two_norm2() const
Definition: istl/vector.hh:233
C::field_type ElementType
Definition: istl/vector.hh:34
BlockVector(std::shared_ptr< const GFS > gfs, Container &container)
Constructs an BlockVector for an explicitly given vector object.
Definition: istl/vector.hh:92
BlockVector(const BlockVector &rhs)
Definition: istl/vector.hh:62
std::shared_ptr< const GFS > gridFunctionSpaceStorage() const
Definition: istl/vector.hh:326
BlockVector & axpy(const E &a, const BlockVector &y)
Definition: istl/vector.hh:263
void detach()
Definition: istl/vector.hh:130
size_t flatsize() const
Definition: istl/vector.hh:316
BlockVector(const GFS &gfs, Container &container)
Constructs an BlockVector for an explicitly given vector object.
Definition: istl/vector.hh:122
block_type & block(std::size_t i)
Definition: istl/vector.hh:213
GFS::Ordering::Traits::ContainerIndex ContainerIndex
Definition: istl/vector.hh:44
ElementType E
Definition: istl/vector.hh:35
BlockVector(const GFS &gfs, Backend::attached_container tag=Backend::attached_container())
Definition: istl/vector.hh:108
const_iterator begin() const
Definition: istl/vector.hh:300
BlockVector(std::shared_ptr< const GFS > gfs, Backend::unattached_container)
Creates an BlockVector without allocating an underlying ISTL vector.
Definition: istl/vector.hh:83
iterator end()
Definition: istl/vector.hh:305
size_type N() const
Definition: istl/vector.hh:162
C Container
Definition: istl/vector.hh:36
bool attached() const
Definition: istl/vector.hh:152
Dune::template FieldTraits< E >::real_type infinity_norm() const
Definition: istl/vector.hh:248
E dot(const BlockVector &y) const
Definition: istl/vector.hh:258
ISTL::vector_iterator< C > iterator
Definition: istl/vector.hh:46
BlockVector(std::shared_ptr< const GFS > gfs, Backend::attached_container=Backend::attached_container())
Definition: istl/vector.hh:75
Dune::template FieldTraits< E >::real_type one_norm() const
Definition: istl/vector.hh:243
BlockVector(std::shared_ptr< const GFS > gfs, const E &e)
Definition: istl/vector.hh:100
const GFS & gridFunctionSpace() const
Definition: istl/vector.hh:321
ISTL::vector_iterator< const C > const_iterator
Definition: istl/vector.hh:47
BlockVector & operator=(const BlockVector &r)
Definition: istl/vector.hh:167
BlockVector & operator*=(const E &e)
Definition: istl/vector.hh:188
E & operator[](const ContainerIndex &ci)
Definition: istl/vector.hh:223
const std::shared_ptr< Container > & storage() const
Definition: istl/vector.hh:157
BlockVector & operator-=(const BlockVector &e)
Definition: istl/vector.hh:207
GFS GridFunctionSpace
Definition: istl/vector.hh:37
BlockVector & operator+=(const E &e)
Definition: istl/vector.hh:195
const value_type * data(const LFSCache &lfs_cache) const
Definition: istl/vector.hh:142
iterator begin()
Definition: istl/vector.hh:294
Container::field_type field_type
Definition: istl/vector.hh:38
Container::block_type block_type
Definition: istl/vector.hh:39
E operator*(const BlockVector &y) const
Definition: istl/vector.hh:253
const block_type & block(std::size_t i) const
Definition: istl/vector.hh:218
BlockVector(BlockVector &&rhs)
Definition: istl/vector.hh:70
BlockVector(const GFS &gfs, const E &e)
Definition: istl/vector.hh:126
E value_type
Definition: istl/vector.hh:42
BlockVector(const GFS &gfs, Backend::unattached_container tag)
Creates an BlockVector without allocating an underlying ISTL vector.
Definition: istl/vector.hh:113
void attach(std::shared_ptr< Container > container)
Definition: istl/vector.hh:147
Container::size_type size_type
Definition: istl/vector.hh:40
const_iterator end() const
Definition: istl/vector.hh:311
Dune::template FieldTraits< E >::real_type two_norm() const
Definition: istl/vector.hh:238
value_type * data(const LFSCache &lfs_cache)
Definition: istl/vector.hh:136
const E & operator[](const ContainerIndex &ci) const
Definition: istl/vector.hh:228
Definition: vectoriterator.hh:113
Various tags for influencing backend behavior.