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

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

#include <dyncompcol.h>

+ Inheritance diagram for oofem::DynCompCol:
+ Collaboration diagram for oofem::DynCompCol:

Public Member Functions

 DynCompCol (int n)
 Constructor. More...
 
 DynCompCol ()
 Constructor. More...
 
 DynCompCol (const DynCompCol &S)
 Copy constructor. More...
 
DynCompColoperator= (const DynCompCol &C)
 Assignment operator. More...
 
virtual ~DynCompCol ()
 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 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...
 
virtual void printStatistics () const
 Prints the receiver statistics (one-line) to stdout. More...
 
const IntArrayrow_ind (int i) const
 Returns row index for i-th column. More...
 
const FloatArraycolumn (int i) const
 Returns column 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 giveRowIndx (int col, int row) const
 Returns the row index of given row at given column, else returns zero. More...
 
int insertRowInColumn (int col, int row)
 Insert row entry into column, preserving order of row indexes, returns the index of new row. More...
 
void checkSizeTowards (IntArray &)
 
void checkSizeTowards (const IntArray &rloc, const IntArray &cloc)
 
void growTo (int)
 

Protected Attributes

FloatArray ** columns_
 
IntArray ** rowind_
 
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 62 of file dyncompcol.h.

Constructor & Destructor Documentation

oofem::DynCompCol::DynCompCol ( int  n)

Constructor.

Before any operation an internal profile must be built.

See also
builInternalStructure

Definition at line 61 of file dyncompcol.C.

References columns_, oofem::SparseMtrx::nColumns, oofem::SparseMtrx::nRows, and rowind_.

oofem::DynCompCol::DynCompCol ( void  )

Constructor.

Before any operation an internal profile must be built.

See also
builInternalStructure

Definition at line 50 of file dyncompcol.C.

References columns_, and rowind_.

Referenced by GiveCopy().

oofem::DynCompCol::DynCompCol ( const DynCompCol S)

Copy constructor.

Definition at line 78 of file dyncompcol.C.

References columns_, oofem::SparseMtrx::nColumns, oofem::SparseMtrx::nRows, rowind_, and oofem::SparseMtrx::version.

oofem::DynCompCol::~DynCompCol ( )
virtual

Destructor.

Definition at line 120 of file dyncompcol.C.

References columns_, oofem::SparseMtrx::nColumns, and rowind_.

Member Function Documentation

int oofem::DynCompCol::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 379 of file dyncompcol.C.

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

int oofem::DynCompCol::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.

optimized low-end implementation

Implements oofem::SparseMtrx.

Definition at line 411 of file dyncompcol.C.

References oofem::FloatArray::at(), columns_, oofem::IntArray::giveSize(), insertRowInColumn(), and oofem::SparseMtrx::version.

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

Returns coefficient at position (i,j).

Implements oofem::SparseMtrx.

Definition at line 542 of file dyncompcol.C.

References oofem::FloatArray::at(), columns_, giveRowIndx(), OOFEM_ERROR, and oofem::SparseMtrx::version.

Referenced by assemble(), giveRowIndx(), insertRowInColumn(), times(), and timesT().

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

Returns coefficient at position (i,j).

Implements oofem::SparseMtrx.

Definition at line 569 of file dyncompcol.C.

References oofem::FloatArray::at(), columns_, giveRowIndx(), oofem::SparseMtrx::nRows, and OOFEM_ERROR.

int oofem::DynCompCol::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 281 of file dyncompcol.C.

References columns_, oofem::Domain::giveBcs(), oofem::EngngModel::giveDomain(), oofem::Domain::giveElements(), oofem::ActiveBoundaryCondition::giveLocationArrays(), oofem::EngngModel::giveNumberOfDomainEquations(), oofem::IntArray::giveSize(), insertRowInColumn(), oofem::SparseMtrx::nColumns, oofem::SparseMtrx::nRows, OOFEM_LOG_DEBUG, rowind_, and oofem::SparseMtrx::version.

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

