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 // - $Id: application_base.h 2616 2014-08-15 22:57:14Z secanell $
17 //
18 // ----------------------------------------------------------------------------
19 
20 #ifndef _FUEL_CELL_APPLICATION_CORE_APPLICATION_BASE_H_
21 #define _FUEL_CELL_APPLICATION_CORE_APPLICATION_BASE_H_
22 
23 // openFCST objects:
24 #include "application_data.h"
25 #include "fe_vectors.h"
26 #include "event.h"
27 #include "logging.h"
28 
29 // deal.II objects:
30 #include <base/parameter_handler.h>
31 
32 // C++ objects:
33 #include <boost/shared_ptr.hpp>
34 
35 using namespace dealii;
36 
37 namespace FuelCell
38 {
47  namespace ApplicationCore
48  {
114  class ApplicationBase : public Subscriptor
115  {
116  public:
117 
126  ApplicationBase(boost::shared_ptr<ApplicationData> data = boost::shared_ptr<ApplicationData>());
127 
132  ApplicationBase(const ApplicationBase& other);
133 
137  virtual ~ApplicationBase();
138 
145  virtual void declare_parameters(ParameterHandler& param)
146  {
147  print_caller_name(__FUNCTION__);
148  }
149 
162  void print_parameters_to_file(ParameterHandler& param,
163  const std::string& file_name,
164  const ParameterHandler::OutputStyle& style);
177  virtual void initialize(ParameterHandler& param) = 0; // No implementation here
178 
184  virtual void remesh()
185  {
186  print_caller_name(__FUNCTION__);
187  }
188 
194  virtual void init_vector(FEVector& dst) const
195  {
196  print_caller_name(__FUNCTION__);
197  }
198 
202  virtual void start_vector(FEVector& dst, std::string caller) const
203  {
204  print_caller_name(__FUNCTION__);
205  init_vector(dst);
206 
207  };
208 
217  virtual double residual(FEVector& dst,
218  const FEVectors& src,
219  bool apply_boundaries = true)
220  {
221  print_caller_name(__FUNCTION__);
222  }
223 
230  virtual void solve(FEVector& dst,
231  const FEVectors& src) = 0;
232 
239  virtual void Tsolve(FEVector& dst,
240  const FEVectors& src)
241  {
242  print_caller_name(__FUNCTION__);
243  }
244 
250  virtual double estimate(const FEVectors& src)
251  {
252  print_caller_name(__FUNCTION__);
253  }
254 
260  virtual double evaluate(const FEVectors& src)
261  {
262  print_caller_name(__FUNCTION__);
263  }
264 
271  virtual void grid_out(const std::string& filename)
272  {
273  print_caller_name(__FUNCTION__);
274  }
275 
282  virtual void data_out(const std::string& filename,
283  const FEVectors& src)
284  {
285  print_caller_name(__FUNCTION__);
286  }
287 
291  boost::shared_ptr<ApplicationData> get_data();
292 
296  const boost::shared_ptr<ApplicationData> get_data() const;
297 
313  virtual std::string id() const;
314 
319  virtual void notify(const Event& reason);
320 
324  virtual void clear();
325 
329  virtual void clear_events();
330 
331  protected:
332 
336  void print_caller_name(const std::string& caller_name) const;
337 
342  boost::shared_ptr<ApplicationData> data;
343 
356  //std::map<std::string, bool> notifications;
357 
358  #ifdef OPENFCST_WITH_PETSC
359 
362  const unsigned int n_mpi_processes;
363  const unsigned int this_mpi_process;
364  MPI_Comm mpi_communicator;
365 
366  #endif
367 
368  };
369 
370  }// ApplicationCore
371 
372 } // FuelCell
373 
374 #endif
virtual double residual(FEVector &dst, const FEVectors &src, bool apply_boundaries=true)
Compute residual of src and store it into dst.
Definition: application_base.h:217
virtual void start_vector(FEVector &dst, std::string caller) const
Initialize vector to problem size.
Definition: application_base.h:202
virtual void init_vector(FEVector &dst) const
Initialize vector to problem size.
Definition: application_base.h:194
virtual void Tsolve(FEVector &dst, const FEVectors &src)
Solve the dual system assembled with right hand side rhs and return the result in start...
Definition: application_base.h:239
virtual double evaluate(const FEVectors &src)
Evaluate a functional.
Definition: application_base.h:260
virtual void declare_parameters(ParameterHandler &param)
Declare parameters for a parameter file.
Definition: application_base.h:145
virtual void data_out(const std::string &filename, const FEVectors &src)
Write data in the format specified by the ParameterHandler.
Definition: application_base.h:282
virtual void remesh()
Generate the next mesh depending on the mesh generation parameters.
Definition: application_base.h:184
virtual void grid_out(const std::string &filename)
Write the mesh in the format specified by the ParameterHandler.
Definition: application_base.h:271
virtual double estimate(const FEVectors &src)
Estimate cell-wise errors.
Definition: application_base.h:250
Base class for applications.
Definition: application_base.h:114
Objects of this kind are used to notify interior applications of changes provoked by an outer loop...
Definition: event.h:57
BlockVector< double > FEVector
The vector class used by applications.
Definition: application_data.h:39
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:352
boost::shared_ptr< ApplicationData > data
Object for auxiliary data.
Definition: application_base.h:342