OpenFCST: The open-source Fuel Cell Simulation Toolbox
|
Base class for applications. More...
#include <application_base.h>
Public Member Functions | |
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... | |
virtual void | declare_parameters (ParameterHandler &) |
Declare parameters for a parameter file. More... | |
void | print_parameters_to_file (ParameterHandler ¶m, const std::string &file_name, const ParameterHandler::OutputStyle &style) |
Print default parameters for the application to a file. More... | |
virtual void | initialize (ParameterHandler ¶m)=0 |
Pure virtual initialization function. More... | |
virtual void | remesh () |
Generate the next mesh depending on the mesh generation parameters. More... | |
virtual void | init_vector (FEVector &) const |
Initialize vector to problem size. More... | |
virtual void | start_vector (FEVector &dst, std::string) const |
Initialize vector to problem size. More... | |
virtual double | residual (FEVector &, const FEVectors &, bool apply_boundaries=true) |
Compute residual of src and store it into dst . More... | |
virtual void | solve (FEVector &dst, const FEVectors &src)=0 |
Solve the system assembled with right hand side in FEVectors src and return the result in FEVector dst . More... | |
virtual void | Tsolve (FEVector &, const FEVectors &) |
Solve the dual system assembled with right hand side rhs and return the result in start . More... | |
virtual double | estimate (const FEVectors &) |
Estimate cell-wise errors. More... | |
virtual double | evaluate (const FEVectors &) |
Evaluate a functional. More... | |
virtual void | grid_out (const std::string &) |
Write the mesh in the format specified by the ParameterHandler. More... | |
virtual void | data_out (const std::string &filename, const FEVectors &src) |
Write data 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 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... | |
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 | print_caller_name (const std::string &caller_name) const |
Print caller name. More... | |
Protected Attributes | |
boost::shared_ptr < ApplicationData > | data |
Object for auxiliary data. More... | |
Event | notifications |
Accumulate reasons for assembling here. More... | |
Base class for applications.
The idea of these application classes is the possibility to build a chain out of these in order to have several predefined nested solvers. For this, we distinguish applications roughly in two classes, both derived from ApplicationBase:
Linear applications implement the real finite element code like computing residuals on mesh cells, assembling matrices and solving linear systems. Linear application classes are the heart of openFCST. These classes use Equation, Layer, Kinetics, Material and Post-processing class objects in order to build and solve the underlying partial differential equations that describe the physical processes of the problem at hand, and output the solution in a convenient format that can be analyzed in ParaView, such as VTU format.
openFCST uses the continuous Galerkin finite element method (CG FEM) to solve the fuel cell governing equations. This method for solving partial differential equations can be summarized in the following steps:
Linear application classes are directly responsible for steps 1, 2, 5 and 6. Steps 3 and 4 are performed by the Equation, Layer, Kinetics, Material objects inside the application. Step 7 is performed by Post-processing objects inside the linear application.
The execution flow of openFCST is as follows. First, declare_parameters is called to make sure the input file contains all the necessary information and to provide default data for any missing variables, then initialize() is used to read the input file provided by the user and setup the problem computational domain, effective transport properties, and solver parameters. Then, the system of equations is constructed and solved using assembly, residual and solve.
Wrapper applications derived from ApplicationCopy; these usually implement a new solve() function as an iterative solver around another application. Wrapper applications are used to implement adaptive refinement and nonlinear problems. Solving the aforementioned cases, generally involves solving a linear problem iteratively. Wrapper applications therefore use either another wrapper application that contains a linear application or a linear application directly in order to solve the required linear problem. They implement all functions of the ApplicationBase interface either by forwarding them to the next inner application by ApplicationCopy or by providing their own implementation.
FuelCell::ApplicationCore::ApplicationBase::ApplicationBase | ( | boost::shared_ptr< ApplicationData > | data = boost::shared_ptr< ApplicationData >() | ) |
Constructor for an application.
One task of the constructor is declaring parameters for an application. Since this is done consecutively for derived classes, all parameters may be declared in a modular way. Derived classes should create unique subsections in the ParameterHandler.
FuelCell::ApplicationCore::ApplicationBase::ApplicationBase | ( | const ApplicationBase & | other | ) |
Copy constructor.
Generate a new application sharing the same ApplicationData with another one.
|
virtual |
Virtual destructor.
|
virtual |
All true
in notifications
.
|
virtual |
All false
in notifications
.
|
inlinevirtual |
Write data in the format specified by the ParameterHandler.
Pure virtual.
Reimplemented in FuelCell::ApplicationCore::DoFApplication< dim >, FuelCell::Application::AppPemfcNIThermal< dim >, FuelCell::Application::AppPemfcTPSaturation< dim >, FuelCell::Application::AppIncompressibleFlows< dim >, FuelCell::Application::AppPemfc< dim >, FuelCell::Application::AppPemfcCapillaryTwoPhaseNIThermal< dim >, FuelCell::Application::AppCathode< dim >, FuelCell::Application::AppThermalTest< dim >, FuelCell::Application::AppReadMesh< dim >, FuelCell::Application::AppDiffusion< dim >, FuelCell::Application::Thermaltesting< dim >, FuelCell::Application::AppCathodeKG< dim >, FuelCell::Application::AppOhmic< dim >, FuelCell::Application::AppCompressibleFlows< dim >, FuelCell::Application::CapillaryTesting< dim >, and FuelCell::ApplicationCore::ApplicationWrapper.
|
inlinevirtual |
Declare parameters for a parameter file.
This member function is used to identify a parameter in the parameter file.
Reimplemented in FuelCell::Application::AppIncompressibleFlows< dim >, FuelCell::ApplicationCore::newtonBase, FuelCell::ApplicationCore::DoFApplication< dim >, FuelCell::ApplicationCore::Newton3pp, FuelCell::Application::AppCathode< dim >, FuelCell::ApplicationCore::BlockMatrixApplication< dim >, FuelCell::Application::AppPemfcNIThermal< dim >, FuelCell::Application::AppPemfcTPSaturation< dim >, FuelCell::Application::AppPemfc< dim >, FuelCell::Application::AppPemfcCapillaryTwoPhaseNIThermal< dim >, FuelCell::Application::AppReadMesh< dim >, FuelCell::ApplicationCore::NewtonLineSearch, FuelCell::Application::AppDiffusion< dim >, FuelCell::ApplicationCore::ThetaScheme, FuelCell::Application::AppThermalTest< dim >, FuelCell::Application::AppOhmic< dim >, FuelCell::ApplicationCore::OptimizationBlockMatrixApplication< dim >, FuelCell::Application::Thermaltesting< dim >, FuelCell::Application::AppCathodeKG< dim >, FuelCell::Application::AppCompressibleFlows< dim >, FuelCell::Application::CapillaryTesting< dim >, FuelCell::ApplicationCore::PicardBase, FuelCell::ApplicationCore::Picard, FuelCell::ApplicationCore::TransientBase, FuelCell::ApplicationCore::ApplicationWrapper, and FuelCell::ApplicationCore::NewtonBasic.
|
inlinevirtual |
Estimate cell-wise errors.
Pure virtual.
Reimplemented in FuelCell::ApplicationCore::DoFApplication< dim >, FuelCell::Application::AppThermalTest< dim >, and FuelCell::ApplicationCore::ApplicationWrapper.
|
inlinevirtual |
Evaluate a functional.
Pure virtual.
Reimplemented in FuelCell::ApplicationCore::DoFApplication< dim >, FuelCell::Application::AppPemfcNIThermal< dim >, FuelCell::Application::AppPemfcTPSaturation< dim >, FuelCell::Application::AppPemfc< dim >, FuelCell::Application::AppPemfcCapillaryTwoPhaseNIThermal< dim >, FuelCell::Application::AppCathode< dim >, FuelCell::Application::AppDiffusion< dim >, FuelCell::Application::Thermaltesting< dim >, FuelCell::Application::AppOhmic< dim >, FuelCell::Application::CapillaryTesting< dim >, FuelCell::ApplicationCore::ApplicationWrapper, FuelCell::Application::AppStep8< dim >, and FuelCell::Application::AppStep3< dim >.
boost::shared_ptr<ApplicationData> FuelCell::ApplicationCore::ApplicationBase::get_data | ( | ) |
Get access to the protected variable data.
Referenced by FuelCell::ApplicationCore::Newton3pp::set_predefined_parameters().
const boost::shared_ptr<ApplicationData> FuelCell::ApplicationCore::ApplicationBase::get_data | ( | ) | const |
Get read-only access to the protected variable data.
|
virtual |
|
inlinevirtual |
Write the mesh in the format specified by the ParameterHandler.
Pure virtual.
Reimplemented in FuelCell::ApplicationCore::DoFApplication< dim >.
|
virtual |
Return a unique identification string for this application.
In particular, it returns the name of the class in which the object you requested id() from belongs to.
For example:
then,
Reimplemented in FuelCell::ApplicationCore::ApplicationWrapper.
|
inlinevirtual |
Initialize vector to problem size.
Pure virtual.
Reimplemented in FuelCell::ApplicationCore::DoFApplication< dim >, and FuelCell::ApplicationCore::ApplicationWrapper.
|
pure virtual |
Pure virtual initialization function.
This member function is used to read the parameters declared in the constructor from ParameterHandler and then, used to initialize all object including the object that generates the mesh and Equation, Layer, Kinetics, Material objects.
Implemented in FuelCell::Application::AppIncompressibleFlows< dim >, FuelCell::ApplicationCore::newtonBase, FuelCell::ApplicationCore::DoFApplication< dim >, FuelCell::ApplicationCore::Newton3pp, FuelCell::Application::AppCathode< dim >, FuelCell::Application::AppPemfcNIThermal< dim >, FuelCell::Application::AppPemfcTPSaturation< dim >, FuelCell::ApplicationCore::BlockMatrixApplication< dim >, FuelCell::Application::AppPemfc< dim >, FuelCell::Application::AppPemfcCapillaryTwoPhaseNIThermal< dim >, FuelCell::Application::AppReadMesh< dim >, FuelCell::Application::AppThermalTest< dim >, FuelCell::ApplicationCore::NewtonLineSearch, FuelCell::Application::AppDiffusion< dim >, FuelCell::ApplicationCore::AdaptiveRefinement< dim >, FuelCell::ApplicationCore::ThetaScheme, FuelCell::Application::AppOhmic< dim >, FuelCell::ApplicationCore::OptimizationBlockMatrixApplication< dim >, FuelCell::Application::Thermaltesting< dim >, FuelCell::Application::AppCathodeKG< dim >, FuelCell::Application::AppCompressibleFlows< dim >, FuelCell::Application::CapillaryTesting< dim >, FuelCell::ApplicationCore::PicardBase, FuelCell::ApplicationCore::TransientBase, FuelCell::ApplicationCore::Picard, FuelCell::ApplicationCore::ApplicationWrapper, FuelCell::ApplicationCore::NewtonBasic, FuelCell::Application::AppStep3< dim >, and FuelCell::Application::AppStep8< dim >.
|
virtual |
Add a reason for assembling.
Reimplemented in FuelCell::ApplicationCore::ApplicationWrapper.
|
protected |
Print caller name.
void FuelCell::ApplicationCore::ApplicationBase::print_parameters_to_file | ( | ParameterHandler & | param, |
const std::string & | file_name, | ||
const ParameterHandler::OutputStyle & | style | ||
) |
Print default parameters for the application to a file.
Note that this member function MUST be called after declare_parameters.
Example:
|
inlinevirtual |
Generate the next mesh depending on the mesh generation parameters.
Pure virtual.
Reimplemented in FuelCell::ApplicationCore::DoFApplication< dim >, FuelCell::ApplicationCore::BlockMatrixApplication< dim >, and FuelCell::ApplicationCore::ApplicationWrapper.
|
inlinevirtual |
Compute residual of src
and store it into dst
.
The bool variable is used to specify if boundary conditions should be applied using FilteredMatrix.
Pure virtual.
Reimplemented in FuelCell::ApplicationCore::DoFApplication< dim >, and FuelCell::ApplicationCore::ApplicationWrapper.
|
pure virtual |
Solve the system assembled with right hand side in FEVectors src
and return the result in FEVector dst
.
Pure virtual.
Implemented in FuelCell::ApplicationCore::BlockMatrixApplication< dim >, FuelCell::ApplicationCore::newtonBase, FuelCell::Application::AppReadMesh< dim >, FuelCell::ApplicationCore::Newton3pp, FuelCell::ApplicationCore::NewtonLineSearch, FuelCell::ApplicationCore::ThetaScheme, FuelCell::ApplicationCore::PicardBase, FuelCell::ApplicationCore::TransientBase, FuelCell::ApplicationCore::ApplicationWrapper, FuelCell::ApplicationCore::Picard, and FuelCell::ApplicationCore::NewtonBasic.
|
inlinevirtual |
Initialize vector to problem size.
|
inlinevirtual |
Solve the dual system assembled with right hand side rhs
and return the result in start
.
Pure virtual.
Reimplemented in FuelCell::ApplicationCore::ApplicationWrapper.
|
protected |
Object for auxiliary data.
This object is always valid, since it is either handed to the constructor or created there.
|
protected |
Accumulate reasons for assembling here.
If any of those is set, the function solve() of a terminal application must take care of assembling the matrix.