Flow123d
JS_before_hm-1709-g5393e92e3
|
Go to the documentation of this file.
18 sparsity(nrows,ncols),
32 matrix.set_size(nrows, ncols);
69 if(
matrix.n_rows != rdofs.n_rows ||
matrix.n_cols != cdofs.n_rows)
71 set_size(rdofs.n_rows, cdofs.n_rows);
112 uint ic, ir, row, col;
118 tmp_mat.col( col ).zeros();
124 tmp_rhs( row ) = 0.0;
125 tmp_mat.row( row ).zeros();
133 double new_diagonal =
matrix(row, col);
137 else if(new_diagonal == 0.0)
147 tmp_mat(row,col) = new_diagonal;
175 matrix(row, col) += mat_val;
185 matrix(row, col) += mat_val;
213 for(
uint i=0; i < sp.n_rows; i++)
214 for(
uint j=0; j < sp.n_cols; j++)
224 arma::uword n =
matrix.n_rows - 1;
225 ASSERT_LT_DBG(offset, n)(
"Schur complement (offset) dimension mismatch.");
228 arma::mat BinvA =
matrix.submat(offset, 0, n, offset-1) *
matrix.submat(0, 0, offset-1, offset-1).i();
231 schur.
matrix =
matrix.submat(offset, offset, n, n) - BinvA *
matrix.submat(0, offset, offset-1, n);
232 schur.
rhs =
rhs.subvec(offset, n) - BinvA *
rhs.subvec(0, offset-1);
237 schur.
rhs = -1.0 * schur.
rhs;
245 arma::uword n =
matrix.n_rows - 1;
246 ASSERT_LT_DBG(offset, n)(
"Schur complement (offset) dimension mismatch.");
248 reconstructed_solution.set_size(offset);
253 reconstructed_solution = invA *
rhs.subvec(0,offset-1) - invA *
matrix.submat(0, offset, offset-1, n) * schur_solution;
arma::Col< IntIdx > LocDofVec
void add_value(uint row, uint col, double mat_val, double rhs_val)
Adds a single entry into the local system.
arma::vec solution_rows
Cols indices of cols to be eliminated.
void reconstruct_solution_schur(uint offset, const arma::vec &schur_solution, arma::vec &reconstructed_solution) const
Reconstructs the solution from the Schur complement solution: x = invA*b - invA * Bt * schur_solution...
void set_solution(uint loc_dof, double solution, double diag=0.0)
Set the position and value of known solution. E.g. Dirichlet boundary condition.
void set_matrix(arma::mat matrix)
#define ASSERT_EQ_DBG(a, b)
Definition of comparative assert macro (EQual) only for debug mode.
arma::mat sparsity
sparsity pattern
static constexpr double almost_zero
void compute_schur_complement(uint offset, LocalSystem &schur, bool negative=false) const
Computes Schur complement of the local system: S = C - B * invA * Bt Applicable for square matrices....
ArmaMat< double, N, M > mat
arma::mat matrix
local system matrix
LocDofVec elim_cols
Rows indices of rows to be eliminated.
void set_rhs(arma::vec rhs)
arma::vec solution_cols
Values of the known solution (for row dofs).
arma::vec rhs
local system RHS
void eliminate_solution()
uint n_elim_rows
Number of rows/cols to be eliminated due to known solution.
void reset()
Resets the matrix, RHS, dofs to zero and clears solution settings.
#define ASSERT_LT_DBG(a, b)
Definition of comparative assert macro (Less Than) only for debug mode.
LocalSystem()
Default constructor.
void set_size(uint nrows, uint ncols)
void set_sparsity(const arma::umat &sp)
Sets the sparsity pattern for the local system.
void set_solution_col(uint loc_col, double solution)
void set_solution_row(uint loc_row, double solution, double diag=0.0)
arma::vec diag_rows
Values of the known solution (for col dofs).