19 sparsity(nrows,ncols),
33 matrix.set_size(nrows, ncols);
70 if(
matrix.n_rows != rdofs.n_rows ||
matrix.n_cols != cdofs.n_rows)
72 set_size(rdofs.n_rows, cdofs.n_rows);
121 uint ic, ir, row, col;
127 tmp_mat.col( col ).zeros();
133 tmp_rhs( row ) = 0.0;
134 tmp_mat.row( row ).zeros();
142 double new_diagonal =
matrix(row, col);
146 else if(new_diagonal == 0.0)
156 tmp_mat(row,col) = new_diagonal;
182 ASSERT(
sparsity(row,col))(row)(col).error(
"Violation of sparsity pattern.");
184 matrix(row, col) += mat_val;
192 ASSERT(
sparsity(row,col))(row)(col).error(
"Violation of sparsity pattern.");
194 matrix(row, col) += mat_val;
222 for(
uint i=0; i < sp.n_rows; i++)
223 for(
uint j=0; j < sp.n_cols; j++)
233 arma::uword n =
matrix.n_rows - 1;
234 ASSERT_LT(offset, n)(
"Schur complement (offset) dimension mismatch.");
237 arma::mat BinvA =
matrix.submat(offset, 0, n, offset-1) *
matrix.submat(0, 0, offset-1, offset-1).i();
240 schur.
matrix =
matrix.submat(offset, offset, n, n) - BinvA *
matrix.submat(0, offset, offset-1, n);
241 schur.
rhs =
rhs.subvec(offset, n) - BinvA *
rhs.subvec(0, offset-1);
246 schur.
rhs = -1.0 * schur.
rhs;
254 arma::uword n =
matrix.n_rows - 1;
255 ASSERT_LT(offset, n)(
"Schur complement (offset) dimension mismatch.");
257 reconstructed_solution.set_size(offset);
262 reconstructed_solution = invA *
rhs.subvec(0,offset-1) - invA *
matrix.submat(0, offset, offset-1, n) * schur_solution;
#define ASSERT_LT(a, b)
Definition of comparative assert macro (Less Than) only for debug mode.
#define ASSERT_EQ(a, b)
Definition of comparative assert macro (EQual) only for debug mode.
void set_sparsity(const arma::umat &sp)
Sets the sparsity pattern for the local system.
LocDofVec elim_cols
Rows indices of rows to be eliminated.
void set_solution_col(uint loc_col, double solution)
LocalSystem()
Default constructor.
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_size(uint nrows, uint ncols)
uint n_elim_rows
Number of rows/cols to be eliminated due to known solution.
void eliminate_solution()
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...
arma::mat sparsity
sparsity pattern
void set_rhs(arma::vec rhs)
arma::vec rhs
local system RHS
void add_value(uint row, uint col, double mat_val, double rhs_val)
Adds a single entry into the local system.
void set_matrix(arma::mat matrix)
arma::vec solution_rows
Cols indices of cols to be eliminated.
arma::vec solution_cols
Values of the known solution (for row dofs).
arma::vec diag_rows
Values of the known solution (for col dofs).
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....
arma::mat matrix
local system matrix
void reset()
Resets the matrix, RHS, dofs to zero and clears solution settings.
void set_solution_row(uint loc_row, double solution, double diag=0.0)
arma::Col< IntIdx > LocDofVec
ArmaMat< double, N, M > mat