Flow123d  release_2.2.0-33-g759111d
transport_operator_splitting.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 transport_operator_splitting.hh
15  * @brief
16  */
17 
18 #ifndef TRANSPORT_OPERATOR_SPLITTING_HH_
19 #define TRANSPORT_OPERATOR_SPLITTING_HH_
20 
21 #include "coupling/equation.hh"
22 
23 #include <limits>
24 
25 #include "io/output_time.hh"
26 //#include "flow/darcy_flow_mh.hh"
27 #include "flow/mh_dofhandler.hh"
29 #include "fields/field_values.hh"
30 #include "fields/field_set.hh"
31 #include "fields/multi_field.hh"
32 #include "transport/substance.hh"
34 
35 
36 /// external types:
37 class Mesh;
38 class ReactionTerm;
40 class Semchem_interface;
41 class Balance;
42 
43 
44 
45 
46 
47 
48 
49 /**
50  * Abstract interface class for implementations of transport equation within TransportOperatorSplitting.
51  */
53 public:
54 
55  /**
56  * Constructor.
57  */
58  ConcentrationTransportBase(Mesh &init_mesh, const Input::Record in_rec)
59  : EquationBase(init_mesh, in_rec) {};
60 
61 
62  /// Common specification of the input record for secondary equations.
64 
65 
66  /**
67  * Set time interval which is considered as one time step by TransportOperatorSplitting.
68  * In particular the velocity field dosn't change over this interval.
69  *
70  * Dependencies:
71  *
72  * velocity, porosity -> matrix, source_vector
73  * matrix -> time_step
74  *
75  * data_read_times -> time_step (not necessary if we won't stick to jump times)
76  * data -> source_vector
77  * time_step -> scaling
78  *
79  *
80  *
81  */
82  virtual void set_target_time(double target_time) = 0;
83 
84  /**
85  * Use Balance object from upstream equation (e.g. in various couplings) instead of own instance.
86  */
87  virtual void set_balance_object(std::shared_ptr<Balance> balance) = 0;
88 
89  /// Computes a constraint for time step.
90  virtual bool evaluate_time_constraint(double &time_constraint) = 0;
91 
92  /// Return substance indices used in balance.
93  virtual const vector<unsigned int> &get_subst_idx() = 0;
94 
95  /// Calculate the array of concentrations per element (for reactions).
96  virtual void calculate_concentration_matrix() = 0;
97 
98  /// Perform changes to transport solution after reaction step.
99  virtual void update_after_reactions(bool solution_changed) = 0;
100 
101  /// Setter for output stream.
102  virtual void set_output_stream(std::shared_ptr<OutputTime> stream) = 0;
103 
104  /// Getter for output stream.
105  virtual std::shared_ptr<OutputTime> output_stream() = 0;
106 
107  /// Getter for array of concentrations per element.
108  virtual double **get_concentration_matrix() = 0;
109 
110  /// Return PETSc vector with solution for sbi-th substance.
111  virtual const Vec &get_solution(unsigned int sbi) = 0;
112 
113  /// Return array of indices of local elements and parallel distribution of elements.
114  virtual void get_par_info(int * &el_4_loc, Distribution * &el_ds) = 0;
115 
116  /// Return global array of order of elements within parallel vector.
117  virtual int *get_row_4_el() = 0;
118 
119  /// Pass velocity from flow to transport.
120  virtual void set_velocity_field(const MH_DofHandler &dh) = 0;
121 
122  /// Returns number of trnasported substances.
123  virtual unsigned int n_substances() = 0;
124 
125  /// Returns reference to the vector of substnace names.
126  virtual SubstanceList &substances() = 0;
127 
128 
129 };
130 
131 
132 
133 
134 
135 /**
136  * Class with fields that are common to all transport models.
137  */
138 class TransportEqData : public FieldSet {
139 public:
140 
141  TransportEqData();
142  inline virtual ~TransportEqData() {};
143 
144  /// Mobile porosity - usually saturated water content in the case of unsaturated flow model
146 
147  /// Water content - result of unsaturated water flow model or porosity
149 
150  /// Pointer to DarcyFlow field cross_section
152 
153  /// Concentration sources - density of substance source, only positive part is used.
155  /// Concentration sources - Robin type, in_flux = sources_sigma * (sources_conc - mobile_conc)
158 
159 };
160 
161 
162 
163 
164 /**
165  * @brief Empty transport class.
166  */
168 public:
169  inline TransportNothing(Mesh &mesh_in)
170  : AdvectionProcessBase(mesh_in, Input::Record() )
171 
172  {
173  // make module solved for ever
174  auto eq_mark_type = TimeGovernor::marks().new_mark_type();
176  time_->next_time();
177  };
178 
179  inline virtual ~TransportNothing()
180  {}
181 
182  inline void set_velocity_field(const MH_DofHandler &dh) override {};
183 
184  inline virtual void output_data() override {};
185 
186 
187 };
188 
189 
190 
191 /**
192  * @brief Coupling of a transport model with a reaction model by operator splitting.
193  *
194  * Outline:
195  * Transport model is any descendant of TransportBase (even TransportOperatorSplitting itself). This
196  * should perform the transport possibly with diffusion and usually without coupling between substances and phases.
197  *
198  * Reaction is any descendant of the ReactionBase class. This represents reactions in general way of any coupling that
199  * happens between substances and phases on one element or more generally on one DoF.
200  */
201 
203 public:
205 
206  /**
207  * @brief Declare input record type for the equation TransportOperatorSplittiong.
208  *
209  * TODO: The question is if this should be a general coupling class
210  * (e.g. allow coupling TranportDG with reactions even if it is not good idea for numerical reasons.)
211  * To make this a coupling class we should modify all main input files for transport problems.
212  */
213  static const Input::Type::Record & get_input_type();
214 
215  /// Constructor.
216  TransportOperatorSplitting(Mesh &init_mesh, const Input::Record in_rec);
217  /// Destructor.
218  virtual ~TransportOperatorSplitting();
219 
220  virtual void set_velocity_field(const MH_DofHandler &dh) override;
221 
222  void initialize() override;
223  void zero_time_step() override;
224  void update_solution() override;
225 
226  void compute_until_save_time();
227  void compute_internal_step();
228  void output_data() override;
229 
230 
231 
232 private:
233  /// Registrar of class to factory
234  static const int registrar;
235 
236  std::shared_ptr<ConcentrationTransportBase> convection;
237  std::shared_ptr<ReactionTerm> reaction;
238 
239  //double *** semchem_conc_ptr; //dumb 3-dim array (for phases, which are not supported any more)
240  //Semchem_interface *Semchem_reactions;
241 
242  double cfl_convection; ///< Time restriction due to transport
243  double cfl_reaction; ///< Time restriction due to reactions
244 
245 };
246 
247 
248 
249 
250 
251 #endif // TRANSPORT_OPERATOR_SPLITTING_HH_
void set_velocity_field(const MH_DofHandler &dh) override
virtual void zero_time_step()
Definition: equation.hh:100
Abstract base class for equation clasess.
Container for various descendants of FieldCommonBase.
Definition: field_set.hh:61
ConcentrationTransportBase(Mesh &init_mesh, const Input::Record in_rec)
virtual void set_output_stream(std::shared_ptr< OutputTime > stream)=0
Setter for output stream.
virtual void initialize()
Definition: equation.hh:88
Class template representing a field with values dependent on: point, element, and region...
Definition: field.hh:62
void next_time()
Proceed to the next time according to current estimated time step.
virtual int * get_row_4_el()=0
Return global array of order of elements within parallel vector.
virtual void update_after_reactions(bool solution_changed)=0
Perform changes to transport solution after reaction step.
MultiField< 3, FieldValue< 3 >::Scalar > sources_density
Concentration sources - density of substance source, only positive part is used.
virtual double ** get_concentration_matrix()=0
Getter for array of concentrations per element.
Coupling of a transport model with a reaction model by operator splitting.
Definition: mesh.h:97
MultiField< 3, FieldValue< 3 >::Scalar > sources_conc
virtual void set_target_time(double target_time)=0
virtual void set_velocity_field(const MH_DofHandler &dh)=0
Pass velocity from flow to transport.
static Input::Type::Abstract & get_input_type()
Common specification of the input record for secondary equations.
Basic time management functionality for unsteady (and steady) solvers (class Equation).
virtual bool evaluate_time_constraint(double &time_constraint)=0
Computes a constraint for time step.
virtual void output_data()
Write computed fields.
Definition: equation.hh:216
static TimeMarks & marks()
virtual unsigned int n_substances()=0
Returns number of trnasported substances.
std::shared_ptr< ReactionTerm > reaction
virtual std::shared_ptr< OutputTime > output_stream()=0
Getter for output stream.
MultiField< 3, FieldValue< 3 >::Scalar > sources_sigma
Concentration sources - Robin type, in_flux = sources_sigma * (sources_conc - mobile_conc) ...
Accessor to the data with type Type::Record.
Definition: accessors.hh:292
TimeMark::Type new_mark_type()
Definition: time_marks.cc:68
double cfl_convection
Time restriction due to transport.
virtual void output_data() override
Write computed fields.
Class for declaration of polymorphic Record.
Field< 3, FieldValue< 3 >::Scalar > water_content
Water content - result of unsaturated water flow model or porosity.
virtual const vector< unsigned int > & get_subst_idx()=0
Return substance indices used in balance.
Empty transport class.
virtual SubstanceList & substances()=0
Returns reference to the vector of substnace names.
std::shared_ptr< ConcentrationTransportBase > convection
virtual void update_solution()
Definition: equation.hh:117
Classes for storing substance data.
virtual const Vec & get_solution(unsigned int sbi)=0
Return PETSc vector with solution for sbi-th substance.
double cfl_reaction
Time restriction due to reactions.
Record type proxy class.
Definition: type_record.hh:182
Class for representation of a vector of fields of the same physical quantity.
Definition: multi_field.hh:55
virtual void set_balance_object(std::shared_ptr< Balance > balance)=0
Field< 3, FieldValue< 3 >::Scalar > cross_section
Pointer to DarcyFlow field cross_section.
static const double inf_time
Infinity time used for steady case.
virtual void get_par_info(int *&el_4_loc, Distribution *&el_ds)=0
Return array of indices of local elements and parallel distribution of elements.
TimeGovernor * time_
Definition: equation.hh:224
static const int registrar
Registrar of class to factory.
virtual void calculate_concentration_matrix()=0
Calculate the array of concentrations per element (for reactions).