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 // - $Id: adaptive_refinement.h 2617 2014-08-16 16:29:29Z secanell $
14 //
15 //---------------------------------------------------------------------------
16 
17 #ifndef _FUELCELL__ADAPTIVEREFINEMENT_H_
18 #define _FUELCELL__ADAPTIVEREFINEMENT_H_
19 
20 // Deal.II include files:
21 #include <base/parameter_handler.h>
22 #include <base/convergence_table.h>
23 #include <base/smartpointer.h>
24 #include <grid/tria.h>
25 
26 
27 // Fuel cell include files
29 #include "newton_base.h"
31 #include <utils/fcst_utilities.h>
32 
33 // STD include files
34 #include <string>
35 #include <stdio.h>
36 #include <stdlib.h>
37 
38 namespace FuelCell
39 {
40  namespace ApplicationCore
41  {
53  template <int dim>
55  :
56  public ApplicationWrapper
57  {
58  public:
63  :
64  FuelCell::ApplicationCore::ApplicationWrapper(application)
65  {
67  }
68 
75 
80 
104  void declare_parameters ( ParameterHandler& param ) const;
105 
110  void initialize ( ParameterHandler& param );
111 
113 
114 
118  void solve( const std::string param_file,
119  ParameterHandler& param,
120  bool solution_component_changes_between_data_files = false );
121 
125  void run_Newton(bool solution_component_changes_between_data_files = false);
126 
130  void run_Newton ( std::vector<double>& resp,
131  bool solution_component_changes_between_data_files = false );
132 
136  void run_Newton ( std::vector<double>& resp,
137  std::vector<std::vector<double> >& dresp_dl,
138  bool solution_component_changes_between_data_files = false );
139 
141 
145  void test_derivatives ( const std::string input_file,
146  const std::string dvar,
147  const double value,
148  std::vector<double>& resp,
149  std::vector<std::vector<double> >& dresp,
150  const bool gradient = true );
151 
155  void print_parameters() const;
156 
162  {
163  return solution;
164  }
165 
171  {
172  return coarse_solution;
173  }
174 
180  {
181  return coarse_triangulation;
182  }
183 
184  private:
187 
190 
200 
201 
202 
214 
225 
239 
246 
256 
262  unsigned int n_ref;
263 
267  bool gradients;
268 
273 
278 
283 
288 
293 
300  std::vector< ConvergenceTable > convergence_tables;
301  };
302  }
303 }
304 
305 #endif
bool output_initial_mesh
Flag to specify if the initial grid should be saved to a file.
Definition: adaptive_refinement.h:199
unsigned int n_ref
Number of initial refinements for the original mesh.
Definition: adaptive_refinement.h:262
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:245
void run_Newton(bool solution_component_changes_between_data_files=false)
Run Newton application.
std::string filename_initial_mesh
Filename where to output the initial grid.
Definition: adaptive_refinement.h:189
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:255
const FuelCell::ApplicationCore::FEVector & get_coarse_solution() const
This function returns coarse_solution.
Definition: adaptive_refinement.h:170
bool output_intermediate_sol
Boolean flag that is set to true if intermediate solutions, i.e.
Definition: adaptive_refinement.h:213
FuelCell::ApplicationCore::FEVector coarse_solution
Global FE solution at the support points of the initial mesh.
Definition: adaptive_refinement.h:292
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:287
This class is initialized with an application that describes the linearization of the problem that we...
Definition: adaptive_refinement.h:54
FuelCell::ApplicationCore::OptimizationBlockMatrixApplication< dim > * app_linear
Pointer to linear application.
Definition: adaptive_refinement.h:277
FuelCell::ApplicationCore::ApplicationWrapper * app
Poiner to nonlinear application.
Definition: adaptive_refinement.h:282
AdaptiveRefinement(FuelCell::ApplicationCore::ApplicationBase &application)
Constructor.
Definition: adaptive_refinement.h:62
const FuelCell::ApplicationCore::FEVector & get_solution() const
This function returns solution.
Definition: adaptive_refinement.h:161
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:300
Base class for applications.
Definition: application_base.h:114
This class implements either iterative or time-stepping wrapper of applications.
Definition: application_wrapper.h:40
bool output_final_sol
Boolean flag used to specify if the final solution should be output to a file.
Definition: adaptive_refinement.h:224
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:267
bool output_intermediate_resp
Bool flag used to specify if all responses/functionals should be evaluated at intermediate refinement...
Definition: adaptive_refinement.h:238
const Triangulation< dim > & get_coarse_triangulation() const
This function returns coarse_triangulation.
Definition: adaptive_refinement.h:179
Triangulation< dim > coarse_triangulation
Initial mesh.
Definition: adaptive_refinement.h:272
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:39
Application handling matrices and assembling the linear system to solve the sensitivity equations...
Definition: optimization_block_matrix_application.h:62
void print_parameters() const
Print parameters: