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 get_solution_vector(double * &vector, unsigned int &size) {
184  ASSERT( 0 , "Empty transport class do not provide solution!");
185  }
186 
188  ASSERT( 0 , "Empty transport class do not provide solution!");
189  };
190 
191  inline virtual void output_data() {};
192 
193  void set_cross_section_field(const Field< 3, FieldValue<3>::Scalar > &cross_section) {};
194 
196 
197 private:
198 
199  inline void calc_fluxes(vector<vector<double> > &bcd_balance, vector<vector<double> > &bcd_plus_balance, vector<vector<double> > &bcd_minus_balance) {};
200  inline void calc_elem_sources(vector<vector<double> > &mass, vector<vector<double> > &src_balance) {};
201 
202 };
203 
204 
205 
206 /**
207  * @brief Coupling of a transport model with a reaction model by operator splitting.
208  *
209  * Outline:
210  * Transport model is any descendant of TransportBase (even TransportOperatorSplitting itself). This
211  * should perform the transport possibly with diffusion and usually without coupling between substances and phases.
212  *
213  * Reaction is any descendant of the ReactionBase class. This represents reactions in general way of any coupling that
214  * happens between substances and phases on one element or more generally on one DoF.
215  */
216 
218 public:
219 
220  /**
221  * @brief Declare input record type for the equation TransportOperatorSplittiong.
222  *
223  * TODO: The question is if this should be a general coupling class
224  * (e.g. allow coupling TranportDG with reactions even if it is not good idea for numerical reasons.)
225  * To make this a coupling class we should modify all main input files for transport problems.
226  */
228 
229  /// Constructor.
230  TransportOperatorSplitting(Mesh &init_mesh, const Input::Record &in_rec);
231  /// Destructor.
232  virtual ~TransportOperatorSplitting();
233 
234 
235  virtual void set_velocity_field(const MH_DofHandler &dh);
236 
237  void zero_time_step() override;
238  void update_solution() override;
239  //virtual void compute_one_step();
240  //virtual void compute_until();
241  virtual void get_parallel_solution_vector(Vec &vc);
242  virtual void get_solution_vector(double* &vector, unsigned int &size);
243 
245  void compute_internal_step();
246  void output_data();
247 
248 
249  /**
250  * @brief Sets pointer to data of other equations.
251  * TODO: there should be also passed the sigma parameter between dimensions
252  * @param cross_section is pointer to cross_section data of Darcy flow equation
253  */
254  //void set_cross_section_field(const Field< 3, FieldValue<3>::Scalar > &cross_section);
255 
257 
258 
259 private:
260  /**
261  * Implements the virtual method EquationForMassBalance::calc_fluxes().
262  */
263  void calc_fluxes(vector<vector<double> > &bcd_balance, vector<vector<double> > &bcd_plus_balance, vector<vector<double> > &bcd_minus_balance);
264  /**
265  * Implements the virtual method EquationForMassBalance::calc_elem_sources().
266  */
267  void calc_elem_sources(vector<vector<double> > &mass, vector<vector<double> > &src_balance);
268 
271 
273  //int steps;
274 
275 
276 };
277 
278 
279 
280 
281 
282 #endif // TRANSPORT_OPERATOR_SPLITTING_HH_