OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
FuelCell::ApplicationCore::AdaptiveRefinement< dim > Class Template Reference

This class is initialized with an application that describes the linearization of the problem that we would like to solve and the nonlinear solver that drives the process (usually a Newton loop). More...

#include <adaptive_refinement.h>

Inheritance diagram for FuelCell::ApplicationCore::AdaptiveRefinement< dim >:
Inheritance graph
[legend]
Collaboration diagram for FuelCell::ApplicationCore::AdaptiveRefinement< dim >:
Collaboration graph
[legend]

Public Member Functions

 AdaptiveRefinement (FuelCell::ApplicationCore::ApplicationBase &application)
 Constructor. More...
 
 AdaptiveRefinement (FuelCell::ApplicationCore::OptimizationBlockMatrixApplication< dim > &app_lin, FuelCell::ApplicationCore::ApplicationWrapper &app, const FuelCell::ApplicationCore::FEVector &solution=FuelCell::ApplicationCore::FEVector())
 Constructor. More...
 
 ~AdaptiveRefinement ()
 
void declare_parameters (ParameterHandler &param) const
 Declare all parameters that are needed for: More...
 
void initialize (ParameterHandler &param)
 Set up how many equations are needed and read in parameters for the parameter handler in order to initialize data. More...
 
void test_derivatives (const std::string input_file, const std::string dvar, const double value, std::vector< double > &resp, std::vector< std::vector< double > > &dresp, const bool gradient=true)
 Member function used to test the derivatives. More...
 
void print_parameters () const
 Print parameters: More...
 
const
FuelCell::ApplicationCore::FEVector
get_solution () const
 This function returns solution. More...
 
const
FuelCell::ApplicationCore::FEVector
get_coarse_solution () const
 This function returns coarse_solution. More...
 
const Triangulation< dim > & get_coarse_triangulation () const
 This function returns coarse_triangulation. More...
 
Solving functions
void solve (const std::string param_file, ParameterHandler &param, bool solution_component_changes_between_data_files=false)
 Solve the nonlinear problem. More...
 
void run_app (bool solution_component_changes_between_data_files=false)
 Run application. More...
 
void run_app (std::vector< double > &resp, bool solution_component_changes_between_data_files=false)
 Run application. More...
 
void run_app (std::vector< double > &resp, std::vector< std::vector< double > > &dresp_dl, bool solution_component_changes_between_data_files=false)
 Run application. More...
 
- Public Member Functions inherited from FuelCell::ApplicationCore::ApplicationWrapper
 ApplicationWrapper (ApplicationBase &app)
 Constructor for a derived application. More...
 
 ~ApplicationWrapper ()
 Destructor. More...
 
virtual void declare_parameters (ParameterHandler &param)
 Declare parameters for a parameter file. 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 solve (FEVector &dst, const FEVectors &src)
 Solve the system assembled with right hand side in FEVectors src and return the result in FEVector 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...
 

Private Member Functions

void print_convergence_table ()
 

Private Attributes

std::string filename_initial_mesh
 Filename where to output the initial grid. More...
 
bool output_initial_mesh
 Flag to specify if the initial grid should be saved to a file. More...
 
bool output_intermediate_sol
 Boolean flag that is set to true if intermediate solutions, i.e. More...
 
bool output_final_sol
 Boolean flag used to specify if the final solution should be output to a file. More...
 
std::string filename_final_sol
 Filename where the final solution will be output. More...
 
bool output_intermediate_resp
 Bool flag used to specify if all responses/functionals should be evaluated at intermediate refinement levels. More...
 
bool L1_L2_error_and_convergence_rate
 Use true if you have the exact or analytical solution to compare your numerical results with. More...
 
bool nonlinear_solver_for_linear_problem
 Use true along with zero initial guess defined in your application to solve a linear problem by means of using any of the FCST nonlinear solvers. More...
 
unsigned int n_ref
 Number of initial refinements for the original mesh. More...
 
bool gradients
 Compute the gradients? More...
 
Triangulation< dimcoarse_triangulation
 Initial mesh. More...
 
FuelCell::ApplicationCore::OptimizationBlockMatrixApplication
< dim > * 
app_linear
 Pointer to linear application. More...
 
FuelCell::ApplicationCore::ApplicationWrapperapp
 Poiner to nonlinear application. More...
 
