OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
SolverUtils Namespace Reference

This namespace is used to include routines that are used in the solve() routine of several applications such as AppCathode and AppPemfc. More...

Functions

void check_diagonal (const BlockSparseMatrix< double > &A)
 Check that the diagonal of the matrix does not have any zeros. More...
 
void output_diagonal (const BlockSparseMatrix< double > &A)
 Output diagonal elements of the stiffness matrix to the screen. More...
 
void print_diagonal (const BlockSparseMatrix< double > &A, const std::string &file=std::string("diag_matrix.dat"))
 Print the diagonal elements of a matrix to a file named diag_matrix.dat. More...
 
void repair_diagonal (BlockSparseMatrix< double > &A)
 This member function is used to make sure that the BlockSpareMatrix has no zeros in the diagonal. More...
 
void repair_diagonal (BlockSparseMatrix< double > &A, FuelCell::ApplicationCore::FEVector &, const FuelCell::ApplicationCore::FEVector &)
 This member function is used to make sure that the BlockSpareMatrix has no zeros in the diagonal. More...
 

Detailed Description

This namespace is used to include routines that are used in the solve() routine of several applications such as AppCathode and AppPemfc.

Author
Marc Secanell, 2008

Function Documentation

void SolverUtils::check_diagonal ( const BlockSparseMatrix< double > &  A)

Check that the diagonal of the matrix does not have any zeros.

If it does, the code issues a warning on optimized mode or throws an exception on debug mode

void SolverUtils::output_diagonal ( const BlockSparseMatrix< double > &  A)

Output diagonal elements of the stiffness matrix to the screen.

void SolverUtils::print_diagonal ( const BlockSparseMatrix< double > &  A,
const std::string &  file = std::string("diag_matrix.dat") 
)

Print the diagonal elements of a matrix to a file named diag_matrix.dat.

void SolverUtils::repair_diagonal ( BlockSparseMatrix< double > &  A)

This member function is used to make sure that the BlockSpareMatrix has no zeros in the diagonal.

If it has zeros, then, the diagonal is filled with the average value between the largest and the smallest number in the diagonal.

In most problems you will need to use this class to remove zeros in the diagonal for the equations that are not physical in certain domains. For example, when solving the catalyst layer, the membrane potential inside the GDL is NOT a physical quantity. Instead of adding a small number during assembly which would affect the solution, we add zeros. Then, we modify the diagonal matrix so that the value is zero everywhere on that domain and the fluxes at the boundaries between domains are not accounted for.

PETScWrappers::MPI::SparseMatrix matrix implementation alsos included. It is very similar to the BlockSparseMatrix<double> implementation.

Note
PETScWrappers::MPI::SparseMatrix implementation requires that the matrix is writable, i.e. compressed
PETScWrappers::MPI::SparseMatrix implementation compresses matrix before returning

Referenced by FuelCell::InitialAndBoundaryData::apply_zero_boundary_values_to_linear_system().

Here is the caller graph for this function:

void SolverUtils::repair_diagonal ( BlockSparseMatrix< double > &  A,
FuelCell::ApplicationCore::FEVector ,
const FuelCell::ApplicationCore::FEVector  
)

This member function is used to make sure that the BlockSpareMatrix has no zeros in the diagonal.

If it has zeros, then we rewrite the equation so that we ensure the solution at that node has a value of zero. This is done by passing the solution vector to the function and setting the RHS to this value. The zero in the system matrix is set to 1, so that we have $ 1(-\delta u) = \delta u $