Flow123d  last_with_con_2.0.0-4-g42e6930
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  /// Computes a constraint for time step.
66  virtual bool evaluate_time_constraint(double &time_constraint) = 0;
67 
68  /**
69  * Sets the pointer to concentration matrix for the mobile zone,
70  * all substances and on all elements (given by transport).
71  */
72  ReactionTerm &concentration_matrix(double **concentration, Distribution *conc_distr,
73  int *el_4_loc, int *row_4_el)
74  {
75  concentration_matrix_ = concentration;
76  distribution_ = conc_distr;
77  el_4_loc_ = el_4_loc;
78  row_4_el_ = row_4_el;
79  return *this;
80  }
81  //@}
82 
83  /** @brief Output method.
84  *
85  * Some reaction models have their own data to output (sorption, dual porosity)
86  * - this is where it must be reimplemented.
87  * On the other hand, some do not have (linear reaction, pade approximant)
88  * - that is why it is not pure virtual.
89  */
90  virtual void output_data(void){};
91 
92  /// Disable changes in TimeGovernor by empty method.
93  void choose_next_time(void) override;
94 
95 protected:
96  /**
97  * Communicate parallel concentration vectors into sequential output vector.
98  */
99  virtual void output_vector_gather(void){};
100 
101  /**
102  * Computation of reaction term on a single element.
103  * Inputs should be loc_el and local copies of concentrations of the element, which is then returned.
104  */
105  virtual double **compute_reaction(double **concentrations, int loc_el) =0;
106 
107  /**
108  * Pointer to two-dimensional array[species][elements] containing concentrations.
109  */
111 
112  /// Indices of elements belonging to local dofs.
113  int *el_4_loc_;
114  /// Indices of rows belonging to elements.
115  int *row_4_el_;
116 
117  /// Pointer to reference to distribution of elements between processors.
119 
120  /// Names belonging to substances.
121  /**
122  * Must be same as in the transport.
123  */
125 
126  /// Pointer to a transport output stream.
127  std::shared_ptr<OutputTime> output_stream_;
128 
129 };
130 
131 #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:95
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:48
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)
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.