OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
oofem::DynCompRow Class Reference

Implementation of sparse matrix stored in compressed column storage. More...

#include <dyncomprow.h>

+ Inheritance diagram for oofem::DynCompRow:
+ Collaboration diagram for oofem::DynCompRow:

Public Member Functions

 DynCompRow (int n)
 Constructor. More...
 
 DynCompRow ()
 Constructor. More...
 
 DynCompRow (const DynCompRow &S)
 Copy constructor. More...
 
DynCompRowoperator= (const DynCompRow &C)
 Assignment operator. More...
 
virtual ~DynCompRow ()
 Destructor. More...
 
SparseMtrxGiveCopy () const
 Returns a newly allocated copy of receiver. More...
 
virtual void times (const FloatArray &x, FloatArray &answer) const
 Evaluates $ y = A \cdot x $. More...
 
virtual void timesT (const FloatArray &x, FloatArray &answer) const
 Evaluates $ y = A^{\mathrm{T}} \cdot x $. More...
 
virtual void times (double x)
 Multiplies receiver by scalar value. More...
 
virtual int buildInternalStructure (EngngModel *, int, const UnknownNumberingScheme &)
 Builds internal structure of receiver. More...
 
virtual int assemble (const IntArray &loc, const FloatMatrix &mat)
 Assembles sparse matrix from contribution of local elements. More...
 
virtual int assemble (const IntArray &rloc, const IntArray &cloc, const FloatMatrix &mat)
 Assembles sparse matrix from contribution of local elements. More...
 
virtual bool canBeFactorized () const
 Determines, whether receiver can be factorized. More...
 
virtual void zero ()
 Zeroes the receiver. More...
 
virtual const char * giveClassName () const
 
virtual SparseMtrxType giveType () const
 Sparse matrix type identification. More...
 
virtual bool isAsymmetric () const
 Returns true if asymmetric. More...
 
virtual void printStatistics () const
 Prints the receiver statistics (one-line) to stdout. More...
 
virtual double & at (int i, int j)
 Returns coefficient at position (i,j). More...
 
virtual double at (int i, int j) const
 Returns coefficient at position (i,j). More...
 
void ILUPYourself (int part_fill=5, double drop_tol=1.e-8)
 Performs LU factorization on yourself; modifies receiver This routine computes the L and U factors of the ILU(p). More...
 
void ILUPsolve (const FloatArray &x, FloatArray &y) const
 
void ILUPtrans_solve (const FloatArray &x, FloatArray &y) const
 
const IntArraycol_ind (int i) const
 Returns col index for i-th row. More...
 
const FloatArrayrow (int i) const
 Returns row values. More...
 
- Public Member Functions inherited from oofem::SparseMtrx
 SparseMtrx (int n, int m)
 Constructor, creates (n,m) sparse matrix. More...
 
 SparseMtrx ()
 Constructor. More...
 
virtual ~SparseMtrx ()
 Destructor. More...
 
SparseMtrxVersionType giveVersion ()
 Return receiver version. More...
 
void checkBounds (int i, int j) const
 Checks size of receiver towards requested bounds. More...
 
int giveNumberOfRows () const
 Returns number of rows of receiver. More...
 
int giveNumberOfColumns () const
 Returns number of columns of receiver. More...
 
bool isSquare () const
 Returns nonzero if receiver is square matrix. More...
 
bool isNotEmpty () const
 Tests for empty matrix. More...
 
virtual void times (const FloatMatrix &B, FloatMatrix &answer) const
 Evaluates $ C = A^{\mathrm{T}} \cdot B $. More...
 
virtual void timesT (const FloatMatrix &B, FloatMatrix &answer) const
 Evaluates $ C = A^{\mathrm{T}} \cdot B $. More...
 
virtual void add (double x, SparseMtrx &m)
 Adds x * m. More...
 
virtual void addDiagonal (double x, FloatArray &m)
 Adds x * m (treats m as a diagonal matrix, stored as an array) More...
 
