Flow123d  release_1.8.2-1603-g0109a2b
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"
34 
35 class Mesh;
36 
37 /// Class representing dual porosity model in transport.
39 {
40 public:
42 
43  /**
44  * Static variable for new input data types input
45  */
46  static const Input::Type::Record & get_input_type();
47 
48  /// DualPorosity data
49  class EqData : public FieldSet
50  {
51  public:
52 
53  /// Collect all fields
54  EqData();
55 
56  MultiField<3, FieldValue<3>::Scalar > diffusion_rate_immobile; ///< Mass transfer coefficients between mobile and immobile pores.
57  Field<3, FieldValue<3>::Scalar > porosity_immobile; ///< Immobile porosity field.
58 
59  MultiField<3, FieldValue<3>::Scalar> init_conc_immobile; ///< Initial concentrations in the immobile zone.
60 
61  Field<3, FieldValue<3>::Scalar > porosity; ///< Porosity field.
62 
63  MultiField<3, FieldValue<3>::Scalar> conc_immobile; ///< Calculated concentrations in the immobile zone.
64 
65  /// Fields indended for output, i.e. all input fields plus those representing solution.
67 
68  };
69 
70  /// Constructor.
71  DualPorosity(Mesh &init_mesh, Input::Record in_rec);
72 
73  ///Destructor.
74  ~DualPorosity(void);
75 
76  /// Prepares the object to usage.
77  /**
78  * Allocating memory, reading input, initialization of fields.
79  */
80  void initialize() override;
81 
82  /**
83  * Does first computation after initialization process.
84  * The time is set and initial condition is set and output.
85  */
86  void zero_time_step() override;
87 
88  /**
89  * Updates the solution according to the dual porosity model.
90  */
91  void update_solution(void) override;
92 
93  /// Main output routine.
94  void output_data(void) override;
95 
96 protected:
97  /**
98  * This method disables to use constructor without parameters.
99  */
100  DualPorosity();
101 
102  /// Resolves construction of following reactions.
103  void make_reactions();
104 
105  /// Sets initial condition from input.
106  void set_initial_condition();
107  /// Initializes field sets.
108  void initialize_fields();
109  /// Allocates petsc vectors, prepares them for output and creates output vector scatter.
110  void allocate_output_mpi(void);
111 
112  double **compute_reaction(double **concentrations, int loc_el) override;
113 
114  /// Gathers all the parallel vectors to enable them to be output.
115  void output_vector_gather(void) override;
116 
117  /**
118  * Pointer to twodimensional array[substance][elements] containing concentrations either in immobile.
119  */
120  double **conc_immobile;
121 
122  /**
123  * Equation data - all data fields are in this set.
124  */
126 
128 
129  /**
130  * Input data set - fields in this set are read from the input file.
131  */
133 
134  std::shared_ptr<ReactionTerm> reaction_mobile; ///< Reaction running in mobile zone
135  std::shared_ptr<ReactionTerm> reaction_immobile; ///< Reaction running in immobile zone
136 
137  /// Dual porosity computational scheme tolerance.
138  /** According to this tolerance the analytical solution of dual porosity concentrations or
139  * simple forward difference approximation of concentrations is chosen for computation.
140  */
142 
143  ///@name members used in output routines
144  //@{
145  VecScatter vconc_out_scatter; ///< Output vector scatter.
146  Vec *vconc_immobile; ///< PETSC concentration vector for immobile phase (parallel).
147  std::vector<VectorSeqDouble> conc_immobile_out; ///< concentration array output for immobile phase (gathered - sequential)
148  //@}
149 
150 private:
151  /// Registrar of class to factory
152  static const int registrar;
153 
154 };
155 
156 #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.
Accessor to input data conforming to declared Array.
Definition: accessors.hh:552
void output_data(void) override
Main output routine.
MultiField< 3, FieldValue< 3 >::Scalar > conc_immobile
Calculated concentrations in the immobile zone.
FieldSet output_fields
Fields indended for output, i.e. all input fields plus those representing solution.
Class template representing a field with values dependent on: point, element, and region...
Definition: field.hh:62
void zero_time_step() override
Definition: mesh.h:99
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.
Input::Array output_array
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:277
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:171
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_