Flow123d  release_2.2.0-914-gf1a3a4f
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
LocalSystem Class Reference

#include <local_system.hh>

Public Types

typedef arma::uvec 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 (unsigned int nrows, unsigned int 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...
 

Detailed Description

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 26 of file local_system.hh.

Member Typedef Documentation

typedef arma::uvec LocalSystem::DofVec

Definition at line 29 of file local_system.hh.

Constructor & Destructor Documentation

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.

Member Function Documentation

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 178 of file local_system.cc.

Here is the caller graph for this function:

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 188 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 197 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.

Here is the caller graph for this function:

const arma::mat& LocalSystem::get_matrix ( )
inline

Definition at line 64 of file local_system.hh.

Here is the caller graph for this function:

const arma::vec& LocalSystem::get_rhs ( )
inline

Definition at line 65 of file local_system.hh.

Here is the caller graph for this function:

void LocalSystem::reset ( )

Resets the matrix, RHS, dofs to zero and clears solution settings.

Definition at line 43 of file local_system.cc.

Here is the caller graph for this function:

void LocalSystem::reset ( unsigned int  nrows,
unsigned int  ncols 
)

Resize and reset.

Definition at line 53 of file local_system.cc.

void LocalSystem::reset ( const DofVec row_dofs,
const DofVec col_dofs 
)

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)

Definition at line 205 of file local_system.cc.

Here is the caller graph for this function:

void LocalSystem::set_rhs ( arma::vec  rhs)

Definition at line 211 of file local_system.cc.

Here is the caller graph for this function:

void LocalSystem::set_size ( unsigned int  nrows,
unsigned int  ncols 
)
protected

Definition at line 27 of file local_system.cc.

Here is the caller graph for this function:

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.

Here is the caller graph for this function:

void LocalSystem::set_solution_col ( uint  loc_col,
double  solution 
)

Definition at line 91 of file local_system.cc.

Here is the caller graph for this function:

void LocalSystem::set_solution_row ( uint  loc_row,
double  solution,
double  diag = 0.0 
)

Definition at line 84 of file local_system.cc.

Here is the caller graph for this function:

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 216 of file local_system.cc.

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class LinSys
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 179 of file local_system.hh.

Member Data Documentation

constexpr double LocalSystem::almost_zero = std::numeric_limits<double>::min()
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 163 of file local_system.hh.

DofVec LocalSystem::col_dofs

Definition at line 36 of file local_system.hh.

arma::vec LocalSystem::diag_rows
protected

Definition at line 153 of file local_system.hh.

DofVec LocalSystem::elim_cols
protected

Definition at line 150 of file local_system.hh.

DofVec LocalSystem::elim_rows
protected

Definition at line 149 of file local_system.hh.

arma::mat LocalSystem::matrix
protected

local system matrix

Definition at line 143 of file local_system.hh.

unsigned int LocalSystem::n_elim_cols
protected

Definition at line 148 of file local_system.hh.

unsigned int LocalSystem::n_elim_rows
protected

Definition at line 148 of file local_system.hh.

arma::vec LocalSystem::rhs
protected

local system RHS

Definition at line 144 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 36 of file local_system.hh.

arma::vec LocalSystem::solution_cols
protected

Definition at line 152 of file local_system.hh.

arma::vec LocalSystem::solution_rows
protected

Definition at line 151 of file local_system.hh.

arma::mat LocalSystem::sparsity
protected

sparsity pattern

Definition at line 146 of file local_system.hh.


The documentation for this class was generated from the following files: