OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
FuelCell::ApplicationCore::PicardBase Class Referenceabstract

Base class for all classes performing Picard iterations. More...

#include <picard_base.h>

Inheritance diagram for FuelCell::ApplicationCore::PicardBase:
Inheritance graph
[legend]
Collaboration diagram for FuelCell::ApplicationCore::PicardBase:
Collaboration graph
[legend]

Public Member Functions

 PicardBase (ApplicationBase &app)
 Constructor, receiving the application computing the residual and solving the linear problem. More...
 
virtual void declare_parameters (ParameterHandler &param)
 Declare the input parameters. More...
 
virtual void initialize (ParameterHandler &param)
 Read the parameters. More...
 
void initialize_initial_guess (BlockVector< double > &dst)
 Control object for the Picard iteration. More...
 
virtual void assemble ()
 Instead of assembling, this function only sets a flag, such that the inner application will be required to assemble a new derivative matrix next time solve() is called. More...
 
virtual double residual (FuelCell::ApplicationCore::FEVector &dst, const FuelCell::ApplicationCore::FEVectors &rhs)
 Returns the L2-norm of the residual and the residual vector in "dst" using the residual function in the ApplicationBase used to initialize the application. More...
 
virtual void solve (FuelCell::ApplicationCore::FEVector &u, const FuelCell::ApplicationCore::FEVectors &in_vectors)=0
 The actual Picard solver. More...
 
- Public Member Functions inherited from FuelCell::ApplicationCore::ApplicationWrapper
 ApplicationWrapper (ApplicationBase &app)
 Constructor for a derived application. More...
 
 ~ApplicationWrapper ()
 Destructor. More...
 
virtual void remesh ()
 Generate the next mesh depending on the mesh generation parameters. More...
 
virtual void init_vector (FEVector &dst) const
 Initialize vector to problem size. More...
 
virtual double residual (FEVector &dst, const FEVectors &src, bool apply_boundaries=true)
 Compute residual of src and store it into dst. More...
 
virtual void Tsolve (FEVector &dst, const FEVectors &src)
 Solve the dual system assembled with right hand side rhs and return the result in start. More...
 
virtual double estimate (const FEVectors &src)
 Estimate cell-wise errors. More...
 
virtual double evaluate (const FEVectors &src)
 Evaluate a functional. More...
 
virtual void grid_out (const std::string &filename) const
 
virtual void data_out (const std::string &filename, const FEVectors &src)
 Write data in the format specified by the ParameterHandler. More...
 
virtual std::string id () const
 Return a unique identification string for this application. More...
 
virtual void notify (const Event &reason)
 Add a reason for assembling. More...
 
- Public Member Functions inherited from FuelCell::ApplicationCore::ApplicationBase
 ApplicationBase (boost::shared_ptr< ApplicationData > data=boost::shared_ptr< ApplicationData >())
 Constructor for an application. More...
 
 ApplicationBase (const ApplicationBase &other)
 Copy constructor. More...
 
virtual ~ApplicationBase ()
 Virtual destructor. More...
 
void print_parameters_to_file (ParameterHandler &param, const std::string &file_name, const ParameterHandler::OutputStyle &style)
 Print default parameters for the application to a file. More...
 
virtual void start_vector (FEVector &dst, std::string) const
 Initialize vector to problem size. More...
 
virtual void grid_out (const std::string &)
 Write the mesh in the format specified by the ParameterHandler. More...
 
boost::shared_ptr
< ApplicationData
get_data ()
 Get access to the protected variable data. More...
 
const boost::shared_ptr
< ApplicationData
get_data () const
 Get read-only access to the protected variable data. More...
 
virtual void clear ()
 All true in notifications. More...
 
virtual void clear_events ()
 All false in notifications. More...
 
virtual unsigned int get_solution_index ()
 Returns solution index. More...
 

Protected Member Functions

void debug_output (const FEVector &sol, const FEVector &update, const FEVector &residual) const
 Function used to output any necessary information at each Picard iteration for debugging purposes. More...
 
- Protected Member Functions inherited from FuelCell::ApplicationCore::ApplicationWrapper
SmartPointer< ApplicationBaseget_wrapped_application ()
 Gain access to the inner application. More...
 
- Protected Member Functions inherited from FuelCell::ApplicationCore::ApplicationBase
void print_caller_name (const std::string &caller_name) const
 Print caller name. More...
 

Protected Attributes

bool assemble_now
 This flag is set by the function assemble(), indicating that the matrix must be assembled anew upon start. More...
 
double abs_tolerance
 Absolute tolerance for the Picard convergence loop. More...
 
double rel_tolerance
 Relative tolerance for the Picard convergence loop. More...
 
int maxsteps
 Maximu no. More...
 
bool debug_solution
 Print updated solution after each step into file. More...
 
bool debug_residual
 Print Picard residual after each step into file Picard_rNNN? More...
 
unsigned int debug
 Write debug output to FcstUtilities::log; the higher the number, the more output. More...
 
unsigned int step
 The number of a basic Picard iteration. More...
 
double numIter
 Number of Iterations;. More...
 
std::vector< unsigned int > blocks
 This vector specifies the blocks of the global solution which are supposed to be treated specially. More...
 
unsigned int n_blocks
 The total number of blocks. More...
 
- Protected Attributes inherited from FuelCell::ApplicationCore::ApplicationWrapper
SmartPointer< ApplicationBaseapp
 Pointer to the application this one depends upon. More...
 
- Protected Attributes inherited from FuelCell::ApplicationCore::ApplicationBase
boost::shared_ptr
< ApplicationData
data
 Object for auxiliary data. More...
 
Event notifications
 Accumulate reasons for assembling here. More...
 

Detailed Description

Base class for all classes performing Picard iterations.

Children of this class mainly differ in the formulation of the problem. Currently only one algorithm which inverts the complete stiffness matrix is implemented.

Parameters

The parameters that control Picard solvers are defined in the subsection Picard in the data input file. The parameters are the following:

* subsection Picard
* set Max steps = 100 # Maximum number of iterations
* set Absolute tolerance = 1.e-8 # Absolute tolerance
* set Relative tolerance = 1.e-3 # Relative tolerance
* set Debug level = 0
* set Debug residual = false # Would you like the code to output the residual at every Picard iteration?
* set Debug solution = false # Would you like the code to output the solution at every Picard iteration?
* end
*
Author
Mayank Sabharwal, 2015

Constructor & Destructor Documentation

FuelCell::ApplicationCore::PicardBase::PicardBase ( ApplicationBase app)

Constructor, receiving the application computing the residual and solving the linear problem.

Member Function Documentation

virtual void FuelCell::ApplicationCore::PicardBase::assemble ( )
virtual

Instead of assembling, this function only sets a flag, such that the inner application will be required to assemble a new derivative matrix next time solve() is called.

void FuelCell::ApplicationCore::PicardBase::debug_output ( const FEVector sol,
const FEVector update,
const FEVector residual 
) const
protected

Function used to output any necessary information at each Picard iteration for debugging purposes.

virtual void FuelCell::ApplicationCore::PicardBase::declare_parameters ( ParameterHandler &  param)
virtual

Declare the input parameters.

The following are the parameters used and their default values: In section: "Picard"

  • "Absolute Tolerance",
  • "Relative Tolerance",
  • "Max steps",

Reimplemented from FuelCell::ApplicationCore::ApplicationWrapper.

Reimplemented in FuelCell::ApplicationCore::Picard.

virtual void FuelCell::ApplicationCore::PicardBase::initialize ( ParameterHandler &  param)
virtual

Read the parameters.

Reimplemented from FuelCell::ApplicationCore::ApplicationWrapper.

Reimplemented in FuelCell::ApplicationCore::Picard.

void FuelCell::ApplicationCore::PicardBase::initialize_initial_guess ( BlockVector< double > &  dst)
inline

Control object for the Picard iteration.

virtual double FuelCell::ApplicationCore::PicardBase::residual ( FuelCell::ApplicationCore::FEVector dst,
const FuelCell::ApplicationCore::FEVectors rhs 
)
virtual

Returns the L2-norm of the residual and the residual vector in "dst" using the residual function in the ApplicationBase used to initialize the application.

The FEVectors rhs should contain at least the following vectors:

  • Note
    Finish this section
virtual void FuelCell::ApplicationCore::PicardBase::solve ( FuelCell::ApplicationCore::FEVector u,
const FuelCell::ApplicationCore::FEVectors in_vectors 
)
pure virtual

The actual Picard solver.

In this section, the Picard solver performs the iterations necessary to solve the nonlinear system. During the process it will call assemble() and residual() as needed. Once it is done, it will return the solution as parameter {u}.

Reimplemented from FuelCell::ApplicationCore::ApplicationWrapper.

Implemented in FuelCell::ApplicationCore::Picard.

Member Data Documentation

double FuelCell::ApplicationCore::PicardBase::abs_tolerance
protected

Absolute tolerance for the Picard convergence loop.

bool FuelCell::ApplicationCore::PicardBase::assemble_now
protected

This flag is set by the function assemble(), indicating that the matrix must be assembled anew upon start.

std::vector<unsigned int> FuelCell::ApplicationCore::PicardBase::blocks
protected

This vector specifies the blocks of the global solution which are supposed to be treated specially.

Such blocks usually include the density or molar fraction of oxygen (burns as a result of chemical reactions) and the density or molar fraction of hydrogen (burns as well as a result of chemical reactions). These blocks are defined in the parameter files manually. Therefore, you need to know them beforehand. Knowing these blocks, the non-linear solver checks against the negative values in those blocks and reduces the solution update if needed to keep the values positive.

unsigned int FuelCell::ApplicationCore::PicardBase::debug
protected

Write debug output to FcstUtilities::log; the higher the number, the more output.

bool FuelCell::ApplicationCore::PicardBase::debug_residual
protected

Print Picard residual after each step into file Picard_rNNN?

bool FuelCell::ApplicationCore::PicardBase::debug_solution
protected

Print updated solution after each step into file.

int FuelCell::ApplicationCore::PicardBase::maxsteps
protected

Maximu no.

of steps for the Picard iterations"

unsigned int FuelCell::ApplicationCore::PicardBase::n_blocks
protected

The total number of blocks.

double FuelCell::ApplicationCore::PicardBase::numIter
protected

Number of Iterations;.

double FuelCell::ApplicationCore::PicardBase::rel_tolerance
protected

Relative tolerance for the Picard convergence loop.

unsigned int FuelCell::ApplicationCore::PicardBase::step
protected

The number of a basic Picard iteration.


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