Memosa-FVM  0.2
CRMatrixTranspose< T_Coeff, X, B > Class Template Reference

#include <CRMatrixTranspose.h>

Inheritance diagram for CRMatrixTranspose< T_Coeff, X, B >:
Collaboration diagram for CRMatrixTranspose< T_Coeff, X, B >:

Public Types

typedef T_Coeff Coeff
 
typedef Array< CoeffCoeffArray
 
typedef Array< X > XArray
 
typedef Array< B > BArray
 

Public Member Functions

 CRMatrixTranspose (const CRConnectivity &conn)
 
template<class X2 , class B2 >
 CRMatrixTranspose (const CRMatrixTranspose< Coeff, X2, B2 > &m)
 
 DEFINE_TYPENAME ("CRMatrixTranspose<"+NumTypeTraits< Coeff >::getTypeName()+","+NumTypeTraits< X >::getTypeName()+","+NumTypeTraits< B >::getTypeName()+">")
 
virtual void initAssembly ()
 
virtual void multiply (IContainer &yB, const IContainer &xB) const
 
virtual void multiplyAndAdd (IContainer &yB, const IContainer &xB) const
 
const CRConnectivitygetConnectivity () const
 
Array< Coeff > & getCoeff ()
 
const Array< Coeff > & getCoeff () const
 
shared_ptr< Array< Coeff > > getCoeffPtr () const
 
- Public Member Functions inherited from Matrix
 Matrix ()
 
virtual ~Matrix ()
 
 DEFINE_TYPENAME ("Matrix")
 
virtual shared_ptr< ArrayBasequadProduct (const IContainer &xB) const
 
virtual void forwardGS (IContainer &xB, IContainer &bB, IContainer &residual) const
 
virtual void reverseGS (IContainer &xB, IContainer &bB, IContainer &residual) const
 
virtual void Jacobi (IContainer &xnew, const IContainer &xold, const IContainer &b) const
 
virtual void iluSolve (IContainer &xB, const IContainer &bB, const IContainer &residual) const
 
virtual void spikeSolve (IContainer &xB, const IContainer &bB, const IContainer &residual, const SpikeStorage &spike_storage) const
 
virtual void solveBoundary (IContainer &xB, IContainer &bB, IContainer &residual) const
 
virtual void computeResidual (const IContainer &xB, const IContainer &bB, IContainer &residual) const
 
virtual int createCoarsening (IContainer &coarseIndex, const int groupSize, const double weighRatioThreshold)
 
virtual void eliminateBoundaryEquations (IContainer &xB)
 
virtual void printRow (const int nr) const
 
virtual void * getDiagData () const
 
virtual void * getOffDiagData () const
 
virtual int getDiagDataSize () const
 
virtual int getOffDiagDataSize () const
 
virtual shared_ptr< MatrixcreateMergeMatrix (const LinearSystemMerger &mergeLS)
 
virtual void setFlatMatrix (Matrix &fmg) const
 
virtual void transpose ()
 
virtual shared_ptr
< CRConnectivity
createCoarseConnectivity (const IContainer &coarseIndex, const CRConnectivity &coarseToFine, const StorageSite &coarseRowSite, const StorageSite &coarseColSite)
 
virtual shared_ptr< MatrixcreateCoarseMatrix (const IContainer &coarseIndex, const CRConnectivity &coarseToFine, const CRConnectivity &coarseConnectivity)
 
virtual bool isInvertible ()
 

Private Attributes

const CRConnectivity_conn
 
const Array< int > & _row
 
const Array< int > & _col
 
shared_ptr< Array< Coeff > > _coeffPtr
 
Array< Coeff > & _coeff
 

Detailed Description

template<class T_Coeff, class X, class B>
class CRMatrixTranspose< T_Coeff, X, B >

This class is similar to CRMatrix except that it stores the transpose of the matrix implied by the CRConnectivity object that is given to it. This is useful in situations like node to cell interpolation matrix where the connectivity we have is cell to nodes but the matrix we want is one which stores the weights of node to cell interpolation. In such cases we can create a matrix of this class using the cell to node connectivity but use it in a multiplication operation with the cell value array to get the node value array. It is also very useful for ib faces since storing ib face to cell (or ib face to particle) connectivity is a lot cheaper than the transpose.

