openCARP
Doxygen code documentation for the open cardiac electrophysiology simulator openCARP
Public Types | Public Member Functions | Public Attributes | List of all members
SF::abstract_vector< T, S > Class Template Referenceabstract

#include <SF_abstract_vector.h>

Collaboration diagram for SF::abstract_vector< T, S >:

Public Types

enum  ltype { algebraic, nodal, elemwise, unset }
 

Public Member Functions

virtual ~abstract_vector ()=default
 
virtual void init (const meshdata< mesh_int_t, mesh_real_t > &imesh, int idpn, ltype inp_layout)=0
 
virtual void init (const abstract_vector< T, S > &vec)=0
 
virtual void init (int igsize, int ilsize, int idpn=1, ltype ilayout=unset)=0
 
std::tuple< int, int > init_common (const meshdata< mesh_int_t, mesh_real_t > &imesh, int idpn, ltype inp_layout)
 
virtual void set (const vector< T > &idx, const vector< S > &vals, const bool additive=false)=0
 
virtual void set (const vector< T > &idx, const S val)=0
 
virtual void set (const S val)=0
 
virtual void set (const T idx, const S val)=0
 
virtual void get (const vector< T > &idx, S *out)=0
 
virtual S get (const T idx)=0
 
virtual void operator*= (const S sca)=0
 
virtual void operator/= (const S sca)=0
 
virtual void operator*= (const abstract_vector< T, S > &vec)=0
 
virtual void add_scaled (const abstract_vector< T, S > &vec, S k)=0
 
virtual void operator+= (const abstract_vector< T, S > &vec)=0
 
virtual void operator-= (const abstract_vector< T, S > &vec)=0
 
virtual void operator+= (S c)=0
 
virtual void operator= (const vector< S > &rhs)=0
 
virtual void operator= (const abstract_vector< T, S > &rhs)=0
 
virtual void shallow_copy (const abstract_vector< T, S > &v)=0
 
virtual void deep_copy (const abstract_vector< T, S > &v)=0
 
virtual void overshadow (const abstract_vector< T, S > &sub, bool member, int offset, int sz, bool share)=0
 
virtual T lsize () const =0
 
virtual T gsize () const =0
 
virtual void get_ownership_range (T &start, T &stop) const =0
 
virtual S * ptr ()=0
 
virtual const S * const_ptr () const =0
 
virtual void release_ptr (S *&p)=0
 
virtual void const_release_ptr (const S *&p) const =0
 
virtual S mag () const =0
 
virtual S sum () const =0
 
virtual S min () const =0
 
virtual S dot (const abstract_vector< T, S > &v) const =0
 
virtual bool is_init () const =0
 
virtual std::string to_string () const =0
 
virtual bool equals (const abstract_vector< T, S > &rhs) const =0
 
virtual void finish_assembly ()=0
 
virtual void forward (abstract_vector< T, S > &out, scattering &sc, bool add=false)=0
 
virtual void backward (abstract_vector< T, S > &out, scattering &sc, bool add=false)=0
 
virtual void apply_scattering (scattering &sc, bool fwd)=0
 
size_t write_ascii (const char *file, bool write_header)
 
template<typename V >
size_t write_binary (FILE *fd)
 Write a vector to HD in binary. File descriptor is already set up. More...
 
template<typename V >
size_t write_binary (std::string file)
 write binary. Open file descriptor myself. More...
 
template<typename V >
size_t read_binary (FILE *fd)
 
template<typename V >
size_t read_binary (std::string file)
 
size_t read_ascii (FILE *fd)
 
size_t read_ascii (std::string file)
 

Public Attributes

const meshdata< mesh_int_t, mesh_real_t > * mesh = NULL
 the connected mesh More...
 
int dpn = 0
 d.o.f. per mesh vertex. More...
 
ltype layout = unset
 used vector layout (nodal, algebraic, unset) More...
 

Detailed Description

