OOFEM 3.0
Loading...
Searching...
No Matches
oofem::CompCol Class Reference

#include <compcol.h>

Inheritance diagram for oofem::CompCol:
Collaboration diagram for oofem::CompCol:

Public Member Functions

 CompCol (int n=0)
 CompCol (const CompCol &S)
 Copy constructor.
CompColoperator= (const CompCol &C)
 Assignment operator.
virtual ~CompCol ()
 Destructor.
std::unique_ptr< SparseMtrxclone () const override
void times (const FloatArray &x, FloatArray &answer) const override
void timesT (const FloatArray &x, FloatArray &answer) const override
void times (double x) override
int buildInternalStructure (EngngModel *, int, const UnknownNumberingScheme &s) override
int assemble (const IntArray &loc, const FloatMatrix &mat) override
int assemble (const IntArray &rloc, const IntArray &cloc, const FloatMatrix &mat) override
bool canBeFactorized () const override
 Determines, whether receiver can be factorized.
void zero () override
 Zeroes the receiver.
double & at (int i, int j) override
 Returns coefficient at position (i,j).
double at (int i, int j) const override
 Returns coefficient at position (i,j).
void toFloatMatrix (FloatMatrix &answer) const override
 Converts receiving sparse matrix to a dense float matrix.
void printYourself () const override
 Prints receiver to stdout. Works only for relatively small matrices.
const char * giveClassName () const override
SparseMtrxType giveType () const override
 Sparse matrix type identification.
bool isAsymmetric () const override
 Returns true if asymmetric.
FloatArraygiveValues ()
IntArraygiveRowIndex ()
IntArraygiveColPtr ()
const int giveNumberOfNonzeros ()
const double & values (int i) const
const int & row_ind (int i) const
const int & col_ptr (int i) const
Public Member Functions inherited from oofem::SparseMtrx
 SparseMtrx (int n=0, int m=0)
virtual ~SparseMtrx ()
 Destructor.
SparseMtrxVersionType giveVersion ()
 Return receiver version.
void checkBounds (int i, int j) const
int giveNumberOfRows () const
 Returns number of rows of receiver.
int giveNumberOfColumns () const
 Returns number of columns of receiver.
bool isSquare () const
 Returns nonzero if receiver is square matrix.
bool isNotEmpty () const
 Tests for empty matrix.
virtual void times (const FloatMatrix &B, FloatMatrix &answer) const
virtual void timesT (const FloatMatrix &B, FloatMatrix &answer) const
virtual void add (double x, SparseMtrx &m)
virtual void addDiagonal (double x, FloatArray &m)
virtual int buildInternalStructure (EngngModel *eModel, int n, int m, const IntArray &I, const IntArray &J)
virtual int buildInternalStructure (EngngModel *eModel, int di, const UnknownNumberingScheme &r_s, const UnknownNumberingScheme &c_s)
virtual int assembleBegin ()
 Starts assembling the elements.
virtual int assembleEnd ()
 Returns when assemble is completed.
virtual SparseMtrxfactorized ()
virtual FloatArraybackSubstitutionWith (FloatArray &y) const
virtual double computeNorm () const
 Returns the norm of receiver.
virtual std::unique_ptr< SparseMtrxgiveSubMatrix (const IntArray &rows, const IntArray &cols)
virtual bool isAllocatedAt (int i, int j) const
 Checks whether memory is allocated at position (i,j).
virtual void printStatistics () const
 Prints the receiver statistics (one-line) to stdout.
virtual void writeToFile (const char *fname) const
 Helpful for debugging, writes the matrix to given file.
std::string errorInfo (const char *func) const
 Error printing helper.
FloatArray operator* (const FloatArray &x) const
 IML compatibility, \( A \cdot x\).
FloatArray trans_mult (const FloatArray &x) const
 IML compatibility, \( A^{\mathrm{T}} \cdot x\).

Protected Member Functions

double operator() (int i, int j) const
 implements 0-based access
double & operator() (int i, int j)
 implements 0-based access

Protected Attributes

FloatArray val
IntArray rowind
IntArray colptr
int base
int nz
Protected Attributes inherited from oofem::SparseMtrx
int nRows
 Number of rows.
int nColumns
 Number of columns.
SparseMtrxVersionType version

Additional Inherited Members

Public Types inherited from oofem::SparseMtrx
typedef long SparseMtrxVersionType

Detailed Description

Implementation of sparse matrix stored in compressed column storage.

Definition at line 84 of file compcol.h.

Constructor & Destructor Documentation

◆ CompCol() [1/2]

oofem::CompCol::CompCol ( int n = 0)

Constructor. Before any operation an internal profile must be built.