virtual int buildInternalStructure (EngngModel *eModel, int n, int m, const IntArray &I, const IntArray &J)
 Builds internal structure of receiver based on I and J. More...
 
virtual int buildInternalStructure (EngngModel *eModel, int di, const UnknownNumberingScheme &r_s, const UnknownNumberingScheme &c_s)
 Build internal structure of receiver. More...
 
virtual int assembleBegin ()
 Starts assembling the elements. More...
 
virtual int assembleEnd ()
 Returns when assemble is completed. More...
 
virtual SparseMtrxfactorized ()
 Returns the receiver factorized. More...
 
virtual FloatArraybackSubstitutionWith (FloatArray &y) const
 Computes the solution of linear system $ A\cdot x = y $ where A is receiver. More...
 
virtual double computeNorm () const
 Returns the norm of receiver. More...
 
virtual SparseMtrxgiveSubMatrix (const IntArray &rows, const IntArray &cols)
 
virtual bool isAllocatedAt (int i, int j) const
 Checks whether memory is allocated at position (i,j). More...
 
virtual void toFloatMatrix (FloatMatrix &answer) const
 Converts receiving sparse matrix to a dense float matrix. More...
 
virtual void printYourself () const
 Prints receiver to stdout. Works only for relatively small matrices. More...
 
virtual void writeToFile (const char *fname) const
 Helpful for debugging, writes the matrix to given file. More...
 
std::string errorInfo (const char *func) const
 Error printing helper. More...
 
FloatArray operator* (const FloatArray &x) const
 IML compatibility, $ A \cdot x$. More...
 
FloatArray trans_mult (const FloatArray &x) const
 IML compatibility, $ A^{\mathrm{T}} \cdot x$. More...
 

Protected Member Functions

double operator() (int i, int j) const
 implements 0-based access More...
 
double & operator() (int i, int j)
 implements 0-based access More...
 
int giveColIndx (int row, int col) const
 returns the column index of given column at given row, else returns zero. More...
 
int insertColInRow (int row, int col)
 insert column entry into row, preserving order of column indexes, returns the index of new row. More...
 
void checkSizeTowards (IntArray &)
 
void checkSizeTowards (const IntArray &rloc, const IntArray &cloc)
 
void growTo (int)
 
void qsortRow (IntArray &ind, IntArray &ir, FloatArray &val, int l, int r)
 
int qsortRowPartition (IntArray &ind, IntArray &ir, FloatArray &val, int l, int r)
 

Protected Attributes

FloatArray ** rows_
 
IntArray ** colind_
 
IntArray diag_rowptr_
 
int base_
 
- Protected Attributes inherited from oofem::SparseMtrx
int nRows
 Number of rows. More...
 
int nColumns
 Number of columns. More...
 
SparseMtrxVersionType version
 Allows to track if receiver changes. More...
 

Additional Inherited Members

- Public Types inherited from oofem::SparseMtrx
typedef long SparseMtrxVersionType
 

Detailed Description

Implementation of sparse matrix stored in compressed column storage.

Designed to allow simple dynamic runtime grow of receiver.

Definition at line 57 of file dyncomprow.h.

Constructor & Destructor Documentation

oofem::DynCompRow::DynCompRow ( int  n)

Constructor.

Before any operation an internal profile must be built.

See also
builInternalStructure

Definition at line 63 of file dyncomprow.C.

References colind_, oofem::SparseMtrx::nColumns, oofem::SparseMtrx::nRows, and rows_.

oofem::DynCompRow::DynCompRow ( void  )

Constructor.

Before any operation an internal profile must be built.

See also
builInternalStructure

Definition at line 56 of file dyncomprow.C.

References colind_, and rows_.

Referenced by GiveCopy().

oofem::DynCompRow::DynCompRow ( const DynCompRow S)

Copy constructor.

Definition at line 76 of file dyncomprow.C.

