OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
equation_base.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: equation_base.h
11 // - Description: This is a base class for all available openFCST equations
12 // - Developers: Valentin N. Zingan, University of Alberta
13 // Marc Secanell Gallart, University of Alberta
14 //
15 // ----------------------------------------------------------------------------
16 
17 #ifndef _FCST_FUELCELLSHOP_EQUATION_EQUATION_BASE_H_
18 #define _FCST_FUELCELLSHOP_EQUATION_EQUATION_BASE_H_
19 
20 #include "system_management.h"
21 #include "dof_application.h"
23 #include "base_layer.h"
24 #include "fem_extras.h"
25 #include "fcst_utilities.h"
26 #include "fcst_constants.h"
27 
28 using namespace dealii;
29 using namespace FuelCell::ApplicationCore;
30 
31 namespace FuelCellShop
32 {
33 namespace Equation
34 {
35 
37 
38 
62  struct BoundaryType
63  {
67  std::string boundary_name;
68 
72  unsigned int boundary_id;
73 
77  std::string boundary_condition;
78  };
79 
87  struct OutputType
88  {
92  std::string variable_name;
93 
104  };
105 
106  // ############################################################################################## Bhaiya #######
107 
122  {
126  unsigned int solution_index;
127 
131  unsigned int block_index;
132 
137  unsigned int fetype_index;
138 
145  };
146 
147  // ############################################################################################## Bhaiya #######
148 
150 
152 
153 
154  // ############################################################################################## Bhaiya #######
155 
160  DeclException2(VariableShouldExistForEquation,
161  std::string,
162  std::string,
163  << "The user-defined variable with name \"" << arg1 << "\" should be one of the solution variables for equation with name \"" << arg2 << "\"");
164 
170  DeclException2(IndexDoNotMatch,
171  std::string,
172  std::string,
173  << "The index of variable \"" << arg1 << "\" do not match with the index of equation \"" << arg2 << "\"");
174 
175  // ############################################################################################## Bhaiya #######
176 
178 
198 template<int dim>
199 class EquationBase : public Subscriptor
200 {
201 public:
202 
204 
205 
212  {
213  print_caller_name(__FUNCTION__);
214  }
215 
222  {
223  print_caller_name(__FUNCTION__);
224  }
225 
232  {
233  print_caller_name(__FUNCTION__);
234  }
235 
242  {
243  print_caller_name(__FUNCTION__);
244  }
245 
247 
249 
250 
257  {
258  AssertThrow( !internal_cell_couplings.empty() , ExcInternalError() );
259  return internal_cell_couplings;
260  }
261 
268  {
269  AssertThrow( !internal_flux_couplings.empty() , ExcInternalError() );
270  return internal_flux_couplings;
271  }
272 
279  {
280  AssertThrow( !component_materialID_value.empty() , ExcInternalError() );
281  return component_materialID_value;
282  }
283 
290  {
291  AssertThrow( !component_boundaryID_value.empty() , ExcInternalError() );
292  return component_boundaryID_value;
293  }
294 
300  const std::vector< BoundaryType >& get_boundary_types() const
301  {
302  return boundary_types;
303  }
304 
310  const std::vector< std::vector< BoundaryType > >& get_multi_boundary_types() const
311  {
312  return multi_boundary_types;
313  }
314 
320  const std::vector< OutputType >& get_output_types() const
321  {
322  return output_types;
323  }
324 
330  const std::vector< std::vector< OutputType > >& get_multi_output_types() const
331  {
332  return multi_output_types;
333  }
334 
340  const std::string& get_equation_name() const
341  {
342  return equation_name;
343  }
344 
350  const std::vector<unsigned int>& get_matrix_block_indices() const
351  {
352  return matrix_block_indices;
353  }
354 
360  const std::vector<unsigned int>& get_residual_indices() const
361  {
362  return residual_indices;
363  }
364 
370  virtual void print_equation_info() const
371  {
372  print_caller_name(__FUNCTION__);
373  }
374 
376 
384 
392 
393 protected:
394 
396 
397 
414  EquationBase(FuelCell::SystemManagement& sys_management);
415 
419  virtual ~EquationBase();
420 
424  virtual void declare_parameters(ParameterHandler& param) const;
425 
429  virtual void initialize(ParameterHandler& param);
430 
435  virtual void set_parameters(const std::vector<std::string>& name_dvar,
436  const std::vector<double>& value_dvar,
437  ParameterHandler& param)
438  {
439  print_caller_name(__FUNCTION__);
440  }
441 
443 
445 
446 
452  {
453  print_caller_name(__FUNCTION__);
454  }
455 
461  {
462  print_caller_name(__FUNCTION__);
463  }
464 
470  {
471  print_caller_name(__FUNCTION__);
472  }
473 
480  {
481  print_caller_name(__FUNCTION__);
482  }
483 
490  {
491  print_caller_name(__FUNCTION__);
492  }
493 
495 
497 
498 
505  {
506  print_caller_name(__FUNCTION__);
507  }
508 
515  {
516  print_caller_name(__FUNCTION__);
517  }
518 
525  {
526  print_caller_name(__FUNCTION__);
527  }
528 
535  {
536  print_caller_name(__FUNCTION__);
537  }
538 
544  virtual void make_boundary_types()
545  {
546  print_caller_name(__FUNCTION__);
547  }
548 
555  {
556  print_caller_name(__FUNCTION__);
557  }
558 
564  virtual void make_output_types()
565  {
566  print_caller_name(__FUNCTION__);
567  }
568 
574  virtual void make_multi_output_types()
575  {
576  print_caller_name(__FUNCTION__);
577  }
578 
585  {
586  print_caller_name(__FUNCTION__);
587  }
588 
594  virtual void make_residual_indices()
595  {
596  print_caller_name(__FUNCTION__);
597  }
598 
600 
602 
603 
609  void standard_to_block_wise(FullMatrix<double>& target) const;
610 
616  void standard_to_block_wise(Vector<double>& target) const;
617 
631  void dealII_to_appframe(FuelCell::ApplicationCore::MatrixVector& dst,
632  const FullMatrix<double>& src,
633  const std::vector<unsigned int>& matrix_block_indices) const;
634 
648  void dealII_to_appframe(FuelCell::ApplicationCore::FEVector& dst,
649  const Vector<double>& src,
650  const std::vector<unsigned int>& residual_indices) const;
651 
653 
655 
656 
663  bool belongs_to_boundary(const unsigned int& tria_boundary_id,
664  const unsigned int& param_boundary_id) const
665  {
666  return tria_boundary_id == param_boundary_id;
667  }
668 
670 
672 
673 
680  void print_caller_name(const std::string& caller_name) const;
681 
683 
685  // DATA //
687 
689 
690 
695  unsigned int dofs_per_cell;
696 
698 
700 
701 
706  unsigned int n_q_points_cell;
707 
709 
711 
712 
717  unsigned int n_q_points_bdry;
718 
720 
722 
723 
728 
733 
735 
737 
738 
745 
747 
748 
755 
757 
758 
763  std::vector<double> JxW_cell;
764 
766 
768 
769 
776 
778 
779 
786 
788 
789 
794  std::vector<double> JxW_bdry;
795 
800  std::vector< Point<dim> > normal_vectors;
801 
806  std::vector< std::vector< Point<dim> > > tangential_vectors;
807 
809 
811 
812 
818 
825 
832 
842 
852 
858  std::vector< BoundaryType > boundary_types;
859 
865  std::vector< std::vector< BoundaryType > > multi_boundary_types;
866 
872  std::vector< OutputType > output_types;
873 
879  std::vector< std::vector< OutputType > > multi_output_types;
880 
885  std::string equation_name;
886 
892  std::string name_base_variable;
893 
899  std::vector<unsigned int> matrix_block_indices;
900 
906  std::vector<unsigned int> residual_indices;
907 
913  std::vector<bool> counter;
914 
916 
917 };
918 
919 } // Equation
920 
921 } // FuelCellShop
922 
923 #endif
This simple structure describes an output type of a derived equation class.
Definition: equation_base.h:87
virtual void set_parameters(const std::vector< std::string > &name_dvar, const std::vector< double > &value_dvar, ParameterHandler &param)
Set parameters using the parameter file, in order to run parametric/optimization studies.
Definition: equation_base.h:435
std::vector< double > JxW_cell
Jacobian of mapping by Weight in the quadrature points of a cell.
Definition: equation_base.h:763
unsigned int solution_index
Index of the user-defined solution variable, retrieved from #SystemManagement.
Definition: equation_base.h:126
bool variable_initial_data
true, if variable initial data is prescribed on a part of the domain.
Definition: equation_base.h:383
const std::string & get_equation_name() const
This function returns equation_name of a derived equation class.
Definition: equation_base.h:340
virtual void make_component_materialID_value()
This function fills out component_materialID_value of a derived equation class.
Definition: equation_base.h:524
std::vector< std::vector< OutputType > > multi_output_types
The list of multiple output types of a derived equation class.
Definition: equation_base.h:879
virtual void print_equation_info() const
This function prints out the equations info of a derived equation class.
Definition: equation_base.h:370
bool belongs_to_boundary(const unsigned int &tria_boundary_id, const unsigned int &param_boundary_id) const
This function returns true if a boundary indicator of an external face on the triangulation coincides...
Definition: equation_base.h:663
std::vector< BoundaryType > boundary_types
The list of boundary types of a derived equation class.
Definition: equation_base.h:858
unsigned int boundary_id
Boundary indicator.
Definition: equation_base.h:72
virtual void make_assemblers_bdry_constant_data(const typename FuelCell::ApplicationCore::DoFApplication< dim >::FaceInfo &bdry_info)
This function is overridden in the derived equation classes.
Definition: equation_base.h:469
FuelCell::SystemManagement * system_management
Pointer to the external YourApplication&lt;dim&gt;::system_management object.
Definition: equation_base.h:817
const component_boundaryID_value_map & get_component_boundaryID_value() const
This function returns component_boundaryID_value of a derived equation class.
Definition: equation_base.h:289
const std::vector< OutputType > & get_output_types() const
This function returns output_types of a derived equation class.
Definition: equation_base.h:320
unsigned int dofs_per_cell
Number of degrees of freedom per cell.
Definition: equation_base.h:695
const std::vector< std::vector< OutputType > > & get_multi_output_types() const
This function returns multi_output_types of a derived equation class.
Definition: equation_base.h:330
std::vector< OutputType > output_types
The list of output types of a derived equation class.
Definition: equation_base.h:872
virtual void make_boundary_types()
This function fills out boundary_types of a derived equation class.
Definition: equation_base.h:544
virtual void make_assemblers_cell_constant_data(const typename FuelCell::ApplicationCore::DoFApplication< dim >::CellInfo &cell_info)
This function is overridden in the derived equation classes.
Definition: equation_base.h:460
std::vector< unsigned int > residual_indices
The residual indices (a derived equation class) drawn from the global structure (a derived equation c...
Definition: equation_base.h:906
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
std::map< std::string, std::map< types::material_id, double > > component_materialID_value_map
The typedef for the std::map that reflects the following structure:
Definition: initial_and_boundary_data.h:79
std::string name_base_variable
Const std::string member storing name of the base solution variable corresponding to the equation rep...
Definition: equation_base.h:892
virtual void make_multi_boundary_types()
This function fills out multi_boundary_types of a derived equation class.
Definition: equation_base.h:554
std::map< std::string, std::map< types::boundary_id, double > > component_boundaryID_value_map
The typedef for the std::map that reflects the following structure:
Definition: initial_and_boundary_data.h:90
std::string boundary_condition
Type of boundary condition.
Definition: equation_base.h:77
bool variable_boundary_data
true, if variable Dirichlet boundary conditions are prescribed on a part of the boundary.
Definition: equation_base.h:391
virtual void make_component_boundaryID_value()
This function fills out component_boundaryID_value of a derived equation class.
Definition: equation_base.h:534
This class is created for the objects handed to the mesh loops.
Definition: mesh_loop_info_objects.h:625
const std::vector< unsigned int > & get_residual_indices() const
This function returns residual_indices of a derived equation class.
Definition: equation_base.h:360
std::vector< MatrixBlock< FullMatrix< double > > > MatrixVector
The matrix vector used in the mesh loops.
Definition: matrix_block.h:102
const std::vector< unsigned int > & get_matrix_block_indices() const
This function returns matrix_block_indices of a derived equation class.
Definition: equation_base.h:350
DoFHandler< dim >::active_face_iterator bdry
Currently active DoFHandler&lt;dim&gt; active boundary iterator.
Definition: equation_base.h:732
component_materialID_value_map component_materialID_value
This object reflects the following structure (see FuelCell::InitialAndBoundaryData namespace docs): ...
Definition: equation_base.h:841
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...
virtual void assemble_bdry_residual(FuelCell::ApplicationCore::FEVector &bdry_residual, const typename FuelCell::ApplicationCore::DoFApplication< dim >::FaceInfo &bdry_info, FuelCellShop::Layer::BaseLayer< dim > *const layer)
Assemble local boundary residual.
Definition: equation_base.h:239
unsigned int n_q_points_bdry
Number of quadrature points per boundary.
Definition: equation_base.h:717
virtual void make_assemblers_cell_variable_data(const typename FuelCell::ApplicationCore::DoFApplication< dim >::CellInfo &cell_info, FuelCellShop::Layer::BaseLayer< dim > *const layer)
This function is overridden in the derived equation classes.
Definition: equation_base.h:478
couplings_map internal_flux_couplings
This object contains the info on how the &quot;X&quot; and &quot;Y&quot; of a derived equation class are coupled (DG FEM ...
Definition: equation_base.h:831
virtual void assemble_cell_matrix(FuelCell::ApplicationCore::MatrixVector &cell_matrices, const typename FuelCell::ApplicationCore::DoFApplication< dim >::CellInfo &cell_info, FuelCellShop::Layer::BaseLayer< dim > *const layer)
Assemble local cell matrix.
Definition: equation_base.h:209
virtual void make_residual_indices()
This function fills out residual_indices of a derived equation class.
Definition: equation_base.h:594
std::string variable_name
Variable name.
Definition: equation_base.h:92
virtual void make_assemblers_generic_constant_data()
This function is overridden in the derived equation classes.
Definition: equation_base.h:451
const couplings_map & get_internal_cell_couplings() const
This function returns internal_cell_couplings of a derived equation class.
Definition: equation_base.h:256
unsigned int block_index
Block index of the matrix relating to the variable corresponding to an equation, retrieved from #Syst...
Definition: equation_base.h:131
std::vector< Point< dim > > normal_vectors
Normal vectors in the quadrature points of a boundary.
Definition: equation_base.h:800
std::vector< unsigned int > matrix_block_indices
The system matrix block indices (a derived equation class) drawn from the global structure (a derived...
Definition: equation_base.h:899
virtual void assemble_bdry_matrix(FuelCell::ApplicationCore::MatrixVector &bdry_matrices, const typename FuelCell::ApplicationCore::DoFApplication< dim >::FaceInfo &bdry_info, FuelCellShop::Layer::BaseLayer< dim > *const layer)
Assemble local boundary matrix.
Definition: equation_base.h:229
const component_materialID_value_map & get_component_materialID_value() const
This function returns component_materialID_value of a derived equation class.
Definition: equation_base.h:278
std::vector< std::vector< Point< dim > > > tangential_vectors
Tangential vectors in the quadrature points of a boundary.
Definition: equation_base.h:806
virtual void make_output_types()
This function fills out output_types of a derived equation class.
Definition: equation_base.h:564
std::string variable_interpretation
Variable interpretation.
Definition: equation_base.h:103
This class contains generic data and methods heavily used by all derived equation classes...
Definition: equation_base.h:199
virtual void assemble_cell_residual(FuelCell::ApplicationCore::FEVector &cell_residual, const typename FuelCell::ApplicationCore::DoFApplication< dim >::CellInfo &cell_info, FuelCellShop::Layer::BaseLayer< dim > *const layer)
Assemble local cell residual.
Definition: equation_base.h:219
virtual void make_matrix_block_indices()
This function fills out matrix_block_indices of a derived equation class.
Definition: equation_base.h:584
virtual void make_internal_cell_couplings()
This function fills out internal_cell_couplings of a derived equation class.
Definition: equation_base.h:504
component_boundaryID_value_map component_boundaryID_value
This object reflects the following structure (see FuelCell::InitialAndBoundaryData namespace docs): ...
Definition: equation_base.h:851
IMPORTANT: Add all new solution variables and equations here !
Definition: system_management.h:271
This simple structure stores certain information regarding a particular variable for the equation (al...
Definition: equation_base.h:121
couplings_map internal_cell_couplings
This object contains the info on how the equations and solution variables of a derived equation class...
Definition: equation_base.h:824
const std::vector< BoundaryType > & get_boundary_types() const
This function returns boundary_types of a derived equation class.
Definition: equation_base.h:300
virtual void make_assemblers_bdry_variable_data(const typename FuelCell::ApplicationCore::DoFApplication< dim >::FaceInfo &bdry_info, FuelCellShop::Layer::BaseLayer< dim > *const layer)
This function is overridden in the derived equation classes.
Definition: equation_base.h:488
This simple structure describes a boundary type of a derived equation class.
Definition: equation_base.h:62
Definition: dof_application.h:85
virtual void make_internal_flux_couplings()
This function fills out internal_flux_couplings (DG FEM only) of a derived equation class...
Definition: equation_base.h:514
std::string boundary_name
Boundary name.
Definition: equation_base.h:67
std::vector< double > JxW_bdry
Jacobian of mapping by Weight in the quadrature points of a boundary.
Definition: equation_base.h:794
DoFHandler< dim >::active_cell_iterator cell
Currently active DoFHandler&lt;dim&gt; active cell iterator.
Definition: equation_base.h:727
const std::vector< std::vector< BoundaryType > > & get_multi_boundary_types() const
This function returns multi_boundary_types of a derived equation class.
Definition: equation_base.h:310
BlockVector< double > FEVector
The vector class used by applications.
Definition: application_data.h:39
const couplings_map & get_internal_flux_couplings() const
This function returns internal_flux_couplings (DG FEM only) of a derived equation class...
Definition: equation_base.h:267
std::vector< bool > counter
This vector contains the collection of internal &quot;counters&quot; used by the derived equation classes...
Definition: equation_base.h:913
Virtual class used to characterize a generic layer interface.
Definition: base_layer.h:58
unsigned int n_q_points_cell
Number of quadrature points per cell.
Definition: equation_base.h:706
std::vector< std::vector< BoundaryType > > multi_boundary_types
The list of multiple boundary types of a derived equation class.
Definition: equation_base.h:865
bool indices_exist
Boolean storing whether indices exist or not.
Definition: equation_base.h:144
std::string equation_name
The name of a derived equation class.
Definition: equation_base.h:885
unsigned int fetype_index
Index corresponding to type of fevalue object used for this variable.
Definition: equation_base.h:137
virtual void make_multi_output_types()
This function fills out multi_output_types of a derived equation class.
Definition: equation_base.h:574