Flow123d  master-f44eb46
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.
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.
117 
118  /// Return PETSc vector with solution for sbi-th substance.
119  virtual Vec get_component_vec(unsigned int sbi) = 0;
120 
121  /// Returns number of trnasported substances.
122  virtual unsigned int n_substances() = 0;
123 
124  /// Returns reference to the vector of substnace names.
125  virtual SubstanceList &substances() = 0;
126 
127 
128 };
129 
130 
131 
132 
133 
134 /**
135  * Class with fields that are common to all transport models.
136  */
137 class TransportEqFields : public FieldSet {
138 public:
139 
141  inline virtual ~TransportEqFields() {};
142 
143  /// Mobile porosity - usually saturated water content in the case of unsaturated flow model
145 
146  /// Water content - result of unsaturated water flow model or porosity
148 
149  /// Pointer to DarcyFlow field cross_section
151 
152  /// Flow flux, can be result of water flow model.
154 
155  /// Concentration sources - density of substance source, only positive part is used.
157  /// Concentration sources - Robin type, in_flux = sources_sigma * (sources_conc - mobile_conc)
160 
161 };
162 
163 
164 
165 
166 /**
167  * @brief Empty transport class.
168  */
170 public:
171  inline TransportNothing(Mesh &mesh_in)
172  : AdvectionProcessBase(mesh_in, Input::Record() )
173 
174  {
175  // make module solved for ever
177  // auto eq_mark_type = TimeGovernor::marks().new_mark_type();
179  time_->next_time();
180  };
181 
182  inline virtual ~TransportNothing()
183  {
184  if(time_) delete time_;
185  }
186 
187  inline virtual void output_data() override {};
188 
189 
190 };
191 
192 
193 
194 /**
195  * @brief Coupling of a transport model with a reaction model by operator splitting.
196  *
197  * Outline:
198  * Transport model is any descendant of TransportBase (even TransportOperatorSplitting itself). This
199  * should perform the transport possibly with diffusion and usually without coupling between substances and phases.
200  *
201  * Reaction is any descendant of the ReactionBase class. This represents reactions in general way of any coupling that
202  * happens between substances and phases on one element or more generally on one DoF.
203  */
204 
206 public:
208 
209  /**
210  * @brief Declare input record type for the equation TransportOperatorSplittiong.
211  *
212  * TODO: The question is if this should be a general coupling class
213  * (e.g. allow coupling TranportDG with reactions even if it is not good idea for numerical reasons.)
214  * To make this a coupling class we should modify all main input files for transport problems.
215  */
216  static const Input::Type::Record & get_input_type();
217 
218  /// Constructor.
219  TransportOperatorSplitting(Mesh &init_mesh, const Input::Record in_rec);
220  /// Destructor.
221  virtual ~TransportOperatorSplitting();
222 
223  void initialize() override;
224  void zero_time_step() override;
225  void update_solution() override;
226 
229  void output_data() override;
230 
231 
232 
233 private:
234  /// Registrar of class to factory
235  static const int registrar;
236 
237  std::shared_ptr<ConcentrationTransportBase> convection;
238  std::shared_ptr<ReactionTerm> reaction;
239 
240  double cfl_convection; ///< Time restriction due to transport
241 };
242 
243 
244 
245 
246 
247 #endif // TRANSPORT_OPERATOR_SPLITTING_HH_
ConcentrationTransportBase(Mesh &init_mesh, const Input::Record in_rec)
virtual SubstanceList & substances()=0
Returns reference to the vector of substnace names.
virtual void set_balance_object(std::shared_ptr< Balance > balance)=0
virtual void compute_p0_interpolation()=0
Compute P0 interpolation of the solution (used in reaction term).
virtual void update_after_reactions(bool solution_changed)=0
Perform changes to transport solution after reaction step.
virtual unsigned int n_substances()=0
Returns number of trnasported substances.
std::vector< std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > > FieldFEScalarVec
virtual FieldFEScalarVec & get_p0_interpolation()=0
Getter for P0 interpolation by FieldFE.
virtual bool evaluate_time_constraint(double &time_constraint)=0
Computes a constraint for time step.
virtual Vec get_component_vec(unsigned int sbi)=0
Return PETSc vector with solution for sbi-th substance.
static Input::Type::Abstract & get_input_type()
Common specification of the input record for secondary equations.
virtual void set_target_time(double target_time)=0
virtual void set_output_stream(std::shared_ptr< OutputTime > stream)=0
Setter for output stream.
virtual const vector< unsigned int > & get_subst_idx()=0
Return substance indices used in balance.
std::shared_ptr< Balance > balance() const
Definition: equation.hh:189
TimeGovernor * time_
Definition: equation.hh:241
Container for various descendants of FieldCommonBase.
Definition: field_set.hh:159
Class template representing a field with values dependent on: point, element, and region.
Definition: field.hh:92
Accessor to the data with type Type::Record.
Definition: accessors.hh:291
Class for declaration of polymorphic Record.
Record type proxy class.
Definition: type_record.hh:182
Definition: mesh.h:362
Class for representation of a vector of fields of the same physical quantity.
Definition: multi_field.hh:87
The class for outputting data during time.
Definition: output_time.hh:51
Basic time management functionality for unsteady (and steady) solvers (class Equation).
static const double inf_time
Infinity time used for steady case.
static TimeMarks & marks()
void next_time()
Proceed to the next time according to current estimated time step.
TimeMark::Type new_mark_type()
Definition: time_marks.cc:68
Field< 3, FieldValue< 3 >::Scalar > water_content
Water content - result of unsaturated water flow model or porosity.
MultiField< 3, FieldValue< 3 >::Scalar > sources_sigma
Concentration sources - Robin type, in_flux = sources_sigma * (sources_conc - mobile_conc)
MultiField< 3, FieldValue< 3 >::Scalar > sources_conc
MultiField< 3, FieldValue< 3 >::Scalar > sources_density
Concentration sources - density of substance source, only positive part is used.
Field< 3, FieldValue< 3 >::Scalar > porosity
Mobile porosity - usually saturated water content in the case of unsaturated flow model.
Field< 3, FieldValue< 3 >::VectorFixed > flow_flux
Flow flux, can be result of water flow model.
Field< 3, FieldValue< 3 >::Scalar > cross_section
Pointer to DarcyFlow field cross_section.
Empty transport class.
virtual void output_data() override
Write computed fields.
Coupling of a transport model with a reaction model by operator splitting.
void output_data() override
Write computed fields.
virtual ~TransportOperatorSplitting()
Destructor.
double cfl_convection
Time restriction due to transport.
static const int registrar
Registrar of class to factory.
static const Input::Type::Record & get_input_type()
Declare input record type for the equation TransportOperatorSplittiong.
std::shared_ptr< ConcentrationTransportBase > convection
TransportOperatorSplitting(Mesh &init_mesh, const Input::Record in_rec)
Constructor.
std::shared_ptr< ReactionTerm > reaction
Abstract base class for equation clasess.
Abstract linear system class.
Definition: balance.hh:40
Basic time management class.