Flow123d  release_3.0.0-680-gbed5aba
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 
32 class Distribution;
33 class Mesh;
34 class OutputTime;
35 namespace Input {
36  class Record;
37  namespace Type {
38  class Abstract;
39  }
40 }
41 
42 
44 {
45 public:
46  TYPEDEF_ERR_INFO( EI_Substance, std::string);
47  TYPEDEF_ERR_INFO( EI_Model, std::string);
48  DECLARE_INPUT_EXCEPTION( ExcUnknownSubstance, << "Unknown substance name: " << EI_Substance::qval);
49  DECLARE_INPUT_EXCEPTION( ExcWrongDescendantModel, << "Impossible descendant model: " << EI_Model::qval);
50 
51  /**
52  * Static variable for definition of common input record in reaction term.
53  */
54  static Input::Type::Abstract & it_abstract_term();
55  static Input::Type::Abstract & it_abstract_mobile_term();
56  static Input::Type::Abstract & it_abstract_immobile_term();
57  static Input::Type::Abstract & it_abstract_reaction();
58 
59  /// Constructor.
60  /** @param init_mesh is the reference to the computational mesh
61  * @param in_rec is the input record
62  */
63  ReactionTerm(Mesh &init_mesh, Input::Record in_rec);
64 
65  /// Destructor.
66  ~ReactionTerm(void);
67 
68 
69  ///@name Setters
70  //@{
71  ///Sets the names of substances considered in transport.
73  {substances_.initialize(substances); return *this;}
74 
75  ///Sets the output stream which is given from transport class.
76  ReactionTerm &output_stream(std::shared_ptr<OutputTime> ostream)
77  {output_stream_=ostream; return *this;}
78 
79  /// Computes a constraint for time step.
80  virtual bool evaluate_time_constraint(double &time_constraint) = 0;
81 
82  /**
83  * Sets the pointer to concentration matrix for the mobile zone,
84  * all substances and on all elements (given by transport).
85  */
86  ReactionTerm &concentration_matrix(double **concentration, Distribution *conc_distr,
87  LongIdx *el_4_loc, LongIdx *row_4_el)
88  {
89  concentration_matrix_ = concentration;
90  distribution_ = conc_distr;
91  el_4_loc_ = el_4_loc;
92  row_4_el_ = row_4_el;
93  return *this;
94  }
95  //@}
96 
97  /** @brief Output method.
98  *
99  * Some reaction models have their own data to output (sorption, dual porosity)
100  * - this is where it must be reimplemented.
101  * On the other hand, some do not have (linear reaction, pade approximant)
102  * - that is why it is not pure virtual.
103  */
104  virtual void output_data(void) override {};
105 
106  /// Disable changes in TimeGovernor by empty method.
107  void choose_next_time(void) override;
108 
109 protected:
110  /**
111  * Communicate parallel concentration vectors into sequential output vector.
112  */
113  virtual void output_vector_gather(void){};
114 
115  /**
116  * Computation of reaction term on a single element.
117  * Inputs should be loc_el and local copies of concentrations of the element, which is then returned.
118  */
119  virtual double **compute_reaction(double **concentrations, int loc_el) =0;
120 
121  /**
122  * Pointer to two-dimensional array[species][elements] containing concentrations.
123  */
125 
126  /// Indices of elements belonging to local dofs.
128  /// Indices of rows belonging to elements.
130 
131  /// Pointer to reference to distribution of elements between processors.
133 
134  /// Names belonging to substances.
135  /**
136  * Must be same as in the transport.
137  */
139 
140  /// Pointer to a transport output stream.
141  std::shared_ptr<OutputTime> output_stream_;
142 
143 };
144 
145 #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.
double ** concentration_matrix_
TYPEDEF_ERR_INFO(EI_KeyName, const string)
virtual void initialize()
Definition: equation.hh:88
virtual void output_vector_gather(void)
Abstract linear system class.
Definition: balance.hh:35
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:80
std::shared_ptr< OutputTime > output_stream_
Pointer to a transport output stream.
Distribution * distribution_
Pointer to reference to distribution of elements between processors.
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.
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.