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

Class implementing sparse matrix stored in skyline form. More...

#include <skyline.h>

+ Inheritance diagram for oofem::Skyline:
+ Collaboration diagram for oofem::Skyline:

Public Member Functions

 Skyline (int n)
 Constructor. More...
 
 Skyline ()
 Constructor. More...
 
virtual ~Skyline ()
 Destructor. More...
 
virtual 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 void add (double x, SparseMtrx &m)
 Adds x * m. More...
 
virtual int buildInternalStructure (EngngModel *, int, const UnknownNumberingScheme &)
 Builds internal structure of receiver. More...
 
virtual SparseMtrxgiveSubMatrix (const IntArray &rows, const IntArray &cols)
 
int setInternalStructure (IntArray &a)
 Allocates and builds internal structure according to given array holding addresses of diagonal members values (adr). 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 SparseMtrxfactorized ()
 Returns the receiver factorized. More...
 
virtual FloatArraybackSubstitutionWith (FloatArray &) const
 Computes the solution of linear system $ A\cdot x = y $ where A is receiver. More...
 
virtual void zero ()
 Zeroes the receiver. More...
 
void rbmodes (FloatMatrix &r, int &nse, IntArray &se, double limit, int tc)
 Splits the receiver to LDLT form, and computes the rigid body motions. More...
 
void ldl_feti_sky (FloatArray &x, FloatArray &y, int nse, double limit, IntArray &se)
 Solves the singular system of equations, the receiver should be factorized using rbmodes service. More...
 
virtual double & at (int, int)
 Returns coefficient at position (i,j). More...
 
virtual double at (int i, int j) const
 Returns coefficient at position (i,j). More...
 
virtual bool isAllocatedAt (int i, int j) const
 Returns 0 if the memory is not allocated at position (i,j). More...
 
int giveNumberOfNonZeros () const
 
virtual void toFloatMatrix (FloatMatrix &answer) const
 Converts receiving sparse matrix to a dense float matrix. More...
 
virtual void printYourself () const
 Prints receiver to stdout. More...
 
virtual void writeToFile (const char *fname) const
 Helpful for debugging, writes the matrix to given file. More...
 
int giveAllocatedSize ()
 
virtual SparseMtrxType giveType () const
 Sparse matrix type identification. More...
 
virtual bool isAsymmetric () const
 Returns true if asymmetric. More...
 
virtual const char * giveClassName () const
 
- 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 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 double computeNorm () const
 Returns the norm of receiver. More...
 
virtual void printStatistics () const
 Prints the receiver statistics (one-line) to stdout. 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

 Skyline (int, int, double *, const IntArray &)
 

Protected Attributes

int nwk
 Total number of nonzero coefficients stored. More...
 
IntArray adr
 Integer array holding addresses of diagonal members. More...
 
double * mtrx
 Vector of stored coefficients. More...
 
int isFactorized
 Flag indicating whether factorized. More...
 
- 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

Class implementing sparse matrix stored in skyline form.

This class assumes symmetric form of matrix to be stored, i.e., only upper half part is therefore stored. Coefficients are stored in one dimensional float array, containing for each column the values from the diagonal to the last nonzero entry. This requires to remember the addresses of diagonal members in such array (adr attribute)

Attribute 'isFactorized' is True if the skyline is already in U(T).D.U factorized form, else it is False. Attribute adr is array of diagonal members, it's size is size+1 (adr[0]=neni, adr[1]=1) Attribute mtrx is double pointer to skyline stored in a array form (but we start from index 1)

Tasks:

  • building its internal storage structure (method 'buildInternalStructure')
  • store and localize local matrices (method 'localize')
  • performing standard operations : multiplication by array (method 'times')
  • possible factorization and backSubstitution (recognized by nonzero result of canBeFactorized) (methods 'factorize' and 'backSubstitution')
  • setting all coefficients to zero (method 'zero')
See also
SparseMtrx class

Definition at line 68 of file skyline.h.

Constructor & Destructor Documentation

oofem::Skyline::Skyline ( int  n)

Constructor.

Before any operation an internal profile must be built.

See also
builInternalStructure

Definition at line 62 of file skyline.C.

References isFactorized, mtrx, and nwk.

oofem::Skyline::Skyline ( )

Constructor.

Before any operation an internal profile must be built.

See also
builInternalStructure

Definition at line 73 of file skyline.C.

References isFactorized, mtrx, and nwk.

Referenced by GiveCopy(), and giveSubMatrix().

oofem::Skyline::~Skyline ( )
virtual

Destructor.

Definition at line 83 of file skyline.C.

References oofem::SparseMtrx::giveNumberOfRows(), and mtrx.

oofem::Skyline::Skyline ( int  neq,
int  nwk1,
double *  mtrx1,
const IntArray adr1 
)
protected

