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 // Mayank Sabharwal, University of Alberta
15 // Aslan Kosakian, University of Alberta
16 //
17 // ----------------------------------------------------------------------------
18 
19 #ifndef _FCST_FUELCELLSHOP_EQUATION_EQUATION_BASE_H_
20 #define _FCST_FUELCELLSHOP_EQUATION_EQUATION_BASE_H_
21 #include <boost/shared_ptr.hpp>
22 
26 #include <layers/base_layer.h>
27 #include <utils/fem_extras.h>
28 #include <utils/fcst_utilities.h>
29 #include <utils/fcst_constants.h>
30 #include <equation_auxiliaries.h>
32 
33 using namespace dealii;
34 using namespace FuelCell::ApplicationCore;
35 
36 namespace FuelCellShop
37 {
38  namespace Equation
39  {
40 
42 
43 
49  struct EquationFlags
50  {
63  };
64 
84  struct BoundaryType
85  {
87  std::string boundary_name;
88 
90  unsigned int boundary_id;
91 
93  std::string boundary_condition;
94  };
95 
101  struct OutputType
102  {
104  std::string variable_name;
105 
114  };
115 
116 
117  // ############################################################################################## Bhaiya #######
118 
120 
122 
123 
127  DeclException2(VariableShouldExistForEquation,
128  std::string,
129  std::string,
130  << "The user-defined variable with name \"" << arg1 << "\" should be one of the solution variables for equation with name \"" << arg2 << "\"");
131 
137  DeclException2(IndexDoNotMatch,
138  std::string,
139  std::string,
140  << "The index of variable \"" << arg1 << "\" do not match with the index of equation \"" << arg2 << "\"");
142 
159  template<int dim>
160  class EquationBase : public Subscriptor
161  {
162  public:
163 
165 
166 
177  virtual void assemble_cell_matrix(FuelCell::ApplicationCore::MatrixVector& cell_matrices,
180 
192  virtual void assemble_cell_residual(FuelCell::ApplicationCore::FEVector& cell_residual,
195 
210  {
211  print_caller_name(__FUNCTION__);
212  }
213 
214 
229  {
230  print_caller_name(__FUNCTION__);
231  }
232 
234 
236 
237 
243  {
244  AssertThrow( !internal_cell_couplings.empty() , ExcInternalError() );
245  return internal_cell_couplings;
246  }
247 
253  {
254  AssertThrow( !internal_flux_couplings.empty() , ExcInternalError() );
255  return internal_flux_couplings;
256  }
257 
263  {
264  AssertThrow( !component_materialID_value.empty() , ExcInternalError() );
265  return component_materialID_value;
266  }
267 
273  {
274  AssertThrow( !component_boundaryID_value.empty() , ExcInternalError() );
275  return component_boundaryID_value;
276  }
277 
282  const std::vector< BoundaryType >& get_boundary_types() const
283  {
284  return boundary_types;
285  }
286 
291  const std::vector< std::vector< BoundaryType > >& get_multi_boundary_types() const
292  {
293  return multi_boundary_types;
294  }
295 
300  const std::vector< OutputType >& get_output_types() const
301  {
302  return output_types;
303  }
304 
309  const std::vector< std::vector< OutputType > >& get_multi_output_types() const
310  {
311  return multi_output_types;
312  }
313 
319  const std::string& get_equation_name() const
320  {
321  return equation_name;
322  }
323 
329  const std::vector<unsigned int>& get_matrix_block_indices() const
330  {
331  return matrix_block_indices;
332  }
333 
339  const std::vector<unsigned int>& get_residual_indices() const
340  {
341  return residual_indices;
342  }
343 
349  virtual void print_equation_info() const
350  {
351  print_caller_name(__FUNCTION__);
352  }
354 
360 
366 
367  protected:
368 
370 
371 
388  EquationBase(FuelCell::SystemManagement& sys_management,boost::shared_ptr< FuelCell::ApplicationCore::ApplicationData > data =
389  boost::shared_ptr< FuelCell::ApplicationCore::ApplicationData >());
390 
394  virtual ~EquationBase();
395 
399  virtual void declare_parameters(ParameterHandler& param) const;
400 
404  virtual void initialize(ParameterHandler& param);
405 
409  virtual void set_parameters(const std::vector<std::string>& name_dvar,
410  const std::vector<double>& value_dvar,
411  ParameterHandler& param) {
412  print_caller_name(__FUNCTION__);
413  }
414 
416 
418 
419 
431  print_caller_name(__FUNCTION__);
432  }
433 
443  print_caller_name(__FUNCTION__);
444  }
445 
451  print_caller_name(__FUNCTION__);
452  }
453 
463  {
464  print_caller_name(__FUNCTION__);
465  }
466 
472  {
473  print_caller_name(__FUNCTION__);
474  }
475 
485  {
486  if ( assemble_flags.assemble_generic_data )
487  {
488  make_assemblers_generic_constant_data();
489  assemble_flags.assemble_generic_data = false;
490  }
491 
492  if ( assemble_flags.assemble_cell_constant_data )
493  {
494  make_assemblers_cell_constant_data(cell_info);
495  assemble_flags.assemble_cell_constant_data = false;
496  }
497 
498  make_assemblers_cell_variable_data(cell_info, layer);
499  }
501 
503 
504 
508  print_caller_name(__FUNCTION__);
509  }
510 
515  {
516  print_caller_name(__FUNCTION__);
517  }
518 
523  print_caller_name(__FUNCTION__);
524  }
525 
530  print_caller_name(__FUNCTION__);
531  }
532 
536  virtual void make_boundary_types() {
537  print_caller_name(__FUNCTION__);
538  }
539 
543  virtual void make_multi_boundary_types() {
544  print_caller_name(__FUNCTION__);
545  }
546 
550  virtual void make_output_types() {
551  print_caller_name(__FUNCTION__);
552  }
553 
557  virtual void make_multi_output_types() {
558  print_caller_name(__FUNCTION__);
559  }
560 
567  virtual void make_matrix_block_indices() {
568  print_caller_name(__FUNCTION__);
569  }
570 
577  virtual void make_residual_indices() {
578  print_caller_name(__FUNCTION__);
579  }
581 
583 
584 
592  print_caller_name(__FUNCTION__);
593  }
594 
604  print_caller_name(__FUNCTION__);
605  }
606 
607 
616  print_caller_name(__FUNCTION__);
617  }
618 
627  print_caller_name(__FUNCTION__);
628  }
629 
638  print_caller_name(__FUNCTION__);
639  }
640 
647  print_caller_name(__FUNCTION__);
648  }
649 
656  print_caller_name(__FUNCTION__);
657  }
659 
661 
662 
665  void standard_to_block_wise(FullMatrix<double>& target) const;
666 
670  void standard_to_block_wise(Vector<double>& target) const;
671 
679  void dealII_to_appframe(FuelCell::ApplicationCore::MatrixVector& dst,
680  const FullMatrix<double>& src,
681  const std::vector<unsigned int>& matrix_block_indices) const;
682 
689  void dealII_to_appframe(FuelCell::ApplicationCore::FEVector& dst,
690  const Vector<double>& src,
691  const std::vector<unsigned int>& residual_indices) const;
693 
695 
696 
700  bool belongs_to_boundary(const unsigned int& tria_boundary_id,
701  const unsigned int& param_boundary_id) const
702  {
703  return tria_boundary_id == param_boundary_id;
704  }
705 
707 
709 
710 
714  void print_caller_name(const std::string& caller_name) const;
716  // DATA //
719 
721 
722 
723  unsigned int dofs_per_cell;
725 
727 
728 
729  unsigned int n_q_points_cell;
731 
733 
734 
736  unsigned int n_q_points_bdry;
737 
739 
741 
742 
745 
748 
750 
752 
753 
755 
757 
758 
760 
762 
763 
764  std::vector<double> JxW_cell;
765 
767 
769 
770 
772 
774 
775 
777 
779 
780 
782  std::vector<double> JxW_bdry;
783 
785  std::vector< Point<dim> > normal_vectors;
786 
788  std::vector< std::vector< Point<dim> > > tangential_vectors;
789 
791 
793 
794 
799 
805 
811 
821 
831 
835  std::vector< BoundaryType > boundary_types;
836 
840  std::vector< std::vector< BoundaryType > > multi_boundary_types;
841 
845  std::vector< OutputType > output_types;
846 
850  std::vector< std::vector< OutputType > > multi_output_types;
851 
855  std::string equation_name;
856 
861  std::string name_base_variable;
862 
867  std::vector<unsigned int> matrix_block_indices;
868 
872  std::vector<unsigned int> residual_indices;
873 
878  std::vector<bool> counter;
886 
890  boost::shared_ptr< FuelCell::ApplicationCore::ApplicationData > data;
891 
895  std::string solution_vector_name;
896 
900  std::string residual_vector_name;
901 
903  };
904 
905  } // Equation
906 
907 } // FuelCellShop
908 
909 #endif
This structure describes an output type of a derived equation class.
Definition: equation_base.h:101
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:409
std::vector< double > JxW_cell
Jacobian of mapping by Weight in the quadrature points of a cell.
Definition: equation_base.h:764
boost::shared_ptr< FuelCell::ApplicationCore::ApplicationData > data
Data object for the application data to be passed to the equation classes.
Definition: equation_base.h:890
bool variable_initial_data
true, if variable initial data is prescribed on a part of the domain.
Definition: equation_base.h:359
const std::string & get_equation_name() const
This function returns equation_name of a derived equation class.
Definition: equation_base.h:319
bool assemble_generic_data
Flag used to let equation clases know that generic data has already been initialized.
Definition: equation_base.h:54
virtual void make_component_materialID_value()
This function fills out component_materialID_value of a derived equation class.
Definition: equation_base.h:522
std::vector< std::vector< OutputType > > multi_output_types
The list of multiple output types of a derived equation class.
Definition: equation_base.h:850
virtual void print_equation_info() const
This function prints out the equations info of a derived equation class.
Definition: equation_base.h:349
bool assemble_cell_constant_data
Flag used to let equation class know that cell_constant data has already been initialized.
Definition: equation_base.h:58
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:700
std::vector< BoundaryType > boundary_types
The list of boundary types of a derived equation class.
Definition: equation_base.h:835
void select_cell_assemblers(const typename FuelCell::ApplicationCore::DoFApplication< dim >::CellInfo &cell_info, FuelCellShop::Layer::BaseLayer< dim > *const layer)
This routine is used to select the make_assembly routines that need to be called inside assemble_cell...
Definition: equation_base.h:483
unsigned int boundary_id
Boundary indicator.
Definition: equation_base.h:90
virtual void assemble_cell_linear_matrix(FuelCell::ApplicationCore::MatrixVector &cell_matrices, const typename FuelCell::ApplicationCore::DoFApplication< dim >::CellInfo &cell_info, FuelCellShop::Layer::BaseLayer< dim > *const layer)
Assemble the local cell matrix for Linear problems.
Definition: equation_base.h:613
virtual void make_assemblers_bdry_constant_data(const typename FuelCell::ApplicationCore::DoFApplication< dim >::FaceInfo &bdry_info)
Definition: equation_base.h:450
FuelCell::SystemManagement * system_management
Pointer to the external YourApplication&lt;dim&gt;::system_management object.
Definition: equation_base.h:798
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:272
const std::vector< OutputType > & get_output_types() const
This function returns output_types of a derived equation class.
Definition: equation_base.h:300
unsigned int dofs_per_cell
Number of degrees of freedom per cell.
Definition: equation_base.h:723
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:309
std::vector< OutputType > output_types
The list of output types of a derived equation class.
Definition: equation_base.h:845
Enumeration for flags used in equation classes to control assembly.
Definition: equation_base.h:49
virtual void make_boundary_types()
This function fills out boundary_types of a derived equation class.
Definition: equation_base.h:536
virtual void assemble_bdry_linear_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 for linear problems.
Definition: equation_base.h:644
virtual void make_assemblers_cell_constant_data(const typename FuelCell::ApplicationCore::DoFApplication< dim >::CellInfo &cell_info)
Function used to initialize cell speciific information that remains constant regardless of the cell b...
Definition: equation_base.h:442
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:872
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
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:74
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:861
virtual void make_multi_boundary_types()
This function fills out multi_boundary_types of a derived equation class.
Definition: equation_base.h:543
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:85
std::string boundary_condition
Type of boundary condition.
Definition: equation_base.h:93
virtual void assemble_cell_Jacobian_matrix(FuelCell::ApplicationCore::MatrixVector &cell_matrices, const typename FuelCell::ApplicationCore::DoFApplication< dim >::CellInfo &cell_info, FuelCellShop::Layer::BaseLayer< dim > *const layer)
Assemble the local Jacobian Matrix for Non-Linear problems.
Definition: equation_base.h:589
bool variable_boundary_data
true, if variable Dirichlet boundary conditions are prescribed on a part of the boundary.
Definition: equation_base.h:365
virtual void make_component_boundaryID_value()
This function fills out component_boundaryID_value of a derived equation class.
Definition: equation_base.h:529
This class is created for the objects handed to the mesh loops.
Definition: mesh_loop_info_objects.h:544
virtual void assemble_bdry_Jacobian_matrix(FuelCell::ApplicationCore::MatrixVector &bdry_matrices, const typename FuelCell::ApplicationCore::DoFApplication< dim >::FaceInfo &bdry_info, FuelCellShop::Layer::BaseLayer< dim > *const layer)
Assemble local Jacobian boundary matrix for Non-Linear problems.
Definition: equation_base.h:601
const std::vector< unsigned int > & get_residual_indices() const
This function returns residual_indices of a derived equation class.
Definition: equation_base.h:339
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:329
virtual void assemble_cell_linear_rhs(FuelCell::ApplicationCore::FEVector &cell_residual, const typename FuelCell::ApplicationCore::DoFApplication< dim >::CellInfo &cell_info, FuelCellShop::Layer::BaseLayer< dim > *const layer)
Assemble local cell RHS for Linear problems.
Definition: equation_base.h:635
DoFHandler< dim >::active_face_iterator bdry
Currently active DoFHandler&lt;dim&gt; active boundary iterator.
Definition: equation_base.h:747
component_materialID_value_map component_materialID_value
This object reflects the following structure (see FuelCell::InitialAndBoundaryData namespace docs): ...
Definition: equation_base.h:820
EquationFlags assemble_flags
This vector contains a collection of internal flags to tell derived equation classes what needs to be...
Definition: equation_base.h:885
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:226
std::string residual_vector_name
The name of the residual vector name in FEVectors.
Definition: equation_base.h:900
unsigned int n_q_points_bdry
Number of quadrature points per boundary.
Definition: equation_base.h:736
virtual void make_assemblers_cell_variable_data(const typename FuelCell::ApplicationCore::DoFApplication< dim >::CellInfo &cell_info, FuelCellShop::Layer::BaseLayer< dim > *const layer)
Function used to compute cell specific information such as shape functions, shape function gradients...
Definition: equation_base.h:461
bool assemble_cell_variable_data_matrix
Flag used to let assemble_cell_variable_data know that derivatives do not need to computed as only th...
Definition: equation_base.h:62
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:810
virtual void make_residual_indices()
This function is only needed to provide the last argument to dealII_to_appframe.
Definition: equation_base.h:577
std::string variable_name
Variable name.
Definition: equation_base.h:104
virtual void make_assemblers_generic_constant_data()
Function used to initialize variable information that will be needed to assemble matrix and residual ...
Definition: equation_base.h:430
const couplings_map & get_internal_cell_couplings() const
This function returns internal_cell_couplings of a derived equation class.
Definition: equation_base.h:242
std::vector< Point< dim > > normal_vectors
Normal vectors in the quadrature points of a boundary.
Definition: equation_base.h:785
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:867
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:207
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:262
std::vector< std::vector< Point< dim > > > tangential_vectors
Tangential vectors in the quadrature points of a boundary.
Definition: equation_base.h:788
virtual void make_output_types()
This function fills out output_types of a derived equation class.
Definition: equation_base.h:550
std::string variable_interpretation
Variable interpretation.
Definition: equation_base.h:113
This is the base class used for all Equation classes.
Definition: equation_base.h:160
virtual void make_matrix_block_indices()
This function is only needed to provide the last argument to dealII_to_appframe.
Definition: equation_base.h:567
virtual void make_internal_cell_couplings()
This function fills out internal_cell_couplings of a derived equation class.
Definition: equation_base.h:507
virtual void assemble_bdry_linear_rhs(FuelCell::ApplicationCore::FEVector &bdry_residual, const typename FuelCell::ApplicationCore::DoFApplication< dim >::FaceInfo &bdry_info, FuelCellShop::Layer::BaseLayer< dim > *const layer)
Assemble local boundary RHS for linear problems.
Definition: equation_base.h:653
component_boundaryID_value_map component_boundaryID_value
This object reflects the following structure (see FuelCell::InitialAndBoundaryData namespace docs): ...
Definition: equation_base.h:830
virtual void assemble_cell_residual_rhs(FuelCell::ApplicationCore::FEVector &cell_residual, const typename FuelCell::ApplicationCore::DoFApplication< dim >::CellInfo &cell_info, FuelCellShop::Layer::BaseLayer< dim > *const layer)
Assemble local cell RHS for nonlinear problems.
Definition: equation_base.h:624
IMPORTANT: Add all new solution variables and equations here !
Definition: system_management.h:300
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:804
const std::vector< BoundaryType > & get_boundary_types() const
This function returns boundary_types of a derived equation class.
Definition: equation_base.h:282
virtual void make_assemblers_bdry_variable_data(const typename FuelCell::ApplicationCore::DoFApplication< dim >::FaceInfo &bdry_info, FuelCellShop::Layer::BaseLayer< dim > *const layer)
Definition: equation_base.h:470
This structure describes a boundary type of a derived equation class.
Definition: equation_base.h:84
Definition: dof_application.h:70
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:87
std::vector< double > JxW_bdry
Jacobian of mapping by Weight in the quadrature points of a boundary.
Definition: equation_base.h:782
DoFHandler< dim >::active_cell_iterator cell
Currently active DoFHandler&lt;dim&gt; active cell iterator.
Definition: equation_base.h:744
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:291
BlockVector< double > FEVector
The vector class used by applications.
Definition: application_data.h:46
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:252
std::vector< bool > counter
This vector contains the collection of internal &quot;counters&quot; used by the derived equation classes...
Definition: equation_base.h:878
Virtual class used to characterize a generic layer interface.
Definition: base_layer.h:58
std::string solution_vector_name
The name of the solution vector in FEVectors.
Definition: equation_base.h:895
unsigned int n_q_points_cell
Number of quadrature points per cell.
Definition: equation_base.h:729
std::vector< std::vector< BoundaryType > > multi_boundary_types
The list of multiple boundary types of a derived equation class.
Definition: equation_base.h:840
std::string equation_name
The name of a derived equation class.
Definition: equation_base.h:855
virtual void make_multi_output_types()
This function fills out multi_output_types of a derived equation class.
Definition: equation_base.h:557