Flow123d
reaction.hh
Go to the documentation of this file.
1 /** @brief class Linear_reaction is used to enable simulation of simple chemical reactions
2  *
3  * Class in this file makes it possible to realize simulation of reaction of the first order by simple matrix multiplication.
4  * One step of the linear reaction is represented as a product of a matrix containing concentrations of observed speciesin elements in rows multiplied by so called
5  * reaction_matrix. Through this way radioactive decay can bee also realized and that was exactly what we did at the begining of journey. :-)
6  * Matrix containing concentrations has a dimension Nxn, where N is a number of elements in mesh and n denotes a number of transported chemical species.
7  * The reaction_matrix is a square matrix and it has a dimension nxn.
8  *
9  */
10 #ifndef REACT
11 #define REACT
12 
13 #include "coupling/equation.hh"
14 
15 class Mesh;
16 class Element;
17 class Distribution;
18 class OutputTime;
19 
20 
22 {
23 public:
24 
25  /**
26  * Static variable for definition of common input record in reaction term.
27  */
29 
30  /// Specification of the output record.
31  /**
32  * Need not to be used by all reaction models, but they should
33  * allow output of similar fields.
34  */
36 
37  /// Constructor.
38  /** @param init_mesh is the reference to the computational mesh
39  * @param in_rec is the input record
40  */
41  ReactionTerm(Mesh &init_mesh, Input::Record in_rec);
42 
43  /// Destructor.
44  ~ReactionTerm(void);
45 
46 
47  ///@name Setters
48  //@{
49  ///Sets the names of substances considered in transport.
51  {names_=names; return *this;}
52 
53  ///Sets the output stream which is given from transport class.
55  {output_stream_=&ostream; return *this;}
56 
57  /**
58  * Sets the pointer to concentration matrix for the mobile zone,
59  * all substances and on all elements (given by transport).
60  */
61  ReactionTerm &concentration_matrix(double **concentration, Distribution *conc_distr,
62  int *el_4_loc, int *row_4_el)
63  {
64  concentration_matrix_ = concentration;
65  distribution = conc_distr;
66  this->el_4_loc = el_4_loc;
67  this->row_4_el = row_4_el;
68  return *this;
69  }
70  //@}
71 
72  /** @brief Output method.
73  *
74  * Some reaction models have their own data to output (sorption, dual porosity) - this is where it must be solved.
75  * On the other hand, some do not have (linear reaction, pade approximant) - that is why it is not pure virtual.
76  */
77  virtual void output_data(void){};
78 
79  /// Disable changes in TimeGovernor by empty method.
80  void choose_next_time(void) override;
81 
82 protected:
83  /**
84  * Communicate parallel concentration vectors into sequential output vector.
85  */
86  virtual void output_vector_gather(void){};
87 
88  /**
89  * Computation of reaction term on a single element.
90  * Inputs should be loc_el and local copies of concentrations of the element, which is then returned.
91  */
92  virtual double **compute_reaction(double **concentrations, int loc_el);
93 
94  /** Initialize data from record in input file.
95  * It is intended to use in ascendants.
96  */
97  virtual void init_from_input(Input::Record in_rec) {};
98 
99  /**
100  * Pointer to two-dimensional array[species][elements] containing concentrations.
101  */
102  double **concentration_matrix_;
103 
104  /// Indices of elements belonging to local dofs.
105  int *el_4_loc;
106  /// Indices of rows belonging to elements.
107  int *row_4_el;
108 
109  /// Pointer to reference to distribution of elements between processors.
111 
112  /// Names belonging to substances.
113  /**
114  * Must be same as in the transport.
115  */
117 
118  /// Pointer to a transport output stream.
120 
121 };
122 
123 #endif // REACT