Flow123d  jenkins-Flow123d-windows32-release-multijob-51
sorption_base.hh
Go to the documentation of this file.
1 /** @brief Class SorptionBase is abstract class representing model of sorption in transport.
2  *
3  * The sorption is described by several types of isotherms - linear, Freundlich or Langmuir.
4  * Limited solubility can be considered.
5  *
6  * Interpolation tables are used to speed up evaluation of isotherms.
7  *
8  *
9  */
10 #ifndef SORPTION_BASE_H
11 #define SORPTION_BASE_H
12 
13 #include <vector>
14 
16 #include "fields/field_set.hh"
17 #include "reaction/reaction.hh"
18 
19 class Isotherm;
20 class Mesh;
21 class Distribution;
22 
24 {
25 public:
26  /**
27  * Static variable for new input data types input
28  */
30 
31  struct SorptionRecord {
32  typedef enum { simple, ///< Only sorption model is considered in transport.
33  mobile, ///< Sorption model in mobile zone of dual porosity model is considered.
34  immobile ///< Sorption model in immobile zone of dual porosity model is considered.
35  } Type;
36  };
37 
38  /// Creates the input record for different cases of sorption model (simple or in dual porosity).
40 
41  static Input::Type::Selection make_output_selection(const string &output_field_name, const string &selection_name)
42  {
43  return EqData(output_field_name).output_fields.make_output_field_selection(selection_name)
44  .close();
45  }
46 
47  class EqData : public FieldSet
48  {
49  public:
50  /**
51  * Sorption type specifies a kind of equilibrial description of adsorption.
52  */
54 
55  /// Collect all fields
56  EqData(const string &output_field_name);
57 
58  Field<3, FieldValue<3>::EnumVector > sorption_type; ///< Discrete need Selection for initialization.
59  Field<3, FieldValue<3>::Scalar > rock_density; ///< Rock matrix density.
60 
61  /// Multiplication coefficients (k, omega) for all types of isotherms.
62  /** Langmuir: c_s = omega * (alpha*c_a)/(1- alpha*c_a), Linear: c_s = k*c_a */
64  /// Langmuir sorption coeficients alpha (in fraction c_s = omega * (alpha*c_a)/(1- alpha*c_a)).
66 
67  Field<3, FieldValue<3>::Vector> init_conc_solid; ///< Initial sorbed concentrations.
68  Field<3, FieldValue<3>::Scalar > porosity; ///< Porosity field copied from transport.
69 
70  MultiField<3, FieldValue<3>::Scalar> conc_solid; ///< Calculated sorbed concentrations, for output only.
71 
72  /// Input data set - fields in this set are read from the input file.
74 
75  /// Fields indended for output, i.e. all input fields plus those representing solution.
77 
78  };
79 
80  /**
81  * Constructor with parameter for initialization of a new declared class member
82  */
83  SorptionBase(Mesh &init_mesh, Input::Record in_rec);
84  /**
85  * Destructor.
86  */
87  virtual ~SorptionBase(void);
88 
89  /// Prepares the object to usage.
90  /**
91  * Allocating memory, reading input, initialization of fields.
92  */
93  void initialize() override;
94 
95  /**
96  * Does first computation after initialization process.
97  * The time is set and initial condition is set and output.
98  */
99  void zero_time_step() override;
100 
101  /// Updates the solution.
102  /**
103  * Goes through local distribution of elements and calls @p compute_reaction.
104  */
105  void update_solution(void) override;
106 
107  void output_data(void) override;
108 
109 
110 protected:
111  /**
112  * This method disables to use constructor without parameters.
113  */
114  SorptionBase();
115 
116  /** Initializes possible following reactions from input record.
117  * It should be called after setting mesh, time_governor, distribution and concentration_matrix
118  * if there are some setting methods for reactions called (they are not at the moment, so it could be part of init_from_input).
119  */
120  void make_reactions();
121 
122  /// Reads names of substances from input and creates indexing to global vector of substance,
124 
125  /// Initializes private members of sorption from the input record.
126  void initialize_from_input();
127 
128  /// Initializes field sets.
129  void initialize_fields();
130 
131  ///Reads and sets initial condition for concentration in solid.
132  void set_initial_condition();
133 
134  /// Allocates petsc vectors, prepares them for output and creates vector scatter.
135  void allocate_output_mpi(void);
136 
137  /// Gathers all the parallel vectors to enable them to be output.
138  void output_vector_gather(void) override;
139 
140  /**
141  * For simulation of sorption in just one element either inside of MOBILE or IMMOBILE pores.
142  */
143  double **compute_reaction(double **concentrations, int loc_el);
144 
145  /// Reinitializes the isotherm.
146  /**
147  * On data change the isotherm is recomputed, possibly new interpolation table is made.
148  * Pure virtual method.
149  */
150  virtual void isotherm_reinit(std::vector<Isotherm> &isotherms, const ElementAccessor<3> &elm) = 0;
151 
152  /**
153  * Creates interpolation table for isotherms.
154  */
155  void make_tables(void);
156 
157 
158  /// Pointer to equation data. The object is constructed in descendants.
160 
161  /**
162  * Temporary nr_of_points can be computed using step_length. Should be |nr_of_region x nr_of_substances| matrix later.
163  */
165  /**
166  * Molar masses of dissolved species (substances)
167  */
169  /**
170  * Density of the solvent.
171  * TODO: Could be done region dependent, easily.
172  */
174  /**
175  * Critical concentrations of species dissolved in water.
176  */
178  /**
179  * Concentration table limits of species dissolved in water.
180  */
182  /**
183  * Three dimensional array contains intersections between isotherms and mass balance lines.
184  * It describes behaviour of sorbents in mobile pores of various rock matrix enviroments.
185  * Up to |nr_of_region x nr_of_substances x n_points| doubles. Because of equidistant step
186  * lenght in cocidered system of coordinates, just function values are stored.
187  */
189 
190  unsigned int n_substances_; //< number of substances that take part in the sorption mode
191 
192  /// Mapping from local indexing of substances to global.
194 
195  /**
196  * Array for storage infos about sorbed species concentrations.
197  */
198  double** conc_solid;
199 
201 
203 
204  /** Reaction model that follows the sorption.
205  */
208 
209  ///@name members used in output routines
210  //@{
211  VecScatter vconc_out_scatter; ///< Output vector scatter.
212  Vec *vconc_solid; ///< PETSC sorbed concentration vector (parallel).
213  Vec *vconc_solid_out; ///< PETSC sorbed concentration vector output (gathered - sequential)
214  double **conc_solid_out; ///< sorbed concentration array output (gathered - sequential)
215  //@}
216 };
217 
218 #endif //SORPTION_BASE_H
void allocate_output_mpi(void)
Allocates petsc vectors, prepares them for output and creates vector scatter.
Container for various descendants of FieldCommonBase.
Definition: field_set.hh:51
MultiField< 3, FieldValue< 3 >::Scalar > conc_solid
Calculated sorbed concentrations, for output only.
void make_reactions()
Accessor to input data conforming to declared Array.
Definition: accessors.hh:521
Sorption model in immobile zone of dual porosity model is considered.
double solvent_density_
ReactionTerm * reaction_liquid
std::vector< std::vector< Isotherm > > isotherms
virtual ~SorptionBase(void)
void initialize_substance_ids()
Reads names of substances from input and creates indexing to global vector of substance,.
Field< 3, FieldValue< 3 >::EnumVector > sorption_type
Discrete need Selection for initialization.
EqData(const string &output_field_name)
Collect all fields.
Field< 3, FieldValue< 3 >::Vector > isotherm_other
Langmuir sorption coeficients alpha (in fraction c_s = omega * (alpha*c_a)/(1- alpha*c_a)).
Class template representing a field with values dependent on: point, element, and region...
Definition: field.hh:48
Input::Type::Selection output_selection
Vec * vconc_solid_out
PETSC sorbed concentration vector output (gathered - sequential)
double ** compute_reaction(double **concentrations, int loc_el)
void zero_time_step() override
static Input::Type::Record input_type
Field< 3, FieldValue< 3 >::Scalar > rock_density
Rock matrix density.
Definition: mesh.h:108
std::vector< double > molar_masses_
static Input::Type::Selection sorption_type_selection
Field< 3, FieldValue< 3 >::Vector > init_conc_solid
Initial sorbed concentrations.
std::vector< double > table_limit_
Field< 3, FieldValue< 3 >::Vector > isotherm_mult
Multiplication coefficients (k, omega) for all types of isotherms.
std::vector< unsigned int > substance_global_idx_
Mapping from local indexing of substances to global.
void initialize_fields()
Initializes field sets.
void output_data(void) override
Output method.
Field< 3, FieldValue< 3 >::Scalar > porosity
Porosity field copied from transport.
Vec * vconc_solid
PETSC sorbed concentration vector (parallel).
FieldSet output_fields
Fields indended for output, i.e. all input fields plus those representing solution.
void initialize_from_input()
Initializes private members of sorption from the input record.
std::vector< double > solubility_vec_
Accessor to the data with type Type::Record.
Definition: accessors.hh:308
unsigned int n_interpolation_steps_
void make_tables(void)
virtual void isotherm_reinit(std::vector< Isotherm > &isotherms, const ElementAccessor< 3 > &elm)=0
Reinitializes the isotherm.
ReactionTerm * reaction_solid
static Input::Type::Record record_factory(SorptionRecord::Type)
Creates the input record for different cases of sorption model (simple or in dual porosity)...
double ** conc_solid_out
sorbed concentration array output (gathered - sequential)
void output_vector_gather(void) override
Gathers all the parallel vectors to enable them to be output.
static Input::Type::Selection make_output_selection(const string &output_field_name, const string &selection_name)
Input::Array output_array
void update_solution(void) override
Updates the solution.
const Selection & close() const
void set_initial_condition()
Reads and sets initial condition for concentration in solid.
Input::Type::Selection make_output_field_selection(const string &name, const string &desc="")
Definition: field_set.cc:69
double ** conc_solid
Sorption model in mobile zone of dual porosity model is considered.
Record type proxy class.
Definition: type_record.hh:161
VecScatter vconc_out_scatter
Output vector scatter.
Class for representation of a vector of fields of the same physical quantity.
Definition: field.hh:309
unsigned int n_substances_
EqData * data_
Pointer to equation data. The object is constructed in descendants.
Template for classes storing finite set of named values.
Only sorption model is considered in transport.
FieldSet input_data_set_
Input data set - fields in this set are read from the input file.
void initialize() override
Prepares the object to usage.