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

#include <SF_abstract_matrix.h>

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

Public Member Functions

virtual ~abstract_matrix ()=default
 
virtual void init (T iNRows, T iNCols, T ilrows, T ilcols, T loc_offset, T mxent)
 
void init (const meshdata< mesh_int_t, mesh_real_t > &imesh, const T irow_dpn, const T icol_dpn, const T max_edges)
 
const meshdata< mesh_int_t, mesh_real_t > * mesh_ptr () const
 
int dpn_row () const
 
int dpn_col () const
 
virtual void zero ()=0
 
virtual void mult (const abstract_vector< T, S > &x, abstract_vector< T, S > &b) const =0
 
virtual void mult_LR (const abstract_vector< T, S > &L, const abstract_vector< T, S > &R)=0
 
virtual void diag_add (const abstract_vector< T, S > &diag)=0
 
virtual void get_diagonal (abstract_vector< T, S > &vec) const =0
 
virtual void finish_assembly ()=0
 
virtual void scale (S s)=0
 
virtual void add_scaled_matrix (const abstract_matrix< T, S > &A, const S s, const bool same_nnz)=0
 
virtual void duplicate (const abstract_matrix< T, S > &M)=0
 
virtual void set_values (const vector< T > &row_idx, const vector< T > &col_idx, const vector< S > &vals, bool add)=0
 
virtual void set_values (const vector< T > &row_idx, const vector< T > &col_idx, const S *vals, bool add)=0
 
virtual void set_value (T row_idx, T col_idx, S val, bool add)=0
 
void get_values (const vector< T > &row_idx, const vector< T > &col_idx, vector< S > &values) const
 
virtual S get_value (SF_int row_idx, SF_int col_idx) const =0
 
virtual void write (const char *filename) const =0
 
bool equals (const abstract_matrix< T, S > &rhs) const
 
std::string to_string () const
 

Protected Member Functions

 abstract_matrix ()
 

Protected Attributes

const meshdata< mesh_int_t, mesh_real_t > * mesh
 pointer to the associated mesh More...
 
int NRows
 global number of rows More...
 
int NCols
 global number of cols More...
 
int row_dpn
 row dpn More...
 
int col_dpn
 col dpn More...
 
