Flow123d  jenkins-Flow123d-linux-release-multijob-282
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 "fields/multi_field.hh"
18 #include "fields/vec_seq_double.hh"
20 
21 class Isotherm;
22 class Mesh;
23 
25 {
26 public:
27  TYPEDEF_ERR_INFO( EI_ArrayName, std::string);
28  DECLARE_INPUT_EXCEPTION( ExcSubstanceCountMatch, << "The size of the input array " << EI_ArrayName::qval
29  << " does not match the number of substances.");
30 
31  /**
32  * Static variable for new input data types input
33  */
35 
36  struct SorptionRecord {
37  typedef enum { simple, ///< Only sorption model is considered in transport.
38  mobile, ///< Sorption model in mobile zone of dual porosity model is considered.
39  immobile ///< Sorption model in immobile zone of dual porosity model is considered.
40  } Type;
41  };
42 
43  /// Creates the input record for different cases of sorption model (simple or in dual porosity).
45 
46  static Input::Type::Selection make_output_selection(const string &output_field_name, const string &selection_name)
47  {
48  return EqData(output_field_name).output_fields.make_output_field_selection(selection_name)
49  .close();
50  }
51 
52  class EqData : public FieldSet
53  {
54  public:
55  /**
56  * Sorption type specifies a kind of equilibrial description of adsorption.
57  */
59 
60  /// Collect all fields
61  EqData(const string &output_field_name);
62 
63  Field<3, FieldValue<3>::EnumVector > sorption_type; ///< Discrete need Selection for initialization.
64  Field<3, FieldValue<3>::Scalar > rock_density; ///< Rock matrix density.
65 
66  /// Multiplication coefficients (k, omega) for all types of isotherms.
67  /** Langmuir: c_s = omega * (alpha*c_a)/(1- alpha*c_a), Linear: c_s = k*c_a */
69  /// Langmuir sorption coeficients alpha (in fraction c_s = omega * (alpha*c_a)/(1- alpha*c_a)).
71 
72  Field<3, FieldValue<3>::Vector> init_conc_solid; ///< Initial sorbed concentrations.
73  Field<3, FieldValue<3>::Scalar > porosity; ///< Porosity field copied from transport.
74 
75  MultiField<3, FieldValue<3>::Scalar> conc_solid; ///< Calculated sorbed concentrations, for output only.
76 
77  /// Input data set - fields in this set are read from the input file.
79 
80  /// Fields indended for output, i.e. all input fields plus those representing solution.
82 
83  };
84 
85  /**
86  * Constructor with parameter for initialization of a new declared class member
87  */
88  SorptionBase(Mesh &init_mesh, Input::Record in_rec);
89  /**
90  * Destructor.
91  */
92  virtual ~SorptionBase(void);
93 
94  /// Prepares the object to usage.
95  /**
96  * Allocating memory, reading input, initialization of fields.
97  */
98  void initialize() override;
99 
100  /**
101  * Does first computation after initialization process.
102  * The time is set and initial condition is set and output.
103  */
104  void zero_time_step() override;
105 
106  /// Updates the solution.
107  /**
108  * Goes through local distribution of elements and calls @p compute_reaction.
109  */
110  void update_solution(void) override;
111 
112  void output_data(void) override;
113 
114 
115 protected:
116  /**
117  * This method disables to use constructor without parameters.
118  */
119  SorptionBase();
120 
121  /** Initializes possible following reactions from input record.
122  * It should be called after setting mesh, time_governor, distribution and concentration_matrix
123  * if there are some setting methods for reactions called (they are not at the moment, so it could be part of init_from_input).
124  */
125  void make_reactions();
126 
127  /// Reads names of substances from input and creates indexing to global vector of substance.
128  /** Also creates the local vector of molar masses. */
130 
131  /// Initializes private members of sorption from the input record.
132  void initialize_from_input();
133 
134  /// Initializes field sets.
135  void initialize_fields();
136 
137  ///Reads and sets initial condition for concentration in solid.
138  void set_initial_condition();
139 
140  /// Allocates petsc vectors, prepares them for output and creates vector scatter.
141  void allocate_output_mpi(void);
142 
143  /// Gathers all the parallel vectors to enable them to be output.
144  void output_vector_gather(void) override;
145 
146  /**
147  * For simulation of sorption in just one element either inside of MOBILE or IMMOBILE pores.
148  */
149  double **compute_reaction(double **concentrations, int loc_el);
150 
151  /// Reinitializes the isotherm.
152  /**
153  * On data change the isotherm is recomputed, possibly new interpolation table is made.
154  * Pure virtual method.
155  */
156  virtual void isotherm_reinit(std::vector<Isotherm> &isotherms, const ElementAccessor<3> &elm) = 0;
157 
158  /**
159  * Creates interpolation table for isotherms.
160  */
161  void make_tables(void);
162 
163 
164  /// Pointer to equation data. The object is constructed in descendants.
166 
167  /**
168  * Temporary nr_of_points can be computed using step_length. Should be |nr_of_region x nr_of_substances| matrix later.
169  */
171  /**
172  * Density of the solvent.
173  * TODO: Could be done region dependent, easily.
174  */
176  /**
177  * Critical concentrations of species dissolved in water.
178  */
180  /**
181  * Concentration table limits of species dissolved in water.
182  */
184  /**
185  * Three dimensional array contains intersections between isotherms and mass balance lines.
186  * It describes behaviour of sorbents in mobile pores of various rock matrix enviroments.
187  * Up to |nr_of_region x nr_of_substances x n_points| doubles. Because of equidistant step
188  * lenght in cocidered system of coordinates, just function values are stored.
189  */
191 
192  unsigned int n_substances_; //< number of substances that take part in the sorption mode
193 
194  /// Mapping from local indexing of substances to global.
196 
197  /**
198  * Array for storage infos about sorbed species concentrations.
199  */
200  double** conc_solid;
201 
203 
205 
206  /** Reaction model that follows the sorption.
207  */
210 
211  ///@name members used in output routines
212  //@{
213  VecScatter vconc_out_scatter; ///< Output vector scatter.
214  Vec *vconc_solid; ///< PETSC sorbed concentration vector (parallel).
215  std::vector<VectorSeqDouble> conc_solid_out; ///< sorbed concentration array output (gathered - sequential)
216  //@}
217 };
218 
219 #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()
std::vector< VectorSeqDouble > conc_solid_out
sorbed concentration array output (gathered - sequential)
Accessor to input data conforming to declared Array.
Definition: accessors.hh:558
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)
DECLARE_INPUT_EXCEPTION(ExcSubstanceCountMatch,<< "The size of the input array "<< EI_ArrayName::qval<< " does not match the number of substances.")
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:52
Input::Type::Selection output_selection
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:109
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:327
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)...
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:76
double ** conc_solid
Sorption model in mobile zone of dual porosity model is considered.
Record type proxy class.
Definition: type_record.hh:169
VecScatter vconc_out_scatter
Output vector scatter.
Class for representation of a vector of fields of the same physical quantity.
Definition: multi_field.hh:45
unsigned int n_substances_
EqData * data_
Pointer to equation data. The object is constructed in descendants.
TYPEDEF_ERR_INFO(EI_ArrayName, std::string)
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.