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 //
15 // ----------------------------------------------------------------------------
16 
17 #ifndef _FCST_FUELCELL_SYSTEM_MANAGEMENT_H_
18 #define _FCST_FUELCELL_SYSTEM_MANAGEMENT_H_
19 //-- dealII
20 #include <deal.II/base/parameter_handler.h>
21 
22 //-- OpenFCST
25 #include <utils/logging.h>
26 
27 //-- boost libraries
28 #include <boost/algorithm/string/join.hpp>
29 
30 using namespace dealii;
31 using namespace FuelCell::ApplicationCore;
32 
41 typedef std::map< std::string , std::map<std::string, DoFTools::Coupling> > couplings_map;
42 
64 {
65  nothing = 0,
66 
79 
82 
85 
91 
93 
98 
103 
108 
113 
118 
123 };
124 
125 
141 namespace FuelCell
142 {
143  namespace ApplicationCore
144  {
146  {
147  noSolver = 0,
151  };
152  }
153 }
154 
179 
182 };
183 
184 
185 namespace FuelCell
186 {
187 
300 class SystemManagement : public Subscriptor
301 {
302 public:
303 
305 
306 
314 
325  Table<2, DoFTools::Coupling>& cell_couplings,
326  Table<2, DoFTools::Coupling>& flux_couplings);
327 
331  ~SystemManagement();
332 
343  Table<2, DoFTools::Coupling>& rcell_couplings,
344  Table<2, DoFTools::Coupling>& rflux_couplings)
345  {
346  block_info = &rblock_info;
347  cell_couplings = &rcell_couplings;
348  flux_couplings = &rflux_couplings;
349  }
350 
354  void declare_parameters(ParameterHandler& param) const;
355 
359  void initialize(ParameterHandler& param);
360 
362 
364 
365 // The # and ## preprocessor operators are available in C++ and ANSI/ISO C.
366 // The # operator causes a replacement-text token to be converted to a string surrounded by quotes.
367 const std::string& get_VariableNames(const VariableNames value)
368 {
369  static std::map<VariableNames, std::string> VariableNames_strings;
370  if (VariableNames_strings.size() == 0){
371 #define INSERT_ELEMENT(p) VariableNames_strings[p] = #p
375 #undef INSERT_ELEMENT
376  }
377 
378  return VariableNames_strings[value];
379 }
386  const bool solution_in_userlist(const std::string& name) const;
387 
394  const unsigned int solution_name_to_index(const std::string& name) const;
395 
402  //const unsigned int solution_name_to_index(const VariableNames) const;
403 
410  const unsigned int equation_name_to_index(const std::string& name) const;
411 
427  const unsigned int matrix_block_index(const std::string& equation_name,
428  const std::string& solution_name) const;
429 
433  inline bool matrix_block_index_exists(const std::string& equation_name,
434  const std::string& solution_name) const
435  {
436  const unsigned int line = this->equation_name_to_index(equation_name);
437  const unsigned int column = this->solution_name_to_index(solution_name);
438 
439  bool value = false;
440  if ( (*cell_couplings)(line,column) != 0 )
441  value = true;
442 
443  return value;
444  }
445 
450  void make_cell_couplings(const std::vector<couplings_map>& src);
451 
459  void make_flux_couplings(const std::vector<couplings_map>& src);
460 
462 
464 
465 
470  const std::vector<std::string>& get_all_solution_names() const
471  {
472  return all_solution_names;
473  }
474 
479  const std::vector<std::string>& get_all_equation_names() const
480  {
481  return all_equation_names;
482  }
483 
488  const std::vector<std::string>& get_solution_names() const
489  {
490  return solution_names;
491  }
492 
497  const std::vector<std::string>& get_equation_names() const
498  {
499  return equation_names;
500  }
501 
506  const unsigned int& get_number_of_solution_names() const
507  {
508  return n_solution_names;
509  }
510 
522  void print_system_info() const;
523 
525 
527 
528 
534  DeclException2(VariableNotFoundInFCSTVariables,
535  std::string,
536  std::string,
537  << "A " << arg1 << " with name \"" << arg2 << "\" is not stored in available FCST solution variables");
538 
544  DeclException2(EquationNotFoundInFCSTEquations,
545  std::string,
546  std::string,
547  << "An " << arg1 << " with name \"" << arg2 << "\" is not stored in available FCST equations");
548 
554  DeclException2(VariableNotFoundInUserVariables,
555  std::string,
556  std::string,
557  << "A " << arg1 << " with name \"" << arg2 << "\" is not stored in user defined solution variables");
558 
564  DeclException2(EquationNotFoundInUserEquations,
565  std::string,
566  std::string,
567  << "An " << arg1 << " with name \"" << arg2 << "\" is not stored in user defined equations");
568 
577  DeclException5(SystemMatrixBlockDoesNotExist,
578  std::string,
579  unsigned int,
580  unsigned int,
581  std::string,
582  std::string,
583  << "A " << arg1 << " (" << arg2 << "," << arg3 << ") " << "does not exist, because the variable \"" << arg4 << "\" is not coupled with the equation \"" << arg5 << "\"");
584 
586 
588  // DATA //
590 
592 
593 
600 
606  Table<2, DoFTools::Coupling>* cell_couplings;
607 
613  Table<2, DoFTools::Coupling>* flux_couplings;
614 
616 
617 protected:
618 
620 
621 
627  void set_all_solution_names();
628 
634  void set_all_equation_names();
635 
641  void check_solution_names() const;
642 
648  void check_equation_names() const;
649 
651 
653  // DATA //
655 
657 
658 
661  //std::vector<VariableNames > variable_names;
665  std::vector<std::string> all_solution_names;
666 
670  std::vector<std::string> all_equation_names;
671 
675  std::vector<std::string> solution_names;
676 
680  std::vector<std::string> equation_names;
681 
687  unsigned int n_solution_names;
688 
689  std::map<VariableNames, std::string> VariableNames_strings;
691 
692 };
693 
694 } // FuelCell
695 
696 #endif
Definition: system_management.h:181
const std::vector< std::string > & get_equation_names() const
This function returns equation_names.
Definition: system_management.h:497
Definition: system_management.h:86
Definition: system_management.h:115
Definition: system_management.h:121
Definition: system_management.h:78
Definition: system_management.h:107
std::vector< std::string > solution_names
Vector storing the names of user defined solution variables.
Definition: system_management.h:675
A small structure collecting the different BlockIndices of FEVector vectors (for instance, solution) involved in the computations.
Definition: mesh_loop_info_objects.h:173
Definition: system_management.h:150
Definition: system_management.h:99
Definition: system_management.h:102
std::vector< std::string > all_equation_names
Vector storing the names of available FCST equations.
Definition: system_management.h:670
Definition: system_management.h:109
std::map< VariableNames, std::string > VariableNames_strings
Definition: system_management.h:689
Definition: system_management.h:88
VariableNames
The enumeration containing the names of some of the available FCST solution variables and their deriv...
Definition: system_management.h:63
Definition: system_management.h:149
Definition: system_management.h:75
Definition: system_management.h:71
unsigned int n_solution_names
The number of user defined solution variables.
Definition: system_management.h:687
Definition: system_management.h:97
Definition: system_management.h:178
Definition: system_management.h:95
Definition: system_management.h:116
const std::vector< std::string > & get_all_solution_names() const
This function returns all_solution_names.
Definition: system_management.h:470
#define INSERT_ELEMENT(p)
Definition: system_management.h:81
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:41
Definition: system_management.h:120
Definition: system_management.h:119
Definition: system_management.h:69
Definition: system_management.h:76
Definition: system_management.h:147
Definition: system_management.h:73
Definition: system_management.h:84
Definition: system_management.h:101
Definition: system_management.h:100
Definition: system_management.h:83
Definition: system_management.h:94
Definition: system_management.h:180
Definition: system_management.h:74
SolverName
Definition: system_management.h:145
Definition: system_management.h:89
Definition: system_management.h:111
std::vector< std::string > all_solution_names
Vector storing the names of available FCST solution variables.
Definition: system_management.h:665
Definition: system_management.h:77
ReactionNames
Definition: system_management.h:177
Definition: system_management.h:122
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:80
Definition: system_management.h:68
Definition: system_management.h:87
Definition: system_management.h:117
Definition: system_management.h:106
Definition: system_management.h:105
Table< 2, DoFTools::Coupling > * cell_couplings
Pointer to the external YourApplication&lt;dim&gt;::cell_couplings object.
Definition: system_management.h:606
Definition: system_management.h:92
const unsigned int & get_number_of_solution_names() const
This function returns n_solution_names.
Definition: system_management.h:506
Definition: system_management.h:65
Definition: system_management.h:110
Definition: system_management.h:67
IMPORTANT: Add all new solution variables and equations here !
Definition: system_management.h:300
Definition: system_management.h:148
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:342
Definition: system_management.h:72
Definition: system_management.h:96
bool matrix_block_index_exists(const std::string &equation_name, const std::string &solution_name) const
Check if, based on cell_couplings, this block must be assembled.
Definition: system_management.h:433
FuelCell::ApplicationCore::BlockInfo * block_info
Pointer to the external YourApplication&lt;dim&gt;::block_info object.
Definition: system_management.h:599
Definition: system_management.h:112
Definition: system_management.h:90
Definition: system_management.h:70
Definition: system_management.h:104
const std::string & get_VariableNames(const VariableNames value)
Definition: system_management.h:367
const std::vector< std::string > & get_solution_names() const
This function returns solution_names.
Definition: system_management.h:488
const std::vector< std::string > & get_all_equation_names() const
This function returns all_equation_names.
Definition: system_management.h:479
std::vector< std::string > equation_names
Vector storing the names of user defined equations.
Definition: system_management.h:680
Definition: system_management.h:114
Table< 2, DoFTools::Coupling > * flux_couplings
Pointer to the external YourApplication&lt;dim&gt;::flux_couplings (DG FEM only) object.
Definition: system_management.h:613