Flow123d  release_2.2.0-26-ge868538
dual_porosity.hh
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file dual_porosity.hh
15  * @brief Class Dual_por_exchange implements the model of dual porosity.
16  *
17  * It can be part of the transport model and it computes the concentrations of substances both in
18  * mobile and immobile zone. This model can also work above the sorption model - the sorbed concentration
19  * is then computed both from mobile and immobile concentrations. Linear reactions can be define
20  * also in both zones.
21  */
22 
23 #ifndef DUAL_POROSITY_H_
24 #define DUAL_POROSITY_H_
25 
26 #include <vector>
27 #include "input/accessors.hh"
28 
30 #include "fields/field_set.hh"
31 #include "fields/multi_field.hh"
32 #include "fields/vec_seq_double.hh"
35 
36 class Mesh;
37 
38 /// Class representing dual porosity model in transport.
40 {
41 public:
43 
44  /**
45  * Static variable for new input data types input
46  */
47  static const Input::Type::Record & get_input_type();
48 
49  /// DualPorosity data
50  class EqData : public FieldSet
51  {
52  public:
53 
54  /// Collect all fields
55  EqData();
56 
57  MultiField<3, FieldValue<3>::Scalar > diffusion_rate_immobile; ///< Mass transfer coefficients between mobile and immobile pores.
58  Field<3, FieldValue<3>::Scalar > porosity_immobile; ///< Immobile porosity field.
59 
60  MultiField<3, FieldValue<3>::Scalar> init_conc_immobile; ///< Initial concentrations in the immobile zone.
61 
62  Field<3, FieldValue<3>::Scalar > porosity; ///< Porosity field.
63 
64  MultiField<3, FieldValue<3>::Scalar> conc_immobile; ///< Calculated concentrations in the immobile zone.
65 
66  /// Fields indended for output, i.e. all input fields plus those representing solution.
68 
69  };
70 
71  /// Constructor.
72  DualPorosity(Mesh &init_mesh, Input::Record in_rec);
73 
74  ///Destructor.
75  ~DualPorosity(void);
76 
77  /// Prepares the object to usage.
78  /**
79  * Allocating memory, reading input, initialization of fields.
80  */
81  void initialize() override;
82 
83  /**
84  * Does first computation after initialization process.
85  * The time is set and initial condition is set and output.
86  */
87  void zero_time_step() override;
88 
89  /**
90  * Updates the solution according to the dual porosity model.
91  */
92  void update_solution(void) override;
93 
94  /// Main output routine.
95  void output_data(void) override;
96 
97  bool evaluate_time_constraint(double &time_constraint) override;
98 
99 protected:
100  /**
101  * This method disables to use constructor without parameters.
102  */
103  DualPorosity();
104 
105  /// Resolves construction of following reactions.
106  void make_reactions();
107 
108  /// Sets initial condition from input.
109  void set_initial_condition();
110  /// Initializes field sets.
111  void initialize_fields();
112  /// Allocates petsc vectors, prepares them for output and creates output vector scatter.
113  void allocate_output_mpi(void);
114 
115  double **compute_reaction(double **concentrations, int loc_el) override;
116 
117  /// Gathers all the parallel vectors to enable them to be output.
118  void output_vector_gather(void) override;
119 
120  /**
121  * Pointer to twodimensional array[substance][elements] containing concentrations either in immobile.
122  */
123  double **conc_immobile;
124 
125  /**
126  * Equation data - all data fields are in this set.
127  */
129 
130  //Input::Array output_array;
131 
132  /**
133  * Input data set - fields in this set are read from the input file.
134  */
136 
137  std::shared_ptr<ReactionTerm> reaction_mobile; ///< Reaction running in mobile zone
138  std::shared_ptr<ReactionTerm> reaction_immobile; ///< Reaction running in immobile zone
139 
140  /// Dual porosity computational scheme tolerance.
141  /** According to this tolerance the analytical solution of dual porosity concentrations or
142  * simple forward difference approximation of concentrations is chosen for computation.
143  */
145 
146  ///@name members used in output routines
147  //@{
148  VecScatter vconc_out_scatter; ///< Output vector scatter.
149  Vec *vconc_immobile; ///< PETSC concentration vector for immobile phase (parallel).
150  std::vector<VectorSeqDouble> conc_immobile_out; ///< concentration array output for immobile phase (gathered - sequential)
151  //@}
152 
153 private:
154  /// Registrar of class to factory
155  static const int registrar;
156 
157 };
158 
159 #endif //DUAL_POROSITY_H_
ReactionTerm FactoryBaseType
Container for various descendants of FieldCommonBase.
Definition: field_set.hh:61
void set_initial_condition()
Sets initial condition from input.
VecScatter vconc_out_scatter
Output vector scatter.
std::shared_ptr< ReactionTerm > reaction_mobile
Reaction running in mobile zone.
void output_data(void) override
Main output routine.
MultiField< 3, FieldValue< 3 >::Scalar > conc_immobile
Calculated concentrations in the immobile zone.
Class template representing a field with values dependent on: point, element, and region...
Definition: field.hh:62
EquationOutput output_fields
Fields indended for output, i.e. all input fields plus those representing solution.
void zero_time_step() override
Definition: mesh.h:97
Field< 3, FieldValue< 3 >::Scalar > porosity_immobile
Immobile porosity field.
~DualPorosity(void)
Destructor.
std::vector< VectorSeqDouble > conc_immobile_out
concentration array output for immobile phase (gathered - sequential)
void allocate_output_mpi(void)
Allocates petsc vectors, prepares them for output and creates output vector scatter.
void update_solution(void) override
Class ReactionTerm is an abstract class representing reaction term in transport.
double scheme_tolerance_
Dual porosity computational scheme tolerance.
std::shared_ptr< ReactionTerm > reaction_immobile
Reaction running in immobile zone.
void make_reactions()
Resolves construction of following reactions.
void initialize() override
Prepares the object to usage.
Accessor to the data with type Type::Record.
Definition: accessors.hh:292
bool evaluate_time_constraint(double &time_constraint) override
Computes a constraint for time step.
void initialize_fields()
Initializes field sets.
EqData()
Collect all fields.
Class representing dual porosity model in transport.
double ** conc_immobile
void output_vector_gather(void) override
Gathers all the parallel vectors to enable them to be output.
double ** compute_reaction(double **concentrations, int loc_el) override
MultiField< 3, FieldValue< 3 >::Scalar > diffusion_rate_immobile
Mass transfer coefficients between mobile and immobile pores.
static const int registrar
Registrar of class to factory.
MultiField< 3, FieldValue< 3 >::Scalar > init_conc_immobile
Initial concentrations in the immobile zone.
Record type proxy class.
Definition: type_record.hh:182
Field< 3, FieldValue< 3 >::Scalar > porosity
Porosity field.
Class for representation of a vector of fields of the same physical quantity.
Definition: multi_field.hh:55
static const Input::Type::Record & get_input_type()
DualPorosity data.
Vec * vconc_immobile
PETSC concentration vector for immobile phase (parallel).
FieldSet input_data_set_