See also
buildInternalStructure

Definition at line 88 of file compcol.C.

References base, colptr, nz, rowind, oofem::SparseMtrx::SparseMtrx(), and val.

Referenced by CompCol(), operator=(), oofem::SymCompCol::SymCompCol(), and oofem::SymCompCol::SymCompCol().

◆ CompCol() [2/2]

oofem::CompCol::CompCol ( const CompCol & S)

Copy constructor.

Definition at line 97 of file compcol.C.

References base, colptr, CompCol(), oofem::SparseMtrx::nColumns, oofem::SparseMtrx::nRows, nz, rowind, S, oofem::SparseMtrx::SparseMtrx(), and val.

◆ ~CompCol()

virtual oofem::CompCol::~CompCol ( )
inlinevirtual

Destructor.

Definition at line 105 of file compcol.h.

Member Function Documentation

◆ assemble() [1/2]

int oofem::CompCol::assemble ( const IntArray & loc,
const FloatMatrix & mat )
overridevirtual

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.

Reimplemented in oofem::SymCompCol.

Definition at line 275 of file compcol.C.

References colptr, oofem::FloatMatrix::giveNumberOfRows(), oofem::IntArray::giveSize(), oofem::SparseMtrx::nRows, OOFEM_ERROR, rowind, val, and oofem::SparseMtrx::version.

◆ assemble() [2/2]

int oofem::CompCol::assemble ( const IntArray & rloc,
const IntArray & cloc,
const FloatMatrix & mat )
overridevirtual

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.

Reimplemented in oofem::SymCompCol.

Definition at line 318 of file compcol.C.

References colptr, oofem::FloatMatrix::giveNumberOfColumns(), oofem::FloatMatrix::giveNumberOfRows(), oofem::SparseMtrx::nRows, OOFEM_ERROR, rowind, val, and oofem::SparseMtrx::version.

◆ at() [1/2]

double oofem::CompCol::at ( int i,
int j ) const
overridevirtual

Returns coefficient at position (i,j).

Implements oofem::SparseMtrx.

Reimplemented in oofem::SymCompCol.

Definition at line 386 of file compcol.C.

References colptr, oofem::SparseMtrx::giveNumberOfColumns(), oofem::SparseMtrx::giveNumberOfRows(), OOFEM_ERROR, rowind, and val.

◆ at() [2/2]

double & oofem::CompCol::at ( int i,
int j )
overridevirtual

Returns coefficient at position (i,j).

Implements oofem::SparseMtrx.

Reimplemented in oofem::SymCompCol.

Definition at line 372 of file compcol.C.

References colptr, OOFEM_ERROR, rowind, val, and oofem::SparseMtrx::version.

◆ buildInternalStructure()

int oofem::CompCol::buildInternalStructure ( EngngModel * eModel,
int di,
const UnknownNumberingScheme & s )
overridevirtual

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.

Reimplemented in oofem::SymCompCol.

Definition at line 174 of file compcol.C.

References colptr, oofem::Domain::giveBcs(), oofem::EngngModel::giveDomain(), oofem::Domain::giveElement(), oofem::Domain::giveElements(), oofem::ActiveBoundaryCondition::giveLocationArrays(), oofem::EngngModel::giveNumberOfDomainEquations(), oofem::SparseMtrx::nColumns, oofem::SparseMtrx::nRows, nz, OOFEM_LOG_DEBUG, rowind, val, and oofem::SparseMtrx::version.

◆ canBeFactorized()

bool oofem::CompCol::canBeFactorized ( ) const
inlineoverridevirtual

Determines, whether receiver can be factorized.

Implements oofem::SparseMtrx.

Reimplemented in oofem::SymCompCol.

Definition at line 115 of file compcol.h.

◆ clone()

std::unique_ptr< SparseMtrx > oofem::CompCol::clone ( ) const
overridevirtual

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.

Reimplemented in oofem::SymCompCol.

Definition at line 122 of file compcol.C.

◆ col_ptr()

const int & oofem::CompCol::col_ptr ( int i) const
inline

◆ giveClassName()

const char * oofem::CompCol::giveClassName ( ) const
inlineoverridevirtual

Implements oofem::SparseMtrx.

Reimplemented in oofem::SymCompCol.

Definition at line 121 of file compcol.h.

◆ giveColPtr()

IntArray & oofem::CompCol::giveColPtr ( )
inline

◆ giveNumberOfNonzeros()

const int oofem::CompCol::giveNumberOfNonzeros ( )
inline

Definition at line 131 of file compcol.h.

References nz.

Referenced by oofem::SuperLUSolver::solve().

◆ giveRowIndex()