FuelCell::ApplicationCore::FEVector solution
 Global FE solution at the support points of the most refined mesh. More...
 
FuelCell::ApplicationCore::FEVector coarse_solution
 Global FE solution at the support points of the initial mesh. More...
 
std::vector< ConvergenceTable > convergence_tables
 If the exact or analytical solution is available, then those convergence tables collect all necessary information on L1 and L2 norms of the error and convergence rates for each particular component of the numerical solution. More...
 

Additional Inherited Members

- 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 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

template<int dim>
class FuelCell::ApplicationCore::AdaptiveRefinement< dim >

This class is initialized with an application that describes the linearization of the problem that we would like to solve and the nonlinear solver that drives the process (usually a Newton loop).

Then, this class implements the adaptive refinement loop for the application.

Author
M. Secanell, 2006-13

and the concept of sequential applications, simplified parameter study without Dakota, and convergence tables by

Author
Valentin N. Zingan

Constructor & Destructor Documentation

Constructor.

Member Function Documentation

template<int dim>
void FuelCell::ApplicationCore::AdaptiveRefinement< dim >::declare_parameters ( ParameterHandler &  param) const

Declare all parameters that are needed for:

- control of adaptive refinement loop
- control of output options during the loop, e.g. return the solution at each cycle

Currently the options implemented are:

* subsection Adaptive refinement
* set Number of Refinements = 1 # Number of adaptive refinements used
* set Output initial mesh = false # Set flag to true if you want to output a EPS figure of the initial mesh using the value in file initial mesh
* set Output initial mesh filename = initial_mesh # File where the initial mesh will be output
* set Output initial solution = false # Set flag to true if you want to output the initial solution to file
* set Initial solution filename = initial_sol # File where the initial solution will be output
* set Output intermediate solutions = true # Output the solution after each adaptive refinement level
* set Output intermediate responses = true # Output any functional such as current density at each refinement level
* set Output final solution = true # Output final solution to a file named fuel_cell-sol-cycleX where X is the cycle name.
* set Output solution for transfer = false # Check whether a solution on a refined grid should be output to file on a coarse mesh
* set Read in initial solution from file = false # Check whether a stored solution should be read from file and applied to the grid
* end
*
template<int dim>
const FuelCell::ApplicationCore::FEVector& FuelCell::ApplicationCore::AdaptiveRefinement< dim >::get_coarse_solution ( ) const
inline

This function returns coarse_solution.

References FuelCell::ApplicationCore::AdaptiveRefinement< dim >::coarse_solution.

template<int dim>
const Triangulation<dim>& FuelCell::ApplicationCore::AdaptiveRefinement< dim >::get_coarse_triangulation ( ) const
inline

This function returns coarse_triangulation.

References FuelCell::ApplicationCore::AdaptiveRefinement< dim >::coarse_triangulation.

template<int dim>
const FuelCell::ApplicationCore::FEVector& FuelCell::ApplicationCore::AdaptiveRefinement< dim >::get_solution ( ) const
inline

This function returns solution.

References FuelCell::ApplicationCore::AdaptiveRefinement< dim >::solution.

template<int dim>
void FuelCell::ApplicationCore::AdaptiveRefinement< dim >::initialize ( ParameterHandler &  param)
virtual

Set up how many equations are needed and read in parameters for the parameter handler in order to initialize data.

Reimplemented from FuelCell::ApplicationCore::ApplicationWrapper.

template<int dim>
void FuelCell::ApplicationCore::AdaptiveRefinement< dim >::print_convergence_table ( )
private
template<int dim>
void FuelCell::ApplicationCore::AdaptiveRefinement< dim >::print_parameters ( ) const

Print parameters:

template<int dim>
void FuelCell::ApplicationCore::AdaptiveRefinement< dim >::run_app ( bool  solution_component_changes_between_data_files = false)

Run application.

template<int dim>
void FuelCell::ApplicationCore::AdaptiveRefinement< dim >::run_app ( std::vector< double > &  resp,
bool  solution_component_changes_between_data_files = false 
)

Run application.

template<int dim>
void FuelCell::ApplicationCore::AdaptiveRefinement< dim >::run_app ( std::vector< double > &  resp,
std::vector< std::vector< double > > &  dresp_dl,
bool  solution_component_changes_between_data_files = false 
)

