AMDiS 2.10
The Adaptive Multi-Dimensional Simulation Toolbox
VectorFacade< T, VectorImpl > Class Template Reference

The basic container that stores a base vector and a corresponding basis. More...

#include <VectorFacade.hpp>

Public Types

using size_type = typename Impl::size_type
 
using value_type = typename Impl::value_type
 
template<class V >
using HasLocalSize = decltype(std::declval< V >().localSize())
 
template<class V >
using HasGlobalSize = decltype(std::declval< V >().globalSize())
 

Public Member Functions

template<class GlobalBasis , class = std::void_t<decltype(std::declval<GlobalBasis>().indexDistribution())>>
 VectorFacade (GlobalBasis const &basis)
 
Impl const & impl () const
 Return the underlying linear algebra backend.
 
Implimpl ()
 
std::size_t localSize () const
 Return the number of entries in the local part of the vector.
 
std::size_t globalSize () const
 Return the number of entries in the global vector.
 
template<class Basis >
void resize (Basis const &basis)
 Resize the vector to the size of the basis.
 
template<class Basis >
void resizeZero (Basis const &basis)
 Resize the vector to the size of the basis and set to zero.
 
template<class Basis >
void init (Basis const &basis, bool clear)
 
void finish ()
 Finish the insertion of values, see init()
 
template<class Index , class Assign = Assigner::plus_assign, REQUIRES(Concepts::MultiIndex< Index >) >
void insert (Index const &idx, typename Impl::value_type const &value, Assign assign={})
 Insert a single value into the matrix (add or overwrite to existing value) More...
 
template<class Index , REQUIRES(Concepts::MultiIndex< Index >) >
void set (Index const &idx, typename Impl::value_type const &value)
 See insert for assignment operation Assigner::assign.
 
template<class Index , REQUIRES(Concepts::MultiIndex< Index >) >
void add (Index const &idx, typename Impl::value_type const &value)
 See insert for assignment operation Assigner::plus_assign.
 
template<class Index , REQUIRES(Concepts::MultiIndex< Index >) >
Impl::value_type get (Index const &idx) const
 Return the value of the vector at the local index idx.
 
template<class LocalView , class Node , class Buffer , REQUIRES(Concepts::LocalView< LocalView >) , REQUIRES(Concepts::BasisNode< Node >) >
void gather (LocalView const &localView, Node const &node, Buffer &buffer) const
 Extract values from the vector referring to the given local indices and store it into a buffer. More...
 
template<class LocalView , class Buffer , REQUIRES(Concepts::LocalView< LocalView >) >
void gather (LocalView const &localView, Buffer &buffer) const
 
template<class Index , class Buffer , REQUIRES(Concepts::MultiIndex< Index >) >
void gather (std::vector< Index > const &indices, Buffer &buffer)
 Call gather the values associated to the indices into the buffer.
 
template<class LocalView , class Node , class NodeVector , class MaskRange , class Assign , REQUIRES(Concepts::LocalView< LocalView >) , REQUIRES(Concepts::BasisNode< Node >) >
void scatter (LocalView const &localView, Node const &node, NodeVector const &localVector, MaskRange const &mask, Assign assign)
 Insert a block of values into the vector (add or overwrite to existing values) More...
 
template<class LocalView , class Node , class NodeVector , class Assign , REQUIRES(Concepts::LocalView< LocalView >) , REQUIRES(Concepts::BasisNode< Node >) >
void scatter (LocalView const &localView, Node const &node, NodeVector const &localVector, Assign assign)
 Call scatter with MaskRange set to FakeContainer.
 
template<class LocalView , class LocalVector , class Assign , REQUIRES(Concepts::LocalView< LocalView >) >
void scatter (LocalView const &localView, LocalVector const &localVector, Assign assign)
 Call scatter with Node given by the tree of the localView.
 
template<class Index , class Buffer , REQUIRES(Concepts::MultiIndex< Index >) >
void scatter (std::vector< Index > const &indices, Buffer const &values)
 Call scatter the values associated to the indices into the vector.
 