IntArray & oofem::CompCol::giveRowIndex ( )
inline

◆ giveType()

SparseMtrxType oofem::CompCol::giveType ( ) const
inlineoverridevirtual

Sparse matrix type identification.

Implements oofem::SparseMtrx.

Reimplemented in oofem::SymCompCol.

Definition at line 122 of file compcol.h.

References oofem::SMT_CompCol.

◆ giveValues()

FloatArray & oofem::CompCol::giveValues ( )
inline

◆ isAsymmetric()

bool oofem::CompCol::isAsymmetric ( ) const
inlineoverridevirtual

Returns true if asymmetric.

Implements oofem::SparseMtrx.

Reimplemented in oofem::SymCompCol.

Definition at line 123 of file compcol.h.

◆ operator()() [1/2]

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

implements 0-based access

Definition at line 418 of file compcol.C.

References colptr, OOFEM_ERROR, rowind, val, and oofem::SparseMtrx::version.

◆ operator()() [2/2]

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

implements 0-based access

Definition at line 402 of file compcol.C.

References colptr, oofem::SparseMtrx::giveNumberOfColumns(), oofem::SparseMtrx::giveNumberOfRows(), OOFEM_ERROR, rowind, and val.

◆ operator=()

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

Assignment operator.

Definition at line 106 of file compcol.C.

References base, colptr, CompCol(), oofem::SparseMtrx::nColumns, oofem::SparseMtrx::nRows, nz, rowind, val, and oofem::SparseMtrx::version.

◆ printYourself()

void oofem::CompCol::printYourself ( ) const
overridevirtual

Prints receiver to stdout. Works only for relatively small matrices.

Reimplemented from oofem::SparseMtrx.

Definition at line 368 of file compcol.C.

◆ row_ind()

const int & oofem::CompCol::row_ind ( int i) const
inline

◆ times() [1/2]

void oofem::CompCol::times ( const FloatArray & x,
FloatArray & answer ) const
overridevirtual

Evaluates \( y = A \cdot x \)

Parameters
xArray to be multiplied with receiver.
answery.

Reimplemented from oofem::SparseMtrx.

Reimplemented in oofem::SymCompCol.

Definition at line 128 of file compcol.C.

References colptr, oofem::SparseMtrx::giveNumberOfColumns(), oofem::SparseMtrx::giveNumberOfRows(), oofem::FloatArray::giveSize(), OOFEM_ERROR, oofem::FloatArray::resize(), rowind, val, and oofem::FloatArray::zero().

◆ times() [2/2]

void oofem::CompCol::times ( double x)
overridevirtual

Multiplies receiver by scalar value.

Parameters
xValue to multiply receiver.

Reimplemented from oofem::SparseMtrx.

Reimplemented in oofem::SymCompCol.

Definition at line 166 of file compcol.C.

References val, and oofem::SparseMtrx::version.

◆ timesT()

void oofem::CompCol::timesT ( const FloatArray & x,
FloatArray & answer ) const
overridevirtual

Evaluates \( y = A^{\mathrm{T}} \cdot x \)

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

Reimplemented from oofem::SparseMtrx.

Reimplemented in oofem::SymCompCol.

Definition at line 146 of file compcol.C.

References colptr, oofem::SparseMtrx::giveNumberOfColumns(), oofem::FloatArray::giveSize(), OOFEM_ERROR, oofem::FloatArray::resize(), rowind, val, and oofem::FloatArray::zero().

◆ toFloatMatrix()

void oofem::CompCol::toFloatMatrix ( FloatMatrix & answer) const
overridevirtual

Converts receiving sparse matrix to a dense float matrix.

Reimplemented from oofem::SparseMtrx.

Definition at line 365 of file compcol.C.

◆ values()

const double & oofem::CompCol::values ( int i) const
inline

◆ zero()

void oofem::CompCol::zero ( )
overridevirtual

Zeroes the receiver.

Implements oofem::SparseMtrx.

Reimplemented in oofem::SymCompCol.

Definition at line 357 of file compcol.C.

References val, and oofem::SparseMtrx::version.

Member Data Documentation

◆ base

int oofem::CompCol::base
protected

Definition at line 92 of file compcol.h.

Referenced by CompCol(), CompCol(), and operator=().

◆ colptr

◆ nz

int oofem::CompCol::nz
protected

◆ rowind

◆ val


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

This page is part of the OOFEM-3.0 documentation. Copyright Copyright (C) 1994-2025 Borek Patzak Bořek Patzák
Project e-mail: oofem@fsv.cvut.cz
Generated at for OOFEM by doxygen 1.15.0 written by Dimitri van Heesch, © 1997-2011