template<class T, class S>
class SF::abstract_vector< T, S >

An abstract class representing a (possibly distributed) vector.

It is connected to a mesh and offers some convenience features w.r.t. setup and function calls. This is an interface definition, for concrete implementations see the petsc_vector or ginkgo_vector classes.

Template Parameters
TInteger type (indices).
SFloating point type (values).
See also
ginkgo_vector
petsc_vector

Definition at line 54 of file SF_abstract_vector.h.

Member Enumeration Documentation

◆ ltype

template<class T, class S>
enum SF::abstract_vector::ltype

Enumeration of layout types for the vector

Enumerator
algebraic 
nodal 
elemwise 
unset 

Definition at line 59 of file SF_abstract_vector.h.

Constructor & Destructor Documentation

◆ ~abstract_vector()

template<class T, class S>
virtual SF::abstract_vector< T, S >::~abstract_vector ( )
virtualdefault

Default destructor

Member Function Documentation

◆ add_scaled()

template<class T, class S>
virtual void SF::abstract_vector< T, S >::add_scaled ( const abstract_vector< T, S > &  vec,
k 
)
pure virtual

Adds vec scaled by k to this vector (i.e., BLAS axpy).

Parameters
vecThe second vector to scale and multiply this vector with.
kThe scalar.
Here is the caller graph for this function:

◆ apply_scattering()

template<class T, class S>
virtual void SF::abstract_vector< T, S >::apply_scattering ( scattering sc,
bool  fwd 
)
pure virtual

Apply the scattering sc to this vector.

Parameters
scThe scattering class.
fwdUse forward or backwdard scattering.
Here is the caller graph for this function:

◆ backward()

template<class T, class S>
virtual void SF::abstract_vector< T, S >::backward ( abstract_vector< T, S > &  out,
scattering sc,
bool  add = false 
)
pure virtual

Backward scattering. This object is input (from).

Parameters
outScatter to.
scThe scattering class.
addUse additive scattering or overwrite.
Here is the caller graph for this function:

◆ const_ptr()

template<class T, class S>
virtual const S* SF::abstract_vector< T, S >::const_ptr ( ) const
pure virtual

Get a const host pointer to the local data. Use const_release_ptr when done.

Returns
a const host pointer to the local data.
See also
const_release_ptr
Here is the caller graph for this function:

◆ const_release_ptr()

template<class T, class S>
virtual void SF::abstract_vector< T, S >::const_release_ptr ( const S *&  p) const
pure virtual

Release a const pointer to local data

Parameters
pthe const pointer to release
See also
const_ptr
Here is the caller graph for this function:

◆ deep_copy()

template<class T, class S>
virtual void SF::abstract_vector< T, S >::deep_copy ( const abstract_vector< T, S > &  v)
pure virtual

Deep copy into this vector from another abstract_vector.

Parameters
vThe vector to copy from.

: unify with operator= ?

Here is the caller graph for this function:

◆ dot()

template<class T, class S>
virtual S SF::abstract_vector< T, S >::dot ( const abstract_vector< T, S > &  v) const
pure virtual

Compute the dot product of this vector and the vector v.

Parameters
vThe other vector used in the dot product.
Returns
the dot product of this vector and the vector v.
Here is the caller graph for this function:

◆ equals()

template<class T, class S>
virtual bool SF::abstract_vector< T, S >::equals ( const abstract_vector< T, S > &  rhs) const
pure virtual

Whether the this vector and rhs are equal.

Returns
whether the this vector and rhs are equal.
Here is the caller graph for this function:

◆ finish_assembly()

template<class T, class S>
virtual void SF::abstract_vector< T, S >::finish_assembly ( )
pure virtual

Mark the assembly as finished.

Here is the caller graph for this function:

◆ forward()

template<class T, class S>
virtual void SF::abstract_vector< T, S >::forward ( abstract_vector< T, S > &  out,
scattering sc,
bool  add = false 
)
pure virtual

