Flow123d  release_3.0.0-968-gc87a28e79
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 
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 MH_DofHandler;
41 class Mesh;
42 class OutputTime;
43 namespace Input { class Record; }
44 template <int spacedim> class ElementAccessor;
45 
46 
47 
48 
50 public:
51 
52  class ModelEqData : public TransportEqData {
53  public:
54 
60  };
61 
62  /// Type of boundary condition (see also BC_Type)
64  /// Prescribed concentration for Dirichlet/reference concentration for flux b.c.
66  /// Flux value in total/diffusive flux b.c.
68  /// Transition coefficient in total/diffusive flux b.c.
70  /// Initial concentrations.
72  /// Longitudal dispersivity (for each substance).
74  /// Transversal dispersivity (for each substance).
76  /// Molecular diffusivity (for each substance).
78 
79  Field<3, FieldValue<3>::Scalar > rock_density; ///< Rock matrix density.
80  MultiField<3, FieldValue<3>::Scalar > sorption_coefficient; ///< Coefficient of linear sorption.
81 
82 
84 
85 
86 
87  ModelEqData();
88 
89  static constexpr const char * name() { return "Solute_AdvectionDiffusion"; }
90 
91  static string default_output_field() { return "\"conc\""; }
92 
94 
96 
97  };
98 
99 
101 
102 
104 
105  void init_from_input(const Input::Record &in_rec) override;
106 
108  const ElementAccessor<3> &ele_acc,
109  std::vector<double> &mm_coef) override;
110 
112  const ElementAccessor<3> &ele_acc,
113  std::vector<std::vector<double> > &ret_coef) override;
114 
115 
116 
118  const std::vector<arma::vec3> &velocity,
119  const ElementAccessor<3> &ele_acc,
121  std::vector<std::vector<arma::mat33> > &dif_coef) override;
122 
123  void compute_init_cond(const std::vector<arma::vec3> &point_list,
124  const ElementAccessor<3> &ele_acc,
125  std::vector<std::vector<double> > &init_values) override;
126 
127  void get_bc_type(const ElementAccessor<3> &ele_acc,
128  arma::uvec &bc_types) override;
129 
130  void get_flux_bc_data(unsigned int index,
131  const std::vector<arma::vec3> &point_list,
132  const ElementAccessor<3> &ele_acc,
133  std::vector< double > &bc_flux,
134  std::vector< double > &bc_sigma,
135  std::vector< double > &bc_ref_value) override;
136 
137  void get_flux_bc_sigma(unsigned int index,
138  const std::vector<arma::vec3> &point_list,
139  const ElementAccessor<3> &ele_acc,
140  std::vector< double > &bc_sigma) override;
141 
143  const ElementAccessor<3> &ele_acc,
144  std::vector<std::vector<double> > &sources_conc,
145  std::vector<std::vector<double> > &sources_density,
146  std::vector<std::vector<double> > &sources_sigma) override;
147 
148  void compute_sources_sigma(const std::vector<arma::vec3> &point_list,
149  const ElementAccessor<3> &ele_acc,
150  std::vector<std::vector<double> > &sources_sigma) override;
151 
152  ~ConcentrationTransportModel() override;
153 
154 
155  /**
156  * @brief Updates the velocity field which determines some coefficients of the transport equation.
157  *
158  * @param dh mixed hybrid dof handler
159  *
160  * (So far it does not work since the flow module returns a vector of zeros.)
161  * @param velocity_vector Input array of velocity values.
162  */
163  inline void set_velocity_field(const MH_DofHandler &dh) override
164  {
165  mh_dh = &dh;
166  flux_changed = true;
167  }
168 
169  /// Returns number of transported substances.
170  inline unsigned int n_substances() override
171  { return substances_.size(); }
172 
173  /// Returns reference to the vector of substance names.
174  inline SubstanceList &substances() override
175  { return substances_; }
176 
177 
178  // Methods inherited from ConcentrationTransportBase:
179 
180  void set_target_time(double target_time) 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 
194 
195 protected:
196 
197  /// Derived class should implement getter for ModelEqData instance.
198  virtual ModelEqData &data() = 0;
199 
200  /**
201  * Create input type that can be passed to the derived class.
202  * @param implementation String characterizing the numerical method, e.g. DG, FEM, FVM.
203  * @param description Comment used to describe the record key.
204  * @return
205  */
206  static IT::Record get_input_type(const string &implementation, const string &description);
207 
208  /**
209  * Formula to calculate the dispersivity tensor.
210  * @param velocity Fluid velocity.
211  * @param Dm Molecular diffusivity.
212  * @param alphaL Longitudal dispersivity.
213  * @param alphaT Transversal dispersivity.
214  * @param porosity Porosity.
215  * @param cross_cut Cross-section.
216  * @param K Dispersivity tensor (output).
217  */
218  void calculate_dispersivity_tensor(const arma::vec3 &velocity,
219  const arma::mat33 &Dm,
220  double alphaL,
221  double alphaT,
222  double water_content,
223  double porosity,
224  double cross_cut,
225  arma::mat33 &K);
226 
227  /// Indicator of change in advection vector field.
229 
230  /// Transported substances.
232 
233  /// List of indices used to call balance methods for a set of quantities.
235 
236  /// Density of liquid (a global constant).
238 
239  /**
240  * Temporary solution how to pass velocity field form the flow model.
241  * TODO: introduce FieldDiscrete -containing true DOFHandler and data vector and pass such object together with other
242  * data. Possibly make more general set_data method, allowing setting data given by name. needs support from EqDataBase.
243  */
245 
246  std::shared_ptr<OutputTime> output_stream_;
247 
248 
249 
250 };
251 
252 
253 
254 
255 
256 
257 
258 
259 #endif /* CONC_TRANS_MODEL_HH_ */
ConcentrationTransportModel::ModelEqData::bc_type
BCMultiField< 3, FieldValue< 3 >::Enum > bc_type
Type of boundary condition (see also BC_Type)
Definition: concentration_model.hh:63
ConcentrationTransportModel::ModelEqData::get_output_selection
static IT::Selection get_output_selection()
Definition: concentration_model.cc:153
ConcentrationTransportModel::ModelEqData::bc_inflow
@ bc_inflow
Definition: concentration_model.hh:56
ConcentrationTransportModel::n_substances
unsigned int n_substances() override
Returns number of transported substances.
Definition: concentration_model.hh:170
ConcentrationTransportModel::calculate_dispersivity_tensor
void calculate_dispersivity_tensor(const arma::vec3 &velocity, const arma::mat33 &Dm, double alphaL, double alphaT, double water_content, double porosity, double cross_cut, arma::mat33 &K)
Definition: concentration_model.cc:218
ConcentrationTransportModel::set_target_time
void set_target_time(double target_time) override
Definition: concentration_model.hh:180
ConcentrationTransportModel::set_balance_object
void set_balance_object(std::shared_ptr< Balance > balance) override
Definition: concentration_model.cc:374
ConcentrationTransportModel::compute_init_cond
void compute_init_cond(const std::vector< arma::vec3 > &point_list, const ElementAccessor< 3 > &ele_acc, std::vector< std::vector< double > > &init_values) override
Definition: concentration_model.cc:286
ConcentrationTransportModel::ModelEqData::ModelEqData
ModelEqData()
Definition: concentration_model.cc:67
Input
Abstract linear system class.
Definition: balance.hh:37
SubstanceList::size
unsigned int size() const
Definition: substance.hh:87
SubstanceList
Definition: substance.hh:70
TransportEqData
Definition: transport_operator_splitting.hh:147
Balance
Definition: balance.hh:116
ConcentrationTransportModel::ModelEqData::bc_robin_sigma
BCMultiField< 3, FieldValue< 3 >::Scalar > bc_robin_sigma
Transition coefficient in total/diffusive flux b.c.
Definition: concentration_model.hh:69
ConcentrationTransportModel::compute_advection_diffusion_coefficients
void compute_advection_diffusion_coefficients(const std::vector< arma::vec3 > &point_list, const std::vector< arma::vec3 > &velocity, const ElementAccessor< 3 > &ele_acc, std::vector< std::vector< arma::vec3 > > &ad_coef, std::vector< std::vector< arma::mat33 > > &dif_coef) override
Definition: concentration_model.cc:255
substance.hh
Classes for storing substance data.
AdvectionDiffusionModel
Definition: advection_diffusion_model.hh:35
ConcentrationTransportModel::ModelEqData::diff_m
MultiField< 3, FieldValue< 3 >::TensorFixed > diff_m
Molecular diffusivity (for each substance).
Definition: concentration_model.hh:77
ConcentrationTransportModel::set_output_stream
void set_output_stream(std::shared_ptr< OutputTime > stream)
Setter for output stream.
Definition: concentration_model.hh:187
ConcentrationTransportModel::init_from_input
void init_from_input(const Input::Record &in_rec) override
Read necessary data from input record.
Definition: concentration_model.cc:170
ConcentrationTransportModel::compute_sources_sigma
void compute_sources_sigma(const std::vector< arma::vec3 > &point_list, const ElementAccessor< 3 > &ele_acc, std::vector< std::vector< double > > &sources_sigma) override
Definition: concentration_model.cc:353
std::vector< arma::vec3 >
ConcentrationTransportModel::compute_source_coefficients
void compute_source_coefficients(const std::vector< arma::vec3 > &point_list, const ElementAccessor< 3 > &ele_acc, std::vector< std::vector< double > > &sources_conc, std::vector< std::vector< double > > &sources_density, std::vector< std::vector< double > > &sources_sigma) override
Definition: concentration_model.cc:329
ElementAccessor
Definition: fe_value_handler.hh:29
ConcentrationTransportModel::ModelEqData::rock_density
Field< 3, FieldValue< 3 >::Scalar > rock_density
Rock matrix density.
Definition: concentration_model.hh:79
ConcentrationTransportModel::FactoryBaseType
ConcentrationTransportBase FactoryBaseType
Definition: concentration_model.hh:100
ConcentrationTransportModel::substances_
SubstanceList substances_
Transported substances.
Definition: concentration_model.hh:231
arma::vec3
Definition: doxy_dummy_defs.hh:17
ConcentrationTransportModel
Definition: concentration_model.hh:49
ConcentrationTransportModel::mh_dh
const MH_DofHandler * mh_dh
Definition: concentration_model.hh:244
ConcentrationTransportModel::compute_retardation_coefficient
void compute_retardation_coefficient(const std::vector< arma::vec3 > &point_list, const ElementAccessor< 3 > &ele_acc, std::vector< std::vector< double > > &ret_coef) override
Definition: concentration_model.cc:192
advection_diffusion_model.hh
Discontinuous Galerkin method for equation of transport with dispersion.
ConcentrationTransportModel::ModelEqData::disp_t
MultiField< 3, FieldValue< 3 >::Scalar > disp_t
Transversal dispersivity (for each substance).
Definition: concentration_model.hh:75
type_base.hh
type_selection.hh
ConcentrationTransportModel::output_stream_
std::shared_ptr< OutputTime > output_stream_
Definition: concentration_model.hh:246
ConcentrationTransportModel::ModelEqData::bc_dirichlet_value
BCMultiField< 3, FieldValue< 3 >::Scalar > bc_dirichlet_value
Prescribed concentration for Dirichlet/reference concentration for flux b.c.
Definition: concentration_model.hh:65
type_record.hh
ConcentrationTransportModel::get_flux_bc_sigma
void get_flux_bc_sigma(unsigned int index, const std::vector< arma::vec3 > &point_list, const ElementAccessor< 3 > &ele_acc, std::vector< double > &bc_sigma) override
Return transition coefficient for flux b.c.
Definition: concentration_model.cc:320
ConcentrationTransportModel::output_stream
std::shared_ptr< OutputTime > output_stream() override
Getter for output stream.
Definition: concentration_model.hh:190
ConcentrationTransportModel::ModelEqData::Concentration_bc_types
Concentration_bc_types
Definition: concentration_model.hh:55
ConcentrationTransportModel::get_subst_idx
const vector< unsigned int > & get_subst_idx() override
Return substance indices used in balance.
Definition: concentration_model.hh:184
EquationBase::mesh
Mesh & mesh()
Definition: equation.hh:174
ConcentrationTransportModel::set_velocity_field
void set_velocity_field(const MH_DofHandler &dh) override
Updates the velocity field which determines some coefficients of the transport equation.
Definition: concentration_model.hh:163
ConcentrationTransportModel::ModelEqData::bc_dirichlet
@ bc_dirichlet
Definition: concentration_model.hh:57
Input::Record
Accessor to the data with type Type::Record.
Definition: accessors.hh:291
ConcentrationTransportModel::~ConcentrationTransportModel
~ConcentrationTransportModel() override
Definition: concentration_model.cc:370
type_generic.hh
ConcentrationTransportModel::ModelEqData::output_field
MultiField< 3, FieldValue< 3 >::Scalar > output_field
Definition: concentration_model.hh:83
bc_multi_field.hh
ConcentrationTransportModel::ModelEqData::get_bc_type_selection
static const Input::Type::Selection & get_bc_type_selection()
Definition: concentration_model.cc:37
field_values.hh
OutputTime
The class for outputting data during time.
Definition: output_time.hh:50
ConcentrationTransportModel::substances
SubstanceList & substances() override
Returns reference to the vector of substance names.
Definition: concentration_model.hh:174
Input::Type::Selection
Template for classes storing finite set of named values.
Definition: type_selection.hh:65
ConcentrationTransportModel::data
virtual ModelEqData & data()=0
Derived class should implement getter for ModelEqData instance.
ConcentrationTransportModel::ModelEqData::bc_diffusive_flux
@ bc_diffusive_flux
Definition: concentration_model.hh:59
Input::Type::Record
Record type proxy class.
Definition: type_record.hh:182
ConcentrationTransportModel::ModelEqData::sorption_coefficient
MultiField< 3, FieldValue< 3 >::Scalar > sorption_coefficient
Coefficient of linear sorption.
Definition: concentration_model.hh:80
ConcentrationTransportModel::flux_changed
bool flux_changed
Indicator of change in advection vector field.
Definition: concentration_model.hh:228
ConcentrationTransportModel::ModelEqData::bc_flux
BCMultiField< 3, FieldValue< 3 >::Scalar > bc_flux
Flux value in total/diffusive flux b.c.
Definition: concentration_model.hh:67
BCMultiField
Definition: bc_multi_field.hh:29
ConcentrationTransportBase
Definition: transport_operator_splitting.hh:61
Mesh
Definition: mesh.h:80
multi_field.hh
ConcentrationTransportModel::solvent_density_
double solvent_density_
Density of liquid (a global constant).
Definition: concentration_model.hh:237
ConcentrationTransportModel::get_flux_bc_data
void get_flux_bc_data(unsigned int index, const std::vector< arma::vec3 > &point_list, const ElementAccessor< 3 > &ele_acc, std::vector< double > &bc_flux, std::vector< double > &bc_sigma, std::vector< double > &bc_ref_value) override
Return data for diffusive or total flux b.c.
Definition: concentration_model.cc:305
ConcentrationTransportModel::ConcentrationTransportModel
ConcentrationTransportModel(Mesh &mesh, const Input::Record &in_rec)
Definition: concentration_model.cc:163
MultiField
Class for representation of a vector of fields of the same physical quantity.
Definition: multi_field.hh:85
ConcentrationTransportModel::compute_mass_matrix_coefficient
void compute_mass_matrix_coefficient(const std::vector< arma::vec3 > &point_list, const ElementAccessor< 3 > &ele_acc, std::vector< double > &mm_coef) override
Definition: concentration_model.cc:177
ConcentrationTransportModel::ModelEqData::name
static constexpr const char * name()
Definition: concentration_model.hh:89
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
ConcentrationTransportModel::get_bc_type
void get_bc_type(const ElementAccessor< 3 > &ele_acc, arma::uvec &bc_types) override
Definition: concentration_model.cc:294
ConcentrationTransportModel::ModelEqData::disp_l
MultiField< 3, FieldValue< 3 >::Scalar > disp_l
Longitudal dispersivity (for each substance).
Definition: concentration_model.hh:73
ConcentrationTransportModel::ModelEqData::default_output_field
static string default_output_field()
Definition: concentration_model.hh:91
Field
Class template representing a field with values dependent on: point, element, and region.
Definition: field.hh:83
ConcentrationTransportModel::ModelEqData
Definition: concentration_model.hh:52
transport_operator_splitting.hh
ConcentrationTransportModel::ModelEqData::bc_total_flux
@ bc_total_flux
Definition: concentration_model.hh:58
MH_DofHandler
Definition: mh_dofhandler.hh:43
field.hh
ConcentrationTransportModel::subst_idx
vector< unsigned int > subst_idx
List of indices used to call balance methods for a set of quantities.
Definition: concentration_model.hh:234
arma::mat33
Definition: doxy_dummy_defs.hh:18
ConcentrationTransportModel::ModelEqData::init_conc
MultiField< 3, FieldValue< 3 >::Scalar > init_conc
Initial concentrations.
Definition: concentration_model.hh:71