OpenFCST: The open-source Fuel Cell Simulation Toolbox
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
fcst
include
applications
app_test.h
Go to the documentation of this file.
1
//---------------------------------------------------------------------------
2
//
3
// FCST: Fuel Cell Simulation Toolbox
4
//
5
// Copyright (C) 20014 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: app_test.cc
11
// - Description: Simple application used to test different equation classes.
12
// Specially useful to test derivatives.
13
// - Developers: M. Secanell
14
// - $Id: app_test.h 2605 2014-08-15 03:36:44Z secanell $
15
//
16
//---------------------------------------------------------------------------
17
//
18
// #ifndef _FUELCELL__APP_TEST__H
19
// #define _FUELCELL__APP_TEST__H
20
//
21
// // Include deal.II classes
22
// #include "base/parameter_handler.h"
23
// #include "base/function_lib.h"
24
// #include "base/function.h"
25
// #include "base/quadrature_lib.h"
26
//
27
// #include "lac/block_vector.h"
28
// #include "lac/solver_cg.h"
29
// #include "lac/solver_gmres.h"
30
// #include "lac/precondition.h"
31
// #include "lac/precondition_block.h"
32
// #include "lac/block_matrix_array.h"
33
// #include "lac/filtered_matrix.h"
34
// #include "lac/sparse_ilu.h"
35
// #include "lac/sparse_direct.h"
36
//
37
// #include "grid/grid_generator.h"
38
// #include "grid/tria_accessor.h"
39
// #include "grid/tria_iterator.h"
40
// #include "grid/tria_boundary_lib.h"
41
//
42
// #include "fe/fe_values.h"
43
//
44
// #include "numerics/vector_tools.h"
45
// #include "numerics/matrix_tools.h"
46
// #include "numerics/error_estimator.h"
47
//
48
// #include "boost/shared_ptr.hpp"
49
//
50
// // Include appframe classes
51
// #include "appframe/base.h"
52
// #include "block_matrix_application.h"
53
// #include "appframe/matrix_shop_cell.h"
54
// #include "appframe/residual_shop_cell.h"
55
//
56
// // Include FuelCell classes
57
// #include "system_management.h"
58
// #include "optimization_block_matrix_application.h"
59
// #include "solver_utils.h"
60
// #include "operating_conditions.h"
61
// #include "dummy_GDL.h"
62
// #include "PureGas.h"
63
// #include "GasMixture.h"
64
// #include "geometries.h"
65
// #include "homogeneous_CL.h"
66
// #include "platinum.h"
67
// #include "tafel_kinetics.h"
68
// #include "fcst_constants.h"
69
// #include "ideal_gas.h"
70
// #include "SGL_24_BA.h"
71
// #include "design_fibrous_GDL.h"
72
// //Include STL
73
// #include "fstream"
74
// #include "iostream"
75
// #include "sstream"
76
//
77
// // Use namespace of deal.II
78
// using namespace dealii;
79
//
80
// namespace FuelCell
81
// {
82
// /**
83
// * This namespace is used for all those auxiliary classes that are used by AppTest.
84
// * These are mainly classes that inherit Function<dim> and that are necessary in order to call
85
// * some subroutine from deal.II. For example InitialSolution is created in order to use the
86
// * deal.II class VectorInterpolate which in turn is used to set up the initial solution to the problem.
87
// */
88
// namespace InitialSolution
89
// {
90
// /**
91
// * This class is used when solving the problem using Newton's method to provide an initial solution.
92
// * This function is called in VectorTools::interpolate(..,..,InitialSolution<dim> marc,...)
93
// * It provides a solution that satisfies Dirichlet boundaries and has a gradient.
94
// */
95
// template <int dim>
96
// //class InitialSolution
97
// class AppTestIC
98
// :
99
// public Function<dim>
100
// {
101
// public:
102
// /**
103
// * Constructor
104
// */
105
// AppTestIC (FuelCell::OperatingConditions* );
106
// /**
107
// * Destructor
108
// */
109
// ~AppTestIC ();
110
// /**
111
// *
112
// */
113
// double value (const Point<dim> &p, unsigned int) const;
114
// /**
115
// * This is the member function that computes the value of the initial
116
// * solution for a given point.
117
// */
118
// void vector_value (const Point<dim> &p,
119
// Vector<double> &v) const;
120
//
121
// private:
122
// /**
123
// Operating conditions class object
124
// */
125
// FuelCell::OperatingConditions* OC;
126
//
127
// };
128
// } //end namespace InitialSolution
129
//
130
//
131
// namespace Application
132
// {
133
// //---------------------------------------------------------------------------
134
// //---------------------------------------------------------------------------
135
// //---------------------------------------------------------------------------
136
// /**
137
// *
138
// * This class is used to develop and test new applications. All functions are blank so all will
139
// * have to be implemented.
140
// */
141
// template <int dim>
142
// class AppTest
143
// :
144
// public FuelCell::ApplicationCore::OptimizationBlockMatrixApplication<dim>
145
// {
146
// public:
147
//
148
// /**
149
// * Constructor.
150
// * @note the pointer data is initialized to boost::shared_ptr<> (), this means that
151
// * the pointer is empty and when we do data.get() it will return 0. This is good because at ApplicationBase
152
// * constructor an ApplicationData will be constructed.
153
// */
154
// AppTest (boost::shared_ptr<FuelCell::ApplicationCore::ApplicationData> data =
155
// boost::shared_ptr<FuelCell::ApplicationCore::ApplicationData> ());
156
//
157
// /**
158
// * Destructor
159
// */
160
// ~AppTest();
161
// /**
162
// * Declare all parameters that are needed for:
163
// * - the computation of the equation coefficients
164
// * - the control of the linear system solution
165
// * - ...
166
// */
167
// virtual void declare_parameters(ParameterHandler& param);
168
//
169
// /**
170
// * Function called by optimization loop in order to set the values in the
171
// * ParameterHandler to the new design parameters.
172
// * Since ParameterHandler depends on the problem we are solving, set_parameters() is set
173
// * at the most inner loop of the application.
174
// */
175
// virtual void set_parameters(const std::vector<std::string>& name_dvar,
176
// const std::vector<double>& value_dvar,
177
// ParameterHandler& param);
178
//
179
// /**
180
// * Set up how many equations are needed and
181
// * read in parameters for the parameter handler in order to initialize data
182
// */
183
// void _initialize(ParameterHandler& param);
184
//
185
// /**
186
// * Call the other initialize routines from the inherited classes
187
// */
188
// virtual void initialize(ParameterHandler& param);
189
//
190
// /**
191
// * Initialize nonlinear solution
192
// * Note that this routine is extremely important since it is used to resize the solution vector. Therefore,
193
// * it always has to exist. Otherwise you will receive an error such as:
194
// * An error occurred in line <306> of file </home/secanell/Programs/fcst/contrib/deal.II/deal.II/include/deal.II/lac/block_indices.h> in function
195
// * std::pair<unsigned int, unsigned int> dealii::BlockIndices::global_to_local(unsigned int) const
196
// * The violated condition was:
197
// * i<total_size()
198
// * The name and call sequence of the exception was: ExcIndexRange(i, 0, total_size())
199
// * Additional Information: Index 0 is not in [0,0[
200
// * To initialize the solution vector at least you need the following:
201
// * src.reinit(this->block_info.global);
202
// */
203
// void init_solution(FuelCell::ApplicationCore::FEVector& src) ;
204
// /**
205
// * Integration of local bilinear form. Here we loop over the quadrature
206
// * points and over degrees of freedom in order to compute the matrix for the cell
207
// * This routine depends on the problem at hand and is called by assemble() in DoF_Handler
208
// * class
209
// * The matrix to be assembled is:
210
// \f[
211
// \begin{array}{l}
212
// M(i,j).block(0) = \int_{\Omega} a \nabla \phi_i \nabla \phi_j d\Omega + \int_{\Omega} \phi_i \frac{\partial f}{\partial u_0}\Big|_n \phi_j d\Omega \\
213
// \end{array}
214
// \f]
215
// */
216
// virtual void cell_matrix(MatrixVector& cell_matrices,
217
// const typename DoFApplication<dim>::CellInfo& cell);
218
// /**
219
// * Integration of the rhs of the equations. Here we loop over the quadrature
220
// * points and over degrees of freedom in order to compute the right
221
// * hand side for each cell
222
// * This routine depends on the problem at hand and is called by residual() in DoF_Handler
223
// * class
224
// * @note This function is called residual because in the case of nonlinear systems
225
// * the rhs is equivalent to the residual
226
// */
227
// virtual void cell_residual(FuelCell::ApplicationCore::FEVector& cell_vector,
228
// const typename DoFApplication<dim>::CellInfo& cell);
229
//
230
// /**
231
// * Integration of local bilinear form.
232
// */
233
// virtual void cell_dresidual_dlambda(std::vector<FuelCell::ApplicationCore::FEVector >& cell_vector,
234
// const typename DoFApplication<dim>::CellInfo& cell,
235
// std::vector<std::vector<double> >& src);
236
//
237
// /**
238
// * Member function used to set dirichlet boundary conditions.
239
// * This function is application specific and it only computes the boundary_value
240
// * values that are used to constraint the linear system of equations that is being
241
// * solved
242
// */
243
// virtual void dirichlet_bc(std::map<unsigned int, double>& boundary_values) const;
244
//
245
// /**
246
// * Solve the linear system of equations
247
// */
248
// virtual void solve(FuelCell::ApplicationCore::FEVector& start,
249
// const FuelCell::ApplicationCore::FEVectors& rhs);
250
//
251
// /**
252
// * Estimate error per cell
253
// */
254
// virtual double estimate(const FuelCell::ApplicationCore::FEVectors& sol);
255
//
256
// /**
257
// * This class is called by responses to make sure that all responses requested are
258
// * implemented in either cell_responses, global_responses or face_responses.
259
// * @note Every time we add a new response that we can calculate we need to update this
260
// * file.
261
// */
262
// virtual void check_responses();
263
//
264
// /**
265
// * Compute the value of all objective function and constraints
266
// */
267
// virtual void cell_responses (std::vector<double>& resp,
268
// const typename DoFApplication<dim>::CellInfo& info,
269
// const FuelCell::ApplicationCore::FEVector& sol);
270
// /**
271
// * This class is used to evaluate all responses that do not require looping over cells.
272
// * An example of one of this types of constraints is the solid volume fraction.
273
// */
274
// virtual void global_responses (std::vector<double>& resp,
275
// const FuelCell::ApplicationCore::FEVector& sol);
276
//
277
// /**
278
// * This class is used to evaluate the derivative of all the functionals that require looping over cells
279
// * with respect to the design variables.
280
// * This class is called by responses to evaluate the response at each cell.
281
// */
282
// virtual void cell_dresponses_dl(std::vector<std::vector<double> >& cell_df_dl,
283
// const typename DoFApplication<dim>::CellInfo& info,
284
// const FuelCell::ApplicationCore::FEVector& sol);
285
//
286
// /**
287
// * This class is used to evaluate the sensitivities of all responses that do not require looping over cells
288
// * with respect of the design variables.
289
// * An example of one of this types of constraints is the solid volume fraction.
290
// */
291
// virtual void global_dresponses_dl(std::vector<std::vector<double> >& df_dl,
292
// const FuelCell::ApplicationCore::FEVector& sol);
293
// /**
294
// * This class is used to evaluate the derivative of all the functionals that require looping over cells
295
// * with respect of the unknowns of the system of governing equations.
296
// * This class is called by responses to evaluate the response at each cell.
297
// */
298
// virtual void cell_dresponses_du(std::vector<FuelCell::ApplicationCore::FEVector >& cell_df_du,
299
// const typename DoFApplication<dim>::CellInfo& info,
300
// std::vector<std::vector<double> >& src);
301
//
302
// /**
303
// * This class is used to evaluate the sensitivities of all responses that do not require looping over cells
304
// * with respecto of the unknowns of the system of governing equations.
305
// * An example of one of this types of constraints is the solid volume fraction.
306
// */
307
// virtual void global_dresponses_du(std::vector<FuelCell::ApplicationCore::FEVector >& df_du,
308
// const FuelCell::ApplicationCore::FEVector& src);
309
//
310
// /**
311
// * Post-processing. Evaluate a functional such as the objective function of an
312
// * optimization problem
313
// */
314
// virtual double evaluate (const FuelCell::ApplicationCore::FEVectors& src);
315
//
316
// /**
317
// * Reimplementation of the routine in the base class BaseApplication in namespace AppFrame so
318
// * that the right labels are outputed and so that I can compute and output the source term.
319
// */
320
// /*virtual void data_out(const std::string &basename,
321
// const FuelCell::ApplicationCore::FEVectors &src);
322
// */
323
// protected:
324
// /**
325
// * Structure where we store the problem we want to solve.
326
// * Each vector component contains a string with the
327
// * name of the equation we want to solve
328
// * Then, the number of components is equation_names.size()
329
// */
330
// std::vector<std::string> equation_names;
331
// /**
332
// * Structure where we store the name of each component
333
// * in our problem. The component names are stored in the same
334
// * way as they are stored in the solution.
335
// */
336
// std::vector<std::string> component_names;
337
//
338
// /** Operating conditions */
339
// FuelCell::OperatingConditions OC;
340
//
341
// /** Create an object to generate the mesh*/
342
// FuelCellShop::Geometry::Cathode<dim> grid;
343
//
344
// /** The object GDL layer will contain all the information relevant to the
345
// * the GDL. We can request any effective property from this class
346
// */
347
// boost::shared_ptr<FuelCellShop::Layer::GasDiffusionLayer<dim> > CGDL;
348
//
349
// /** The object CCL layer will contain all the information relevant to the
350
// * the catalyst layer. We can request any effective property from this class
351
// */
352
// FuelCellShop::Layer::HomogeneousCL<dim> CCL;
353
//
354
// /**
355
// * List of solution variables that are required to solve the equations in the
356
// * kinetics class (e.g. oxygen concentration, protonic/electronic potential,
357
// * temperature etc.) Used by set_solution to ensure that all required variables are set.
358
// */
359
// std::vector<std::string> required_solution_names;
360
//
361
// FuelCell::SystemManagement sys_mgnt;
362
// };
363
//
364
// }
365
// }
366
//
367
// #endif //_FUELCELL__APP_TEST_H
Generated on Sun Dec 11 2016 12:33:18 for OpenFCST: The open-source Fuel Cell Simulation Toolbox by
1.8.5