Flow123d  JS_before_hm-2196-g9bdbf60c0
assembly_reaction.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 assembly_reaction.hh
15  * @brief
16  */
17 
18 #ifndef ASSEMBLY_REACTION_HH_
19 #define ASSEMBLY_REACTION_HH_
20 
24 #include "fem/fe_p.hh"
25 #include "fem/fe_values.hh"
27 //#include "coupling/balance.hh"
29 
30 
31 
32 template <unsigned int dim>
34 {
35 public:
36  typedef typename DualPorosity::EqFields EqFields;
37  typedef typename DualPorosity::EqData EqData;
38 
39  static constexpr const char * name() { return "InitConditionAssemblyDp"; }
40 
41  /// Constructor.
42  InitConditionAssemblyDp(EqFields *eq_fields, EqData *eq_data)
43  : AssemblyBase<dim>(0), eq_fields_(eq_fields), eq_data_(eq_data) {
46  }
47 
48  /// Destructor.
50 
51  /// Initialize auxiliary vectors and other data members
52  void initialize(ElementCacheMap *element_cache_map) {
53  //this->balance_ = eq_data_->balance_;
54  this->element_cache_map_ = element_cache_map;
55  }
56 
57 
58  /// Assemble integral over element
59  inline void cell_integral(DHCellAccessor cell, unsigned int element_patch_idx)
60  {
61  ASSERT_EQ_DBG(cell.dim(), dim).error("Dimension of element mismatch!");
62 
63  dof_p0_ = cell.get_loc_dof_indices()[0];
64  auto p = *( this->bulk_points(element_patch_idx).begin() );
65 
66  //setting initial solid concentration for substances involved in adsorption
67  for (unsigned int sbi = 0; sbi < eq_data_->substances_.size(); sbi++)
68  {
69  eq_fields_->conc_immobile_fe[sbi]->vec().set( dof_p0_, eq_fields_->init_conc_immobile[sbi](p) );
70  }
71  }
72 
73 
74 private:
75  /// Data objects shared with Elasticity
78 
79  /// Sub field set contains fields used in calculation.
81 
82  IntIdx dof_p0_; ///< Index of local DOF
83 
84  template < template<IntDim...> class DimAssembly>
85  friend class GenericAssembly;
86 };
87 
88 template <unsigned int dim>
89 class ReactionAssemblyDp : public AssemblyBase<dim>
90 {
91 public:
92  typedef typename DualPorosity::EqFields EqFields;
93  typedef typename DualPorosity::EqData EqData;
94 
95  static constexpr const char * name() { return "InitConditionAssemblyDp"; }
96 
97  /// Constructor.
98  ReactionAssemblyDp(EqFields *eq_fields, EqData *eq_data)
99  : AssemblyBase<dim>(0), eq_fields_(eq_fields), eq_data_(eq_data) {
101  this->used_fields_ += eq_fields_->porosity;
104  }
105 
106  /// Destructor.
108 
109  /// Initialize auxiliary vectors and other data members
110  void initialize(ElementCacheMap *element_cache_map) {
111  //this->balance_ = eq_data_->balance_;
112  this->element_cache_map_ = element_cache_map;
113  }
114 
115 
116  /// Assemble integral over element
117  inline void cell_integral(DHCellAccessor cell, unsigned int element_patch_idx)
118  {
119  ASSERT_EQ_DBG(cell.dim(), dim).error("Dimension of element mismatch!");
120 
121  auto p = *( this->bulk_points(element_patch_idx).begin() );
122 
123  // if porosity_immobile == 0 then mobile concentration stays the same
124  // and immobile concentration cannot change
126  if (por_immob_ == 0.0) return;
127 
128  // get data from fields
129  dof_p0_ = cell.get_loc_dof_indices()[0];
131  arma::Col<double> diff_vec(eq_data_->substances_.size());
132  for (sbi_=0; sbi_<eq_data_->substances_.size(); sbi_++) // Optimize: SWAP LOOPS
133  diff_vec[sbi_] = eq_fields_->diffusion_rate_immobile[sbi_](p);
134 
136 
137  for (sbi_ = 0; sbi_ < eq_data_->substances_.size(); sbi_++) //over all substances
138  {
139  exponent_ = diff_vec[sbi_] * temp_exponent_;
140  //previous values
143 
144  // ---compute average concentration------------------------------------------
146  / (por_mob_ + por_immob_);
147 
149 
150  // the following 2 conditions guarantee:
151  // 1) stability of forward Euler's method
152  // 2) the error of forward Euler's method will not be large
153  if(eq_data_->time_->dt() <= por_mob_*por_immob_/(max(diff_vec)*(por_mob_+por_immob_)) &&
155  {
157  // ---compute concentration in mobile area
159 
160  // ---compute concentration in immobile area
162  }
163  else //analytic solution
164  {
165  temp_ = exp(-exponent_);
166  // ---compute concentration in mobile area
168 
169  // ---compute concentration in immobile area
171  }
172 
175  }
176  }
177 
178 
179 private:
180  /// Data objects shared with Elasticity
183 
184  /// Sub field set contains fields used in calculation.
186 
187  unsigned int sbi_; ///< Index of substance
188  IntIdx dof_p0_; ///< Index of local DOF
189  double conc_average_; ///< weighted (by porosity) average of concentration
190  double conc_mob_, conc_immob_; ///< new mobile and immobile concentration
191  double previous_conc_mob_, previous_conc_immob_; ///< mobile and immobile concentration in previous time step
192  double conc_max_; ///< difference between concentration and average concentration
193  double por_mob_, por_immob_; ///< mobile and immobile porosity
194  double exponent_, temp_exponent_, temp_; ///< Precomputed values
195 
196  template < template<IntDim...> class DimAssembly>
197  friend class GenericAssembly;
198 };
199 
200 template <unsigned int dim>
202 {
203 public:
205  typedef typename SorptionBase::EqData EqData;
206 
207  static constexpr const char * name() { return "InitConditionAssemblySorp"; }
208 
209  /// Constructor.
211  : AssemblyBase<dim>(0), eq_fields_(eq_fields), eq_data_(eq_data) {
214  }
215 
216  /// Destructor.
218 
219  /// Initialize auxiliary vectors and other data members
220  void initialize(ElementCacheMap *element_cache_map) {
221  //this->balance_ = eq_data_->balance_;
222  this->element_cache_map_ = element_cache_map;
223  }
224 
225 
226  /// Assemble integral over element
227  inline void cell_integral(DHCellAccessor cell, unsigned int element_patch_idx)
228  {
229  ASSERT_EQ_DBG(cell.dim(), dim).error("Dimension of element mismatch!");
230 
231  dof_p0_ = cell.get_loc_dof_indices()[0];
232  auto p = *( this->bulk_points(element_patch_idx).begin() );
233 
234  //setting initial solid concentration for substances involved in adsorption
235  for (unsigned int sbi = 0; sbi < eq_data_->n_substances_; sbi++)
236  {
238  }
239  }
240 
241 
242 private:
243  /// Data objects shared with Elasticity
246 
247  /// Sub field set contains fields used in calculation.
249 
250  IntIdx dof_p0_; ///< Index of local DOF
251 
252  template < template<IntDim...> class DimAssembly>
253  friend class GenericAssembly;
254 };
255 
256 #endif /* ASSEMBLY_REACTION_HH_ */
257 
DualPorosity::EqFields::diffusion_rate_immobile
MultiField< 3, FieldValue< 3 >::Scalar > diffusion_rate_immobile
Mass transfer coefficients between mobile and immobile pores.
Definition: dual_porosity.hh:71
InitConditionAssemblyDp::used_fields_
FieldSet used_fields_
Sub field set contains fields used in calculation.
Definition: assembly_reaction.hh:80
ReactionAssemblyDp::sbi_
unsigned int sbi_
Index of substance.
Definition: assembly_reaction.hh:187
InitConditionAssemblyDp::EqData
DualPorosity::EqData EqData
Definition: assembly_reaction.hh:37
InitConditionAssemblySorp::used_fields_
FieldSet used_fields_
Sub field set contains fields used in calculation.
Definition: assembly_reaction.hh:248
ReactionAssemblyDp::name
static constexpr const char * name()
Definition: assembly_reaction.hh:95
SorptionBase::EqFields::conc_solid_fe
FieldFEScalarVec conc_solid_fe
Underlaying FieldFE for each substance of conc_solid.
Definition: sorption_base.hh:106
TimeGovernor::dt
double dt() const
Definition: time_governor.hh:565
InitConditionAssemblyDp::EqFields
DualPorosity::EqFields EqFields
Definition: assembly_reaction.hh:36
ReactionAssemblyDp::dof_p0_
IntIdx dof_p0_
Index of local DOF.
Definition: assembly_reaction.hh:188
ReactionAssemblyDp::initialize
void initialize(ElementCacheMap *element_cache_map)
Initialize auxiliary vectors and other data members.
Definition: assembly_reaction.hh:110
ReactionAssemblyDp::previous_conc_mob_
double previous_conc_mob_
Definition: assembly_reaction.hh:191
DualPorosity::EqData::scheme_tolerance_
double scheme_tolerance_
Dual porosity computational scheme tolerance.
Definition: dual_porosity.hh:98
SubstanceList::size
unsigned int size() const
Definition: substance.hh:87
ReactionAssemblyDp
Definition: assembly_reaction.hh:89
ReactionAssemblyDp::cell_integral
void cell_integral(DHCellAccessor cell, unsigned int element_patch_idx)
Assemble integral over element.
Definition: assembly_reaction.hh:117
InitConditionAssemblySorp
Definition: assembly_reaction.hh:201
SorptionBase::EqData::n_substances_
unsigned int n_substances_
number of substances that take part in the sorption mode
Definition: sorption_base.hh:133
InitConditionAssemblySorp::eq_fields_
EqFields * eq_fields_
Data objects shared with Elasticity.
Definition: assembly_reaction.hh:244
ElementCacheMap
Directing class of FieldValueCache.
Definition: field_value_cache.hh:151
IntIdx
int IntIdx
Definition: index_types.hh:25
InitConditionAssemblyDp::dof_p0_
IntIdx dof_p0_
Index of local DOF.
Definition: assembly_reaction.hh:82
fe_values.hh
Class FEValues calculates finite element data on the actual cells such as shape function values,...
InitConditionAssemblyDp::eq_fields_
EqFields * eq_fields_
Data objects shared with Elasticity.
Definition: assembly_reaction.hh:76
DualPorosity::EqFields::init_conc_immobile
MultiField< 3, FieldValue< 3 >::Scalar > init_conc_immobile
Initial concentrations in the immobile zone.
Definition: dual_porosity.hh:74
ASSERT_EQ_DBG
#define ASSERT_EQ_DBG(a, b)
Definition of comparative assert macro (EQual) only for debug mode.
Definition: asserts.hh:332
DHCellAccessor::dim
unsigned int dim() const
Return dimension of element appropriate to cell.
Definition: dh_cell_accessor.hh:101
DualPorosity::EqFields::conc_immobile_fe
FieldFEScalarVec conc_immobile_fe
Underlaying FieldFE for each substance of conc_immobile.
Definition: dual_porosity.hh:79
InitConditionAssemblyDp
Definition: assembly_reaction.hh:33
InitConditionAssemblyDp::initialize
void initialize(ElementCacheMap *element_cache_map)
Initialize auxiliary vectors and other data members.
Definition: assembly_reaction.hh:52
assembly_base.hh
SorptionBase::EqFields
Definition: sorption_base.hh:82
fe_p.hh
Definitions of basic Lagrangean finite elements with polynomial shape functions.
SorptionBase::EqFields::init_conc_solid
MultiField< 3, FieldValue< 3 >::Scalar > init_conc_solid
Initial sorbed concentrations.
Definition: sorption_base.hh:102
DualPorosity::EqData::time_
TimeGovernor * time_
TimeGovernor object shared with assembly classes.
Definition: dual_porosity.hh:101
InitConditionAssemblySorp::name
static constexpr const char * name()
Definition: assembly_reaction.hh:207
ReactionAssemblyDp::conc_max_
double conc_max_
difference between concentration and average concentration
Definition: assembly_reaction.hh:192
ReactionAssemblyDp::eq_data_
EqData * eq_data_
Definition: assembly_reaction.hh:182
SorptionBase::EqData
DualPorosity data.
Definition: sorption_base.hh:123
InitConditionAssemblyDp::InitConditionAssemblyDp
InitConditionAssemblyDp(EqFields *eq_fields, EqData *eq_data)
Constructor.
Definition: assembly_reaction.hh:42
InitConditionAssemblySorp::EqFields
SorptionBase::EqFields EqFields
Definition: assembly_reaction.hh:204
DualPorosity::EqData
DualPorosity data.
Definition: dual_porosity.hh:87
ReactionAssemblyDp::eq_fields_
EqFields * eq_fields_
Data objects shared with Elasticity.
Definition: assembly_reaction.hh:181
generic_assembly.hh
quadrature_lib.hh
Definitions of particular quadrature rules on simplices.
ReactionAssemblyDp::ReactionAssemblyDp
ReactionAssemblyDp(EqFields *eq_fields, EqData *eq_data)
Constructor.
Definition: assembly_reaction.hh:98
ReactionAssemblyDp::por_immob_
double por_immob_
mobile and immobile porosity
Definition: assembly_reaction.hh:193
ReactionAssemblyDp::previous_conc_immob_
double previous_conc_immob_
mobile and immobile concentration in previous time step
Definition: assembly_reaction.hh:191
ReactionAssemblyDp::temp_exponent_
double temp_exponent_
Definition: assembly_reaction.hh:194
SorptionBase::EqData::substance_global_idx_
std::vector< unsigned int > substance_global_idx_
Mapping from local indexing of substances to global.
Definition: sorption_base.hh:131
ReactionAssemblyDp::~ReactionAssemblyDp
~ReactionAssemblyDp()
Destructor.
Definition: assembly_reaction.hh:107
DualPorosity::EqFields::porosity_immobile
Field< 3, FieldValue< 3 >::Scalar > porosity_immobile
Immobile porosity field.
Definition: dual_porosity.hh:72
InitConditionAssemblySorp::initialize
void initialize(ElementCacheMap *element_cache_map)
Initialize auxiliary vectors and other data members.
Definition: assembly_reaction.hh:220
ReactionAssemblyDp::conc_mob_
double conc_mob_
Definition: assembly_reaction.hh:190
FieldSet
Container for various descendants of FieldCommonBase.
Definition: field_set.hh:159
DualPorosity::EqFields::porosity
Field< 3, FieldValue< 3 >::Scalar > porosity
Porosity field.
Definition: dual_porosity.hh:76
InitConditionAssemblySorp::InitConditionAssemblySorp
InitConditionAssemblySorp(EqFields *eq_fields, EqData *eq_data)
Constructor.
Definition: assembly_reaction.hh:210
ReactionAssemblyDp::EqFields
DualPorosity::EqFields EqFields
Definition: assembly_reaction.hh:92
AssemblyBase::bulk_points
Range< BulkPoint > bulk_points(unsigned int element_patch_idx) const
Return BulkPoint range of appropriate dimension.
Definition: assembly_base.hh:104
InitConditionAssemblySorp::eq_data_
EqData * eq_data_
Definition: assembly_reaction.hh:245
DualPorosity::EqFields
DualPorosity fields.
Definition: dual_porosity.hh:64
bulk
@ bulk
Definition: generic_assembly.hh:33
dual_porosity.hh
Class Dual_por_exchange implements the model of dual porosity.
DHCellAccessor
Cell accessor allow iterate over DOF handler cells.
Definition: dh_cell_accessor.hh:43
ReactionAssemblyDp::conc_average_
double conc_average_
weighted (by porosity) average of concentration
Definition: assembly_reaction.hh:189
InitConditionAssemblyDp::~InitConditionAssemblyDp
~InitConditionAssemblyDp()
Destructor.
Definition: assembly_reaction.hh:49
InitConditionAssemblySorp::dof_p0_
IntIdx dof_p0_
Index of local DOF.
Definition: assembly_reaction.hh:250
field_value_cache.hh
AssemblyBase::active_integrals_
int active_integrals_
Holds mask of active integrals.
Definition: assembly_base.hh:191
DHCellAccessor::get_loc_dof_indices
LocDofVec get_loc_dof_indices() const
Returns the local indices of dofs associated to the cell on the local process.
Definition: dh_cell_accessor.hh:88
ReactionTerm::EqData::substances_
SubstanceList substances_
Definition: reaction_term.hh:88
AssemblyBase
Definition: assembly_base.hh:34
ReactionAssemblyDp::conc_immob_
double conc_immob_
new mobile and immobile concentration
Definition: assembly_reaction.hh:190
InitConditionAssemblyDp::eq_data_
EqData * eq_data_
Definition: assembly_reaction.hh:77
ReactionTerm::EqFields::conc_mobile_fe
FieldFEScalarVec conc_mobile_fe
FieldFEs representing P0 interpolation of mobile concentration (passed from transport).
Definition: reaction_term.hh:73
ReactionAssemblyDp::used_fields_
FieldSet used_fields_
Sub field set contains fields used in calculation.
Definition: assembly_reaction.hh:185
InitConditionAssemblyDp::cell_integral
void cell_integral(DHCellAccessor cell, unsigned int element_patch_idx)
Assemble integral over element.
Definition: assembly_reaction.hh:59
ReactionAssemblyDp::temp_
double temp_
Precomputed values.
Definition: assembly_reaction.hh:194
InitConditionAssemblyDp::name
static constexpr const char * name()
Definition: assembly_reaction.hh:39
GenericAssembly
Generic class of assemblation.
Definition: generic_assembly.hh:160
ReactionAssemblyDp::por_mob_
double por_mob_
Definition: assembly_reaction.hh:193
InitConditionAssemblySorp::EqData
SorptionBase::EqData EqData
Definition: assembly_reaction.hh:205
AssemblyBase::element_cache_map_
ElementCacheMap * element_cache_map_
ElementCacheMap shared with GenericAssembly object.
Definition: assembly_base.hh:193
InitConditionAssemblySorp::cell_integral
void cell_integral(DHCellAccessor cell, unsigned int element_patch_idx)
Assemble integral over element.
Definition: assembly_reaction.hh:227
InitConditionAssemblySorp::~InitConditionAssemblySorp
~InitConditionAssemblySorp()
Destructor.
Definition: assembly_reaction.hh:217
ReactionAssemblyDp::exponent_
double exponent_
Definition: assembly_reaction.hh:194
ReactionAssemblyDp::EqData
DualPorosity::EqData EqData
Definition: assembly_reaction.hh:93
IntDim
unsigned int IntDim
A dimension index type.
Definition: mixed.hh:19