Foam::scalarSquareMatrix Foam::scalarSquareMatrix::LUinvert() const { scalarSquareMatrix luMatrix = *this; scalarSquareMatrix luInvert(luMatrix.n()); scalarField column(luMatrix.n()); labelList pivotIndices(luMatrix.n()); LUDecompose(luMatrix, pivotIndices); for (label j = 0; j < luMatrix.n(); j++) { for (label i = 0; i < luMatrix.n(); i++) { column[i] = 0.0; } column[j] = 1.0; LUBacksubstitute(luMatrix, pivotIndices, column); for (label i = 0; i < luMatrix.n(); i++) { luInvert[i][j] = column[i]; } } return luInvert; }
Foam::scalar Foam::det(SquareMatrix<Type>& matrix) { labelList pivotIndices(matrix.n()); label sign; LUDecompose(matrix, pivotIndices, sign); return detDecomposed(matrix, sign); }
void Foam::LUsolve ( scalarSquareMatrix& matrix, Field<Type>& sourceSol ) { labelList pivotIndices(matrix.n()); LUDecompose(matrix, pivotIndices); LUBacksubstitute(matrix, pivotIndices, sourceSol); }
Foam::scalar Foam::det(const SquareMatrix<Type>& matrix) { SquareMatrix<Type> matrixTmp = matrix; labelList pivotIndices(matrix.n()); label sign; LUDecompose(matrixTmp, pivotIndices, sign); return detDecomposed(matrixTmp, sign); }
void Foam::SIBS::SIMPR ( const ODE& ode, const scalar xStart, const scalarField& y, const scalarField& dydx, const scalarField& dfdx, const scalarSquareMatrix& dfdy, const scalar deltaX, const label nSteps, scalarField& yEnd ) const { scalar h = deltaX/nSteps; scalarSquareMatrix a(n_); for (register label i=0; i<n_; i++) { for (register label j=0; j<n_; j++) { a[i][j] = -h*dfdy[i][j]; } ++a[i][i]; } labelList pivotIndices(n_); LUDecompose(a, pivotIndices); for (register label i=0; i<n_; i++) { yEnd[i] = h*(dydx[i] + h*dfdx[i]); } LUBacksubstitute(a, pivotIndices, yEnd); scalarField del(yEnd); scalarField ytemp(n_); for (register label i=0; i<n_; i++) { ytemp[i] = y[i] + del[i]; } scalar x = xStart + h; ode.derivatives(x, ytemp, yEnd); for (register label nn=2; nn<=nSteps; nn++) { for (register label i=0; i<n_; i++) { yEnd[i] = h*yEnd[i] - del[i]; } LUBacksubstitute(a, pivotIndices, yEnd); for (register label i=0; i<n_; i++) { ytemp[i] += (del[i] += 2.0*yEnd[i]); } x += h; ode.derivatives(x, ytemp, yEnd); } for (register label i=0; i<n_; i++) { yEnd[i] = h*yEnd[i] - del[i]; } LUBacksubstitute(a, pivotIndices, yEnd); for (register label i=0; i<n_; i++) { yEnd[i] += ytemp[i]; } }