Flow123d  release_3.0.0-1193-g9220a69
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 "mesh/long_idx.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 
33 class Distribution;
34 class Mesh;
35 class OutputTime;
36 namespace Input {
37  class Record;
38  namespace Type {
39  class Abstract;
40  }
41 }
42 
43 
45 {
46 public:
47  TYPEDEF_ERR_INFO( EI_Substance, std::string);
48  TYPEDEF_ERR_INFO( EI_Model, std::string);
49  DECLARE_INPUT_EXCEPTION( ExcUnknownSubstance, << "Unknown substance name: " << EI_Substance::qval);
50  DECLARE_INPUT_EXCEPTION( ExcWrongDescendantModel, << "Impossible descendant model: " << EI_Model::qval);
51 
52  /**
53  * Static variable for definition of common input record in reaction term.
54  */
55  static Input::Type::Abstract & it_abstract_term();
56  static Input::Type::Abstract & it_abstract_mobile_term();
57  static Input::Type::Abstract & it_abstract_immobile_term();
58  static Input::Type::Abstract & it_abstract_reaction();
59 
60  /// Constructor.
61  /** @param init_mesh is the reference to the computational mesh
62  * @param in_rec is the input record
63  */
64  ReactionTerm(Mesh &init_mesh, Input::Record in_rec);
65 
66  /// Destructor.
67  ~ReactionTerm(void);
68 
69 
70  ///@name Setters
71  //@{
72  ///Sets the names of substances considered in transport.
74  {substances_.initialize(substances); return *this;}
75 
76  ///Sets the output stream which is given from transport class.
77  ReactionTerm &output_stream(std::shared_ptr<OutputTime> ostream)
78  {output_stream_=ostream; return *this;}
79 
80  /// Computes a constraint for time step.
81  virtual bool evaluate_time_constraint(double &time_constraint) = 0;
82 
83  /**
84  * Sets the pointer to concentration matrix for the mobile zone,
85  * all substances and on all elements (given by transport).
86  */
87  ReactionTerm &concentration_matrix(double **concentration, Distribution *conc_distr,
88  LongIdx *el_4_loc, LongIdx *row_4_el)
89  {
90  concentration_matrix_ = concentration;
91  distribution_ = conc_distr;
92  el_4_loc_ = el_4_loc;
93  row_4_el_ = row_4_el;
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  /// Sets the pointer to DOF handler (shared through the reaction tree)
111  ReactionTerm &set_dh(std::shared_ptr<DOFHandlerMultiDim> dof_handler)
112  {
113  dof_handler_ = dof_handler;
114  return *this;
115  }
116 
117 protected:
118  /**
119  * Computation of reaction term on a single element.
120  * Inputs should be loc_el and local copies of concentrations of the element, which is then returned.
121  */
122  virtual double **compute_reaction(double **concentrations, int loc_el) =0;
123 
124  /**
125  * Pointer to two-dimensional array[species][elements] containing concentrations.
126  */
128 
129  /// Indices of elements belonging to local dofs.
131  /// Indices of rows belonging to elements.
133 
134  /// Pointer to reference to distribution of elements between processors.
136 
137  /// Names belonging to substances.
138  /**
139  * Must be same as in the transport.
140  */
142 
143  /// Pointer to a transport output stream.
144  std::shared_ptr<OutputTime> output_stream_;
145 
146  /// Pointer to DOF handler used through the reaction tree
147  std::shared_ptr<DOFHandlerMultiDim> dof_handler_;
148 
149 };
150 
151 #endif // REACTION_TERM_H
int LongIdx
Define type that represents indices of large arrays (elements, nodes, dofs etc.)
Definition: long_idx.hh:22
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...
double ** concentration_matrix_
TYPEDEF_ERR_INFO(EI_KeyName, const string)
virtual void initialize()
Definition: equation.hh:88
Abstract linear system class.
Definition: balance.hh:37
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:76
std::shared_ptr< OutputTime > output_stream_
Pointer to a transport output stream.
Distribution * distribution_
Pointer to reference to distribution of elements between processors.
ReactionTerm & set_dh(std::shared_ptr< DOFHandlerMultiDim > dof_handler)
Sets the pointer to DOF handler (shared through the reaction tree)
Accessor to the data with type Type::Record.
Definition: accessors.hh:292
The class for outputting data during time.
Definition: output_time.hh:50
Class for declaration of polymorphic Record.
LongIdx * row_4_el_
Indices of rows belonging to elements.
Classes for storing substance data.
std::shared_ptr< DOFHandlerMultiDim > dof_handler_
Pointer to DOF handler used through the reaction tree.
ReactionTerm & concentration_matrix(double **concentration, Distribution *conc_distr, LongIdx *el_4_loc, LongIdx *row_4_el)
LongIdx * el_4_loc_
Indices of elements belonging to local dofs.
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.