The class is templated with the types of coefficient, x and b arrays as template parameters. Since the primary use of this class is for storing interpolation matrices from one site to another we have a special constructor that can create a CRMatrixTranspose object of the same Coeff type but different X and B (e.g. to interpolate vector variables). For this reason the coeff is stored as a shared_ptr.

Definition at line 41 of file CRMatrixTranspose.h.

Member Typedef Documentation

template<class T_Coeff, class X, class B>
typedef Array<B> CRMatrixTranspose< T_Coeff, X, B >::BArray

Definition at line 47 of file CRMatrixTranspose.h.

template<class T_Coeff, class X, class B>
typedef T_Coeff CRMatrixTranspose< T_Coeff, X, B >::Coeff

Definition at line 44 of file CRMatrixTranspose.h.

template<class T_Coeff, class X, class B>
typedef Array<Coeff> CRMatrixTranspose< T_Coeff, X, B >::CoeffArray

Definition at line 45 of file CRMatrixTranspose.h.

template<class T_Coeff, class X, class B>
typedef Array<X> CRMatrixTranspose< T_Coeff, X, B >::XArray

Definition at line 46 of file CRMatrixTranspose.h.

Constructor & Destructor Documentation

template<class T_Coeff, class X, class B>
CRMatrixTranspose< T_Coeff, X, B >::CRMatrixTranspose ( const CRConnectivity conn)
inline

Definition at line 50 of file CRMatrixTranspose.h.

References logCtor.

50  :
51  Matrix(),
52  _conn(conn),
53  _row(_conn.getRow()),
54  _col(_conn.getCol()),
57  {
58  logCtor();
59  }
const Array< int > & getCol() const
const Array< int > & getRow() const
const Array< int > & _col
Matrix()
Definition: Matrix.cpp:8
#define logCtor()
Definition: RLogInterface.h:26
shared_ptr< Array< Coeff > > _coeffPtr
Array< Coeff > & _coeff
const Array< int > & _row
Array< Coeff > CoeffArray
const CRConnectivity & _conn
int getLength() const
Definition: Array.h:87
template<class T_Coeff, class X, class B>
template<class X2 , class B2 >
CRMatrixTranspose< T_Coeff, X, B >::CRMatrixTranspose ( const CRMatrixTranspose< Coeff, X2, B2 > &  m)
inline

Definition at line 65 of file CRMatrixTranspose.h.

References logCtor.

65  :
66  Matrix(),
68  _row(_conn.getRow()),
69  _col(_conn.getCol()),
72  {
73  logCtor();
74  }
const Array< int > & getCol() const
const Array< int > & getRow() const
const Array< int > & _col
shared_ptr< Array< Coeff > > getCoeffPtr() const
Matrix()
Definition: Matrix.cpp:8
#define logCtor()
Definition: RLogInterface.h:26
const CRConnectivity & getConnectivity() const
shared_ptr< Array< Coeff > > _coeffPtr
Array< Coeff > & _coeff
const Array< int > & _row
const CRConnectivity & _conn

Member Function Documentation

template<class T_Coeff, class X, class B>
CRMatrixTranspose< T_Coeff, X, B >::DEFINE_TYPENAME ( "CRMatrixTranspose<"+NumTypeTraits< Coeff >::getTypeName()+","+NumTypeTraits< X >::getTypeName()+","+NumTypeTraits< B >::getTypeName()+">"  )
template<class T_Coeff, class X, class B>
Array<Coeff>& CRMatrixTranspose< T_Coeff, X, B >::getCoeff ( )
inline

Definition at line 123 of file CRMatrixTranspose.h.

References CRMatrixTranspose< T_Coeff, X, B >::_coeff.

123 {return _coeff;}
Array< Coeff > & _coeff
template<class T_Coeff, class X, class B>
const Array<Coeff>& CRMatrixTranspose< T_Coeff, X, B >::getCoeff ( ) const
inline

Definition at line 124 of file CRMatrixTranspose.h.

References CRMatrixTranspose< T_Coeff, X, B >::_coeff.

