Flow123d  release_2.2.0-36-g163dc99
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  */
47 
48  /// Constructor.
49  /** @param init_mesh is the reference to the computational mesh
50  * @param in_rec is the input record
51  */
52  ReactionTerm(Mesh &init_mesh, Input::Record in_rec);
53 
54  /// Destructor.
55  ~ReactionTerm(void);
56 
57 
58  ///@name Setters
59  //@{
60  ///Sets the names of substances considered in transport.
62  {substances_.initialize(substances); return *this;}
63 
64  ///Sets the output stream which is given from transport class.
65  ReactionTerm &output_stream(std::shared_ptr<OutputTime> ostream)
66  {output_stream_=ostream; return *this;}
67 
68  /// Computes a constraint for time step.
69  virtual bool evaluate_time_constraint(double &time_constraint) = 0;
70 
71  /**
72  * Sets the pointer to concentration matrix for the mobile zone,
73  * all substances and on all elements (given by transport).
74  */
75  ReactionTerm &concentration_matrix(double **concentration, Distribution *conc_distr,
76  int *el_4_loc, int *row_4_el)
77  {
78  concentration_matrix_ = concentration;
79  distribution_ = conc_distr;
80  el_4_loc_ = el_4_loc;
81  row_4_el_ = row_4_el;
82  return *this;
83  }
84  //@}
85 
86  /** @brief Output method.
87  *
88  * Some reaction models have their own data to output (sorption, dual porosity)
89  * - this is where it must be reimplemented.
90  * On the other hand, some do not have (linear reaction, pade approximant)
91  * - that is why it is not pure virtual.
92  */
93  virtual void output_data(void) override {};
94 
95  /// Disable changes in TimeGovernor by empty method.
96  void choose_next_time(void) override;
97 
98 protected:
99  /**
100  * Communicate parallel concentration vectors into sequential output vector.
101  */
102  virtual void output_vector_gather(void){};
103 
104  /**
105  * Computation of reaction term on a single element.
106  * Inputs should be loc_el and local copies of concentrations of the element, which is then returned.
107  */
108  virtual double **compute_reaction(double **concentrations, int loc_el) =0;
109 
110  /**
111  * Pointer to two-dimensional array[species][elements] containing concentrations.
112  */
114 
115  /// Indices of elements belonging to local dofs.
116  int *el_4_loc_;
117  /// Indices of rows belonging to elements.
118  int *row_4_el_;
119 
120  /// Pointer to reference to distribution of elements between processors.
122 
123  /// Names belonging to substances.
124  /**
125  * Must be same as in the transport.
126  */
128 
129  /// Pointer to a transport output stream.
130  std::shared_ptr<OutputTime> output_stream_;
131 
132 };
133 
134 #endif // REACTION_TERM_H
virtual void output_data(void) override
Output method.
Abstract base class for equation clasess.
double ** concentration_matrix_
virtual void output_vector_gather(void)
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:97
int * row_4_el_
Indices of rows belonging to elements.
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
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.
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)
virtual bool evaluate_time_constraint(double &time_constraint)=0
Computes a constraint for time step.
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.