OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
application_base.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 //
3 // FCST: Fuel Cell Simulation Toolbox
4 //
5 // Copyright (C) 2006-2009 by Guido Kanschat
6 // Copyright (C) 2006-2014 by Energy Systems Design Laboratory, University of Alberta
7 //
8 // This software is distributed under the MIT License
9 // For more information, see the README file in /doc/LICENSE
10 //
11 // - Class: application_base.h
12 // - Description: This class implements the interface of applications
13 // - Developers: Guido Kanschat, Texas A&M University
14 // Valentin N. Zingan, University of Alberta
15 // Marc Secanell, University of Alberta
16 //
17 // ----------------------------------------------------------------------------
18 
19 #ifndef _FUEL_CELL_APPLICATION_CORE_APPLICATION_BASE_H_
20 #define _FUEL_CELL_APPLICATION_CORE_APPLICATION_BASE_H_
21 
22 // openFCST objects:
25 #include <application_core/event.h>
26 #include <utils/logging.h>
27 
28 // deal.II objects:
29 #include <deal.II/base/parameter_handler.h>
30 
31 // C++ objects:
32 #include <boost/shared_ptr.hpp>
33 
34 using namespace dealii;
35 
36 namespace FuelCell
37 {
46  namespace ApplicationCore
47  {
113  class ApplicationBase : public Subscriptor
114  {
115  public:
116 
125  ApplicationBase(boost::shared_ptr<ApplicationData> data = boost::shared_ptr<ApplicationData>());
126 
131  ApplicationBase(const ApplicationBase& other);
132 
136  virtual ~ApplicationBase();
137 
144  virtual void declare_parameters(ParameterHandler& )
145  {
146  print_caller_name(__FUNCTION__);
147  }
148 
161  void print_parameters_to_file(ParameterHandler& param,
162  const std::string& file_name,
163  const ParameterHandler::OutputStyle& style);
176  virtual void initialize(ParameterHandler& param) = 0; // No implementation here
177 
183  virtual void remesh()
184  {
185  print_caller_name(__FUNCTION__);
186  }
187 
193  virtual void init_vector(FEVector& ) const
194  {
195  print_caller_name(__FUNCTION__);
196  }
197 
201  virtual void start_vector(FEVector& dst, std::string ) const
202  {
203  print_caller_name(__FUNCTION__);
204  init_vector(dst);
205 
206  };
207 
216  virtual double residual(FEVector& /*dst*/,
217  const FEVectors& /*src*/,
218  bool apply_boundaries = true)
219  {
220  print_caller_name(__FUNCTION__);
221 
222  return -1;
223  }
224 
231  virtual void solve(FEVector& dst,
232  const FEVectors& src) = 0;
233 
240  virtual void Tsolve(FEVector& /*dst*/,
241  const FEVectors& /*src*/)
242  {
243  print_caller_name(__FUNCTION__);
244  }
245 
251  virtual double estimate(const FEVectors& )
252  {
253  print_caller_name(__FUNCTION__);
254  return -1;
255  }
256 
262  virtual double evaluate(const FEVectors& )
263  {
264  print_caller_name(__FUNCTION__);
265  return -1;
266  }
267 
273  virtual void grid_out(const std::string& )
274  {
275  print_caller_name(__FUNCTION__);
276  }
277 
283  virtual void data_out(const std::string& filename,
284  const FEVectors& src)
285  {
286  print_caller_name(__FUNCTION__);
287  }
288 
292  boost::shared_ptr<ApplicationData> get_data();
293 
297  const boost::shared_ptr<ApplicationData> get_data() const;
298 
314  virtual std::string id() const;
315 
320  virtual void notify(const Event& reason);
321 
325  virtual void clear();
326 
330  virtual void clear_events();
331 
335  virtual unsigned int get_solution_index();
336 
337  protected:
338 
342  void print_caller_name(const std::string& caller_name) const;
343 
348  boost::shared_ptr<ApplicationData> data;
349 
362  //std::map<std::string, bool> notifications;
363 
364  #ifdef OPENFCST_WITH_PETSC
365 
368  const unsigned int n_mpi_processes;
369  const unsigned int this_mpi_process;
370  MPI_Comm mpi_communicator;
371 
372  #endif
373  };
374 
375  }// ApplicationCore
376 
377 } // FuelCell
378 
379 #endif
virtual void init_vector(FEVector &) const
Initialize vector to problem size.
Definition: application_base.h:193
virtual double residual(FEVector &, const FEVectors &, bool apply_boundaries=true)
Compute residual of src and store it into dst.
Definition: application_base.h:216
virtual void data_out(const std::string &filename, const FEVectors &src)
Write data in the format specified by the ParameterHandler.
Definition: application_base.h:283
virtual void grid_out(const std::string &)
Write the mesh in the format specified by the ParameterHandler.
Definition: application_base.h:273
virtual void remesh()
Generate the next mesh depending on the mesh generation parameters.
Definition: application_base.h:183
virtual double estimate(const FEVectors &)
Estimate cell-wise errors.
Definition: application_base.h:251
Base class for applications.
Definition: application_base.h:113
virtual double evaluate(const FEVectors &)
Evaluate a functional.
Definition: application_base.h:262
Objects of this kind are used to notify interior applications of changes provoked by an outer loop...
Definition: event.h:51
virtual void declare_parameters(ParameterHandler &)
Declare parameters for a parameter file.
Definition: application_base.h:144
BlockVector< double > FEVector
The vector class used by applications.
Definition: application_data.h:46
The data type used in function calls of Application.
Definition: fe_vectors.h:59
Event notifications
Accumulate reasons for assembling here.
Definition: application_base.h:358
virtual void start_vector(FEVector &dst, std::string) const
Initialize vector to problem size.
Definition: application_base.h:201
boost::shared_ptr< ApplicationData > data
Object for auxiliary data.
Definition: application_base.h:348
virtual void Tsolve(FEVector &, const FEVectors &)
Solve the dual system assembled with right hand side rhs and return the result in start...
Definition: application_base.h:240