OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
adaptive_refinement.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------
2 //
3 // FCST: Fuel Cell Simulation Toolbox
4 //
5 // Copyright (C) 2009-13 by Energy Systems Design Laboratory, University of Alberta
6 //
7 // This software is distributed under the MIT License.
8 // For more information, see the README file in /doc/LICENSE
9 //
10 // - Class: adaptive_refinement.h
11 // - Description: Child of ApplicationWrapper used to implement adaptive refinement
12 // - Developers: M. Secanell, Valentin N. Zingan
13 //
14 //---------------------------------------------------------------------------
15 
16 #ifndef _FUELCELL__ADAPTIVEREFINEMENT_H_
17 #define _FUELCELL__ADAPTIVEREFINEMENT_H_
18 
19 // Deal.II include files:
20 #include <deal.II/base/parameter_handler.h>
21 #include <deal.II/base/convergence_table.h>
22 #include <deal.II/base/smartpointer.h>
23 #include <deal.II/grid/tria.h>
24 
25 
26 // Fuel cell include files
29 #include <utils/fcst_utilities.h>
30 
31 // STD include files
32 #include <string>
33 #include <stdio.h>
34 #include <stdlib.h>
35 
36 namespace FuelCell
37 {
38  namespace ApplicationCore
39  {
51  template <int dim>
53  :
54  public ApplicationWrapper
55  {
56  public:
61  :
62  FuelCell::ApplicationCore::ApplicationWrapper(application)
63  {
65  }
66 
73 
78 
102  void declare_parameters ( ParameterHandler& param ) const;
103 
108  void initialize ( ParameterHandler& param );
109 
111 
112 
116  void solve( const std::string param_file,
117  ParameterHandler& param,
118  bool solution_component_changes_between_data_files = false );
119 
123  void run_app(bool solution_component_changes_between_data_files = false);
124 
128  void run_app ( std::vector<double>& resp,
129  bool solution_component_changes_between_data_files = false );
130 
134  void run_app ( std::vector<double>& resp,
135  std::vector<std::vector<double> >& dresp_dl,
136  bool solution_component_changes_between_data_files = false );
138 
142  void test_derivatives ( const std::string input_file,
143  const std::string dvar,
144  const double value,
145  std::vector<double>& resp,
146  std::vector<std::vector<double> >& dresp,
147  const bool gradient = true );
148 
152  void print_parameters() const;
153 
159  {
160  return solution;
161  }
162 
168  {
169  return coarse_solution;
170  }
171 
177  {
178  return coarse_triangulation;
179  }
180 
181  private:
184 
189 
199 
200 
201 
213 
224 
231  std::string filename_final_sol;
232 
246 
253 
263 
269  unsigned int n_ref;
270 
274  bool gradients;
275 
280 
285 
290 
295 
300 
307  std::vector< ConvergenceTable > convergence_tables;
308  };
309  }
310 }
311 
312 #endif
bool output_initial_mesh
Flag to specify if the initial grid should be saved to a file.
Definition: adaptive_refinement.h:198
unsigned int n_ref
Number of initial refinements for the original mesh.
Definition: adaptive_refinement.h:269
bool L1_L2_error_and_convergence_rate
Use true if you have the exact or analytical solution to compare your numerical results with...
Definition: adaptive_refinement.h:252
std::string filename_initial_mesh
Filename where to output the initial grid.
Definition: adaptive_refinement.h:188
bool nonlinear_solver_for_linear_problem
Use true along with zero initial guess defined in your application to solve a linear problem by means...
Definition: adaptive_refinement.h:262
const FuelCell::ApplicationCore::FEVector & get_coarse_solution() const
This function returns coarse_solution.
Definition: adaptive_refinement.h:167
bool output_intermediate_sol
Boolean flag that is set to true if intermediate solutions, i.e.
Definition: adaptive_refinement.h:212
FuelCell::ApplicationCore::FEVector coarse_solution
Global FE solution at the support points of the initial mesh.
Definition: adaptive_refinement.h:299
void declare_parameters(ParameterHandler &param) const
Declare all parameters that are needed for:
FuelCell::ApplicationCore::FEVector solution
Global FE solution at the support points of the most refined mesh.
Definition: adaptive_refinement.h:294
This class is initialized with an application that describes the linearization of the problem that we...
Definition: adaptive_refinement.h:52
FuelCell::ApplicationCore::OptimizationBlockMatrixApplication< dim > * app_linear
Pointer to linear application.
Definition: adaptive_refinement.h:284
FuelCell::ApplicationCore::ApplicationWrapper * app
Poiner to nonlinear application.
Definition: adaptive_refinement.h:289
AdaptiveRefinement(FuelCell::ApplicationCore::ApplicationBase &application)
Constructor.
Definition: adaptive_refinement.h:60
const FuelCell::ApplicationCore::FEVector & get_solution() const
This function returns solution.
Definition: adaptive_refinement.h:158
void initialize(ParameterHandler &param)
Set up how many equations are needed and read in parameters for the parameter handler in order to ini...
std::vector< ConvergenceTable > convergence_tables
If the exact or analytical solution is available, then those convergence tables collect all necessary...
Definition: adaptive_refinement.h:307
Base class for applications.
Definition: application_base.h:113
This class implements either iterative or time-stepping wrapper of applications.
Definition: application_wrapper.h:39
bool output_final_sol
Boolean flag used to specify if the final solution should be output to a file.
Definition: adaptive_refinement.h:223
void solve(const std::string param_file, ParameterHandler &param, bool solution_component_changes_between_data_files=false)
Solve the nonlinear problem.
bool gradients
Compute the gradients?
Definition: adaptive_refinement.h:274
std::string filename_final_sol
Filename where the final solution will be output.
Definition: adaptive_refinement.h:231
bool output_intermediate_resp
Bool flag used to specify if all responses/functionals should be evaluated at intermediate refinement...
Definition: adaptive_refinement.h:245
const Triangulation< dim > & get_coarse_triangulation() const
This function returns coarse_triangulation.
Definition: adaptive_refinement.h:176
void run_app(bool solution_component_changes_between_data_files=false)
Run application.
Triangulation< dim > coarse_triangulation
Initial mesh.
Definition: adaptive_refinement.h:279
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.
BlockVector< double > FEVector
The vector class used by applications.
Definition: application_data.h:46
Application handling matrices and assembling the linear system to solve the sensitivity equations...
Definition: optimization_block_matrix_application.h:49
void print_parameters() const
Print parameters: