Flow123d  JS_before_hm-978-gfd4e3d8
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 output stream.
116  virtual std::shared_ptr<OutputTime> output_stream() = 0;
117 
118  /// Getter for P0 interpolation by FieldFE.
119  virtual FieldFEScalarVec& get_p0_interpolation() = 0;
120 
121  /// Return PETSc vector with solution for sbi-th substance.
122  virtual Vec get_component_vec(unsigned int sbi) = 0;
123 
124  /// Return array of indices of local elements and parallel distribution of elements.
125  virtual void get_par_info(LongIdx * &el_4_loc, Distribution * &el_ds) = 0;
126 
127  /// Return global array of order of elements within parallel vector.
128  virtual LongIdx *get_row_4_el() = 0;
129 
130  /// Returns number of trnasported substances.
131  virtual unsigned int n_substances() = 0;
132 
133  /// Returns reference to the vector of substnace names.
134  virtual SubstanceList &substances() = 0;
135 
136 
137 };
138 
139 
140 
141 
142 
143 /**
144  * Class with fields that are common to all transport models.
145  */
146 class TransportEqData : public FieldSet {
147 public:
148 
149  TransportEqData();
150  inline virtual ~TransportEqData() {};
151 
152  /// Mobile porosity - usually saturated water content in the case of unsaturated flow model
154 
155  /// Water content - result of unsaturated water flow model or porosity
157 
158  /// Pointer to DarcyFlow field cross_section
160 
161  /// Flow flux, can be result of water flow model.
163 
164  /// Concentration sources - density of substance source, only positive part is used.
166  /// Concentration sources - Robin type, in_flux = sources_sigma * (sources_conc - mobile_conc)
169 
170 };
171 
172 
173 
174 
175 /**
176  * @brief Empty transport class.
177  */
179 public:
180  inline TransportNothing(Mesh &mesh_in)
181  : AdvectionProcessBase(mesh_in, Input::Record() )
182 
183  {
184  // make module solved for ever
186  // auto eq_mark_type = TimeGovernor::marks().new_mark_type();
188  time_->next_time();
189  };
190 
191  inline virtual ~TransportNothing()
192  {
193  if(time_) delete time_;
194  }
195 
196  inline virtual void output_data() override {};
197 
198 
199 };
200 
201 
202 
203 /**
204  * @brief Coupling of a transport model with a reaction model by operator splitting.
205  *
206  * Outline:
207  * Transport model is any descendant of TransportBase (even TransportOperatorSplitting itself). This
208  * should perform the transport possibly with diffusion and usually without coupling between substances and phases.
209  *
210  * Reaction is any descendant of the ReactionBase class. This represents reactions in general way of any coupling that
211  * happens between substances and phases on one element or more generally on one DoF.
212  */
213 
215 public:
217 
218  /**
219  * @brief Declare input record type for the equation TransportOperatorSplittiong.
220  *
221  * TODO: The question is if this should be a general coupling class
222  * (e.g. allow coupling TranportDG with reactions even if it is not good idea for numerical reasons.)
223  * To make this a coupling class we should modify all main input files for transport problems.
224  */
225  static const Input::Type::Record & get_input_type();
226 
227  /// Constructor.
228  TransportOperatorSplitting(Mesh &init_mesh, const Input::Record in_rec);
229  /// Destructor.
230  virtual ~TransportOperatorSplitting();
231 
232  void initialize() override;
233  void zero_time_step() override;
234  void update_solution() override;
235 
236  void compute_until_save_time();
237  void compute_internal_step();
238  void output_data() override;
239 
240 
241 
242 private:
243  /// Registrar of class to factory
244  static const int registrar;
245 
246  std::shared_ptr<ConcentrationTransportBase> convection;
247  std::shared_ptr<ReactionTerm> reaction;
248 
249  //double *** semchem_conc_ptr; //dumb 3-dim array (for phases, which are not supported any more)
250  //Semchem_interface *Semchem_reactions;
251 
252  double cfl_convection; ///< Time restriction due to transport
253  double cfl_reaction; ///< Time restriction due to reactions
254 
255 };
256 
257 
258 
259 
260 
261 #endif // TRANSPORT_OPERATOR_SPLITTING_HH_
Abstract base class for equation clasess.
Container for various descendants of FieldCommonBase.
Definition: field_set.hh:74
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.
Abstract linear system class.
Definition: balance.hh:40
Class template representing a field with values dependent on: point, element, and region...
Definition: field.hh:92
MultiField< 3, FieldValue< 3 >::Scalar > sources_density
Concentration sources - density of substance source, only positive part is used.
Coupling of a transport model with a reaction model by operator splitting.
Definition: mesh.h:78
MultiField< 3, FieldValue< 3 >::Scalar > sources_conc
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
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: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.
Field< 3, FieldValue< 3 >::Scalar > water_content
Water content - result of unsaturated water flow model or porosity.
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
Field< 3, FieldValue< 3 >::Scalar > cross_section
Pointer to DarcyFlow field cross_section.
static const double inf_time
Infinity time used for steady case.
static const int registrar
Registrar of class to factory.