124 {return _coeff;}
Array< Coeff > & _coeff
template<class T_Coeff, class X, class B>
shared_ptr<Array<Coeff> > CRMatrixTranspose< T_Coeff, X, B >::getCoeffPtr ( ) const
inline

Definition at line 125 of file CRMatrixTranspose.h.

References CRMatrixTranspose< T_Coeff, X, B >::_coeffPtr.

125 {return _coeffPtr;}
shared_ptr< Array< Coeff > > _coeffPtr
template<class T_Coeff, class X, class B>
const CRConnectivity& CRMatrixTranspose< T_Coeff, X, B >::getConnectivity ( ) const
inlinevirtual

Reimplemented from Matrix.

Definition at line 121 of file CRMatrixTranspose.h.

References CRMatrixTranspose< T_Coeff, X, B >::_conn.

121 {return _conn;}
const CRConnectivity & _conn
template<class T_Coeff, class X, class B>
virtual void CRMatrixTranspose< T_Coeff, X, B >::initAssembly ( )
inlinevirtual

Implements Matrix.

Definition at line 83 of file CRMatrixTranspose.h.

References CRMatrixTranspose< T_Coeff, X, B >::_coeff, and Array< T >::zero().

84  {
85  _coeff.zero();
86  }
virtual void zero()
Definition: Array.h:281
Array< Coeff > & _coeff
template<class T_Coeff, class X, class B>
virtual void CRMatrixTranspose< T_Coeff, X, B >::multiply ( IContainer yB,
const IContainer xB 
) const
inlinevirtual

y = this * x

Reimplemented from Matrix.

Definition at line 93 of file CRMatrixTranspose.h.

References CRMatrixTranspose< T_Coeff, X, B >::multiplyAndAdd(), and IContainer::zero().

94  {
95  yB.zero();
96  this->multiplyAndAdd(yB,xB);
97  }
virtual void multiplyAndAdd(IContainer &yB, const IContainer &xB) const
virtual void zero()=0
template<class T_Coeff, class X, class B>
virtual void CRMatrixTranspose< T_Coeff, X, B >::multiplyAndAdd ( IContainer yB,
const IContainer xB 
) const
inlinevirtual

y += this * x

Reimplemented from Matrix.

Definition at line 104 of file CRMatrixTranspose.h.

References CRMatrixTranspose< T_Coeff, X, B >::_coeff, CRMatrixTranspose< T_Coeff, X, B >::_col, CRMatrixTranspose< T_Coeff, X, B >::_conn, CRMatrixTranspose< T_Coeff, X, B >::_row, StorageSite::getCount(), and CRConnectivity::getRowSite().

Referenced by CRMatrixTranspose< T_Coeff, X, B >::multiply().

105  {
106  BArray& y = dynamic_cast<BArray&>(yB);
107  const XArray& x = dynamic_cast<const XArray&>(xB);
108 
109  const int nRows = _conn.getRowSite().getCount();
110  for(int nr=0; nr<nRows; nr++)
111  {
112  for (int nb = _row[nr]; nb<_row[nr+1]; nb++)
113  {
114  const int j = _col[nb];
115  y[nr] += _coeff[nb]*x[j];
116  }
117  }
118  }
const Array< int > & _col
Array< Coeff > & _coeff
int getCount() const
Definition: StorageSite.h:39
const Array< int > & _row
const CRConnectivity & _conn
const StorageSite & getRowSite() const

Member Data Documentation

template<class T_Coeff, class X, class B>
Array<Coeff>& CRMatrixTranspose< T_Coeff, X, B >::_coeff
private
template<class T_Coeff, class X, class B>
shared_ptr<Array<Coeff> > CRMatrixTranspose< T_Coeff, X, B >::_coeffPtr
private
template<class T_Coeff, class X, class B>
const Array<int>& CRMatrixTranspose< T_Coeff, X, B >::_col
private
template<class T_Coeff, class X, class B>
const CRConnectivity& CRMatrixTranspose< T_Coeff, X, B >::_conn
private
template<class T_Coeff, class X, class B>
const Array<int>& CRMatrixTranspose< T_Coeff, X, B >::_row
private

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