References colind_, oofem::SparseMtrx::nColumns, oofem::SparseMtrx::nRows, rows_, and oofem::SparseMtrx::version.

oofem::DynCompRow::~DynCompRow ( )
virtual

Destructor.

Definition at line 104 of file dyncomprow.C.

References colind_, oofem::SparseMtrx::nRows, and rows_.

Member Function Documentation

int oofem::DynCompRow::assemble ( const IntArray loc,
const FloatMatrix mat 
)
virtual

Assembles sparse matrix from contribution of local elements.

This method for each element adds its contribution to itself. Mapping between local element contribution and its global position is given by local code numbers of element.

Parameters
locLocation array. The values corresponding to zero loc array value are not assembled.
matContribution to be assembled using loc array.
Returns
Zero iff successful.

Implements oofem::SparseMtrx.

Definition at line 321 of file dyncomprow.C.

References at(), oofem::IntArray::at(), oofem::FloatMatrix::at(), oofem::FloatMatrix::giveNumberOfRows(), oofem::IntArray::giveSize(), OOFEM_ERROR, and oofem::SparseMtrx::version.

int oofem::DynCompRow::assemble ( const IntArray rloc,
const IntArray cloc,
const FloatMatrix mat 
)
virtual

Assembles sparse matrix from contribution of local elements.

This method for each element adds its contribution to itself. Mapping between local element contribution and its global position is given by row and column local code numbers.

Parameters
rlocRow location array. The values corresponding to zero loc array value are not assembled.
clocColumn location array. The values corresponding to zero loc array value are not assembled.
matContribution to be assembled using rloc and cloc arrays. The rloc position determines the row, the cloc position determines the corresponding column.
Returns
Zero iff successful.

Implements oofem::SparseMtrx.

Definition at line 352 of file dyncomprow.C.

References oofem::FloatArray::at(), oofem::IntArray::giveSize(), insertColInRow(), rows_, and oofem::SparseMtrx::version.

double & oofem::DynCompRow::at ( int  i,
int  j 
)
virtual

Returns coefficient at position (i,j).

Implements oofem::SparseMtrx.

Definition at line 406 of file dyncomprow.C.

References oofem::FloatArray::at(), giveColIndx(), OOFEM_ERROR, rows_, and oofem::SparseMtrx::version.

Referenced by assemble(), giveColIndx(), ILUPsolve(), ILUPtrans_solve(), ILUPYourself(), insertColInRow(), times(), and timesT().

double oofem::DynCompRow::at ( int  i,
int  j 
) const
virtual

Returns coefficient at position (i,j).

Implements oofem::SparseMtrx.

Definition at line 421 of file dyncomprow.C.

References oofem::FloatArray::at(), giveColIndx(), oofem::SparseMtrx::nColumns, oofem::SparseMtrx::nRows, OOFEM_ERROR, and rows_.

int oofem::DynCompRow::buildInternalStructure ( EngngModel eModel,
int  di,
const UnknownNumberingScheme s 
)
virtual

Builds internal structure of receiver.

This method determines the internal profile of sparse matrix, allocates necessary space for storing nonzero coefficients and initializes receiver. In general, the profile of sparse matrix is determined using one (or more) loop over local code numbers of elements. This method must be called before any operation, like assembly, zeroing, or multiplication.

Parameters
eModelPointer to corresponding engineering model.
diDomain index specify which domain to use.
sDetermines unknown numbering scheme.
Returns
Zero iff successful.

Implements oofem::SparseMtrx.

Definition at line 218 of file dyncomprow.C.

References oofem::IntArray::at(), colind_, oofem::Timer::getUtime(), oofem::Domain::giveBcs(), oofem::EngngModel::giveDomain(), oofem::Domain::giveElements(), oofem::ActiveBoundaryCondition::giveLocationArrays(), oofem::EngngModel::giveNumberOfDomainEquations(), oofem::IntArray::giveSize(), insertColInRow(), oofem::SparseMtrx::nColumns, oofem::SparseMtrx::nRows, OOFEM_LOG_DEBUG, rows_, oofem::Timer::startTimer(), oofem::Timer::stopTimer(), and oofem::SparseMtrx::version.