int lsize
 size of local matrix (#locally stored rows) More...
 
int start
 start row index of local matrix portion More...
 
int stop
 stio row index of local matrix portion More...
 

Detailed Description

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

FEM matrix class.

It connects a mesh with a sparse matrix.

Template Parameters
TInteger type (indices).
SFloating point type (values).
See also
ginkgo_matrix
petsc_matrix

Definition at line 44 of file SF_abstract_matrix.h.

Constructor & Destructor Documentation

◆ abstract_matrix()

template<class T, class S>
SF::abstract_matrix< T, S >::abstract_matrix ( )
inlineprotected

Default constructor.

Definition at line 48 of file SF_abstract_matrix.h.

◆ ~abstract_matrix()

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

Default destructor

Member Function Documentation

◆ add_scaled_matrix()

template<class T, class S>
virtual void SF::abstract_matrix< T, S >::add_scaled_matrix ( const abstract_matrix< T, S > &  A,
const S  s,
const bool  same_nnz 
)
pure virtual

Compute M += sA

Parameters
AThe matrix to scale and add into this matrix.
sThe scalar to scale the matrix A with.
same_nnzWhether A and this matrix share the same nonzero pattern.
Here is the caller graph for this function:

◆ diag_add()

template<class T, class S>
virtual void SF::abstract_matrix< T, S >::diag_add ( const abstract_vector< T, S > &  diag)
pure virtual

Add values to the diagonal of this matrix.

Parameters
diagThe values to add to the diagonal.
Here is the caller graph for this function:

◆ dpn_col()

template<class T, class S>
int SF::abstract_matrix< T, S >::dpn_col ( ) const
inline

Get the number of col d.o.f per mesh node

Returns
the number of col d.o.f per mesh node

Definition at line 153 of file SF_abstract_matrix.h.

Here is the caller graph for this function:

◆ dpn_row()

template<class T, class S>
int SF::abstract_matrix< T, S >::dpn_row ( ) const
inline

Get the number of row d.o.f per mesh node

Returns
the number of row d.o.f per mesh node

Definition at line 146 of file SF_abstract_matrix.h.

Here is the caller graph for this function:

◆ duplicate()

template<class T, class S>
virtual void SF::abstract_matrix< T, S >::duplicate ( const abstract_matrix< T, S > &  M)
pure virtual

Duplicate the matrix M into this matrix.

Parameters
MThe duplicated matrix.
Here is the caller graph for this function:

◆ equals()

template<class T, class S>
bool SF::abstract_matrix< T, S >::equals ( const abstract_matrix< T, S > &  rhs) const
inline

Check equality between this matrix and another.

Parameters
rhsThe other matrix.
Returns
whether this matrix and rhs are equal.
Note
This function is a sequential implementation and iterates over the matrix and can be slow.

Definition at line 300 of file SF_abstract_matrix.h.

◆ finish_assembly()

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

Mark assembly as being finished.

Here is the caller graph for this function:

◆ get_diagonal()

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

Store the diagonal values of this martix in a vector.

Parameters
vecThe output vector containing the matrix's diagonal.
Here is the caller graph for this function:

◆ get_value()

template<class T, class S>
virtual S SF::abstract_matrix< T, S >::get_value ( SF_int  row_idx,
SF_int  col_idx 
) const
pure virtual

Get a single value of the matrix.

Parameters
row_idxThe requested row index.
col_idxThe requested column index.
Returns
the requested value.
Here is the caller graph for this function:

◆ get_values()

template<class T, class S>
void SF::abstract_matrix< T, S >::get_values ( const vector< T > &  row_idx,
const vector< T > &  col_idx,
vector< S > &  values 
) const
inline

Extract values of the matrix at specified indices.

Parameters
row_idxThe requested row indices.
col_idxThe requested column indices.
valuesThe returned values of the matrix.
Note
This function is a sequential implementation and iterates over the matrix and can be slow.

Definition at line 264 of file SF_abstract_matrix.h.

◆ init() [1/2]

template<class T, class S>
virtual void SF::abstract_matrix< T, S >::init ( iNRows,
iNCols,
ilrows,
ilcols,
loc_offset,
mxent 
)
inlinevirtual

Initialize a matrix with the requested sizes.

Parameters
iNRowsglobal number of rows
iNColsglobal number of cols
ilrowslocal number of rows
ilcolslocal number of cols
loc_offsetoffset of local partition in parallel layout
mxentmaximum expected number of entries per row

Definition at line 86 of file SF_abstract_matrix.h.

Here is the caller graph for this function:

◆ init() [2/2]

template<class T, class S>
void SF::abstract_matrix< T, S >::init ( const meshdata< mesh_int_t, mesh_real_t > &  imesh,
const T  irow_dpn,
const T  icol_dpn,
const T  max_edges 
)
inline

Initialize a matrix dimensions based on a given mesh.

Parameters
imeshmesh we associated to matrix
irow_dpnrow dpn
icol_dpncol dpn
max_edgesmax number of edges, if -1 max edges will be computed on the fly

Definition at line 105 of file SF_abstract_matrix.h.

◆ mesh_ptr()

template<class T, class S>
const meshdata<mesh_int_t, mesh_real_t>* SF::abstract_matrix< T, S >::mesh_ptr ( ) const
inline

Get the associated mesh pointer.

Returns
the associated mesh pointer.

Definition at line 136 of file SF_abstract_matrix.h.

Here is the caller graph for this function:

◆ mult()

template<class T, class S>
virtual void SF::abstract_matrix< T, S >::mult ( const abstract_vector< T, S > &  x,
abstract_vector< T, S > &  b 
) const
pure virtual

Multiply this matrix with x and store the result in b (compute b := M x).

Parameters
xvector x to multiply this matrix with
boutput vector
Here is the caller graph for this function:

◆ mult_LR()

template<class T, class S>
virtual void SF::abstract_matrix< T, S >::mult_LR ( const abstract_vector< T, S > &  L,
const abstract_vector< T, S > &  R 
)
pure virtual

Scales the matrix on the left and right using diagonal matrices stored as vectors (compute M := L M R).

Parameters
Lleft diagonal matrix used for scaling
Rright diagonal matrix used for scaling
Here is the caller graph for this function:

◆ scale()

template<class T, class S>
virtual void SF::abstract_matrix< T, S >::scale ( s)
pure virtual

Scale the matrix with a scalar.

Parameters
sThe scalar to scale the matrix with.
Here is the caller graph for this function:

◆ set_value()

template<class T, class S>
virtual void SF::abstract_matrix< T, S >::set_value ( row_idx,
col_idx,
val,
bool  add 
)
pure virtual

Overwrite or add one value into this matrix.

Parameters
row_idxThe row index.
col_idxThe column index.
valThe value to set.
addWhether to add the value into this matrix or overwrite.
Here is the caller graph for this function:

◆ set_values() [1/2]

template<class T, class S>
virtual void SF::abstract_matrix< T, S >::set_values ( const vector< T > &  row_idx,
const vector< T > &  col_idx,
const vector< S > &  vals,
bool  add 
)
pure virtual

Overwrite or add the values into this matrix.

Parameters
row_idxThe row indices.
col_idxThe column indices.
valsThe values to set.
addWhether to add the values into this matrix or overwrite.
Note
finish_assembly() needs to be called after all calls to this function.
Here is the caller graph for this function:

◆ set_values() [2/2]

template<class T, class S>
virtual void SF::abstract_matrix< T, S >::set_values ( const vector< T > &  row_idx,
const vector< T > &  col_idx,
const S *  vals,
bool  add 
)
pure virtual

Overwrite or add the values into this matrix.

Parameters
row_idxThe row indices.
col_idxThe column indices.
valsThe values to set.
addWhether to add the values into this matrix or overwrite.
Note
finish_assembly() needs to be called after all calls to this function.

◆ to_string()

template<class T, class S>
std::string SF::abstract_matrix< T, S >::to_string ( ) const
inline

A string format for the current matrix.

Returns
a string format for the current matrix.

Definition at line 319 of file SF_abstract_matrix.h.

◆ write()

template<class T, class S>
virtual void SF::abstract_matrix< T, S >::write ( const char *  filename) const
pure virtual

Writes the matrix to a file.

Parameters
filenameThe file to write to.
Here is the caller graph for this function:

◆ zero()

template<class T, class S>
virtual void SF::abstract_matrix< T, S >::zero ( )
pure virtual

Zero matrix values.

Here is the caller graph for this function:

Member Data Documentation

◆ col_dpn

template<class T, class S>
int SF::abstract_matrix< T, S >::col_dpn
protected

col dpn

Definition at line 65 of file SF_abstract_matrix.h.

◆ lsize

template<class T, class S>
int SF::abstract_matrix< T, S >::lsize
protected

size of local matrix (#locally stored rows)

Definition at line 67 of file SF_abstract_matrix.h.

◆ mesh

template<class T, class S>
const meshdata<mesh_int_t, mesh_real_t>* SF::abstract_matrix< T, S >::mesh
protected

pointer to the associated mesh

Definition at line 60 of file SF_abstract_matrix.h.

◆ NCols

template<class T, class S>
int SF::abstract_matrix< T, S >::NCols
protected

global number of cols

Definition at line 63 of file SF_abstract_matrix.h.

◆ NRows

template<class T, class S>
int SF::abstract_matrix< T, S >::NRows
protected

global number of rows

Definition at line 62 of file SF_abstract_matrix.h.

◆ row_dpn

template<class T, class S>
int SF::abstract_matrix< T, S >::row_dpn
protected

row dpn

Definition at line 64 of file SF_abstract_matrix.h.

◆ start

template<class T, class S>
int SF::abstract_matrix< T, S >::start
protected

start row index of local matrix portion

Definition at line 68 of file SF_abstract_matrix.h.

◆ stop

template<class T, class S>
int SF::abstract_matrix< T, S >::stop
protected

stio row index of local matrix portion

Definition at line 69 of file SF_abstract_matrix.h.


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