OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DAE_wrapper.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------
2 // C++ Interface: DAE_wrapper.cc
3 //
4 // Description: Class used as a wrapper for all applications that will be
5 // solved using the DAE_solver.
6 //
7 // Author: Peter Dobson <pdobson@ualberta.ca>, (C) 2011
8 // University of Alberta
9 //
10 // Copyright: See COPYING file that comes with this distribution
11 //
12 //---------------------------------------------------------------------------
13 
14 #ifndef FUEL_CELL__DAE_WRAPPER__H
15 #define FUEL_CELL__DAE_WRAPPER__H
16 
17 //------------------------------
18 // STD DECLARATIONS
19 //------------------------------
20 #include <iostream>
21 
22 
23 #include <boost/shared_ptr.hpp>
24 //------------------------------
25 // DEAL.II DECLARATIONS
26 //------------------------------
27 #include <base/parameter_handler.h>
28 
29 //------------------------------
30 // ALGLIB DECLARATIONS
31 //------------------------------
32 #include "integration.h"
33 
34 //------------------------------
35 // FUEL CELL DECLARATIONS
36 //------------------------------
37 #include "DAE_solver.h"
38 #include "logging.h"
39 
42 // Must be very careful with this... it is now 'declared' as a global variable within FCST
43 // The 'definition' of the pointer in included in the .cc file.
44 // The implementation (assignment) of an object to the pointer should be within the derived class
45 #ifdef _OPENMP
46  #include <omp.h>
47 #else
48  #define omp_get_thread_num() 0
49 #endif
50 extern void *ptr_DAE_object[20];
51 
52 using namespace dealii;
53 using namespace alglib;
54 
55 namespace FuelCell
56 {
57 namespace ApplicationCore
58 {
82  class DAEWrapper
83  {
84  public:
85 
87  DAEWrapper();
88 
91 
99  double integrate(double lb, double ub, std::vector<double>& W, std::vector<double>& F);
100 
108  void get_quadrature_points (double lb, double ub, std::vector<double>& X, std::vector<double>& W, FuelCell::ApplicationCore::DAESolver* prob);
109 
111  virtual void setup_DAE_solver () = 0;
112 
120  virtual void fsub (double &, double [], double [], double []) = 0;
121 
122 
130  virtual void dfsub (double &, double [], double [], double []) = 0;
131 
138  virtual void gsub (int &, double [], double &) = 0;
139 
145  virtual void dgsub (int &, double [], double []) = 0;
146 
153  virtual void guess (double &, double [], double [], double []) = 0;
154 
156  inline void verbosity(int i)
157  {n_output = i;}
158 
164  void DAE_Error(int flag);
165 
167  {
168  delete [] mm;
169  delete [] zeta;
170  delete [] fixpnt;
171  delete [] tol;
172  delete [] ltol;
173  delete prob;
174  if (ptr_DAE_object[omp_get_thread_num()] != NULL)
175  {
177  //delete ptr_DAE_object;
178  }
179  }
180 
181  protected:
182 
184  int n_mesh;
185 
187  double *mesh;
188 
190  int n_colloc;
191 
193  int n_output;
194 
196  int n_comp;
197 
199  int n_y;
200 
202  int *mm;
203 
207  int m_star;
208 
210  double boundary_0;
211 
213  double boundary_1;
214 
216  double *zeta;
217 
220 
222  double *fixpnt;
223 
224  int *ltol;
225 
226  double *tol;
227 
229  double cm_to_m;
230 
232  double cm2_to_m2;
233 
235  double cm3_to_m3;
236  };
237 
238 }
239 }
240 #endif
~DAEWrapper()
Destructor.
Definition: DAE_wrapper.h:90
void verbosity(int i)
Set the verbosity variable (controls output to screen)
Definition: DAE_wrapper.h:156
void * ptr_DAE_object[20]
double F()
Faraday constant, .
Definition: fcst_constants.h:38
#define omp_get_thread_num()
Definition: DAE_wrapper.h:48
int * mm
array of integers storing the order of each PDE
Definition: DAE_wrapper.h:202
double cm3_to_m3
Convert from centimetres cubed to metres cubed.
Definition: DAE_wrapper.h:235
double * fixpnt
Array of fixed points on the mesh.
Definition: DAE_wrapper.h:222
double * tol
Definition: DAE_wrapper.h:226
int n_comp
number of PDEs
Definition: DAE_wrapper.h:196
int n_output
Output integer variable.
Definition: DAE_wrapper.h:193
FuelCell::ApplicationCore::DAESolver * prob
DAE problem solver object.
Definition: DAE_wrapper.h:219
double cm2_to_m2
Convert from centimetres squared to metres squared.
Definition: DAE_wrapper.h:232
double * zeta
Array of boundary points.
Definition: DAE_wrapper.h:216
This class provides an interface to the Fortran 77 code COLDAE.
Definition: DAE_solver.h:105
double * mesh
Array of mesh points.
Definition: DAE_wrapper.h:187
This class is to be used as a wrapper for the functions needed in the DAESolver.
Definition: DAE_wrapper.h:82
int n_y
number of Algebraic constraints
Definition: DAE_wrapper.h:199
double cm_to_m
Convert from centimetres to metres.
Definition: DAE_wrapper.h:229
double boundary_1
Right boundary point.
Definition: DAE_wrapper.h:213
int n_mesh
Number of mesh points.
Definition: DAE_wrapper.h:184
int n_colloc
Number of collocation points.
Definition: DAE_wrapper.h:190
int * ltol
Definition: DAE_wrapper.h:224
double boundary_0
Left boundary point.
Definition: DAE_wrapper.h:210
void clear_memory()
Definition: DAE_wrapper.h:166
int m_star
Integer representing the total number of variables given by .
Definition: DAE_wrapper.h:207