template<class LocalInd , class Func >
void forEach (LocalInd const &localInd, Func &&func)
 Apply func to each value at given indices localInd. More...
 
template<class LocalInd , class Func >
void forEach (LocalInd const &localInd, Func &&func) const
 Apply func to each value at given indices localInd. More...
 

Detailed Description

template<class T, template< class > class VectorImpl>
class AMDiS::VectorFacade< T, VectorImpl >

The basic container that stores a base vector and a corresponding basis.

A vector storing all the assembled Operators indexed with DOF indices. The vector data is associated to a global basis.

Template Parameters
TThe coefficient type of the vector
VectorImplA linear-algebra backend for the vector storage

Constructor & Destructor Documentation

◆ VectorFacade()

VectorFacade ( GlobalBasis const &  basis)
inline

Constructor. Forwards the basis to the implementation class and constructs a (type-erased) size-info object.

References VectorFacade< T, VectorImpl >::resizeZero().

Member Function Documentation

◆ forEach() [1/2]

void forEach ( LocalInd const &  localInd,
Func &&  func 
)
inline

Apply func to each value at given indices localInd.

First, synchronizes the values of the vector, then applies the functor to each local value associated to the local indices localInd.

[[mutable]]

◆ forEach() [2/2]

void forEach ( LocalInd const &  localInd,
Func &&  func 
) const
inline

Apply func to each value at given indices localInd.

First, synchronizes the values of the vector, then applies the functor to each local value associated to the local indices localInd.

[[const]]

◆ gather()

void gather ( LocalView const &  localView,
Node const &  node,
Buffer &  buffer 
) const
inline

Extract values from the vector referring to the given local indices and store it into a buffer.

Collect value of indices and store them into a buffer. The buffer must be a vector-like container with buffer.resize() and buffer.begin(). The indices must be stored in an iterable container.

If the vector is not in synchronized state, collects all necessary values possibly from neighbouring processors.

[[expects: localView is bound to an element]] [[expects: node is in localView.tree()]] [[possibly neighbor-wise collective operation]]

◆ init()

void init ( Basis const &  basis,
bool  clear 
)
inline

Prepare the vector for insertion of values, finish the insertion with finish().

Referenced by VectorFacade< T, VectorImpl >::resize(), and VectorFacade< T, VectorImpl >::resizeZero().

◆ insert()

void insert ( Index const &  idx,
typename Impl::value_type const &  value,
Assign  assign = {} 
)
inline

Insert a single value into the matrix (add or overwrite to existing value)

Inserts or adds a value into a certain location dof (given as dof multi-index) of a vector. The insertion mode is determined by the assign functor. Use Assigner::plus_assign for adding values (default) or Assigner::assign for overwriting (setting) values. Different insertion modes can not be mixed!

Insertion must be closed with a call to finish().

[[not collective]]

Referenced by VectorFacade< T, VectorImpl >::add(), and VectorFacade< T, VectorImpl >::set().

◆ scatter()

void scatter ( LocalView const &  localView,
Node const &  node,
NodeVector const &  localVector,
MaskRange const &  mask,
Assign  assign 
)
inline

Insert a block of values into the vector (add or overwrite to existing values)

Inserts or adds values into certain locations of a vector. Insertion indices are extracted from the given localView. The insertion mode is determined by the assign functor. Use Assigner::plus_assign for adding values (default) or Assigner::assign for overwriting (setting) values. Different insertion modes can not be mixed! The localVector is assumed to be a continuous memory container with a data() method to get a pointer to the beginning.

The mask models a boolean range with at least a begin() method. Must be forward iterable for at least localVector.size() elements. Does not need an end() method. See, e.g. FakeContainer.

Insertion must be closed with a call to finish(). It is not allowed to switch insertion mode before calling finish().

[[expects: localView is bound to an element]] [[expects: node is in localView.tree()]] [[not collective]]

Referenced by VectorFacade< T, VectorImpl >::scatter().


The documentation for this class was generated from the following file: