OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
system_management.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 //
3 // FCST: Fuel Cell Simulation Toolbox
4 //
5 // Copyright (C) 2006-2015 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: system_management.h
11 // - Description: This class manages systems of equations
12 // - Developers: Valentin N. Zingan, University of Alberta
13 // Marc Secanell Gallart, University of Alberta
14 // - Id: $Id$
15 //
16 // ----------------------------------------------------------------------------
17 
18 #ifndef _FCST_FUELCELL_SYSTEM_MANAGEMENT_H_
19 #define _FCST_FUELCELL_SYSTEM_MANAGEMENT_H_
20 
21 #include <base/parameter_handler.h>
22 
23 #include "matrix_block.h"
24 #include "mesh_loop_info_objects.h"
25 #include "logging.h"
26 
27 #include <boost/algorithm/string/join.hpp>
28 
29 using namespace dealii;
30 using namespace FuelCell::ApplicationCore;
31 
40 typedef std::map< std::string , std::map<std::string, DoFTools::Coupling> > couplings_map;
41 
63 {
64  nothing = 0,
65 
78 
81 
84 
90 
92 
97 
102 
107 
112 
117 
122 };
123 
124 
125 
150 
153 };
154 
155 
156 namespace FuelCell
157 {
158 
271 class SystemManagement : public Subscriptor
272 {
273 public:
274 
276 
277 
285 
296  Table<2, DoFTools::Coupling>& cell_couplings,
297  Table<2, DoFTools::Coupling>& flux_couplings);
298 
302  ~SystemManagement();
303 
314  Table<2, DoFTools::Coupling>& rcell_couplings,
315  Table<2, DoFTools::Coupling>& rflux_couplings)
316  {
317  block_info = &rblock_info;
318  cell_couplings = &rcell_couplings;
319  flux_couplings = &rflux_couplings;
320  }
321 
325  void declare_parameters(ParameterHandler& param) const;
326 
330  void initialize(ParameterHandler& param);
331 
333 
335 
336 // The # and ## preprocessor operators are available in C++ and ANSI/ISO C.
337 // The # operator causes a replacement-text token to be converted to a string surrounded by quotes.
338 const std::string& get_VariableNames(const VariableNames value)
339 {
340  static std::map<VariableNames, std::string> VariableNames_strings;
341  if (VariableNames_strings.size() == 0){
342 #define INSERT_ELEMENT(p) VariableNames_strings[p] = #p
346 #undef INSERT_ELEMENT
347  }
348 
349  return VariableNames_strings[value];
350 }
357  const bool solution_in_userlist(const std::string& name) const;
358 
365  const unsigned int solution_name_to_index(const std::string& name) const;
366 
373  //const unsigned int solution_name_to_index(const VariableNames) const;
374 
381  const unsigned int equation_name_to_index(const std::string& name) const;
382 
398  const unsigned int matrix_block_index(const std::string& equation_name,
399  const std::string& solution_name) const;
400 
408  void make_cell_couplings(const std::vector<couplings_map>& src);
409 
417  void make_flux_couplings(const std::vector<couplings_map>& src);
418 
420 
422 
423 
428  const std::vector<std::string>& get_all_solution_names() const
429  {
430  return all_solution_names;
431  }
432 
437  const std::vector<std::string>& get_all_equation_names() const
438  {
439  return all_equation_names;
440  }
441 
446  const std::vector<std::string>& get_solution_names() const
447  {
448  return solution_names;
449  }
450 
455  const std::vector<std::string>& get_equation_names() const
456  {
457  return equation_names;
458  }
459 
464  const unsigned int& get_number_of_solution_names() const
465  {
466  return n_solution_names;
467  }
468 
480  void print_system_info() const;
481 
483 
485 
486 
492  DeclException2(VariableNotFoundInFCSTVariables,
493  std::string,
494  std::string,
495  << "A " << arg1 << " with name \"" << arg2 << "\" is not stored in available FCST solution variables");
496 
502  DeclException2(EquationNotFoundInFCSTEquations,
503  std::string,
504  std::string,
505  << "An " << arg1 << " with name \"" << arg2 << "\" is not stored in available FCST equations");
506 
512  DeclException2(VariableNotFoundInUserVariables,
513  std::string,
514  std::string,
515  << "A " << arg1 << " with name \"" << arg2 << "\" is not stored in user defined solution variables");
516 
522  DeclException2(EquationNotFoundInUserEquations,
523  std::string,
524  std::string,
525  << "An " << arg1 << " with name \"" << arg2 << "\" is not stored in user defined equations");
526 
535  DeclException5(SystemMatrixBlockDoesNotExist,
536  std::string,
537  unsigned int,
538  unsigned int,
539  std::string,
540  std::string,
541  << "A " << arg1 << " (" << arg2 << "," << arg3 << ") " << "does not exist, because the variable \"" << arg4 << "\" is not coupled with the equation \"" << arg5 << "\"");
542 
544 
546  // DATA //
548 
550 
551 
558 
564  Table<2, DoFTools::Coupling>* cell_couplings;
565 
571  Table<2, DoFTools::Coupling>* flux_couplings;
572 
574 
575 protected:
576 
578 
579 
585  void set_all_solution_names();
586 
592  void set_all_equation_names();
593 
599  void check_solution_names() const;
600 
606  void check_equation_names() const;
607 
609 
611  // DATA //
613 
615 
616 
619  //std::vector<VariableNames > variable_names;
623  std::vector<std::string> all_solution_names;
624 
628  std::vector<std::string> all_equation_names;
629 
633  std::vector<std::string> solution_names;
634 
638  std::vector<std::string> equation_names;
639 
645  unsigned int n_solution_names;
646 
647  std::map<VariableNames, std::string> VariableNames_strings;
649 
650 };
651 
652 } // FuelCell
653 
654 #endif
Definition: system_management.h:152
const std::vector< std::string > & get_equation_names() const
This function returns equation_names.
Definition: system_management.h:455
Definition: system_management.h:85
Definition: system_management.h:114
Definition: system_management.h:120
Definition: system_management.h:77
Definition: system_management.h:106
std::vector< std::string > solution_names
Vector storing the names of user defined solution variables.
Definition: system_management.h:633
A small structure collecting the different BlockIndices of FEVector vectors (for instance, solution) involved in the computations.
Definition: mesh_loop_info_objects.h:182
Definition: system_management.h:98
Definition: system_management.h:101
std::vector< std::string > all_equation_names
Vector storing the names of available FCST equations.
Definition: system_management.h:628
Definition: system_management.h:108
std::map< VariableNames, std::string > VariableNames_strings
Definition: system_management.h:647
Definition: system_management.h:87
VariableNames
The enumeration containing the names of some of the available FCST solution variables and their deriv...
Definition: system_management.h:62
Definition: system_management.h:74
Definition: system_management.h:70
unsigned int n_solution_names
The number of user defined solution variables.
Definition: system_management.h:645
Definition: system_management.h:96
Definition: system_management.h:149
Definition: system_management.h:94
Definition: system_management.h:115
const std::vector< std::string > & get_all_solution_names() const
This function returns all_solution_names.
Definition: system_management.h:428
#define INSERT_ELEMENT(p)
Definition: system_management.h:80
std::map< std::string, std::map< std::string, DoFTools::Coupling > > couplings_map
The typedef for the map of cell or flux (DG FEM only) couplings stored in the actual equation classes...
Definition: system_management.h:40
Definition: system_management.h:119
Definition: system_management.h:118
Definition: system_management.h:68
Definition: system_management.h:75
Definition: system_management.h:72
Definition: system_management.h:83
Definition: system_management.h:100
Definition: system_management.h:99
Definition: system_management.h:82
Definition: system_management.h:93
Definition: system_management.h:151
Definition: system_management.h:73
Definition: system_management.h:88
Definition: system_management.h:110
std::vector< std::string > all_solution_names
Vector storing the names of available FCST solution variables.
Definition: system_management.h:623
Definition: system_management.h:76
ReactionNames
Definition: system_management.h:148
Definition: system_management.h:121
DeclException2(VariableShouldExistForEquation, std::string, std::string,<< "The user-defined variable with name \""<< arg1<< "\" should be one of the solution variables for equation with name \""<< arg2<< "\"")
Exception thrown when a particular variable required by the equation class, does not exist in the use...
Definition: system_management.h:79
Definition: system_management.h:67
Definition: system_management.h:86
Definition: system_management.h:116
Definition: system_management.h:105
Definition: system_management.h:104
Table< 2, DoFTools::Coupling > * cell_couplings
Pointer to the external YourApplication&lt;dim&gt;::cell_couplings object.
Definition: system_management.h:564
Definition: system_management.h:91
const unsigned int & get_number_of_solution_names() const
This function returns n_solution_names.
Definition: system_management.h:464
Definition: system_management.h:64
Definition: system_management.h:109
Definition: system_management.h:66
IMPORTANT: Add all new solution variables and equations here !
Definition: system_management.h:271
void initialize(FuelCell::ApplicationCore::BlockInfo &rblock_info, Table< 2, DoFTools::Coupling > &rcell_couplings, Table< 2, DoFTools::Coupling > &rflux_couplings)
This function assembles.
Definition: system_management.h:313
Definition: system_management.h:71
Definition: system_management.h:95
FuelCell::ApplicationCore::BlockInfo * block_info
Pointer to the external YourApplication&lt;dim&gt;::block_info object.
Definition: system_management.h:557
Definition: system_management.h:111
Definition: system_management.h:89
Definition: system_management.h:69
Definition: system_management.h:103
const std::string & get_VariableNames(const VariableNames value)
Definition: system_management.h:338
const std::vector< std::string > & get_solution_names() const
This function returns solution_names.
Definition: system_management.h:446
const std::vector< std::string > & get_all_equation_names() const
This function returns all_equation_names.
Definition: system_management.h:437
std::vector< std::string > equation_names
Vector storing the names of user defined equations.
Definition: system_management.h:638
Definition: system_management.h:113
Table< 2, DoFTools::Coupling > * flux_couplings
Pointer to the external YourApplication&lt;dim&gt;::flux_couplings (DG FEM only) object.
Definition: system_management.h:571