Forward scattering. This object is input (from).

Parameters
outScatter to.
scThe scattering class.
addUse additive scattering or overwrite.
Here is the caller graph for this function:

◆ get() [1/2]

template<class T, class S>
virtual void SF::abstract_vector< T, S >::get ( const vector< T > &  idx,
S *  out 
)
pure virtual

Get the values at the requested indices

Parameters
idxThe indices to get.
outThe values at the requested indices.
Here is the caller graph for this function:

◆ get() [2/2]

template<class T, class S>
virtual S SF::abstract_vector< T, S >::get ( const T  idx)
pure virtual

Get the value of one index

Parameters
idxThe index to get.
Returns
the requested value

◆ get_ownership_range()

template<class T, class S>
virtual void SF::abstract_vector< T, S >::get_ownership_range ( T &  start,
T &  stop 
) const
pure virtual

Get the range of indices owned by this processor.

Parameters
startthe first index owned.
stopone more than the last index owned.
Here is the caller graph for this function:

◆ gsize()

template<class T, class S>
virtual T SF::abstract_vector< T, S >::gsize ( ) const
pure virtual

Get the global size.

Returns
the global size.
Here is the caller graph for this function:

◆ init() [1/3]

template<class T, class S>
virtual void SF::abstract_vector< T, S >::init ( const meshdata< mesh_int_t, mesh_real_t > &  imesh,
int  idpn,
ltype  inp_layout 
)
pure virtual

Init the vector dimensions based on a give mesh.

Parameters
imeshThe mesh defining the parallel layout of the vector.
idpnThe number of d.o.f. per mesh vertex.
inp_layoutThe vector layout.

◆ init() [2/3]

template<class T, class S>
virtual void SF::abstract_vector< T, S >::init ( const abstract_vector< T, S > &  vec)
pure virtual

Initialize a vector from the setup of another given vector.

Parameters
vecVector to replicate the setup from.

◆ init() [3/3]

template<class T, class S>
virtual void SF::abstract_vector< T, S >::init ( int  igsize,
int  ilsize,
int  idpn = 1,
ltype  ilayout = unset 
)
pure virtual

Initialize a vector directly with set sizes.

Parameters
igsizeGlobal size
ilsizeLocal size
idpnNumber of d.o.f. used per mesh node
ilayoutVector layout w.r.t. used mesh.

◆ init_common()

template<class T, class S>
std::tuple<int, int> SF::abstract_vector< T, S >::init_common ( const meshdata< mesh_int_t, mesh_real_t > &  imesh,
int  idpn,
ltype  inp_layout 
)
inline

Non backend-specific vector initialization based on a mesh.

Parameters
imeshThe mesh defining the parallel layout of the vector.
idpnThe number of d.o.f. per mesh vertex.
inp_layoutThe vector layout.
Returns
a tuple with computed sizes N and n.

Definition at line 105 of file SF_abstract_vector.h.

◆ is_init()

template<class T, class S>
virtual bool SF::abstract_vector< T, S >::is_init ( ) const
pure virtual

Whether the vector is initialized.

Returns
whether the vector is initialized.
Here is the caller graph for this function:

◆ lsize()

template<class T, class S>
virtual T SF::abstract_vector< T, S >::lsize ( ) const
pure virtual

Get the local size.

Returns
the local size.
Here is the caller graph for this function:

◆ mag()

template<class T, class S>
virtual S SF::abstract_vector< T, S >::mag ( ) const
pure virtual

Compute the L2 norm of this vector.

Returns
the L2 norm of this vector.
Here is the caller graph for this function:

◆ min()

template<class T, class S>
virtual S SF::abstract_vector< T, S >::min ( ) const
pure virtual

Find the minimum value of this vector.

Returns
the minimum value of this vector.
Here is the caller graph for this function:

◆ operator*=() [1/2]

template<class T, class S>
virtual void SF::abstract_vector< T, S >::operator*= ( const S  sca)
pure virtual

