Flow123d
release_3.0.0-1073-g8f35d56
|
#include <local_system.hh>
Public Types | |
typedef arma::Col< LongIdx > | DofVec |
Public Member Functions | |
LocalSystem () | |
Default constructor. More... | |
LocalSystem (unsigned int nrows, unsigned int ncols) | |
Constructor. More... | |
void | reset () |
Resets the matrix, RHS, dofs to zero and clears solution settings. More... | |
void | reset (arma::uword nrows, arma::uword ncols) |
Resize and reset. More... | |
void | reset (const DofVec &row_dofs, const DofVec &col_dofs) |
const arma::mat & | get_matrix () |
const arma::vec & | get_rhs () |
void | set_solution (unsigned int loc_dof, double solution, double diag=0.0) |
Set the position and value of known solution. E.g. Dirichlet boundary condition. More... | |
void | set_solution_row (uint loc_row, double solution, double diag=0.0) |
void | set_solution_col (uint loc_col, double solution) |
void | eliminate_solution () |
void | add_value (unsigned int row, unsigned int col, double mat_val, double rhs_val) |
Adds a single entry into the local system. More... | |
void | add_value (unsigned int row, unsigned int col, double mat_val) |
Matrix entry. Adds a single entry into the local system matrix. More... | |
void | add_value (unsigned int row, double rhs_val) |
RHS entry. Adds a single entry into the local system RHS. More... | |
void | set_matrix (arma::mat matrix) |
void | set_rhs (arma::vec rhs) |
void | set_sparsity (const arma::umat &sp) |
Sets the sparsity pattern for the local system. More... | |
Public Attributes | |
DofVec | row_dofs |
DofVec | col_dofs |
Protected Member Functions | |
void | set_size (unsigned int nrows, unsigned int ncols) |
Protected Attributes | |
arma::mat | matrix |
local system matrix More... | |
arma::vec | rhs |
local system RHS More... | |
arma::mat | sparsity |
sparsity pattern More... | |
unsigned int | n_elim_rows |
unsigned int | n_elim_cols |
DofVec | elim_rows |
DofVec | elim_cols |
arma::vec | solution_rows |
arma::vec | solution_cols |
arma::vec | diag_rows |
Static Protected Attributes | |
static constexpr double | almost_zero = std::numeric_limits<double>::min() |
Friends | |
class | LinSys |
vector of global row indices where the solution is set (dirichlet BC) More... | |
Local system class is meant to be used for local assembly and then pass to global linear system. The key idea is to take care of known solution values (Dirichlet boundary conditions) in a common way.
Usage of the class consists of 3 steps: 1) create local system, set global DoFs. 2) set all known values (Dirichlet BC) 3) set matrix and RHS entries (if the entry is on dirichlet row or column, it is now taken care of) 4) eliminate known solution and possibly fix the diagonal entries of the local system, where Dirichlet BC is set
TODO:
Definition at line 27 of file local_system.hh.
typedef arma::Col<LongIdx> LocalSystem::DofVec |
Definition at line 30 of file local_system.hh.
LocalSystem::LocalSystem | ( | ) |
Default constructor.
Object must be initialized by subsequent call of reset(nrows, ncols).
Definition at line 8 of file local_system.cc.
LocalSystem::LocalSystem | ( | unsigned int | nrows, |
unsigned int | ncols | ||
) |
Constructor.
nrows
is number of rows of local system ncols
is number of columns of local system
Definition at line 12 of file local_system.cc.
void LocalSystem::add_value | ( | unsigned int | row, |
unsigned int | col, | ||
double | mat_val, | ||
double | rhs_val | ||
) |
Adds a single entry into the local system.
row
is local row index of local system col
is local column index of local system mat_val
is matrix entry value rhs_val
is RHS entry value
Definition at line 176 of file local_system.cc.
void LocalSystem::add_value | ( | unsigned int | row, |
unsigned int | col, | ||
double | mat_val | ||
) |
Matrix entry. Adds a single entry into the local system matrix.
row
is local row index of local system col
is local column index of local system mat_val
is matrix entry value
Definition at line 186 of file local_system.cc.
void LocalSystem::add_value | ( | unsigned int | row, |
double | rhs_val | ||
) |
RHS entry. Adds a single entry into the local system RHS.
row
is local row index of local system rhs_val
is RHS entry value
Definition at line 195 of file local_system.cc.
void LocalSystem::eliminate_solution | ( | ) |
When finished with assembly of the local system, this function eliminates all the known dofs.
It is skipped if there is not any solution dof set.
During elimination, the (global) diagonal entries on the rows, where the solution is set, might be zero. Therefore it is necessary to set a proper value to the diagonal entry and respective RHS entry, such that the given solution holds. If preferred diagonal value has been set by set_solution
then it is used.
Calling this function after the assembly of local system is finished is users's responsibility.
Definition at line 109 of file local_system.cc.
|
inline |
|
inline |
void LocalSystem::reset | ( | ) |
Resets the matrix, RHS, dofs to zero and clears solution settings.
Definition at line 43 of file local_system.cc.
void LocalSystem::reset | ( | arma::uword | nrows, |
arma::uword | ncols | ||
) |
Resize and reset.
Definition at line 53 of file local_system.cc.
Resize and reset. Set dofs vectors to reuse arrays provided by given vectors. Given vectors can not be changed until next call to of any reset function.
Definition at line 66 of file local_system.cc.
void LocalSystem::set_matrix | ( | arma::mat | matrix | ) |
void LocalSystem::set_rhs | ( | arma::vec | rhs | ) |
|
protected |
void LocalSystem::set_solution | ( | unsigned int | loc_dof, |
double | solution, | ||
double | diag = 0.0 |
||
) |
Set the position and value of known solution. E.g. Dirichlet boundary condition.
loc_dofs
is local row index in solution vector solution
is the values of the solution diag_val
is preferred diagonal value on the solution row
Definition at line 76 of file local_system.cc.
void LocalSystem::set_solution_col | ( | uint | loc_col, |
double | solution | ||
) |
void LocalSystem::set_solution_row | ( | uint | loc_row, |
double | solution, | ||
double | diag = 0.0 |
||
) |
void LocalSystem::set_sparsity | ( | const arma::umat & | sp | ) |
Sets the sparsity pattern for the local system.
Due to petsc options: MatSetOption(matrix_, MAT_IGNORE_ZERO_ENTRIES, PETSC_TRUE) all zeros will be thrown away from the system. If we do not want some zero entries in the system matrix to be thrown away, we can set these entries with this almost zero value.
Almost_zero values will be set in all entries: sp(i,j) != 0
Definition at line 214 of file local_system.cc.
|
friend |
vector of global row indices where the solution is set (dirichlet BC)
vector of solution values at global_solution_rows
indices (dirichlet BC) diagonal values for dirichlet BC rows (set in set_solution) Optimization. Is false if solution (at least one entry) is known.
Definition at line 180 of file local_system.hh.
|
staticprotected |
Due to petsc options: MatSetOption(matrix_, MAT_IGNORE_ZERO_ENTRIES, PETSC_TRUE) all zeros will be thrown away from the system. If we do not want some zero entries in the system matrix to be thrown away, we can set these entries with this almost zero value.
This is done for example when BC values are eliminated and later the BC changes to different type (e.g. seepage). Another case is keeping the structure of matrix unchanged for the schur complements - for that we fill the whole diagonal (escpecially block C in darcy flow) with artificial zeros.
Definition at line 164 of file local_system.hh.
DofVec LocalSystem::col_dofs |
Definition at line 37 of file local_system.hh.
|
protected |
Definition at line 154 of file local_system.hh.
|
protected |
Definition at line 151 of file local_system.hh.
|
protected |
Definition at line 150 of file local_system.hh.
|
protected |
local system matrix
Definition at line 144 of file local_system.hh.
|
protected |
Definition at line 149 of file local_system.hh.
|
protected |
Definition at line 149 of file local_system.hh.
|
protected |
local system RHS
Definition at line 145 of file local_system.hh.
DofVec LocalSystem::row_dofs |
Global row and col indices. Are public and can be freely set. Nevertheless one can also provide reference to already existing arrays through specific constructor or reset function.
Definition at line 37 of file local_system.hh.
|
protected |
Definition at line 153 of file local_system.hh.
|
protected |
Definition at line 152 of file local_system.hh.
|
protected |
sparsity pattern
Definition at line 147 of file local_system.hh.