Flow123d  JS_before_hm-927-g0a4a2b5
concentration_model.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 concentration_model.hh
15  * @brief Discontinuous Galerkin method for equation of transport with dispersion.
16  * @author Jan Stebel
17  */
18 
19 #ifndef CONC_TRANS_MODEL_HH_
20 #define CONC_TRANS_MODEL_HH_
21 
22 #include <boost/exception/info.hpp> // for operator<<, err...
23 #include <memory> // for shared_ptr
24 #include <string> // for string
25 #include <vector> // for vector
26 #include <armadillo>
28 #include "fields/field_values.hh" // for FieldValue<>::S...
29 #include "fields/bc_multi_field.hh"
30 #include "fields/field.hh"
31 #include "fields/multi_field.hh"
32 #include "input/type_base.hh" // for Array
33 #include "input/type_generic.hh" // for Instance
34 #include "input/type_record.hh" // for Record
35 #include "input/type_selection.hh" // for Selection
36 #include "transport/substance.hh" // for SubstanceList
37 #include "transport/transport_operator_splitting.hh" // for ConcentrationTr...
38 
39 class Balance;
40 class Mesh;
41 class OutputTime;
42 namespace Input { class Record; }
43 template <int spacedim> class ElementAccessor;
44 
45 
46 
47 
49 public:
50 
51  class ModelEqData : public TransportEqData {
52  public:
53 
58  bc_diffusive_flux
59  };
60 
61  /// Type of boundary condition (see also BC_Type)
63  /// Prescribed concentration for Dirichlet/reference concentration for flux b.c.
65  /// Flux value in total/diffusive flux b.c.
67  /// Transition coefficient in total/diffusive flux b.c.
69  /// Initial concentrations.
71  /// Longitudal dispersivity (for each substance).
73  /// Transversal dispersivity (for each substance).
75  /// Molecular diffusivity (for each substance).
77 
78  Field<3, FieldValue<3>::Scalar > rock_density; ///< Rock matrix density.
79  MultiField<3, FieldValue<3>::Scalar > sorption_coefficient; ///< Coefficient of linear sorption.
80 
81 
83 
84 
85 
86  ModelEqData();
87 
88  static constexpr const char * name() { return "Solute_AdvectionDiffusion"; }
89 
90  static string default_output_field() { return "\"conc\""; }
91 
92  static const Input::Type::Selection & get_bc_type_selection();
93 
94  static IT::Selection get_output_selection();
95 
96  };
97 
98 
100 
101 
102  ConcentrationTransportModel(Mesh &mesh, const Input::Record &in_rec);
103 
104  void init_from_input(const Input::Record &in_rec) override;
105 
106  void compute_mass_matrix_coefficient(const Armor::array &point_list,
107  const ElementAccessor<3> &ele_acc,
108  std::vector<double> &mm_coef) override;
109 
110  void compute_retardation_coefficient(const Armor::array &point_list,
111  const ElementAccessor<3> &ele_acc,
112  std::vector<std::vector<double> > &ret_coef) override;
113 
114 
115 
116  void compute_advection_diffusion_coefficients(const Armor::array &point_list,
117  const std::vector<arma::vec3> &velocity,
118  const ElementAccessor<3> &ele_acc,
120  std::vector<std::vector<arma::mat33> > &dif_coef) override;
121 
122  void compute_init_cond(const Armor::array &point_list,
123  const ElementAccessor<3> &ele_acc,
124  std::vector<std::vector<double> > &init_values) override;
125 
126  void get_bc_type(const ElementAccessor<3> &ele_acc,
127  arma::uvec &bc_types) override;
128 
129  void get_flux_bc_data(unsigned int index,
130  const Armor::array &point_list,
131  const ElementAccessor<3> &ele_acc,
132  std::vector< double > &bc_flux,
133  std::vector< double > &bc_sigma,
134  std::vector< double > &bc_ref_value) override;
135 
136  void get_flux_bc_sigma(unsigned int index,
137  const Armor::array &point_list,
138  const ElementAccessor<3> &ele_acc,
139  std::vector< double > &bc_sigma) override;
140 
141  void compute_source_coefficients(const Armor::array &point_list,
142  const ElementAccessor<3> &ele_acc,
143  std::vector<std::vector<double> > &sources_conc,
144  std::vector<std::vector<double> > &sources_density,
145  std::vector<std::vector<double> > &sources_sigma) override;
146 
147  void compute_sources_sigma(const Armor::array &point_list,
148  const ElementAccessor<3> &ele_acc,
149  std::vector<std::vector<double> > &sources_sigma) override;
150 
151  ~ConcentrationTransportModel() override;
152 
153 
154  /**
155  * @brief Updates the velocity field which determines some coefficients of the transport equation.
156  *
157  * @param dh mixed hybrid dof handler
158  *
159  * (So far it does not work since the flow module returns a vector of zeros.)
160  * @param velocity_vector Input array of velocity values.
161  */
162  inline void set_velocity_field(std::shared_ptr<FieldFE<3, FieldValue<3>::VectorFixed>> flux_field) override
163  {
164  velocity_field_ptr_ = flux_field;
165  flux_changed = true;
166  }
167 
168  /// Returns number of transported substances.
169  inline unsigned int n_substances() override
170  { return substances_.size(); }
171 
172  /// Returns reference to the vector of substance names.
173  inline SubstanceList &substances() override
174  { return substances_; }
175 
176 
177  // Methods inherited from ConcentrationTransportBase:
178 
179  // Must be implemented in descendants.
180  void set_target_time(double) override {};
181 
182  void set_balance_object(std::shared_ptr<Balance> balance) override;
183 
185  { return subst_idx; }
186 
187  void set_output_stream(std::shared_ptr<OutputTime> stream)
188  { output_stream_ = stream; }
189 
190  std::shared_ptr<OutputTime> output_stream() override
191  { return output_stream_; }
192 
193  std::shared_ptr<FieldFE<3, FieldValue<3>::VectorFixed>> velocity_field_ptr() const {
194  return this->velocity_field_ptr_;
195  }
196 
197 
198 
199 protected:
200 
201  /// Derived class should implement getter for ModelEqData instance.
202  virtual ModelEqData &data() = 0;
203 
204  /**
205  * Create input type that can be passed to the derived class.
206  * @param implementation String characterizing the numerical method, e.g. DG, FEM, FVM.
207  * @param description Comment used to describe the record key.
208  * @return
209  */
210  static IT::Record get_input_type(const string &implementation, const string &description);
211 
212  /**
213  * Formula to calculate the dispersivity tensor.
214  * @param velocity Fluid velocity.
215  * @param Dm Molecular diffusivity.
216  * @param alphaL Longitudal dispersivity.
217  * @param alphaT Transversal dispersivity.
218  * @param porosity Porosity.
219  * @param cross_cut Cross-section.
220  * @param K Dispersivity tensor (output).
221  */
222  void calculate_dispersivity_tensor(const arma::vec3 &velocity,
223  const arma::mat33 &Dm,
224  double alphaL,
225  double alphaT,
226  double water_content,
227  double porosity,
228  double cross_cut,
229  arma::mat33 &K);
230 
231  /// Indicator of change in advection vector field.
233 
234  /// Transported substances.
236 
237  /// List of indices used to call balance methods for a set of quantities.
239 
240  /// Density of liquid (a global constant).
242 
243  std::shared_ptr<OutputTime> output_stream_;
244 
245  /// Pointer to velocity field given from Flow equation.
246  std::shared_ptr<FieldFE<3, FieldValue<3>::VectorFixed>> velocity_field_ptr_;
247 
248 
249 };
250 
251 
252 
253 
254 
255 
256 
257 
258 #endif /* CONC_TRANS_MODEL_HH_ */
SubstanceList substances_
Transported substances.
MultiField< 3, FieldValue< 3 >::Scalar > output_field
MultiField< 3, FieldValue< 3 >::Scalar > init_conc
Initial concentrations.
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::VectorFixed > > velocity_field_ptr() const
void set_output_stream(std::shared_ptr< OutputTime > stream)
Setter for output stream.
MultiField< 3, FieldValue< 3 >::Scalar > sorption_coefficient
Coefficient of linear sorption.
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
SubstanceList & substances() override
Returns reference to the vector of substance names.
Definition: mesh.h:78
ConcentrationTransportBase FactoryBaseType
bool flux_changed
Indicator of change in advection vector field.
static constexpr const char * name()
double solvent_density_
Density of liquid (a global constant).
Field< 3, FieldValue< 3 >::Scalar > rock_density
Rock matrix density.
const vector< unsigned int > & get_subst_idx()
Return substance indices used in balance.
MultiField< 3, FieldValue< 3 >::Scalar > disp_t
Transversal dispersivity (for each substance).
BCMultiField< 3, FieldValue< 3 >::Enum > bc_type
Type of boundary condition (see also BC_Type)
BCMultiField< 3, FieldValue< 3 >::Scalar > bc_dirichlet_value
Prescribed concentration for Dirichlet/reference concentration for flux b.c.
Accessor to the data with type Type::Record.
Definition: accessors.hh:292
unsigned int n_substances() override
Returns number of transported substances.
The class for outputting data during time.
Definition: output_time.hh:50
BCMultiField< 3, FieldValue< 3 >::Scalar > bc_robin_sigma
Transition coefficient in total/diffusive flux b.c.
void set_velocity_field(std::shared_ptr< FieldFE< 3, FieldValue< 3 >::VectorFixed >> flux_field) override
Updates the velocity field which determines some coefficients of the transport equation.
std::shared_ptr< OutputTime > output_stream() override
Getter for output stream.
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::VectorFixed > > velocity_field_ptr_
Pointer to velocity field given from Flow equation.
MultiField< 3, FieldValue< 3 >::Scalar > disp_l
Longitudal dispersivity (for each substance).
Discontinuous Galerkin method for equation of transport with dispersion.
std::shared_ptr< OutputTime > output_stream_
BCMultiField< 3, FieldValue< 3 >::Scalar > bc_flux
Flux value in total/diffusive flux b.c.
Classes for storing substance data.
void set_target_time(double) override
MultiField< 3, FieldValue< 3 >::TensorFixed > diff_m
Molecular diffusivity (for each substance).
vector< unsigned int > subst_idx
List of indices used to call balance methods for a set of quantities.
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:89
Template for classes storing finite set of named values.
Definition: field.hh:60