Flow123d
transport_operator_splitting.hh
Go to the documentation of this file.
1 #ifndef TRANSPORT_OPERATOR_SPLITTING_HH_
2 #define TRANSPORT_OPERATOR_SPLITTING_HH_
3 
4 #include "coupling/equation.hh"
5 
6 #include <limits>
7 #include "io/output.h"
8 #include "flow/darcy_flow_mh.hh"
9 #include "flow/mh_dofhandler.hh"
10 #include "fields/field_base.hh"
11 #include "fields/field_values.hh"
13 
14 
15 /// external types:
16 //class LinSys;
17 //struct Solver;
18 class Mesh;
19 //class SchurComplement;
20 //class Distribution;
21 //class SparseGraph;
22 
23 class ReactionTerm;
25 
26 class Semchem_interface;
27 
28 
29 
30 
31 
33 
34 public:
35 
36  AdvectionProcessBase(Mesh &mesh, const Input::Record in_rec) : EquationBase(mesh, in_rec) {};
37 
38  /**
39  * This method takes sequential PETSc vector of side velocities and update
40  * transport matrix. The ordering is same as ordering of sides in the mesh.
41  * We just keep the pointer, but do not destroy the object.
42  *
43  * TODO: We should pass whole velocity field object (description of base functions and dof numbering) and vector.
44  */
45  virtual void set_velocity_field(const MH_DofHandler &dh) = 0;
46 
47 
48 
49  //virtual void set_cross_section_field(const Field< 3, FieldValue<3>::Scalar > &cross_section) = 0;
50 
51  virtual unsigned int n_substances() = 0;
52 
53  virtual vector<string> &substance_names() = 0;
54 
55 
56  /// Common specification of the input record for secondary equations.
58 
59 
60 };
61 
62 
63 
64 /**
65  * @brief Specification of transport model interface.
66  *
67  * Here one has to specify methods for setting or getting data particular to
68  * transport equations.
69  */
71 public:
72 
73  /**
74  * Class with fields that are common to all transport models.
75  */
76  class TransportEqData : public FieldSet {
77  public:
78 
80  inline virtual ~TransportEqData() {};
81 /*
82  Input::Type::Record boundary_input_type() {
83  return EqDataBase::boundary_input_type()
84  .declare_key(OldBcdInput::transport_old_bcd_file_key(), IT::FileName::input(), "Input file with boundary conditions (obsolete).");
85  }
86 */
87  /// Mobile porosity
89 
90  /// Pointer to DarcyFlow field cross_section
92 
93  /// Concentration sources - density of substance source, only positive part is used.
95  /// Concentration sources - Robin type, in_flux = sources_sigma * (sources_conc - mobile_conc)
98 
99  };
100 
101  /**
102  * Specification of the output record. Need not to be used by all transport models, but they should
103  * allow output of similar fields.
104  */
106 
107  TransportBase(Mesh &mesh, const Input::Record in_rec);
108  virtual ~TransportBase();
109 
110  virtual void set_velocity_field(const MH_DofHandler &dh) {
111  mh_dh=&dh;
112  }
113 
114 
115 
116  /**
117  * @brief Sets pointer to data of other equations.
118  * TODO: there should be also passed the sigma parameter between dimensions
119  * @param cross_section is pointer to cross_section data of Darcy flow equation
120  */
121  //virtual void set_cross_section_field(Field<3, FieldValue<3>::Scalar > *cross_section) =0;
122 
123  /**
124  * Getter for mass balance class
125  */
127 
128  /// Returns number of trnasported substances.
129  inline unsigned int n_substances() { return n_subst_; }
130 
131  /// Returns reference to the vector of substnace names.
133 
134  virtual void set_concentration_vector(Vec &vec){};
135 
136 
137 protected:
138 
139  /// Returns the region database.
140  const RegionDB *region_db() { return &mesh_->region_db(); }
141 
142  /// Number of transported substances.
143  unsigned int n_subst_;
144 
145  /// Names of transported substances.
147 
148  /**
149  * Temporary solution how to pass velocity field form the flow model.
150  * TODO: introduce FieldDiscrete -containing true DOFHandler and data vector and pass such object together with other
151  * data. Possibly make more general set_data method, allowing setting data given by name. needs support from EqDataBase.
152  */
154 
155  /**
156  * Mark type mask that is true for time marks of output points of the transport model.
157  * E.g. for TransportOperatorSplitting this is same as the output points of its transport sub-model.
158  */
159  //TimeMark::Type output_mark_type;
160 
161  /// object for calculation and writing the mass balance to file.
163 };
164 
165 
166 
167 /**
168  * @brief Empty transport class.
169  */
171 public:
172  inline TransportNothing(Mesh &mesh_in)
173  : TransportBase(mesh_in, Input::Record() )
174  {
175  // make module solved for ever
176  time_=new TimeGovernor();
177  time_->next_time();
178  };
179 
180  inline virtual ~TransportNothing()
181  {}
182 
183  inline virtual void output_data() {};
184 
185  void set_cross_section_field(const Field< 3, FieldValue<3>::Scalar > &cross_section) {};
186 
188 
189 private:
190 
191  inline void calc_fluxes(vector<vector<double> > &bcd_balance, vector<vector<double> > &bcd_plus_balance, vector<vector<double> > &bcd_minus_balance) {};
192  inline void calc_elem_sources(vector<vector<double> > &mass, vector<vector<double> > &src_balance) {};
193 
194 };
195 
196 
197 
198 /**
199  * @brief Coupling of a transport model with a reaction model by operator splitting.
200  *
201  * Outline:
202  * Transport model is any descendant of TransportBase (even TransportOperatorSplitting itself). This
203  * should perform the transport possibly with diffusion and usually without coupling between substances and phases.
204  *
205  * Reaction is any descendant of the ReactionBase class. This represents reactions in general way of any coupling that
206  * happens between substances and phases on one element or more generally on one DoF.
207  */
208 
210 public:
211 
212  /**
213  * @brief Declare input record type for the equation TransportOperatorSplittiong.
214  *
215  * TODO: The question is if this should be a general coupling class
216  * (e.g. allow coupling TranportDG with reactions even if it is not good idea for numerical reasons.)
217  * To make this a coupling class we should modify all main input files for transport problems.
218  */
220 
221  /// Constructor.
222  TransportOperatorSplitting(Mesh &init_mesh, const Input::Record &in_rec);
223  /// Destructor.
224  virtual ~TransportOperatorSplitting();
225 
226 
227  virtual void set_velocity_field(const MH_DofHandler &dh);
228 
229  void zero_time_step() override;
230  void update_solution() override;
231  //virtual void compute_one_step();
232  //virtual void compute_until();
233 
234 // DELETE
235 // virtual void get_parallel_solution_vector(Vec &vc);
236 // virtual void get_solution_vector(double* &vector, unsigned int &size);
237 
239  void compute_internal_step();
240  void output_data();
241 
242 
243  /**
244  * @brief Sets pointer to data of other equations.
245  * TODO: there should be also passed the sigma parameter between dimensions
246  * @param cross_section is pointer to cross_section data of Darcy flow equation
247  */
248  //void set_cross_section_field(const Field< 3, FieldValue<3>::Scalar > &cross_section);
249 
251 
252 
253 private:
254  /**
255  * Implements the virtual method EquationForMassBalance::calc_fluxes().
256  */
257  void calc_fluxes(vector<vector<double> > &bcd_balance, vector<vector<double> > &bcd_plus_balance, vector<vector<double> > &bcd_minus_balance);
258  /**
259  * Implements the virtual method EquationForMassBalance::calc_elem_sources().
260  */
261  void calc_elem_sources(vector<vector<double> > &mass, vector<vector<double> > &src_balance);
262 
265 
267  //int steps;
268 
269 
270 };
271 
272 
273 
274 
275 
276 #endif // TRANSPORT_OPERATOR_SPLITTING_HH_