81 for ( i = 0; i < S.
nRows; i++ ) {
90 for ( i = 0; i < S.
nRows; i++ ) {
109 for ( i = 0; i <
nRows; i++ ) {
110 delete this->
rows_ [ i ];
117 for ( i = 0; i <
nRows; i++ ) {
138 for ( i = 0; i <
nRows; i++ ) {
139 delete this->
rows_ [ i ];
147 for ( i = 0; i < C.
nRows; i++ ) {
156 for ( i = 0; i <
nRows; i++ ) {
165 for ( i = 0; i < C.
nRows; i++ ) {
189 OOFEM_ERROR(
"Error in CompRow -- incompatible dimensions");
198 for ( j = 0; j <
nRows; j++ ) {
210 for (
int j = 0; j <
nRows; j++ ) {
234 for ( i = 0; i <
nRows; i++ ) {
242 for ( j = 0; j < neq; j++ ) {
248 for ( i = 0; i <
nRows; i++ ) {
249 delete this->
rows_ [ i ];
256 for ( j = 0; j < neq; j++ ) {
261 elem->giveLocationArray(loc, s);
263 for ( i = 1; i <= loc.
giveSize(); i++ ) {
264 if ( ( ii = loc.
at(i) ) ) {
265 for ( j = 1; j <= loc.
giveSize(); j++ ) {
266 if ( ( jj = loc.
at(j) ) ) {
277 std :: vector< IntArray >r_locs;
278 std :: vector< IntArray >c_locs;
280 for (
auto &gbc : domain->
giveBcs() ) {
284 for ( std :: size_t k = 0; k < r_locs.size(); k++ ) {
287 for (
int i = 1; i <= krloc.
giveSize(); i++ ) {
288 if ( ( ii = krloc.
at(i) ) ) {
289 for (
int j = 1; j <= kcloc.
giveSize(); j++ ) {
290 if ( ( jj = kcloc.
at(j) ) ) {
304 for ( j = 0; j < neq; j++ ) {
308 OOFEM_LOG_DEBUG(
"DynCompRow info: neq is %d, nelem is %d\n", neq, nz_);
323 int i, j, ii, jj, dim;
328 OOFEM_ERROR(
"dimension of 'k' and 'loc' mismatch");
335 for ( j = 1; j <= dim; j++ ) {
338 for ( i = 1; i <= dim; i++ ) {
341 this->
at(ii, jj) += mat.
at(i, j);
356 int i, ii, ii1, j, jj, jj1, colindx;
360 for ( i = 0; i < rsize; i++ ) {
361 if ( ( ii = rloc(i) ) ) {
363 for ( j = 0; j < csize; j++ ) {
364 if ( ( jj = cloc(j) ) ) {
369 rows_ [ ii1 ]->
at(colindx) += mat(i, j);
382 for (
int j = 0; j <
nRows; j++ ) {
394 for (
int j = 0; j <
nRows; j++ ) {
398 printf(
"\nDynCompRow info: neq is %d, nelem is %d\n", nRows, nz_);
412 if ( ( colIndx = this->
giveColIndx(i - 1, j - 1) ) ) {
413 return rows_ [ i - 1 ]->
at(colIndx);
416 OOFEM_ERROR(
"Array accessing exception -- (%d,%d) out of bounds", i, j);
424 if ( ( colIndx = this->
giveColIndx(i - 1, j - 1) ) ) {
425 return rows_ [ i - 1 ]->
at(colIndx);
431 OOFEM_ERROR(
"Array accessing exception -- (%d,%d) out of bounds", i, j);
440 return rows_ [ i ]->
at(colIndx);
446 OOFEM_ERROR(
"Array accessing exception -- (%d,%d) out of bounds", i, j);
459 return rows_ [ i ]->
at(colIndx);
462 OOFEM_ERROR(
"Array element (%d,%d) not in sparse structure -- cannot assign", i, j);
470 OOFEM_ERROR(
"Error in CompRow -- incompatible dimensions");
494 for ( i = 0; i < size; i++ ) {
495 maxid =
max( maxid, loc(i) );
502 for ( i = 0; i < size; i++ ) {
503 if ( ( ii = loc(i) ) ) {
504 for ( j = 0; j < size; j++ ) {
505 if ( ( jj = loc(j) ) ) {
521 for ( i = 0; i < rsize; i++ ) {
522 maxid =
max( maxid, rloc(i) );
525 for ( i = 0; i < csize; i++ ) {
526 maxid =
max( maxid, cloc(i) );
533 for ( i = 0; i < rsize; i++ ) {
534 if ( ( ii = rloc(i) ) ) {
535 for ( j = 0; j < csize; j++ ) {
536 if ( ( jj = cloc(j) ) ) {
553 for (
int i = 0; i <
nRows; i++ ) {
554 newrows_ [ i ] =
rows_ [ i ];
555 newcolind_ [ i ] =
colind_ [ i ];
573 int middle = ( left + right ) / 2;
580 if ( this->
colind_ [ row ]->
at(right) == col ) {
584 while ( !( ( ( middleVal = this->
colind_ [ row ]->
at(middle) ) == col ) || ( middle == left ) ) ) {
585 if ( col > middleVal ) {
591 middle = ( left + right ) / 2;
594 if ( middleVal == col ) {
608 int left = 1, right = oldsize;
609 int middle = ( left + right ) / 2;
612 if ( oldsize == 0 ) {
620 if ( this->
colind_ [ row ]->
at(right) == col ) {
624 while ( !( ( ( middleVal = this->
colind_ [ row ]->
at(middle) ) == col ) || ( middle == left ) ) ) {
625 if ( col > middleVal ) {
631 middle = ( left + right ) / 2;
634 if ( middleVal == col ) {
639 if ( col > this->
colind_ [ row ]->
at(oldsize) ) {
641 }
else if ( col < this->
colind_ [ row ]->
at(1) ) {
649 for ( i = oldsize; i >= right; i-- ) {
722 #define ILU_ROW_CHUNK 10 728 int i, ii, j, jcol, k, kk, krow, ck;
730 double multiplier, inorm, val;
741 for ( i = 0; i <
nRows; i++ ) {
749 for ( i = 1; i <
nRows; i++ ) {
763 w(kk - 1) =
rows_ [ i ]->
at(kk);
768 while ( iw.
at(k + 1) < i ) {
777 if ( fabs(multiplier) >= drop_tol * inorm )
785 w.
at( irw(jcol) ) -= multiplier *
rows_ [ krow ]->
at(j + 1);
793 iw.
at(newsize) = jcol;
794 w.
at(newsize) = -multiplier *
rows_ [ krow ]->
at(j + 1);
815 for ( kk = 0; kk < iw.
giveSize(); kk++ ) {
816 if ( ( ( iw(kk) - krow ) > 0 ) && ( ( iw(kk) - krow ) < ( ck - krow ) ) ) {
829 while ( curr <= end ) {
830 if ( ( fabs( w.
at(curr) ) < drop_tol * inorm ) && ( iw.
at(curr) != i ) ) {
832 w.
at(curr) = w.
at(end);
833 irw( iw.
at(curr) ) = 0;
834 iw.
at(curr) = iw.
at(end);
836 irw( iw.
at(curr) ) = curr;
857 lsizeLimit += part_fill;
858 usizeLimit += part_fill;
863 for ( kk = 1; kk <= iw.
giveSize(); kk++ ) {
864 if ( iw.
at(kk) < i ) {
865 if ( ++lnums > lsizeLimit ) {
866 irw( iw.
at(kk) ) = 0;
870 }
else if ( iw.
at(kk) > i ) {
871 if ( ++unums > usizeLimit ) {
872 irw( iw.
at(kk) ) = 0;
888 int kki, indx, idist, previndx = -1;
891 for ( kk = 1; kk <= count; kk++ ) {
895 for ( kki = 1; kki <= kkend; kki++ ) {
896 if ( ( irw( iw.
at(kki) ) != 0 ) && ( iw.
at(kki) > previndx ) && ( ( iw.
at(kki) - previndx ) < idist ) ) {
897 idist = ( iw.
at(kki) - previndx );
906 previndx = iw.
at(indx);
917 irw( iw.
at(indx) ) = 0;
918 iw.
at(indx) = iw.
at(kkend);
919 w.
at(indx) = w.
at(kkend);
920 if ( irw( iw.
at(indx) ) != 0 ) {
921 irw( iw.
at(indx) ) = indx;
946 if ( ( icount - count ) != 1 ) {
947 OOFEM_ERROR(
"%d - row errorr (%d,%d)\n", i, icount, count);
951 for ( kk = 1; kk <= iw.
giveSize(); kk++ ) {
952 irw( iw.
at(kk) ) = 0;
960 OOFEM_LOG_DEBUG(
"\nILUT(%d,%e): user time consumed by factorization: %.2fs\n", part_fill, drop_tol, timer.
getUtime() );
982 for ( i = 0; i < M; i++ ) {
993 for ( i = M - 1; i >= 0; i-- ) {
1017 for ( i = 0; i < M; i++ ) {
1025 for ( i = M - 1; i >= 0; i-- ) {
1087 int i = l - 1, j = r;
1088 double v = fabs( val(r) );
1093 while ( ( fabs( val(++i) ) > v ) ) {
1097 while ( ( v > fabs( val(--j) ) ) ) {
1107 swap = ir( ind(i) );
1108 ir( ind(i) ) = ir( ind(j) );
1109 ir( ind(j) ) = swap;
1118 swap = ir( ind(i) );
1119 ir( ind(i) ) = ir( ind(r) );
1120 ir( ind(r) ) = swap;
int nColumns
Number of columns.
void ILUPsolve(const FloatArray &x, FloatArray &y) const
const FloatArray * row(int i) const
Returns row values.
virtual int giveNumberOfDomainEquations(int di, const UnknownNumberingScheme &num)
Returns number of equations for given domain in active (current time step) time step.
Base class for all matrices stored in sparse format.
double & at(int i)
Coefficient access function.
int max(int i, int j)
Returns bigger value form two given decimals.
virtual void times(const FloatArray &x, FloatArray &answer) const
Evaluates .
DynCompRow & operator=(const DynCompRow &C)
Assignment operator.
#define OOFEM_LOG_DEBUG(...)
Class implementing an array of integers.
int & at(int i)
Coefficient access function.
virtual double & at(int i, int j)
Returns coefficient at position (i,j).
int qsortRowPartition(IntArray &ind, IntArray &ir, FloatArray &val, int l, int r)
int insertColInRow(int row, int col)
insert column entry into row, preserving order of column indexes, returns the index of new row...
double operator()(int i, int j) const
implements 0-based access
void ILUPtrans_solve(const FloatArray &x, FloatArray &y) const
std::vector< std::unique_ptr< GeneralBoundaryCondition > > & giveBcs()
virtual int buildInternalStructure(EngngModel *, int, const UnknownNumberingScheme &)
Builds internal structure of receiver.
REGISTER_SparseMtrx(CompCol, SMT_CompCol)
Implementation of sparse matrix stored in compressed column storage.
Abstract base class allowing to control the way, how equations are assigned to individual DOFs...
void qsortRow(IntArray &ind, IntArray &ir, FloatArray &val, int l, int r)
void resizeWithValues(int n, int allocChunk=0)
Checks size of receiver towards requested bounds.
Abstract base class for all active boundary conditions.
void resizeWithValues(int s, int allocChunk=0)
Checks size of receiver towards requested bounds.
double at(int i, int j) const
Coefficient access function.
void resize(int n)
Checks size of receiver towards requested bounds.
virtual int assemble(const IntArray &loc, const FloatMatrix &mat)
Assembles sparse matrix from contribution of local elements.
virtual void timesT(const FloatArray &x, FloatArray &answer) const
Evaluates .
SparseMtrxVersionType version
Allows to track if receiver changes.
Initializes the variable VERBOSE, in order to get a few intermediate messages on screen: beginning an...
virtual ~DynCompRow()
Destructor.
void checkSizeTowards(IntArray &)
Class representing vector of real numbers.
Implementation of matrix containing floating point numbers.
Dynamically growing compressed row.
void zero()
Zeroes all coefficients of receiver.
Class implementing single timer, providing wall clock and user time capabilities. ...
void times(double s)
Multiplies receiver with scalar.
std::vector< std::unique_ptr< Element > > & giveElements()
int giveColIndx(int row, int col) const
returns the column index of given column at given row, else returns zero.
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...
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.
SparseMtrx * GiveCopy() const
Returns a newly allocated copy of receiver.
virtual void zero()
Zeroes the receiver.
int giveNumberOfRows() const
Returns number of rows of receiver.
double getUtime()
Returns total user time elapsed in seconds.
virtual void printStatistics() const
Prints the receiver statistics (one-line) to stdout.
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.
void resize(int s)
Resizes receiver towards requested size.