Flow123d  JS_before_hm-2208-gb971e62bf
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.
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  /// 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 
228  void compute_internal_step();
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_
TransportEqFields::~TransportEqFields
virtual ~TransportEqFields()
Definition: transport_operator_splitting.hh:141
TransportOperatorSplitting::registrar
static const int registrar
Registrar of class to factory.
Definition: transport_operator_splitting.hh:235
TimeMarks::new_mark_type
TimeMark::Type new_mark_type()
Definition: time_marks.cc:68
time_governor.hh
Basic time management class.
Input
Abstract linear system class.
Definition: balance.hh:40
TransportEqFields::cross_section
Field< 3, FieldValue< 3 >::Scalar > cross_section
Pointer to DarcyFlow field cross_section.
Definition: transport_operator_splitting.hh:150
SubstanceList
Definition: substance.hh:70
ConcentrationTransportBase::get_p0_interpolation
virtual FieldFEScalarVec & get_p0_interpolation()=0
Getter for P0 interpolation by FieldFE.
Balance
Definition: balance.hh:119
TransportEqFields::flow_flux
Field< 3, FieldValue< 3 >::VectorFixed > flow_flux
Flow flux, can be result of water flow model.
Definition: transport_operator_splitting.hh:153
TransportOperatorSplitting::zero_time_step
void zero_time_step() override
Definition: transport_operator_splitting.cc:255
TransportEqFields::water_content
Field< 3, FieldValue< 3 >::Scalar > water_content
Water content - result of unsaturated water flow model or porosity.
Definition: transport_operator_splitting.hh:147
ConcentrationTransportBase::n_substances
virtual unsigned int n_substances()=0
Returns number of trnasported substances.
EquationBase::time_
TimeGovernor * time_
Definition: equation.hh:221
advection_process_base.hh
field_set.hh
TransportOperatorSplitting::FactoryBaseType
AdvectionProcessBase FactoryBaseType
Definition: transport_operator_splitting.hh:207
std::vector
Definition: doxy_dummy_defs.hh:7
ConcentrationTransportBase::compute_p0_interpolation
virtual void compute_p0_interpolation()=0
Compute P0 interpolation of the solution (used in reaction term).
ConcentrationTransportBase::get_subst_idx
virtual const vector< unsigned int > & get_subst_idx()=0
Return substance indices used in balance.
field_fe.hh
type_base.hh
index_types.hh
TransportEqFields::sources_sigma
MultiField< 3, FieldValue< 3 >::Scalar > sources_sigma
Concentration sources - Robin type, in_flux = sources_sigma * (sources_conc - mobile_conc)
Definition: transport_operator_splitting.hh:158
ConcentrationTransportBase::set_output_stream
virtual void set_output_stream(std::shared_ptr< OutputTime > stream)=0
Setter for output stream.
TransportOperatorSplitting::initialize
void initialize() override
Definition: transport_operator_splitting.cc:227
TransportOperatorSplitting::TransportOperatorSplitting
TransportOperatorSplitting(Mesh &init_mesh, const Input::Record in_rec)
Constructor.
Definition: transport_operator_splitting.cc:156
Distribution
Definition: distribution.hh:50
EquationBase::balance
std::shared_ptr< Balance > balance() const
Definition: equation.hh:187
ConcentrationTransportBase::evaluate_time_constraint
virtual bool evaluate_time_constraint(double &time_constraint)=0
Computes a constraint for time step.
Input::Record
Accessor to the data with type Type::Record.
Definition: accessors.hh:291
AdvectionProcessBase
Definition: advection_process_base.hh:19
TransportOperatorSplitting::compute_internal_step
void compute_internal_step()
type_generic.hh
TransportNothing
Empty transport class.
Definition: transport_operator_splitting.hh:169
accessors.hh
TransportOperatorSplitting::get_input_type
static const Input::Type::Record & get_input_type()
Declare input record type for the equation TransportOperatorSplittiong.
Definition: transport_operator_splitting.cc:69
TimeGovernor
Basic time management functionality for unsteady (and steady) solvers (class Equation).
Definition: time_governor.hh:317
TransportOperatorSplitting::update_solution
void update_solution() override
Definition: transport_operator_splitting.cc:270
TransportOperatorSplitting::reaction
std::shared_ptr< ReactionTerm > reaction
Definition: transport_operator_splitting.hh:238
field_values.hh
TransportOperatorSplitting::output_data
void output_data() override
Write computed fields.
Definition: transport_operator_splitting.cc:242
TransportEqFields::porosity
Field< 3, FieldValue< 3 >::Scalar > porosity
Mobile porosity - usually saturated water content in the case of unsaturated flow model.
Definition: transport_operator_splitting.hh:141
Input::Type::Abstract
Class for declaration of polymorphic Record.
Definition: type_abstract.hh:62
OutputTime
The class for outputting data during time.
Definition: output_time.hh:51
TransportNothing::~TransportNothing
virtual ~TransportNothing()
Definition: transport_operator_splitting.hh:182
TransportEqFields::TransportEqFields
TransportEqFields()
Definition: transport_operator_splitting.cc:106
FieldSet
Container for various descendants of FieldCommonBase.
Definition: field_set.hh:159
equation.hh
Abstract base class for equation clasess.
EquationBase
Definition: equation.hh:57
TransportNothing::output_data
virtual void output_data() override
Write computed fields.
Definition: transport_operator_splitting.hh:187
TransportOperatorSplitting::cfl_convection
double cfl_convection
Time restriction due to transport.
Definition: transport_operator_splitting.hh:240
Input::Type::Record
Record type proxy class.
Definition: type_record.hh:182
ConcentrationTransportBase
Definition: transport_operator_splitting.hh:61
Mesh
Definition: mesh.h:355
ConcentrationTransportBase::set_target_time
virtual void set_target_time(double target_time)=0
TransportOperatorSplitting
Coupling of a transport model with a reaction model by operator splitting.
Definition: transport_operator_splitting.hh:205
multi_field.hh
ConcentrationTransportBase::set_balance_object
virtual void set_balance_object(std::shared_ptr< Balance > balance)=0
TimeGovernor::marks
static TimeMarks & marks()
Definition: time_governor.hh:338
TransportOperatorSplitting::compute_until_save_time
void compute_until_save_time()
ConcentrationTransportBase::ConcentrationTransportBase
ConcentrationTransportBase(Mesh &init_mesh, const Input::Record in_rec)
Definition: transport_operator_splitting.hh:69
MultiField
Class for representation of a vector of fields of the same physical quantity.
Definition: multi_field.hh:87
TransportOperatorSplitting::convection
std::shared_ptr< ConcentrationTransportBase > convection
Definition: transport_operator_splitting.hh:237
TimeGovernor::inf_time
static const double inf_time
Infinity time used for steady case.
Definition: time_governor.hh:645
ConcentrationTransportBase::get_input_type
static Input::Type::Abstract & get_input_type()
Common specification of the input record for secondary equations.
Definition: transport_operator_splitting.cc:62
TransportEqFields::sources_density
MultiField< 3, FieldValue< 3 >::Scalar > sources_density
Concentration sources - density of substance source, only positive part is used.
Definition: transport_operator_splitting.hh:156
time_marks.hh
TransportEqFields::sources_conc
MultiField< 3, FieldValue< 3 >::Scalar > sources_conc
Definition: transport_operator_splitting.hh:159
Field
Class template representing a field with values dependent on: point, element, and region.
Definition: field.hh:93
TransportEqFields
Definition: transport_operator_splitting.hh:137
ReactionTerm
Definition: reaction_term.hh:46
TimeGovernor::next_time
void next_time()
Proceed to the next time according to current estimated time step.
Definition: time_governor.cc:670
ConcentrationTransportBase::substances
virtual SubstanceList & substances()=0
Returns reference to the vector of substnace names.
ConcentrationTransportBase::update_after_reactions
virtual void update_after_reactions(bool solution_changed)=0
Perform changes to transport solution after reaction step.
ConcentrationTransportBase::get_component_vec
virtual Vec get_component_vec(unsigned int sbi)=0
Return PETSc vector with solution for sbi-th substance.
TransportOperatorSplitting::~TransportOperatorSplitting
virtual ~TransportOperatorSplitting()
Destructor.
Definition: transport_operator_splitting.cc:219
field.hh
TransportNothing::TransportNothing
TransportNothing(Mesh &mesh_in)
Definition: transport_operator_splitting.hh:171
ConcentrationTransportBase::FieldFEScalarVec
std::vector< std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > > FieldFEScalarVec
Definition: transport_operator_splitting.hh:64