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 reactions.
27  */
29 
30  /**
31  * Specification of the output record. Need not to be used by all reaction models, but they should
32  * allow output of similar fields.
33  */
35 
36  /**
37  * Constructor with parameter for initialization of a new declared class member
38  * TODO: parameter description
39  */
40  ReactionTerm(Mesh &init_mesh, Input::Record in_rec);
41  /**
42  * Destructor.
43  */
44  ~ReactionTerm(void);
45 
46 
47 
48  ///@name Setters
49  //@{
51  {names_=names; return *this;}
52 
54  {output_stream_=&ostream; return *this;}
55 
56  /**
57  * Sets the concentration matrix for the mobile zone, all substances and on all elements.
58  */
59  ReactionTerm &concentration_matrix(double **concentration, Distribution *conc_distr, int *el_4_loc, int *row_4_el)
60  {
61  concentration_matrix_ = concentration;
62  distribution = conc_distr;
63  this->el_4_loc = el_4_loc;
64  this->row_4_el = row_4_el;
65  return *this;
66  }
67  //@}
68 
69  /** Output method.
70  * Some reaction models have their own data to output (sorption, dual porosity) - this is where it must be solved.
71  * On the other hand, some do not have (linear reaction, pade approximant) - that is why it is not pure virtual.
72  */
73  virtual void output_data(void){};
74 
75 
76  /// @name Inherited and not used.
77  /// TODO: make default empty implementation in EquationBase
78  //@{
79 
80  virtual void choose_next_time(void);
81  virtual void get_parallel_solution_vector(Vec &vc);
82  virtual void get_solution_vector(double* &vector, unsigned int &size);
83  //@}
84 
85 protected:
86  /**
87  * Communicate parallel concentration vectors into sequential output vector.
88  */
89  virtual void output_vector_gather(void){};
90 
91  /**
92  * For simulation of chemical reaction in one element only.
93  * Inputs should be loc_el and local copies of concentrations of the element, which is then returned.
94  */
95  virtual double **compute_reaction(double **concentrations, int loc_el);
96 
97  /** Initialize data from record in input file.
98  * It is intended to use in ascendants.
99  */
100  virtual void init_from_input(Input::Record in_rec) {};
101 
102  /**
103  * Pointer to two-dimensional array[species][elements] containing mobile concentrations.
104  */
105  double **concentration_matrix_;
106 
107  /**
108  * Indices of elements belonging to local dofs.
109  */
110  int *el_4_loc;
111  /**
112  * Indices of rows belonging to elements.
113  */
114  int *row_4_el;
115 
116  /**
117  * Pointer to reference to distribution of elements between processors.
118  */
120 
121  /**
122  * Names belonging to substances. Should be same as in the transport.
123  */
125 
126  /// Mapping from local indexing of substances to global
128 
129  /// Pointer to a transport output stream.
131 
132 };
133 
134 #endif