Definition at line 704 of file skyline.C.

References adr, isFactorized, mtrx, and nwk.

Member Function Documentation

void oofem::Skyline::add ( double  x,
SparseMtrx m 
)
virtual

Adds x * m.

Parameters
xValue to multiply m by.
mMatrix to add (should of the same matrix type).

Reimplemented from oofem::SparseMtrx.

Definition at line 633 of file skyline.C.

References mtrx, nwk, and oofem::SparseMtrx::version.

int oofem::Skyline::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 224 of file skyline.C.

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

int oofem::Skyline::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 266 of file skyline.C.

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

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

Returns coefficient at position (i,j).

Implements oofem::SparseMtrx.

Definition at line 93 of file skyline.C.

References adr, oofem::IntArray::at(), oofem::SparseMtrx::giveNumberOfRows(), mtrx, OOFEM_ERROR, and oofem::SparseMtrx::version.

Referenced by assemble(), and giveSubMatrix().

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

Returns coefficient at position (i,j).

Implements oofem::SparseMtrx.

Definition at line 134 of file skyline.C.

References adr, oofem::IntArray::at(), oofem::SparseMtrx::giveNumberOfRows(), mtrx, and OOFEM_ERROR.

FloatArray * oofem::Skyline::backSubstitutionWith ( FloatArray y) const
virtual

Computes the solution of linear system $ A\cdot x = y $ where A is receiver.

Solution vector x overwrites the right hand side vector y. Receiver must be in factorized form.

Parameters
yRight hand side on input, solution on output.
Returns
Pointer to y array.

Reimplemented from oofem::SparseMtrx.

Definition at line 289 of file skyline.C.

References adr, oofem::IntArray::at(), oofem::SparseMtrx::giveNumberOfRows(), and mtrx.

int oofem::Skyline::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 362 of file skyline.C.

References adr, oofem::IntArray::at(), oofem::IntArray::clear(), oofem::Domain::giveBcs(), oofem::ContactManager::giveContactDefinition(), oofem::ContactDefinition::giveContactElement(), oofem::Domain::giveContactManager(), oofem::EngngModel::giveDomain(), oofem::Domain::giveElements(), oofem::ContactElement::giveLocationArray(), oofem::ActiveBoundaryCondition::giveLocationArrays(), oofem::ContactManager::giveNumberOfContactDefinitions(), oofem::EngngModel::giveNumberOfDomainEquations(), oofem::ContactDefinition::giveNumbertOfContactElements(), oofem::UnknownNumberingScheme::giveRequiredNumberOfDomainEquation(), oofem::Domain::hasContactManager(), oofem::UnknownNumberingScheme::isDefault(), oofem::min(), mtrx, oofem::SparseMtrx::nColumns, oofem::SparseMtrx::nRows, nwk, OOFEM_ERROR, oofem::IntArray::resize(), and oofem::SparseMtrx::version.

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

Determines, whether receiver can be factorized.

Implements oofem::SparseMtrx.

Definition at line 115 of file skyline.h.

SparseMtrx * oofem::Skyline::factorized ( )
virtual

Returns the receiver factorized.

$ L^{\mathrm{T}} \cdot D \cdot L $ form is used.

Returns
pointer to the receiver

Reimplemented from oofem::SparseMtrx.

Definition at line 499 of file skyline.C.

References adr, oofem::IntArray::at(), oofem::Timer::getUtime(), oofem::SparseMtrx::giveNumberOfRows(), isFactorized, mtrx, nwk, OOFEM_LOG_DEBUG, oofem::Timer::startTimer(), and oofem::Timer::stopTimer().

int oofem::Skyline::giveAllocatedSize ( )
inline

Definition at line 153 of file skyline.h.

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

Implements oofem::SparseMtrx.

Definition at line 158 of file skyline.h.

SparseMtrx * oofem::Skyline::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 682 of file skyline.C.

References adr, oofem::SparseMtrx::giveNumberOfRows(), mtrx, nwk, OOFEM_ERROR, and Skyline().

int oofem::Skyline::giveNumberOfNonZeros ( ) const
inline

Definition at line 148 of file skyline.h.

Referenced by giveSubMatrix().

SparseMtrx * oofem::Skyline::giveSubMatrix ( const IntArray rows,
const IntArray cols 
)
virtual
virtual SparseMtrxType oofem::Skyline::giveType ( ) const
inlinevirtual

Sparse matrix type identification.

Implements oofem::SparseMtrx.

Definition at line 155 of file skyline.h.

References oofem::SMT_Skyline.

bool oofem::Skyline::isAllocatedAt ( int  i,
int  j 
) const
virtual

Returns 0 if the memory is not allocated at position (i,j).

Reimplemented from oofem::SparseMtrx.