Run application.

template<int dim>
void FuelCell::ApplicationCore::AdaptiveRefinement< dim >::solve ( const std::string  param_file,
ParameterHandler &  param,
bool  solution_component_changes_between_data_files = false 
)

Solve the nonlinear problem.

template<int dim>
void FuelCell::ApplicationCore::AdaptiveRefinement< dim >::test_derivatives ( const std::string  input_file,
const std::string  dvar,
const double  value,
std::vector< double > &  resp,
std::vector< std::vector< double > > &  dresp,
const bool  gradient = true 
)

Member function used to test the derivatives.

Member Data Documentation

Poiner to nonlinear application.

Pointer to linear application.

Global FE solution at the support points of the initial mesh.

Referenced by FuelCell::ApplicationCore::AdaptiveRefinement< dim >::get_coarse_solution().

template<int dim>
Triangulation<dim> FuelCell::ApplicationCore::AdaptiveRefinement< dim >::coarse_triangulation
private
template<int dim>
std::vector< ConvergenceTable > FuelCell::ApplicationCore::AdaptiveRefinement< dim >::convergence_tables
private

If the exact or analytical solution is available, then those convergence tables collect all necessary information on L1 and L2 norms of the error and convergence rates for each particular component of the numerical solution.

template<int dim>
std::string FuelCell::ApplicationCore::AdaptiveRefinement< dim >::filename_final_sol
private

Filename where the final solution will be output.

The final format of the solution will be as follows: filename_final_sol+"_Cycle_" + grid_streamOut.str() + "_Sol_" + sol_streamOut.str(); where Cycle refers to the adaptive refinement cycle and Sol refers to the point in the polarization curve.

template<int dim>
std::string FuelCell::ApplicationCore::AdaptiveRefinement< dim >::filename_initial_mesh
private

Filename where to output the initial grid.

template<int dim>
bool FuelCell::ApplicationCore::AdaptiveRefinement< dim >::gradients
private

Compute the gradients?

template<int dim>
bool FuelCell::ApplicationCore::AdaptiveRefinement< dim >::L1_L2_error_and_convergence_rate
private

Use true if you have the exact or analytical solution to compare your numerical results with.

template<int dim>
unsigned int FuelCell::ApplicationCore::AdaptiveRefinement< dim >::n_ref
private

Number of initial refinements for the original mesh.

Low Priority Todo:
Change the loop so that zero refinements means once through the loop
template<int dim>
bool FuelCell::ApplicationCore::AdaptiveRefinement< dim >::nonlinear_solver_for_linear_problem
private

Use true along with zero initial guess defined in your application to solve a linear problem by means of using any of the FCST nonlinear solvers.

template<int dim>
bool FuelCell::ApplicationCore::AdaptiveRefinement< dim >::output_final_sol
private

Boolean flag used to specify if the final solution should be output to a file.

This flag is set via the input file using:

* subsection Adaptive refinement
* set Output final solution = true # Output final solution to a file named fuel_cell-sol-cycleX where X is the cycle name.
* end
*
template<int dim>
bool FuelCell::ApplicationCore::AdaptiveRefinement< dim >::output_initial_mesh
private

Flag to specify if the initial grid should be saved to a file.

This flag is initialized via the input file using:

* subsection Adaptive refinement
* set Output initial mesh = false # Set flag to true if you want to output a EPS figure of the initial mesh using the value in file initial mesh
* end
*
template<int dim>
bool FuelCell::ApplicationCore::AdaptiveRefinement< dim >::output_intermediate_resp
private

Bool flag used to specify if all responses/functionals should be evaluated at intermediate refinement levels.

This is useful when trying to estimate if the solution is grid independent as eventually the functionals and solution should become independent of refinement level.

This flag is set via the input file using:

* subsection Adaptive refinement
* set Output intermediate responses = true # Output any functional such as current density at each refinement level
* end
*
template<int dim>
bool FuelCell::ApplicationCore::AdaptiveRefinement< dim >::output_intermediate_sol
private

Boolean flag that is set to true if intermediate solutions, i.e.

solutions at intermediate adaptive refinement levels should be saved to file. This flag is set via input file with:

* subsection Adaptive refinement
* set Output intermediate solutions = false
* end
*

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