Convenient operator overload to multiply the vector by a scalar.

Parameters
scaThe scalar to multiply the vector by.
Here is the caller graph for this function:

◆ operator*=() [2/2]

template<class T, class S>
virtual void SF::abstract_vector< T, S >::operator*= ( const abstract_vector< T, S > &  vec)
pure virtual

Convenient operator overload to multiply the vector by another.

Parameters
vecThe second vector to multiply this vector with.

◆ operator+=() [1/2]

template<class T, class S>
virtual void SF::abstract_vector< T, S >::operator+= ( const abstract_vector< T, S > &  vec)
pure virtual

Convenient operator overload to add the vector with another.

Parameters
vecThe second vector to add this vector with.
Here is the caller graph for this function:

◆ operator+=() [2/2]

template<class T, class S>
virtual void SF::abstract_vector< T, S >::operator+= ( c)
pure virtual

Convenient operator overload to add a scalar to this vector (vector shift).

Parameters
cThe scalar to add.

◆ operator-=()

template<class T, class S>
virtual void SF::abstract_vector< T, S >::operator-= ( const abstract_vector< T, S > &  vec)
pure virtual

Convenient operator overload to substract the vector by another.

Parameters
vecThe second vector to substract this vector with.
Here is the caller graph for this function:

◆ operator/=()

template<class T, class S>
virtual void SF::abstract_vector< T, S >::operator/= ( const S  sca)
pure virtual

Convenient operator overload to divide the vector by a scalar.

Parameters
scaThe scalar to divide the vector by.
Here is the caller graph for this function:

◆ operator=() [1/2]

template<class T, class S>
virtual void SF::abstract_vector< T, S >::operator= ( const vector< S > &  rhs)
pure virtual

Deep copy into this vector from a standard (CPU-based) vector.

Parameters
rhsThe vector to copy from.
Here is the caller graph for this function:

◆ operator=() [2/2]

template<class T, class S>
virtual void SF::abstract_vector< T, S >::operator= ( const abstract_vector< T, S > &  rhs)
pure virtual

Deep copy into this vector from another abstract_vector.

Parameters
rhsThe vector to copy from.

◆ overshadow()

template<class T, class S>
virtual void SF::abstract_vector< T, S >::overshadow ( const abstract_vector< T, S > &  sub,
bool  member,
int  offset,
int  sz,
bool  share 
)
pure virtual

Create a subvector which is defined on a superset of procs and has the same layout

Processes not part of the original owner set will have no data

Parameters
subthe vector on the subnodes
membertrue if the process is part of the original vector
offsetoffset of new vector into original
sznumber of entries to extract from original, -1=all
shareuse the same memory
Here is the caller graph for this function:

◆ ptr()

template<class T, class S>
virtual S* SF::abstract_vector< T, S >::ptr ( )
pure virtual

Get a host pointer to the local data. Use release_ptr when done.

Returns
a host pointer to the local data.
See also
release_ptr
Here is the caller graph for this function:

◆ read_ascii() [1/2]

template<class T, class S>
size_t SF::abstract_vector< T, S >::read_ascii ( FILE *  fd)
inline

Definition at line 607 of file SF_abstract_vector.h.

Here is the caller graph for this function:

◆ read_ascii() [2/2]

template<class T, class S>
size_t SF::abstract_vector< T, S >::read_ascii ( std::string  file)
inline

Definition at line 618 of file SF_abstract_vector.h.

◆ read_binary() [1/2]

template<class T, class S>
template<typename V >
size_t SF::abstract_vector< T, S >::read_binary ( FILE *  fd)
inline

Definition at line 559 of file SF_abstract_vector.h.

Here is the caller graph for this function:

◆ read_binary() [2/2]

template<class T, class S>
template<typename V >
size_t SF::abstract_vector< T, S >::read_binary ( std::string  file)
inline

Definition at line 578 of file SF_abstract_vector.h.

