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