Flow123d
sorption_base.hh
Go to the documentation of this file.
1 /** @brief class Sorption is used to enable simulation of sorption described by either linear or Langmuir isotherm in combination with limited solubility under consideration.
2  *
3  * Class in this file makes it possible to handle the dataset describing solid phase as either precipitated or sorbed species.
4  *
5  *
6  *
7  *
8  */
9 #ifndef SORPTION_BASE
10 #define SORPTION_BASE
11 
12 #include <vector>
13 
14 #include "fields/field_base.hh"
15 #include "fields/field_set.hh"
16 #include "reaction/reaction.hh"
17 
18 class Isotherm;
19 class Mesh;
20 class Distribution;
21 
23 {
24 public:
25  /**
26  * Static variable for new input data types input
27  */
29 
30  class EqData : public FieldSet // should be written in class Sorption
31  {
32  public:
33  /**
34  * Sorption type specifies a kind of equilibrial description of adsorption.
35  */
37 
38  /// Collect all fields
39  EqData(const string &output_field_name);
40 
41  Field<3, FieldValue<3>::EnumVector > sorption_type; ///< Discrete need Selection for initialization.
42  Field<3, FieldValue<3>::Scalar > rock_density; ///< Rock matrix density.
43  Field<3, FieldValue<3>::Vector > isotherm_mult; ///< Multiplication coefficients (k, omega) for all types of isotherms. Langmuir: c_s = omega * (alpha*c_a)/(1- alpha*c_a), Linear: c_s = k*c_a
44  Field<3, FieldValue<3>::Vector > isotherm_other; ///< Langmuir sorption coeficients alpha (in fraction c_s = omega * (alpha*c_a)/(1- alpha*c_a)).
45  Field<3, FieldValue<3>::Vector> init_conc_solid; ///< Initial sorbed concentrations.
46 
47  Field<3, FieldValue<3>::Scalar > porosity; ///< Porosity field copied from transport
48 
49  MultiField<3, FieldValue<3>::Scalar> conc_solid; ///< Calculated sorbed concentrations, for output only.
50 
51 
52  /// Input data set - fields in this set are read from the input file.
54 
55  /// Fields indended for output, i.e. all input fields plus those representing solution.
57 
58  };
59 
60  /**
61  * Constructor with parameter for initialization of a new declared class member
62  */
63  SorptionBase(Mesh &init_mesh, Input::Record in_rec);
64  /**
65  * Destructor.
66  */
67  virtual ~SorptionBase(void);
68 
69  void zero_time_step() override;
70 
71  /**
72  * Prepared to compute sorption inside all of considered elements.
73  * It calls compute_reaction(...) for all the elements controled by concrete processor, when the computation is paralelized.
74  */
75  virtual void update_solution(void);
76 
77  static Input::Type::Selection make_output_selection(const string &output_field_name, const string &selection_name)
78  {
79  return EqData(output_field_name).output_fields.make_output_field_selection(selection_name)
80  .close();
81  }
82 
83  /**
84  * Initialization routines that are done in constructors of descendants.
85  * Method data() which access EqData is pure virtual and cannot be called from the base constructor.
86  */
87  //void data_initialization(void);
88  /**
89  * Sets porosity field - makes a field copy from transport.
90  */
91  void set_porosity(Field<3, FieldValue<3>::Scalar > &por_m);
92 
93  /**
94  * Creates interpolation table for isotherms.
95  */
96  void make_tables(void);
97 
98  void output_data(void) override;
99  void output_vector_gather(void) override;
100 
101  /**
102  * Meaningless inherited method.
103  */
104  //void set_concentration_vector(Vec &vec) override;
105 
106 protected:
107  /**
108  * This method disables to use constructor without parameters.
109  */
110  SorptionBase();
111 
113 
114  /// Initializes private members of sorption from the input record.
115  void init_from_input(Input::Record in_rec) override;
116 
117  /** Initializes possible following reactions from input record.
118  * It should be called after setting mesh, time_governor, distribution and concentration_matrix
119  * if there are some setting methods for reactions called (they are not at the moment, so it could be part of init_from_input).
120  */
122 
123  /**
124  * For simulation of sorption in just one element either inside of MOBILE or IMMOBILE pores.
125  */
126  double **compute_reaction(double **concentrations, int loc_el);
127  /**
128  *
129  */
130  virtual void isotherm_reinit(std::vector<Isotherm> &isotherms, const ElementAccessor<3> &elm) = 0;
131 
132  /**
133  * or printing parameters of isotherms under consideration, not necessary to store
134  */
135  void print_sorption_parameters(void);
136 
137  void allocate_output_mpi(void);
138 
139 
140 
142 
143  /**
144  * Number of regions.
145  */
147  /**
148  * Temporary nr_of_points can be computed using step_length. Should be |nr_of_region x nr_of_substances| matrix later.
149  */
151  /**
152  * Molar masses of dissolved species (substances)
153  */
155  /**
156  * Density of the solvent.
157  * TODO: Could be done region dependent, easily.
158  */
160  /**
161  * Critical concentrations of species dissolved in water.
162  */
164  /**
165  * Concentration table limits of species dissolved in water.
166  */
168  /**
169  * Three dimensional array contains intersections between isotherms and mass balance lines.
170  * It describes behaviour of sorbents in mobile pores of various rock matrix enviroments.
171  * Up to |nr_of_region x nr_of_substances x n_points| doubles. Because of equidistant step
172  * lenght in cocidered system of coordinates, just function values are stored.
173  */
175 
176  unsigned int n_substances_; //< number of substances that take part in the sorption mode
177 
178  /// Mapping from local indexing of substances to global.
180 
181  /**
182  * Array for storage infos about sorbed species concentrations.
183  */
184  double** conc_solid;
185 
187 
189 
190  /** Reaction model that follows the sorption.
191  */
193 
194  ///@name members used in output routines
195  //@{
196  Vec *vconc_solid; ///< PETSC sorbed concentration vector (parallel).
197  Vec *vconc_solid_out; ///< PETSC sorbed concentration vector output (gathered - sequential)
198  double **conc_solid_out; ///< sorbed concentration array output (gathered - sequential)
199  //@}
200 };
201 
202 #endif