◆ release_ptr()

template<class T, class S>
virtual void SF::abstract_vector< T, S >::release_ptr ( S *&  p)
pure virtual

Release a pointer to local data

Parameters
pthe pointer to release
See also
ptr
Here is the caller graph for this function:

◆ set() [1/4]

template<class T, class S>
virtual void SF::abstract_vector< T, S >::set ( const vector< T > &  idx,
const vector< S > &  vals,
const bool  additive = false 
)
pure virtual

Set the vector values.

Parameters
idxThe global indices where to set.
valsThe values to set.
additiveWhether to add into the current values or overwrite them.
Here is the caller graph for this function:

◆ set() [2/4]

template<class T, class S>
virtual void SF::abstract_vector< T, S >::set ( const vector< T > &  idx,
const S  val 
)
pure virtual

Set the specified vector indices to one value.

Parameters
idxThe indices where to set.
valThe value to set.

◆ set() [3/4]

template<class T, class S>
virtual void SF::abstract_vector< T, S >::set ( const S  val)
pure virtual

Set the whole vector to one value.

Parameters
valThe value to set.

◆ set() [4/4]

template<class T, class S>
virtual void SF::abstract_vector< T, S >::set ( const T  idx,
const S  val 
)
pure virtual

Set one index to a specific value.

Parameters
idxThe index to be set.
valThe value to set.
Note
Caution: repetitive use of this function can be very inefficient!

◆ shallow_copy()

template<class T, class S>
virtual void SF::abstract_vector< T, S >::shallow_copy ( const abstract_vector< T, S > &  v)
pure virtual

Shallow copy into this vector from another abstract_vector.

I.e., copy the internal pointers only.

Parameters
vThe vector to copy from.
Here is the caller graph for this function:

◆ sum()

template<class T, class S>
virtual S SF::abstract_vector< T, S >::sum ( ) const
pure virtual

Compute the sum of elements of this vector.

Returns
the sum of elements of this vector.
Here is the caller graph for this function:

◆ to_string()

template<class T, class S>
virtual std::string SF::abstract_vector< T, S >::to_string ( ) const
pure virtual

A string format for the current vector.

Returns
a string format for the current vector.
Here is the caller graph for this function:

◆ write_ascii()

template<class T, class S>
size_t SF::abstract_vector< T, S >::write_ascii ( const char *  file,
bool  write_header 
)
inline

Write the vector to a file

Parameters
fileThe file to write to.
write_headerWhether to write the header as well
Returns
the number of characters written.

Definition at line 436 of file SF_abstract_vector.h.

Here is the caller graph for this function:

◆ write_binary() [1/2]

template<class T, class S>
template<typename V >
size_t SF::abstract_vector< T, S >::write_binary ( FILE *  fd)
inline

Write a vector to HD in binary. File descriptor is already set up.

File descriptor is not closed by this function.

Parameters
fdThe already set up file descriptor.

Definition at line 510 of file SF_abstract_vector.h.

Here is the caller graph for this function:

◆ write_binary() [2/2]

template<class T, class S>
template<typename V >
size_t SF::abstract_vector< T, S >::write_binary ( std::string  file)
inline

write binary. Open file descriptor myself.

Definition at line 530 of file SF_abstract_vector.h.

Member Data Documentation

◆ dpn

template<class T, class S>
int SF::abstract_vector< T, S >::dpn = 0

d.o.f. per mesh vertex.

Definition at line 62 of file SF_abstract_vector.h.

◆ layout

template<class T, class S>
ltype SF::abstract_vector< T, S >::layout = unset

used vector layout (nodal, algebraic, unset)

Definition at line 63 of file SF_abstract_vector.h.

◆ mesh

template<class T, class S>
const meshdata<mesh_int_t,mesh_real_t>* SF::abstract_vector< T, S >::mesh = NULL

the connected mesh

Definition at line 61 of file SF_abstract_vector.h.


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