Flow123d  JS_before_hm-1598-g3b021b4
reaction_term.hh
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file reaction_term.hh
15  * @brief Class ReactionTerm is an abstract class representing reaction term in transport.
16  *
17  * Descending classes implements different physical models - dual porosity, sorption, decays,
18  * chemical reactions.
19  */
20 
21 #ifndef REACTION_TERM_H
22 #define REACTION_TERM_H
23 
24 #include <memory> // for shared_ptr
25 #include <string> // for string
26 #include "coupling/equation.hh" // for EquationBase
27 #include "system/index_types.hh" // for LongInt
28 #include "input/input_exception.hh" // for DECLARE_INPUT_EXCEPTION, Exception
29 #include "system/exceptions.hh" // for ExcStream, operator<<, EI, TYPED...
30 #include "transport/substance.hh" // for SubstanceList
31 #include "fem/dofhandler.hh" // for DOFHandlerMultiDim
32 #include "fields/field_fe.hh" // for FieldFE
33 
34 class Distribution;
35 class Mesh;
36 class OutputTime;
37 namespace Input {
38  class Record;
39  namespace Type {
40  class Abstract;
41  }
42 }
43 
44 
46 {
47 public:
48  TYPEDEF_ERR_INFO( EI_Substance, std::string);
49  TYPEDEF_ERR_INFO( EI_Model, std::string);
50  DECLARE_INPUT_EXCEPTION( ExcUnknownSubstance, << "Unknown substance name: " << EI_Substance::qval);
51  DECLARE_INPUT_EXCEPTION( ExcWrongDescendantModel, << "Impossible descendant model: " << EI_Model::qval);
52 
54 
55  /**
56  * Static variable for definition of common input record in reaction term.
57  */
58  static Input::Type::Abstract & it_abstract_term();
59  static Input::Type::Abstract & it_abstract_mobile_term();
60  static Input::Type::Abstract & it_abstract_immobile_term();
61  static Input::Type::Abstract & it_abstract_reaction();
62 
63  /// Constructor.
64  /** @param init_mesh is the reference to the computational mesh
65  * @param in_rec is the input record
66  */
67  ReactionTerm(Mesh &init_mesh, Input::Record in_rec);
68 
69  /// Destructor.
70  ~ReactionTerm(void);
71 
72 
73  ///@name Setters
74  //@{
75  ///Sets the names of substances considered in transport.
77  {substances_.initialize(substances); return *this;}
78 
79  ///Sets the output stream which is given from transport class.
80  ReactionTerm &output_stream(std::shared_ptr<OutputTime> ostream)
81  {output_stream_=ostream; return *this;}
82 
83  /// Computes a constraint for time step.
84  virtual bool evaluate_time_constraint(double &time_constraint) = 0;
85 
86  /**
87  * Sets the pointer to concentration matrix for the mobile zone,
88  * all substances and on all elements (given by transport).
89  */
90  ReactionTerm &concentration_fields(FieldFEScalarVec& conc_mobile)
91  {
92  conc_mobile_fe = conc_mobile;
93  dof_handler_ = conc_mobile_fe[0]->get_dofhandler();
94  return *this;
95  }
96  //@}
97 
98  /** @brief Output method.
99  *
100  * Some reaction models have their own data to output (sorption, dual porosity)
101  * - this is where it must be reimplemented.
102  * On the other hand, some do not have (linear reaction, pade approximant)
103  * - that is why it is not pure virtual.
104  */
105  virtual void output_data(void) override {};
106 
107  /// Disable changes in TimeGovernor by empty method.
108  void choose_next_time(void) override;
109 
110 protected:
111  /// Compute reaction on a single element.
112  virtual void compute_reaction(const DHCellAccessor& dh_cell) = 0;
113 
114  /// FieldFEs representing P0 interpolation of mobile concentration (passed from transport).
115  FieldFEScalarVec conc_mobile_fe;
116 
117  /// Names belonging to substances.
118  /**
119  * Must be same as in the transport.
120  */
122 
123  /// Pointer to a transport output stream.
124  std::shared_ptr<OutputTime> output_stream_;
125 
126  /// Pointer to DOF handler used through the reaction tree
127  std::shared_ptr<DOFHandlerMultiDim> dof_handler_;
128 
129 };
130 
131 #endif // REACTION_TERM_H
virtual void output_data(void) override
Output method.
Abstract base class for equation clasess.
Declaration of class which handles the ordering of degrees of freedom (dof) and mappings between loca...
TYPEDEF_ERR_INFO(EI_KeyName, const string)
virtual void initialize()
Definition: equation.hh:89
Abstract linear system class.
Definition: balance.hh:40
ReactionTerm & output_stream(std::shared_ptr< OutputTime > ostream)
Sets the output stream which is given from transport class.
SubstanceList substances_
Names belonging to substances.
Definition: mesh.h:77
Cell accessor allow iterate over DOF handler cells.
std::shared_ptr< OutputTime > output_stream_
Pointer to a transport output stream.
std::vector< std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > > FieldFEScalarVec
Accessor to the data with type Type::Record.
Definition: accessors.hh:291
The class for outputting data during time.
Definition: output_time.hh:51
Class for declaration of polymorphic Record.
ReactionTerm & concentration_fields(FieldFEScalarVec &conc_mobile)
FieldFEScalarVec conc_mobile_fe
FieldFEs representing P0 interpolation of mobile concentration (passed from transport).
Classes for storing substance data.
std::shared_ptr< DOFHandlerMultiDim > dof_handler_
Pointer to DOF handler used through the reaction tree.
DECLARE_INPUT_EXCEPTION(ExcInputMessage,<< EI_Message::val)
Simple input exception that accepts just string message.
ReactionTerm & substances(SubstanceList &substances)
Sets the names of substances considered in transport.