103 OOFEM_ERROR(
"dimension mismatch - accessing value at (%d,%d)", i, j);
114 d1 = this->
adr.
at(j);
115 ind = d1 + ( j - i );
117 if ( (
adr.
at(j + 1) -
adr.
at(j) ) <= ( j - i ) ) {
118 OOFEM_ERROR(
"request for element which is not in sparse mtrx (%d,%d)", i, j);
144 OOFEM_ERROR(
"dimension mismatch, when accessing value at (%d,%d)", i, j);
155 d1 = this->
adr.
at(j);
156 ind = d1 + ( j - i );
158 if ( (
adr.
at(j + 1) -
adr.
at(j) ) <= ( j - i ) ) {
159 OOFEM_ERROR(
"request for element which is not in sparse mtrx (%d,%d)", i, j);
184 if ( (
adr.
at(j + 1) -
adr.
at(j) ) <= ( j - i ) ) {
198 int d1, d2, pk, size;
204 OOFEM_ERROR(
"Internal error in skyline matrix: num columns != size(adr)-1: %d != %d", size, this->
adr.
giveSize() - 1);
208 answer.
resize(size, size);
211 for (
int j = 1; j <= size; j++ ) {
215 for (
int i = d1; i < d2; i++ ) {
216 answer.
at(pk, j) =
mtrx [ i ];
233 OOFEM_ERROR(
"dimension of 'mat' and 'loc' mismatch");
240 for (
int i = 1; i <= ndofe; i++ ) {
246 for (
int j = 1; j <= ndofe; j++ ) {
270 for (
int i = 1; i <= dim1; i++ ) {
273 for (
int j = 1; j <= dim2; j++ ) {
275 if ( jj && ii <= jj ) {
276 this->
at(ii, jj) += mat.
at(i, j);
295 int ack, ack1, acs, n;
302 for (
int k = 2; k <= n; k++ ) {
304 ack1 =
adr.
at(k + 1);
306 acs = k - ( ack1 - ack ) + 1;
307 for (
int i = ack1 - 1; i > ack; i-- ) {
308 s +=
mtrx [ i ] * y.at(acs);
318 for (
int k = 1; k <= n; k++ ) {
320 y.at(k) /=
mtrx [ acs ];
323 for (
int k = n; k > 0; k-- ) {
325 ack1 =
adr.
at(k + 1);
326 solution.at(k) = y.at(k);
327 acs = k - ( ack1 - ack ) + 1;
328 for (
int i = ack1 - 1; i > ack; i-- ) {
329 y.at(acs) -=
mtrx [ i ] * solution.at(k);
350 mtrx = (
double * ) calloc(
nwk,
sizeof(
double ) );
389 for (
int j = 1; j <= neq; j++ ) {
395 elem->giveLocationArray(loc, s);
397 for (
int ieq : loc ) {
399 maxle =
min(maxle, ieq);
403 for (
int ieq : loc ) {
405 mht.
at(ieq) =
min( maxle, mht.
at(ieq) );
411 std :: vector< IntArray >r_locs;
412 std :: vector< IntArray >c_locs;
414 for (
auto &gbc : domain->
giveBcs() ) {
418 for ( std :: size_t k = 0; k < r_locs.size(); k++ ) {
422 for (
int ii : krloc ) {
424 maxle =
min(maxle, ii);
427 for (
int jj : kcloc ) {
429 mht.
at(jj) =
min( maxle, mht.
at(jj) );
447 for (
int ieq : loc ) {
449 maxle =
min(maxle, ieq);
453 for (
int ieq : loc ) {
455 mht.
at(ieq) =
min( maxle, mht.
at(ieq) );
476 for (
int i = 1; i <= neq; i++ ) {
478 ac1 += ( i - mht.
at(i) + 1 );
481 adr.
at(neq + 1) = ac1;
488 mtrx = (
double * ) calloc( ac1,
sizeof(
double ) );
503 int aci, aci1, acj, acj1, ack, ack1, ac, acs, acri, acrk, n;
523 for (
int k = 2; k <= n; k++ ) {
526 ack1 =
adr.
at(k + 1);
527 acrk = k - ( ack1 - ack ) + 1;
528 for (
int i = acrk + 1; i < k; i++ ) {
531 aci1 =
adr.
at(i + 1);
532 acri = i - ( aci1 - aci ) + 1;
543 for (
int j = acj; j > acj1; j-- ) {
553 for (
int i = ack1 - 1; i > ack; i-- ) {
583 int k, acb, acc, aci, aci1, ac, n;
597 for (
int i = 1; i <= n; i++ ) {
599 aci1 =
adr.
at(i + 1);
600 ac = i - ( aci1 - aci ) + 1;
603 for ( k = aci1 - 1; k >= aci; k-- ) {
604 s +=
mtrx [ k ] * x.
at(acb);
611 for (
int j = ac; j < i; j++ ) {
614 answer.
at(j) += s * x.
at(i);
624 for (
int j = 0; j <
nwk; j++ ) {
637 for (
int j = 0; j <
nwk; j++ ) {
656 FILE *file = fopen(fname,
"w");
659 for (
int i = 1; i <=
nRows; ++i ) {
660 for (
int j = 1; j <=
nColumns; ++j ) {
661 fprintf( file,
"%10.3e ", copy.
at(i, j) );
672 for (
int j = 0; j <
nwk; j++ ) {
690 mtrx1 = (
double * ) malloc( this->
nwk *
sizeof(
double ) );
695 for (
int i = 0; i < this->
nwk; i++ ) {
696 mtrx1 [ i ] = this->
mtrx [ i ];
699 answer =
new Skyline(neq, this->nwk, mtrx1,
adr);
729 for (
int j = 1; j <= cols.
giveSize(); j++ ) {
730 for (
int i = rows.
giveSize(); i >= 1; i-- ) {
738 if ( hasValue && i == j ) {
739 values.at(++nnz) = this->
at( rows.
at(i), cols.
at(j) );
740 positions.at(diagPos++) = nnz;
741 }
else if ( i == j ) {
742 values.at(++nnz) = 0.0;
743 positions.at(diagPos++) = nnz;
744 }
else if ( hasValue ) {
745 values.at(++nnz) = this->
at( rows.
at(i), cols.
at(j) );
751 positions.at(diagPos++) = ++nnz;
754 mtrxValues = (
double * ) malloc( nnz *
sizeof(
double ) );
759 for (
int i = 0; i < nnz-1; i++ ) {
760 mtrxValues [ i + 1] = values [ i ];
772 for (
int i = 0; i < nnz; i++ ) {
786 double limit,
int tc)
792 int i, j, k, ii, jj, kk, lj, uj, li, ui, lk, uk, mi, ise, ib, neq = this->
giveNumberOfRows();
804 if ( tc == 1 || tc == 3 ) {
812 for ( i = 2; i <= neq; i++ ) {
814 uj =
adr.
at(i + 1) - 2;
817 mi = i - ( uj - lj ) - 1;
821 for ( jj = uj; jj > lj; jj-- ) {
823 ui =
adr.
at(j + 1) - 1;
837 for ( kk = uk; kk > jj; kk-- ) {
849 for ( jj = uj + 1; jj > lj; jj-- ) {
852 s +=
mtrx [ jj ] * g;
859 if ( fabs(
mtrx [ lj ]) < limit ) {
865 for ( jj = uj + 1; jj > lj; jj-- ) {
876 for ( j = i + 1; j <= neq; j++ ) {
877 if ( j - (
adr.
at(j + 1) -
adr.
at(j) ) < i ) {
887 if ( tc == 2 || tc == 3 ) {
890 for ( i = 1; i <= ise; i++ ) {
894 for ( jj = uj; jj > lj; jj-- ) {
908 for ( i = 1; i <= ise; i++ ) {
910 for ( j = neq; j > 0; j-- ) {
911 r.
at(se.
at(i), i) = 1.0;
913 uk =
adr.
at(j + 1) - 1;
916 for ( kk = uk; kk > lk; kk-- ) {
917 r.
at(k, i) -=
mtrx [ kk ] * s;
933 int nse,
double limit,
IntArray &se)
955 long i, j, k, ii, lj, uj, neq;
967 for ( i = 1; i <= neq; i++ ) {
969 uj =
adr.
at(i + 1) - 1;
972 for ( j = uj; j > lj; j-- ) {
973 s +=
mtrx [ j ] * y.
at(ii);
1014 for ( i = 1; i <= neq; i++ ) {
1023 for ( i = neq; i > 0; i-- ) {
1027 if ( se.
at(k) == i ) {
1036 for ( j = lj + 1; j < uj; j++ ) {
1037 y.
at(ii) -= s *
mtrx [ j ];
int nColumns
Number of columns.
int giveNumberOfColumns() const
Returns number of columns of receiver.
virtual int buildInternalStructure(EngngModel *, int, const UnknownNumberingScheme &)
Builds internal structure of receiver.
virtual void toFloatMatrix(FloatMatrix &answer) const
Converts receiving sparse matrix to a dense float matrix.
virtual int giveNumberOfDomainEquations(int di, const UnknownNumberingScheme &num)
Returns number of equations for given domain in active (current time step) time step.
virtual bool isAllocatedAt(int i, int j) const
Returns 0 if the memory is not allocated at position (i,j).
Base class for all matrices stored in sparse format.
virtual SparseMtrx * GiveCopy() const
Returns a newly allocated copy of receiver.
virtual SparseMtrx * giveSubMatrix(const IntArray &rows, const IntArray &cols)
virtual double & at(int, int)
Returns coefficient at position (i,j).
double & at(int i)
Coefficient access function.
int isFactorized
Flag indicating whether factorized.
virtual void writeToFile(const char *fname) const
Helpful for debugging, writes the matrix to given file.
IntArray adr
Integer array holding addresses of diagonal members.
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...
#define OOFEM_LOG_DEBUG(...)
Class implementing an array of integers.
int & at(int i)
Coefficient access function.
Class implementing sparse matrix stored in skyline form.
virtual void times(const FloatArray &x, FloatArray &answer) const
Evaluates .
std::vector< std::unique_ptr< GeneralBoundaryCondition > > & giveBcs()
int giveNumberOfRows() const
Returns number of rows of receiver.
#define OOFEM_LOG_INFO(...)
REGISTER_SparseMtrx(CompCol, SMT_CompCol)
void clear()
Clears the array (zero size).
virtual FloatArray * backSubstitutionWith(FloatArray &) const
Computes the solution of linear system where A is receiver.
int nwk
Total number of nonzero coefficients stored.
Abstract base class allowing to control the way, how equations are assigned to individual DOFs...
int setInternalStructure(IntArray &a)
Allocates and builds internal structure according to given array holding addresses of diagonal member...
int giveNumberOfNonZeros() const
virtual SparseMtrx * factorized()
Returns the receiver factorized.
double * mtrx
Vector of stored coefficients.
Abstract base class for all active boundary conditions.
virtual void add(double x, SparseMtrx &m)
Adds x * m.
double at(int i, int j) const
Coefficient access function.
void resize(int n)
Checks size of receiver towards requested bounds.
void rbmodes(FloatMatrix &r, int &nse, IntArray &se, double limit, int tc)
Splits the receiver to LDLT form, and computes the rigid body motions.
SparseMtrxVersionType version
Allows to track if receiver changes.
Initializes the variable VERBOSE, in order to get a few intermediate messages on screen: beginning an...
Class representing vector of real numbers.
Implementation of matrix containing floating point numbers.
virtual bool isDefault() const
Returns true, if receiver is the default engngModel equation numbering scheme; This is useful for som...
virtual int giveRequiredNumberOfDomainEquation() const
Returns required number of domain equation.
ContactManager * giveContactManager()
void resize(int rows, int cols)
Checks size of receiver towards requested bounds.
void zero()
Zeroes all coefficients of receiver.
Class implementing single timer, providing wall clock and user time capabilities. ...
void printYourself() const
Prints matrix to stdout. Useful for debugging.
void zero()
Zeroes all coefficient of receiver.
int giveNumberOfColumns() const
Returns number of columns of receiver.
virtual void zero()
Zeroes the receiver.
int min(int i, int j)
Returns smaller value from two given decimals.
std::vector< std::unique_ptr< Element > > & giveElements()
Abstract base class representing the "problem" under consideration.
int giveSize() const
Returns the size of receiver.
the oofem namespace is to define a context or scope in which all oofem names are defined.
Domain * giveDomain(int n)
Service for accessing particular problem domain.
void clear()
Sets size of receiver to be an empty matrix. It will have zero rows and zero columns size...
virtual int assemble(const IntArray &loc, const FloatMatrix &mat)
Assembles sparse matrix from contribution of local elements.
int giveNumberOfRows() const
Returns number of rows of receiver.
void symmetrized()
Initializes the lower half of the receiver according to the upper half.
double getUtime()
Returns total user time elapsed in seconds.
virtual ~Skyline()
Destructor.
virtual void giveLocationArrays(std::vector< IntArray > &rows, std::vector< IntArray > &cols, CharType type, const UnknownNumberingScheme &r_s, const UnknownNumberingScheme &c_s)
Gives a list of location arrays that will be assembled.
virtual void printYourself() const
Prints receiver to stdout.
void resize(int s)
Resizes receiver towards requested size.