virtual bool oofem::DynCompRow::canBeFactorized ( ) const
inlinevirtual

Determines, whether receiver can be factorized.

Implements oofem::SparseMtrx.

Definition at line 91 of file dyncomprow.h.

void oofem::DynCompRow::checkSizeTowards ( IntArray loc)
protected

Definition at line 489 of file dyncomprow.C.

References oofem::IntArray::giveSize(), growTo(), insertColInRow(), and oofem::max().

void oofem::DynCompRow::checkSizeTowards ( const IntArray rloc,
const IntArray cloc 
)
protected

Definition at line 514 of file dyncomprow.C.

References oofem::IntArray::giveSize(), growTo(), insertColInRow(), and oofem::max().

const IntArray* oofem::DynCompRow::col_ind ( int  i) const
inline

Returns col index for i-th row.

Definition at line 112 of file dyncomprow.h.

virtual const char* oofem::DynCompRow::giveClassName ( ) const
inlinevirtual

Implements oofem::SparseMtrx.

Definition at line 93 of file dyncomprow.h.

int oofem::DynCompRow::giveColIndx ( int  row,
int  col 
) const
protected

returns the column index of given column at given row, else returns zero.

Definition at line 569 of file dyncomprow.C.

References at(), colind_, oofem::IntArray::giveSize(), and row().

Referenced by at(), ILUPYourself(), and operator()().

SparseMtrx * oofem::DynCompRow::GiveCopy ( ) const
virtual

Returns a newly allocated copy of receiver.

Programmer must take care about proper deallocation of allocated space.

Returns
Newly allocated copy of receiver.

Reimplemented from oofem::SparseMtrx.

Definition at line 178 of file dyncomprow.C.

References DynCompRow().

virtual SparseMtrxType oofem::DynCompRow::giveType ( ) const
inlinevirtual

Sparse matrix type identification.

Implements oofem::SparseMtrx.

Definition at line 94 of file dyncomprow.h.

References oofem::SMT_DynCompRow.

void oofem::DynCompRow::growTo ( int  ns)
protected

Definition at line 546 of file dyncomprow.C.

References colind_, oofem::SparseMtrx::nColumns, oofem::SparseMtrx::nRows, and rows_.

Referenced by checkSizeTowards().

void oofem::DynCompRow::ILUPsolve ( const FloatArray x,
FloatArray y 
) const
void oofem::DynCompRow::ILUPtrans_solve ( const FloatArray x,
FloatArray y 
) const
int oofem::DynCompRow::insertColInRow ( int  row,
int  col 
)
protected

insert column entry into row, preserving order of column indexes, returns the index of new row.

Definition at line 604 of file dyncomprow.C.

References at(), oofem::IntArray::at(), oofem::FloatArray::at(), colind_, DynCompRow_CHUNK, oofem::IntArray::giveSize(), oofem::IntArray::resizeWithValues(), oofem::FloatArray::resizeWithValues(), row(), and rows_.

Referenced by assemble(), buildInternalStructure(), and checkSizeTowards().

virtual bool oofem::DynCompRow::isAsymmetric ( ) const
inlinevirtual

Returns true if asymmetric.

Implements oofem::SparseMtrx.

Definition at line 95 of file dyncomprow.h.

double oofem::DynCompRow::operator() ( int  i,
int  j 
) const
protected

implements 0-based access

Definition at line 436 of file dyncomprow.C.

References oofem::FloatArray::at(), giveColIndx(), oofem::SparseMtrx::nColumns, oofem::SparseMtrx::nRows, OOFEM_ERROR, and rows_.

double & oofem::DynCompRow::operator() ( int  i,
int  j 
)
protected

implements 0-based access

Definition at line 451 of file dyncomprow.C.

