Flow123d
release_3.0.0-1210-g1d9e2bd
|
#include <la_linsys_new.hh>
Classes | |
struct | SolveInfo |
Public Types | |
enum | SetValuesMode { INSERT =INSERT_VALUES, ADD =ADD_VALUES, ALLOCATE, DONE, NONE } |
Public Member Functions | |
LinSys (const Distribution *rows_ds) | |
LinSys (LinSys &other) | |
unsigned int | size () |
unsigned int | vec_lsize () |
virtual const Mat * | get_matrix () |
virtual const Vec * | get_rhs () |
void | set_matrix_changed () |
void | set_rhs_changed () |
virtual void | set_tolerances (double r_tol, double a_tol, unsigned int max_it)=0 |
bool | is_matrix_changed () |
bool | is_rhs_changed () |
virtual PetscErrorCode | set_matrix (Mat &matrix, MatStructure str) |
virtual PetscErrorCode | set_rhs (Vec &rhs) |
virtual PetscErrorCode | mat_zero_entries () |
virtual PetscErrorCode | rhs_zero_entries () |
const Vec & | get_solution () |
void | set_solution (Vec sol_vec) |
void | set_solution (double *sol_array) |
void | set_solution () |
double * | get_solution_array () |
virtual void | start_allocation () |
virtual void | start_add_assembly () |
virtual void | start_insert_assembly () |
virtual void | finish_assembly ()=0 |
virtual void | mat_set_values (int nrow, int *rows, int ncol, int *cols, double *vals)=0 |
void | mat_set_value (int row, int col, double val) |
virtual void | rhs_set_values (int nrow, int *rows, double *vals)=0 |
void | rhs_set_value (int row, double val) |
void | set_values (int nrow, int *rows, int ncol, int *cols, PetscScalar *mat_vals, PetscScalar *rhs_vals) |
Set values in the system matrix and values in the right-hand side vector on corresponding rows. More... | |
void | set_local_system (LocalSystem &local) |
void | set_values (std::vector< int > &row_dofs, std::vector< int > &col_dofs, const arma::mat &matrix, const arma::vec &rhs, const arma::vec &row_solution, const arma::vec &col_solution) |
void | add_constraint (int row, double value) |
virtual void | apply_constrains (double scalar)=0 |
virtual SolveInfo | solve ()=0 |
double | get_residual_norm () |
virtual double | compute_residual ()=0 |
double | get_relative_accuracy () |
virtual double | get_absolute_accuracy () |
void | set_symmetric (bool flag=true) |
bool | is_symmetric () |
void | set_positive_definite (bool flag=true) |
void | set_negative_definite (bool flag=true) |
bool | is_positive_definite () |
bool | is_negative_definite () |
bool | is_new () |
bool | is_preallocated () |
void | set_spd_via_symmetric_general (bool flag=true) |
bool | is_spd_via_symmetric_general () |
virtual void | view () |
virtual void | set_from_input (const Input::Record in_rec) |
virtual double | get_solution_precision ()=0 |
virtual | ~LinSys () |
Static Public Member Functions | |
static Input::Type::Abstract & | get_input_type () |
Protected Types | |
typedef std::pair< unsigned, double > | Constraint_ |
typedef std::vector< Constraint_ > | ConstraintVec_ |
Protected Attributes | |
double | r_tol_ |
relative tolerance of linear solver More... | |
double | a_tol_ |
absolute tolerance of linear solver More... | |
unsigned int | max_it_ |
maximum number of iterations of linear solver More... | |
MPI_Comm | comm_ |
SetValuesMode | status_ |
Set value status of the linear system. More... | |
const unsigned | lsize_ |
local number of matrix rows (non-overlapping division of rows) More... | |
unsigned | size_ |
global number of matrix rows, i.e. problem size More... | |
const Distribution * | rows_ds_ |
final distribution of rows of MH matrix More... | |
bool | symmetric_ |
bool | positive_definite_ |
bool | negative_definite_ |
bool | spd_via_symmetric_general_ |
bool | matrix_changed_ |
true if the matrix was changed since the last solve More... | |
bool | rhs_changed_ |
true if the right hand side was changed since the last solve More... | |
Vec | solution_ |
PETSc vector constructed with vb array. More... | |
double * | v_solution_ |
local solution array pointing into Vec solution_ More... | |
bool | own_vec_ |
Indicates if the solution vector has been allocated by this class. More... | |
bool | own_solution_ |
Indicates if the solution array has been allocated by this class. More... | |
double | residual_norm_ |
local solution array pointing into Vec solution_ More... | |
ConstraintVec_ | constraints_ |
std::vector< double > | globalSolution_ |
global solution in numbering for linear system More... | |
Input::Record | in_rec_ |
Static Protected Attributes | |
static constexpr double | default_r_tol_ = 1e-7 |
static constexpr double | default_a_tol_ = 1e-11 |
static constexpr unsigned int | default_max_it_ = 1000 |
Private Member Functions | |
LinSys * | block (i, j) MatrixArray *matrix() virtual solve(Vector solution |
Private Attributes | |
LinSys Vector | RHS |
Friends | |
class | SchurComplement |
LinSys - matrix and a particular way how to compute solution for given RHS, i.e. this class can perform action of the matrix inverse
This is abstract class for members of possible hierarchical tree of the whole system.
Definition at line 169 of file la_linsys_new.hh.
|
protected |
|
protected |
|
inline |
Constructor. Constructor of abstract class should not be called directly, but is used for initialization of member common to all particular solvers.
comm | - MPI communicator |
TODO: Vector solution_ is now initialized to NULL, but it should be rather allocated in the constructor instead of the method set_solution().
Definition at line 128 of file linsys.hh.
|
inlinevirtual |
|
inline |
|
pure virtual |
Apply constrains to assembled matrix. Constrains are given by pairs: global row index, value. i.e. typedef pair<unsigned int, double> Constrain;
What is th meaning of ( const double factor ) form Cambridge code?
Implemented in LinSys_PETSC, and LinSys_BDDC.
|
private |
|
pure virtual |
Explicitly compute residual and its norm for current solution.
Implemented in LinSys_PETSC, SchurComplement, and LinSys_BDDC.
|
pure virtual |
Finish assembly of the whole system. For PETSC this should call MatEndAssembly with MAT_FINAL_ASSEMBLY
Implemented in LinSys_PETSC, and LinSys_BDDC.
|
inlinevirtual |
Returns information on absolute solver accuracy
Reimplemented in LinSys_PETSC.
|
static |
|
inlinevirtual |
Returns PETSC matrix (only for PETSC solvers)
If matrix is changed, method set_matrix_changed() must be called. Example: MatDiagonalSet(schur->get_matrix(), new_diagonal, ADD_VALUES); schur->set_matrix_changed();
Reimplemented in LinSys_PETSC.
Definition at line 187 of file linsys.hh.
|
inline |
|
inline |
|
inlinevirtual |
Returns RHS vector (only for PETSC solvers)
If vector is changed, method set_rhs_changed() must be called. Example: VecScale(schur->get_rhs(), -1.0); schur->set_rhs_changed();
Reimplemented in LinSys_PETSC.
Definition at line 203 of file linsys.hh.
|
inline |
|
inline |
|
pure virtual |
Get precision of solving
Implemented in LinSys_PETSC, SchurComplement, and LinSys_BDDC.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
pure virtual |
Assembly full rectangular submatrix into the system matrix. Should be virtual, implemented differently in particular solvers.
Implemented in LinSys_PETSC, and LinSys_BDDC.
|
inlinevirtual |
Clears entries of the matrix
Reimplemented in LinSys_PETSC, and LinSys_BDDC.
Definition at line 264 of file linsys.hh.
|
inline |
|
pure virtual |
Set values of the system right-hand side. Should be virtual, implemented differently in particular solvers.
Implemented in LinSys_PETSC, and LinSys_BDDC.
|
inlinevirtual |
Clears entries of the right-hand side
Reimplemented in LinSys_PETSC, and LinSys_BDDC.
Definition at line 273 of file linsys.hh.
|
inlinevirtual |
Sets basic parameters of LinSys defined by user in input file and used to calculate
Reimplemented in LinSys_PETSC, SchurComplement, and LinSys_BDDC.
Definition at line 621 of file linsys.hh.
|
inline |
|
inlinevirtual |
Sets PETSC matrix (only for PETSC solvers)
Reimplemented in LinSys_PETSC.
Definition at line 246 of file linsys.hh.
|
inline |
|
inline |
|
inline |
|
inlinevirtual |
Sets RHS vector (only for PETSC solvers)
Reimplemented in LinSys_PETSC.
Definition at line 255 of file linsys.hh.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Provides user knowledge about positive definiteness via symmetric general approach. This is useful for solving Darcy flow by mixed hybrid method, where blocks on subdomains are saddle point but interface among subdomains is only at the block of Lagrange multipliers and is symmetric positive definite. Problem condensed to interface can thus be solved by PCG method, although original problem is saddle point.
|
inline |
|
pure virtual |
Set relative tolerance, absolute tolerance, and maximum number of iterations of the linear solver.
For each of these three parameters we first look for the value at user input if not set we use the value provided to this method and finally the default values are set by the call of this method in the constructor.
Implemented in SchurComplement, LinSys_PETSC, and LinSys_BDDC.
|
inline |
|
inline |
Add given dense matrix to preallocation. Shortcut to assembly into matrix and RHS in one call, possibly apply Dirichlet boundary conditions. row_dofs
- are global indices of rows of dense matrix
and rows of dense vector in global system col_dofs
- are global indices of columns of the matrix, and possibly
Application of Dirichlet conditions: 1) Rows with negative dofs are set to zero. 2) Cols with negative dofs are eliminated. 3) If there are entries on global diagonal. We determine value K either from diagonal of local matrix, or (if it is zero) from diagonal average.
Caveats:
|
inline |
|
pure virtual |
Solve the system and return convergence reason.
Implemented in LinSys_PETSC, SchurComplement, and LinSys_BDDC.
|
inlinevirtual |
Switch linear system into adding assembly. (the only one supported by triplets ??)
Reimplemented in LinSys_PETSC.
Definition at line 341 of file linsys.hh.
|
inlinevirtual |
Switch linear system into allocating assembly. (only for PETSC_MPIAIJ_preallocate_by_assembly)
Reimplemented in LinSys_PETSC.
Definition at line 333 of file linsys.hh.
|
inlinevirtual |
Switch linear system into insert assembly. (not currently used)
Reimplemented in LinSys_PETSC.
Definition at line 349 of file linsys.hh.
|
inline |
|
inlinevirtual |
Output the system in the Matlab format possibly with given ordering. Rather we shoud provide output operator <<, since it is more flexible.
Reimplemented in LinSys_PETSC.
Definition at line 613 of file linsys.hh.
|
friend |
|
protected |
|
protected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
private |
Definition at line 173 of file la_linsys_new.hh.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |