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::ApplicationBase Class Referenceabstract

Base class for applications. More...

#include <application_base.h>

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

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 &param, const std::string &file_name, const ParameterHandler::OutputStyle &style)
 Print default parameters for the application to a file. More...
 
virtual void initialize (ParameterHandler &param)=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...
 

Detailed Description

Base class for applications.

Use of applications

Application chains

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:

  1. Linear applications
  2. Wrapper applications

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:

  1. Discretization of the n-dimensional physical domain, $ \Omega $, into the set $ \mathbb{T}_h $ of disjoint non-overlapping elements $ K $, known commonly as either mesh or grid,
  2. introduction of the finite element space $ \mathcal{V}_h^p $ consisting of continuous scalar-valued polynomial functions $ v_h $ of degree $ p > 0 $ such that for each element $ K \in \mathbb{T}_h: v_h = \sum_{i=1}^{N_s} v_{h,i} \psi_i(\mathbf{x}) $ where $ v_h $ is either the test or solution approximation function, $ N_s = (p+1)^{\text{dim}} $ is the number of support points, $ v_{h,i} $ are the values of $ v_h $ at the support points, and $ \psi_i(\mathbf{x}) $ are basis functions which are compactly supported on $ K $ and elements adjacent to $ K $,
  3. linearization of governing equations if needed,
  4. derivation, using the continuous Galerkin method, of the global and then element-wise weak formulation of the linearized problem,
  5. assemble of the global linear system of equations using the finite element-wise weak form of the PDEs,
  6. solution of the global linear system of equations using the numerical methods of linear algebra, and
  7. post-processing of the solution.

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.

Author
Guido Kanschat, 2006
Marc Secanell, 2006-14
Valentin Zingan, 2012-14

Constructor & Destructor Documentation

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.

Note
Actually, this constructor does nothing, since the base class declares no parameters.
FuelCell::ApplicationCore::ApplicationBase::ApplicationBase ( const ApplicationBase other)

Copy constructor.

Generate a new application sharing the same ApplicationData with another one.

virtual FuelCell::ApplicationCore::ApplicationBase::~ApplicationBase ( )
virtual

Virtual destructor.

Member Function Documentation

virtual void FuelCell::ApplicationCore::ApplicationBase::clear ( )
virtual

All true in notifications.

virtual void FuelCell::ApplicationCore::ApplicationBase::clear_events ( )
virtual

All false in notifications.

virtual void FuelCell::ApplicationCore::ApplicationBase::data_out ( const std::string &  filename,
const FEVectors src 
)
inlinevirtual
virtual void FuelCell::ApplicationCore::ApplicationBase::declare_parameters ( ParameterHandler &  )
inlinevirtual
virtual double FuelCell::ApplicationCore::ApplicationBase::estimate ( const FEVectors )
inlinevirtual
virtual double FuelCell::ApplicationCore::ApplicationBase::evaluate ( const FEVectors )
inlinevirtual
boost::shared_ptr<ApplicationData> FuelCell::ApplicationCore::ApplicationBase::get_data ( )

Get access to the protected variable data.

Referenced by FuelCell::ApplicationCore::Newton3pp::set_predefined_parameters().

Here is the caller graph for this function:

const boost::shared_ptr<ApplicationData> FuelCell::ApplicationCore::ApplicationBase::get_data ( ) const

Get read-only access to the protected variable data.

virtual unsigned int FuelCell::ApplicationCore::ApplicationBase::get_solution_index ( )
virtual

Returns solution index.

Pure virtual.

Reimplemented in FuelCell::Application::AppDiffusion< dim >.

virtual void FuelCell::ApplicationCore::ApplicationBase::grid_out ( const std::string &  )
inlinevirtual

Write the mesh in the format specified by the ParameterHandler.

Pure virtual.

Reimplemented in FuelCell::ApplicationCore::DoFApplication< dim >.

virtual std::string FuelCell::ApplicationCore::ApplicationBase::id ( ) const
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:

* cBase* a = new cBase
* cBase* b = new cDerived
*

then,

* a->id() will return cBase and
* b->id() will return cDerived
*

Reimplemented in FuelCell::ApplicationCore::ApplicationWrapper.

virtual void FuelCell::ApplicationCore::ApplicationBase::init_vector ( FEVector ) const
inlinevirtual

Initialize vector to problem size.

Pure virtual.

Reimplemented in FuelCell::ApplicationCore::DoFApplication< dim >, and FuelCell::ApplicationCore::ApplicationWrapper.

virtual void FuelCell::ApplicationCore::ApplicationBase::initialize ( ParameterHandler &  param)
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.

Note
This function must be overloaded in any derived class using its own values from the parameter file.
Initialization functions of derived classes must make sure to call all functions initialize() of the base classes.

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 void FuelCell::ApplicationCore::ApplicationBase::notify ( const Event reason)
virtual

Add a reason for assembling.

Reimplemented in FuelCell::ApplicationCore::ApplicationWrapper.

void FuelCell::ApplicationCore::ApplicationBase::print_caller_name ( const std::string &  caller_name) const
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:

* ParamterHandler param;
* app.declare_parameters(param);
* app.print_parameters_to_file(param, "default_parameters.txt", ParameterHandler::XML);
*
virtual void FuelCell::ApplicationCore::ApplicationBase::remesh ( )
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.

virtual double FuelCell::ApplicationCore::ApplicationBase::residual ( FEVector ,
const FEVectors ,
bool  apply_boundaries = true 
)
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.

virtual void FuelCell::ApplicationCore::ApplicationBase::solve ( FEVector dst,
const FEVectors src 
)
pure virtual
virtual void FuelCell::ApplicationCore::ApplicationBase::start_vector ( FEVector dst,
std::string   
) const
inlinevirtual

Initialize vector to problem size.

virtual void FuelCell::ApplicationCore::ApplicationBase::Tsolve ( FEVector ,
const FEVectors  
)
inlinevirtual

Solve the dual system assembled with right hand side rhs and return the result in start.

Pure virtual.

Reimplemented in FuelCell::ApplicationCore::ApplicationWrapper.

Member Data Documentation

boost::shared_ptr<ApplicationData> FuelCell::ApplicationCore::ApplicationBase::data
protected

Object for auxiliary data.

This object is always valid, since it is either handed to the constructor or created there.

Event FuelCell::ApplicationCore::ApplicationBase::notifications
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.


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