References oofem::FloatArray::at(), giveColIndx(), OOFEM_ERROR, rows_, and oofem::SparseMtrx::version.

DynCompRow & oofem::DynCompRow::operator= ( const DynCompRow C)

Assignment operator.

Definition at line 131 of file dyncomprow.C.

References base_, colind_, oofem::SparseMtrx::nColumns, oofem::SparseMtrx::nRows, rows_, and oofem::SparseMtrx::version.

void oofem::DynCompRow::printStatistics ( ) const
virtual

Prints the receiver statistics (one-line) to stdout.

Reimplemented from oofem::SparseMtrx.

Definition at line 391 of file dyncomprow.C.

References oofem::FloatArray::giveSize(), oofem::SparseMtrx::nRows, and rows_.

void oofem::DynCompRow::qsortRow ( IntArray ind,
IntArray ir,
FloatArray val,
int  l,
int  r 
)
protected

Definition at line 1072 of file dyncomprow.C.

References qsortRowPartition().

Referenced by ILUPYourself().

int oofem::DynCompRow::qsortRowPartition ( IntArray ind,
IntArray ir,
FloatArray val,
int  l,
int  r 
)
protected

Definition at line 1085 of file dyncomprow.C.

Referenced by qsortRow().

const FloatArray* oofem::DynCompRow::row ( int  i) const
inline

Returns row values.

Definition at line 114 of file dyncomprow.h.

Referenced by giveColIndx(), and insertColInRow().

void oofem::DynCompRow::times ( const FloatArray x,
FloatArray answer 
) const
virtual

Evaluates $ y = A \cdot x $.

Parameters
xArray to be multiplied with receiver.
answery.

Reimplemented from oofem::SparseMtrx.

Definition at line 185 of file dyncomprow.C.

References at(), oofem::FloatArray::at(), colind_, oofem::FloatArray::giveSize(), oofem::SparseMtrx::nColumns, oofem::SparseMtrx::nRows, OOFEM_ERROR, oofem::FloatArray::resize(), rows_, and oofem::FloatArray::zero().

void oofem::DynCompRow::times ( double  x)
virtual

Multiplies receiver by scalar value.

Parameters
xValue to multiply receiver.

Reimplemented from oofem::SparseMtrx.

Definition at line 208 of file dyncomprow.C.

References oofem::SparseMtrx::nRows, rows_, oofem::FloatArray::times(), and oofem::SparseMtrx::version.

void oofem::DynCompRow::timesT ( const FloatArray x,
FloatArray answer 
) const
virtual

Evaluates $ y = A^{\mathrm{T}} \cdot x $.

Parameters
xArray to be multiplied with transpose of the receiver.
answery.

Reimplemented from oofem::SparseMtrx.

Definition at line 466 of file dyncomprow.C.

References at(), oofem::FloatArray::at(), colind_, oofem::FloatArray::giveSize(), oofem::SparseMtrx::nColumns, oofem::SparseMtrx::nRows, OOFEM_ERROR, oofem::FloatArray::resize(), rows_, and oofem::FloatArray::zero().

void oofem::DynCompRow::zero ( )
virtual

Zeroes the receiver.

Implements oofem::SparseMtrx.

Definition at line 380 of file dyncomprow.C.

References oofem::SparseMtrx::nRows, rows_, oofem::SparseMtrx::version, and oofem::FloatArray::zero().

Member Data Documentation

int oofem::DynCompRow::base_
protected

Definition at line 65 of file dyncomprow.h.

Referenced by operator=().

IntArray oofem::DynCompRow::diag_rowptr_
protected

Definition at line 63 of file dyncomprow.h.

Referenced by ILUPsolve(), ILUPtrans_solve(), and ILUPYourself().


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

This page is part of the OOFEM documentation. Copyright (c) 2011 Borek Patzak
Project e-mail: info@oofem.org
Generated at Tue Jan 2 2018 20:07:35 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011