Flow123d  release_1.8.2-1603-g0109a2b
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 "coupling/equation.hh"
25 #include "transport/substance.hh"
26 
27 class Mesh;
28 class Distribution;
29 class OutputTime;
30 
31 
33 {
34 public:
35  TYPEDEF_ERR_INFO( EI_Substance, std::string);
36  TYPEDEF_ERR_INFO( EI_Model, std::string);
37  DECLARE_INPUT_EXCEPTION( ExcUnknownSubstance, << "Unknown substance name: " << EI_Substance::qval);
38  DECLARE_INPUT_EXCEPTION( ExcWrongDescendantModel, << "Impossible descendant model: " << EI_Model::qval);
39 
40  /**
41  * Static variable for definition of common input record in reaction term.
42  */
44 
45  /// Constructor.
46  /** @param init_mesh is the reference to the computational mesh
47  * @param in_rec is the input record
48  */
49  ReactionTerm(Mesh &init_mesh, Input::Record in_rec);
50 
51  /// Destructor.
52  ~ReactionTerm(void);
53 
54 
55  ///@name Setters
56  //@{
57  ///Sets the names of substances considered in transport.
59  {substances_.initialize(substances); return *this;}
60 
61  ///Sets the output stream which is given from transport class.
62  ReactionTerm &output_stream(std::shared_ptr<OutputTime> ostream)
63  {output_stream_=ostream; return *this;}
64 
65  /**
66  * Sets the pointer to concentration matrix for the mobile zone,
67  * all substances and on all elements (given by transport).
68  */
69  ReactionTerm &concentration_matrix(double **concentration, Distribution *conc_distr,
70  int *el_4_loc, int *row_4_el)
71  {
72  concentration_matrix_ = concentration;
73  distribution_ = conc_distr;
74  el_4_loc_ = el_4_loc;
75  row_4_el_ = row_4_el;
76  return *this;
77  }
78  //@}
79 
80  /** @brief Output method.
81  *
82  * Some reaction models have their own data to output (sorption, dual porosity)
83  * - this is where it must be reimplemented.
84  * On the other hand, some do not have (linear reaction, pade approximant)
85  * - that is why it is not pure virtual.
86  */
87  virtual void output_data(void){};
88 
89  /// Disable changes in TimeGovernor by empty method.
90  void choose_next_time(void) override;
91 
92 protected:
93  /**
94  * Communicate parallel concentration vectors into sequential output vector.
95  */
96  virtual void output_vector_gather(void){};
97 
98  /**
99  * Computation of reaction term on a single element.
100  * Inputs should be loc_el and local copies of concentrations of the element, which is then returned.
101  */
102  virtual double **compute_reaction(double **concentrations, int loc_el) =0;
103 
104  /**
105  * Pointer to two-dimensional array[species][elements] containing concentrations.
106  */
108 
109  /// Indices of elements belonging to local dofs.
110  int *el_4_loc_;
111  /// Indices of rows belonging to elements.
112  int *row_4_el_;
113 
114  /// Pointer to reference to distribution of elements between processors.
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 };
127 
128 #endif // REACTION_TERM_H
Abstract base class for equation clasess.
virtual void output_data(void)
Output method.
double ** concentration_matrix_
virtual void output_vector_gather(void)
static Input::Type::Abstract & get_input_type()
ReactionTerm & output_stream(std::shared_ptr< OutputTime > ostream)
Sets the output stream which is given from transport class.
SubstanceList substances_
Names belonging to substances.
void initialize(const Input::Array &in_array)
Read from input array.
Definition: substance.cc:58
Definition: mesh.h:99
int * row_4_el_
Indices of rows belonging to elements.
std::shared_ptr< OutputTime > output_stream_
Pointer to a transport output stream.
ReactionTerm(Mesh &init_mesh, Input::Record in_rec)
Constructor.
Distribution * distribution_
Pointer to reference to distribution of elements between processors.
Accessor to the data with type Type::Record.
Definition: accessors.hh:277
The class for outputting data during time.
Definition: output_time.hh:42
virtual double ** compute_reaction(double **concentrations, int loc_el)=0
DECLARE_INPUT_EXCEPTION(ExcUnknownSubstance,<< "Unknown substance name: "<< EI_Substance::qval)
Class for declaration of polymorphic Record.
void choose_next_time(void) override
Disable changes in TimeGovernor by empty method.
int * el_4_loc_
Indices of elements belonging to local dofs.
~ReactionTerm(void)
Destructor.
Classes for storing substance data.
TYPEDEF_ERR_INFO(EI_Substance, std::string)
ReactionTerm & concentration_matrix(double **concentration, Distribution *conc_distr, int *el_4_loc, int *row_4_el)
ReactionTerm & substances(SubstanceList &substances)
Sets the names of substances considered in transport.