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