OOFEM
2.4
OOFEM.org - Object Oriented Finite Element Solver
|
Implementation of sparse matrix stored in compressed column storage. More...
#include <dyncomprow.h>
Public Member Functions | |
DynCompRow (int n) | |
Constructor. More... | |
DynCompRow () | |
Constructor. More... | |
DynCompRow (const DynCompRow &S) | |
Copy constructor. More... | |
DynCompRow & | operator= (const DynCompRow &C) |
Assignment operator. More... | |
virtual | ~DynCompRow () |
Destructor. More... | |
SparseMtrx * | GiveCopy () const |
Returns a newly allocated copy of receiver. More... | |
virtual void | times (const FloatArray &x, FloatArray &answer) const |
Evaluates . More... | |
virtual void | timesT (const FloatArray &x, FloatArray &answer) const |
Evaluates . 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 IntArray * | col_ind (int i) const |
Returns col index for i-th row. More... | |
const FloatArray * | row (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 . More... | |
virtual void | timesT (const FloatMatrix &B, FloatMatrix &answer) const |
Evaluates . 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 SparseMtrx * | factorized () |
Returns the receiver factorized. More... | |
virtual FloatArray * | backSubstitutionWith (FloatArray &y) const |
Computes the solution of linear system where A is receiver. More... | |
virtual double | computeNorm () const |
Returns the norm of receiver. More... | |
virtual SparseMtrx * | giveSubMatrix (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, . More... | |
FloatArray | trans_mult (const FloatArray &x) const |
IML compatibility, . 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 |
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.
oofem::DynCompRow::DynCompRow | ( | int | n | ) |
Constructor.
Before any operation an internal profile must be built.
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.
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.
|
virtual |
Destructor.
Definition at line 104 of file dyncomprow.C.
References colind_, oofem::SparseMtrx::nRows, and rows_.
|
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.
loc | Location array. The values corresponding to zero loc array value are not assembled. |
mat | Contribution to be assembled using loc array. |
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.
|
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.
rloc | Row location array. The values corresponding to zero loc array value are not assembled. |
cloc | Column location array. The values corresponding to zero loc array value are not assembled. |
mat | Contribution to be assembled using rloc and cloc arrays. The rloc position determines the row, the cloc position determines the corresponding column. |
Implements oofem::SparseMtrx.
Definition at line 352 of file dyncomprow.C.
References oofem::FloatArray::at(), oofem::IntArray::giveSize(), insertColInRow(), rows_, and oofem::SparseMtrx::version.
|
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().
|
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_.
|
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.
eModel | Pointer to corresponding engineering model. |
di | Domain index specify which domain to use. |
s | Determines unknown numbering scheme. |
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.
|
inlinevirtual |
Determines, whether receiver can be factorized.
Implements oofem::SparseMtrx.
Definition at line 91 of file dyncomprow.h.
|
protected |
Definition at line 489 of file dyncomprow.C.
References oofem::IntArray::giveSize(), growTo(), insertColInRow(), and oofem::max().
Definition at line 514 of file dyncomprow.C.
References oofem::IntArray::giveSize(), growTo(), insertColInRow(), and oofem::max().
|
inline |
Returns col index for i-th row.
Definition at line 112 of file dyncomprow.h.
|
inlinevirtual |
Implements oofem::SparseMtrx.
Definition at line 93 of file dyncomprow.h.
|
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()().
|
virtual |
Returns a newly allocated copy of receiver.
Programmer must take care about proper deallocation of allocated space.
Reimplemented from oofem::SparseMtrx.
Definition at line 178 of file dyncomprow.C.
References DynCompRow().
|
inlinevirtual |
Sparse matrix type identification.
Implements oofem::SparseMtrx.
Definition at line 94 of file dyncomprow.h.
References oofem::SMT_DynCompRow.
|
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 |
Definition at line 970 of file dyncomprow.C.
References at(), oofem::FloatArray::at(), colind_, diag_rowptr_, oofem::FloatArray::giveSize(), oofem::FloatArray::resize(), rows_, and oofem::FloatArray::zero().
Referenced by oofem::CompRow_ILUPreconditioner::solve().
void oofem::DynCompRow::ILUPtrans_solve | ( | const FloatArray & | x, |
FloatArray & | y | ||
) | const |
Definition at line 1007 of file dyncomprow.C.
References at(), oofem::FloatArray::at(), colind_, diag_rowptr_, oofem::FloatArray::giveSize(), oofem::FloatArray::resize(), and rows_.
Referenced by oofem::CompRow_ILUPreconditioner::trans_solve().
void oofem::DynCompRow::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).
Definition at line 726 of file dyncomprow.C.
References at(), oofem::IntArray::at(), oofem::FloatArray::at(), colind_, diag_rowptr_, oofem::Timer::getUtime(), giveColIndx(), oofem::IntArray::giveSize(), oofem::FloatArray::giveSize(), ILU_ROW_CHUNK, oofem::SparseMtrx::nColumns, oofem::SparseMtrx::nRows, OOFEM_ERROR, OOFEM_LOG_DEBUG, qsortRow(), oofem::IntArray::resize(), oofem::FloatArray::resize(), oofem::IntArray::resizeWithValues(), oofem::FloatArray::resizeWithValues(), rows_, oofem::Timer::startTimer(), oofem::Timer::stopTimer(), and oofem::SparseMtrx::version.
|
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().
|
inlinevirtual |
Returns true if asymmetric.
Implements oofem::SparseMtrx.
Definition at line 95 of file dyncomprow.h.
|
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_.
|
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.
|
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_.
|
protected |
Definition at line 1072 of file dyncomprow.C.
References qsortRowPartition().
Referenced by ILUPYourself().
|
protected |
Definition at line 1085 of file dyncomprow.C.
Referenced by qsortRow().
|
inline |
Returns row values.
Definition at line 114 of file dyncomprow.h.
Referenced by giveColIndx(), and insertColInRow().
|
virtual |
Evaluates .
x | Array to be multiplied with receiver. |
answer | y. |
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().
|
virtual |
Multiplies receiver by scalar value.
x | Value 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.
|
virtual |
Evaluates .
x | Array to be multiplied with transpose of the receiver. |
answer | y. |
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().
|
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().
|
protected |
Definition at line 65 of file dyncomprow.h.
Referenced by operator=().
|
protected |
Definition at line 62 of file dyncomprow.h.
Referenced by buildInternalStructure(), DynCompRow(), giveColIndx(), growTo(), ILUPsolve(), ILUPtrans_solve(), ILUPYourself(), insertColInRow(), operator=(), times(), timesT(), and ~DynCompRow().
|
protected |
Definition at line 63 of file dyncomprow.h.
Referenced by ILUPsolve(), ILUPtrans_solve(), and ILUPYourself().
|
protected |
Definition at line 61 of file dyncomprow.h.
Referenced by assemble(), at(), buildInternalStructure(), DynCompRow(), growTo(), ILUPsolve(), ILUPtrans_solve(), ILUPYourself(), insertColInRow(), operator()(), operator=(), printStatistics(), times(), timesT(), zero(), and ~DynCompRow().