Definition at line 174 of file skyline.C.

References adr, and oofem::IntArray::at().

Referenced by giveSubMatrix().

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

Returns true if asymmetric.

Implements oofem::SparseMtrx.

Definition at line 156 of file skyline.h.

void oofem::Skyline::ldl_feti_sky ( FloatArray x,
FloatArray y,
int  nse,
double  limit,
IntArray se 
)

Solves the singular system of equations, the receiver should be factorized using rbmodes service.

Parameters
xsolution vector
yright hand side
nsenumber of rigid body motions
limitdetermines the linear dependence or independence
seindexes of singular equations

Definition at line 932 of file skyline.C.

References adr, oofem::IntArray::at(), oofem::FloatArray::at(), oofem::SparseMtrx::giveNumberOfRows(), and mtrx.

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

void oofem::Skyline::printYourself ( ) const
virtual

Prints receiver to stdout.

Reimplemented from oofem::SparseMtrx.

Definition at line 644 of file skyline.C.

References oofem::FloatMatrix::printYourself(), and toFloatMatrix().

void oofem::Skyline::rbmodes ( FloatMatrix r,
int &  nse,
IntArray se,
double  limit,
int  tc 
)

Splits the receiver to LDLT form, and computes the rigid body motions.

Parameters
rmatrix containing the rigid body motions base vectors.
nsenumber of rigid body motions
searray containing indexes of singular eqs.
limitdetermines linear dependence or independence
tctype of calculation = 1 = Decomposition to LDL form = 2 = ? konstruovani baze prostoru ? Ker A = 3 = Decomposition to LDL form and ? konstruovani baze prostoru ? Ker A

Definition at line 785 of file skyline.C.

References adr, oofem::IntArray::at(), oofem::FloatArray::at(), oofem::FloatMatrix::at(), oofem::FloatMatrix::clear(), oofem::SparseMtrx::giveNumberOfRows(), mtrx, nwk, OOFEM_LOG_INFO, oofem::FloatMatrix::resize(), and oofem::FloatMatrix::zero().

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

int oofem::Skyline::setInternalStructure ( IntArray a)

Allocates and builds internal structure according to given array holding addresses of diagonal members values (adr).

Definition at line 338 of file skyline.C.

References adr, oofem::IntArray::at(), oofem::IntArray::giveSize(), mtrx, oofem::SparseMtrx::nColumns, oofem::SparseMtrx::nRows, nwk, OOFEM_ERROR, and oofem::SparseMtrx::version.

void oofem::Skyline::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 578 of file skyline.C.

References adr, oofem::IntArray::at(), oofem::FloatArray::at(), oofem::SparseMtrx::giveNumberOfRows(), oofem::FloatArray::giveSize(), mtrx, OOFEM_ERROR, oofem::FloatArray::resize(), and oofem::FloatArray::zero().

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

Multiplies receiver by scalar value.

Parameters
xValue to multiply receiver.

Reimplemented from oofem::SparseMtrx.

Definition at line 621 of file skyline.C.

References mtrx, nwk, and oofem::SparseMtrx::version.

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

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 97 of file skyline.h.

void oofem::Skyline::toFloatMatrix ( FloatMatrix answer) const
virtual
void oofem::Skyline::writeToFile ( const char *  fname) const
virtual

Helpful for debugging, writes the matrix to given file.

Reimplemented from oofem::SparseMtrx.

Definition at line 654 of file skyline.C.

References oofem::FloatMatrix::at(), oofem::SparseMtrx::nColumns, oofem::SparseMtrx::nRows, and toFloatMatrix().

void oofem::Skyline::zero ( )
virtual

Zeroes the receiver.

Implements oofem::SparseMtrx.

Definition at line 669 of file skyline.C.

References isFactorized, mtrx, nwk, and oofem::SparseMtrx::version.

Member Data Documentation

IntArray oofem::Skyline::adr
protected

Integer array holding addresses of diagonal members.

Definition at line 74 of file skyline.h.

Referenced by assemble(), at(), backSubstitutionWith(), buildInternalStructure(), factorized(), GiveCopy(), isAllocatedAt(), ldl_feti_sky(), rbmodes(), setInternalStructure(), Skyline(), times(), and toFloatMatrix().

int oofem::Skyline::isFactorized
protected

Flag indicating whether factorized.

Definition at line 78 of file skyline.h.

Referenced by factorized(), Skyline(), and zero().

double* oofem::Skyline::mtrx
protected
int oofem::Skyline::nwk
protected

Total number of nonzero coefficients stored.

Definition at line 72 of file skyline.h.

Referenced by add(), buildInternalStructure(), factorized(), GiveCopy(), rbmodes(), setInternalStructure(), Skyline(), times(), and zero().


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:41 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011