Determines, whether receiver can be factorized.

Implements oofem::SparseMtrx.

Definition at line 99 of file dyncompcol.h.

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

Definition at line 712 of file dyncompcol.C.

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

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

Definition at line 740 of file dyncompcol.C.

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

const FloatArray* oofem::DynCompCol::column ( int  i) const
inline

Returns column values.

Definition at line 115 of file dyncompcol.h.

Referenced by oofem::CompCol_ILUPreconditioner::initialize().

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

Implements oofem::SparseMtrx.

Definition at line 101 of file dyncompcol.h.

SparseMtrx * oofem::DynCompCol::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 221 of file dyncompcol.C.

References DynCompCol().

int oofem::DynCompCol::giveRowIndx ( int  col,
int  row 
) const
protected

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

Definition at line 804 of file dyncompcol.C.

References at(), oofem::IntArray::giveSize(), and rowind_.

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

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

Sparse matrix type identification.

Implements oofem::SparseMtrx.

Definition at line 102 of file dyncompcol.h.

References oofem::SMT_DynCompCol.

void oofem::DynCompCol::growTo ( int  ns)
protected
int oofem::DynCompCol::insertRowInColumn ( int  col,
int  row 
)
protected

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

Definition at line 839 of file dyncompcol.C.

References oofem::IntArray::at(), at(), oofem::FloatArray::at(), columns_, DynCompCol_CHUNK, oofem::IntArray::giveSize(), oofem::IntArray::resizeWithValues(), oofem::FloatArray::resizeWithValues(), and rowind_.

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

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

Returns true if asymmetric.

Implements oofem::SparseMtrx.

Definition at line 103 of file dyncompcol.h.

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

Implements 0-based access.

Definition at line 607 of file dyncompcol.C.

References oofem::FloatArray::at(), columns_, giveRowIndx(), oofem::SparseMtrx::nRows, and OOFEM_ERROR.

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

Implements 0-based access.

Definition at line 645 of file dyncompcol.C.

References oofem::FloatArray::at(), columns_, giveRowIndx(), OOFEM_ERROR, and oofem::SparseMtrx::version.

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

Assignment operator.

Definition at line 161 of file dyncompcol.C.

References base_, columns_, oofem::SparseMtrx::nColumns, oofem::SparseMtrx::nRows, rowind_, and oofem::SparseMtrx::version.

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

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

Reimplemented from oofem::SparseMtrx.

Definition at line 522 of file dyncompcol.C.

References oofem::IntArray::giveSize(), oofem::SparseMtrx::nColumns, OOFEM_LOG_DEBUG, and rowind_.

const IntArray* oofem::DynCompCol::row_ind ( int  i) const
inline

Returns row index for i-th column.

Definition at line 113 of file dyncompcol.h.

Referenced by oofem::CompCol_ILUPreconditioner::initialize().

void oofem::DynCompCol::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 227 of file dyncompcol.C.

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

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

Multiplies receiver by scalar value.

Parameters
xValue to multiply receiver.

Reimplemented from oofem::SparseMtrx.

Definition at line 261 of file dyncompcol.C.

References columns_, oofem::SparseMtrx::nColumns, oofem::FloatArray::times(), and oofem::SparseMtrx::version.

void oofem::DynCompCol::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 674 of file dyncompcol.C.

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

void oofem::DynCompCol::zero ( )
virtual

Zeroes the receiver.

Implements oofem::SparseMtrx.

Definition at line 503 of file dyncompcol.C.

References columns_, oofem::SparseMtrx::nColumns, oofem::SparseMtrx::version, and oofem::FloatArray::zero().

Member Data Documentation

int oofem::DynCompCol::base_
protected

Definition at line 73 of file dyncompcol.h.

Referenced by operator=().

FloatArray* * oofem::DynCompCol::columns_
protected
IntArray** oofem::DynCompCol::rowind_
protected

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