Flow123d  JS_before_hm-2198-g122e1f2e2
assembly_lmh_old.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_lmh.hh
15  * @brief
16  */
17 
18 #ifndef ASSEMBLY_LMH_HH_
19 #define ASSEMBLY_LMH_HH_
20 
23 #include "flow/darcy_flow_lmh.hh"
25 
26 #include "system/index_types.hh"
27 #include "mesh/mesh.h"
28 #include "mesh/accessors.hh"
29 #include "mesh/neighbours.h"
30 #include "fem/fe_p.hh"
31 #include "fem/fe_values.hh"
32 #include "fem/fe_rt.hh"
33 #include "fem/fe_values_views.hh"
34 #include "fem/fe_system.hh"
36 
37 #include "la/linsys_PETSC.hh"
38 #include "la/schur.hh"
39 #include "la/local_system.hh"
40 
41 #include "coupling/balance.hh"
42 
43 
44 template <unsigned int dim>
46 {
47 public:
48  typedef typename DarcyLMH::EqFields EqFields;
49  typedef typename DarcyLMH::EqData EqData;
50 
51  static constexpr const char * name() { return "ReadInitCondAssemblyLMH"; }
52 
53  /// Constructor.
54  ReadInitCondAssemblyLMH(EqFields *eq_fields, EqData *eq_data)
55  : AssemblyBase<dim>(0), eq_fields_(eq_fields), eq_data_(eq_data) {
58  }
59 
60  /// Destructor.
62 
63  /// Initialize auxiliary vectors and other data members
64  void initialize(ElementCacheMap *element_cache_map) {
65  this->element_cache_map_ = element_cache_map;
66  }
67 
68 
69  /// Assemble integral over element
70  inline void cell_integral(DHCellAccessor cell, unsigned int element_patch_idx)
71  {
72  if (cell.dim() != dim) return;
73 
75  ASSERT_DBG(l_indices_.n_elem == cell.elm().element()->n_sides());
76 
77  // set initial condition
78  auto p = *( this->bulk_points(element_patch_idx).begin() );
80 
81  for (unsigned int i=0; i<cell.elm()->n_sides(); i++) {
84  }
85  }
86 
87  /// Implements @p AssemblyBase::end.
88  void end() override
89  {
94  }
95 
96 
97 
98 protected:
99  /// Sub field set contains fields used in calculation.
101 
102  /// Data objects shared with Flow equation
105 
106  LocDofVec p_indices_, l_indices_; ///< Vectors of local DOF indices pre-computed on different DOF handlers
107  unsigned int p_idx_, l_idx_; ///< Local DOF indices extract from previous vectors
108  double init_value_, init_value_on_edge_; ///< Pre-computed values of init_pressure.
109 
110  template < template<IntDim...> class DimAssembly>
111  friend class GenericAssembly;
112 
113 };
114 
115 template <unsigned int dim>
117 {
118 public:
119  typedef typename DarcyLMH::EqFields EqFields;
120  typedef typename DarcyLMH::EqData EqData;
121 
122  DECLARE_EXCEPTION( ExcBCNotSupported, << "BC type not supported.\n" );
123 
124  static constexpr const char * name() { return "MHMatrixAssemblyLMH"; }
125 
126  /// Constructor.
127  MHMatrixAssemblyLMH(EqFields *eq_fields, EqData *eq_data)
128  : AssemblyBase<dim>(0), eq_fields_(eq_fields), eq_data_(eq_data), quad_rt_(dim, 2) {
133  this->used_fields_ += eq_fields_->sigma;
138  this->used_fields_ += eq_fields_->bc_type;
140  this->used_fields_ += eq_fields_->bc_flux;
143  }
144 
145  /// Destructor.
146  virtual ~MHMatrixAssemblyLMH() {}
147 
148  /// Initialize auxiliary vectors and other data members
149  void initialize(ElementCacheMap *element_cache_map) {
150  //this->balance_ = eq_data_->balance_;
151  this->element_cache_map_ = element_cache_map;
152 
153  fe_ = std::make_shared< FE_P_disc<dim> >(0);
155 
157 
160 
161  // local numbering of dofs for MH system
162  // note: this shortcut supposes that the fe_system is the same on all elements
163  // TODO the function should be DiscreteSpace.fe(ElementAccessor)
164  // and correct form fe(ad_->dh_->own_range().begin()->elm()) (see documentation of DiscreteSpace::fe)
165  auto fe = eq_data_->dh_->ds()->fe()[Dim<dim>{}];
166  FESystem<dim>* fe_system = dynamic_cast<FESystem<dim>*>(fe.get());
167  eq_data_->loc_side_dofs[dim-1] = fe_system->fe_dofs(0);
168  eq_data_->loc_ele_dof[dim-1] = fe_system->fe_dofs(1)[0];
169  eq_data_->loc_edge_dofs[dim-1] = fe_system->fe_dofs(2);
170 
171  // reconstructed vector for the velocity and pressure
172  // length = local Schur complement offset in LocalSystem
173  eq_data_->schur_offset_[dim-1] = eq_data_->loc_edge_dofs[dim-1][0];
175  }
176 
177 
178  /// Assemble source term (integral over element)
179  inline void cell_integral(DHCellAccessor cell, unsigned int element_patch_idx)
180  {
181  if (cell.dim() != dim) return;
182 
183  // evaluation point
184  auto p = *( this->bulk_points(element_patch_idx).begin() );
185  bulk_local_idx_ = cell.local_idx();
186 
187  { // Assemble sides
188  auto ele = cell.elm();
189  conductivity_ = this->compute_conductivity(cell, p);
191 
192  fe_values_.reinit(ele);
193  auto velocity = fe_values_.vector_view(0);
194 
195  for (unsigned int k=0; k<qsize_; k++)
196  for (unsigned int i=0; i<ndofs_; i++){
197  rhs_val_ = arma::dot(eq_data_->gravity_vec_, velocity.value(i,k))
198  * fe_values_.JxW(k);
200 
201  for (unsigned int j=0; j<ndofs_; j++){
202  mat_val_ =
203  arma::dot( velocity.value(i,k), //TODO: compute anisotropy before
204  (eq_fields_->anisotropy(p)).i() * velocity.value(j,k)
205  )
206  * scale_sides_ * fe_values_.JxW(k);
207 
208  eq_data_->loc_system_[bulk_local_idx_].add_value(i, j, mat_val_);
209  }
210  }
211 
212  // assemble matrix for weights in BDDCML
213  // approximation to diagonal of
214  // S = -C - B*inv(A)*B'
215  // as
216  // diag(S) ~ - diag(C) - 1./diag(A)
217  // the weights form a partition of unity to average a discontinuous solution from neighbouring subdomains
218  // to a continuous one
219  // it is important to scale the effect - if conductivity is low for one subdomain and high for the other,
220  // trust more the one with low conductivity - it will be closer to the truth than an arithmetic average
221 // if ( typeid(*ad_->lin_sys) == typeid(LinSys_BDDC) ) {
222 // const arma::mat& local_matrix = loc_system_.get_matrix();
223 // for(unsigned int i=0; i < ndofs; i++) {
224 // double val_side = local_matrix(i,i);
225 // double val_edge = -1./local_matrix(i,i);
226 //
227 // unsigned int side_row = loc_system_.row_dofs[loc_side_dofs[i]];
228 // unsigned int edge_row = loc_system_.row_dofs[loc_edge_dofs[i]];
229 // static_cast<LinSys_BDDC*>(ad_->lin_sys)->diagonal_weights_set_value( side_row, val_side );
230 // static_cast<LinSys_BDDC*>(ad_->lin_sys)->diagonal_weights_set_value( edge_row, val_edge );
231 // }
232 // }
233  }
234 
235  { // Assemble element
236  // set block B, B': element-side, side-element
237 
238  for(unsigned int side = 0; side < eq_data_->loc_side_dofs[dim-1].size(); side++){
239  eq_data_->loc_system_[bulk_local_idx_].add_value(eq_data_->loc_ele_dof[dim-1], eq_data_->loc_side_dofs[dim-1][side], -1.0);
240  eq_data_->loc_system_[bulk_local_idx_].add_value(eq_data_->loc_side_dofs[dim-1][side], eq_data_->loc_ele_dof[dim-1], -1.0);
241  }
242 
243 // if ( typeid(*ad_->lin_sys) == typeid(LinSys_BDDC) ) {
244 // double val_ele = 1.;
245 // static_cast<LinSys_BDDC*>(ad_->lin_sys)->
246 // diagonal_weights_set_value( loc_system_.row_dofs[loc_ele_dof], val_ele );
247 // }
248  }
249 
250  // Assemble source term
251  this->assemble_source_term(cell, p);
252 
253  // Specialized part of reconstruct from Schur
254  this->postprocess_bulk_integral(cell, element_patch_idx);
255  }
256 
257 
258  inline void boundary_side_integral(DHCellSide cell_side)
259  {
260  ASSERT_EQ_DBG(cell_side.dim(), dim).error("Dimension of element mismatch!");
261  if (!cell_side.cell().is_own()) return;
262 
263  auto p_side = *( this->boundary_points(cell_side).begin() );
264  auto p_bdr = p_side.point_bdr(cell_side.cond().element_accessor() );
265  bulk_local_idx_ = cell_side.cell().local_idx();
266 
268 
269  sidx_ = cell_side.side_idx();
270  side_row_ = eq_data_->loc_side_dofs[dim-1][sidx_]; //local
271  edge_row_ = eq_data_->loc_edge_dofs[dim-1][sidx_]; //local
272 
273  ElementAccessor<3> b_ele = cell_side.side().cond().element_accessor(); // ??
275 
276  if ( type == DarcyMH::EqFields::none) {
277  // homogeneous neumann
278  } else if ( type == DarcyMH::EqFields::dirichlet ) {
279  eq_data_->loc_schur_[bulk_local_idx_].set_solution( sidx_, eq_fields_->bc_pressure(p_bdr) );
280 
281  } else if ( type == DarcyMH::EqFields::total_flux) {
282  // internally we work with outward flux
284  -b_ele.measure() * eq_fields_->bc_robin_sigma(p_bdr) * cross_section_,
285  (-eq_fields_->bc_flux(p_bdr) - eq_fields_->bc_robin_sigma(p_bdr) * eq_fields_->bc_pressure(p_bdr)) * b_ele.measure() * cross_section_);
286  } else if (type==DarcyMH::EqFields::seepage) {
287  eq_data_->is_linear=false;
288 
289  char & switch_dirichlet = eq_data_->bc_switch_dirichlet[b_ele.idx()];
291  side_flux_ = -eq_fields_->bc_flux(p_bdr) * b_ele.measure() * cross_section_;
292 
293  // ** Update BC type. **
294  dirichlet_switch(switch_dirichlet, cell_side);
295 
296  eq_data_->save_local_system_[bulk_local_idx_] = (bool) switch_dirichlet;
297 
298  // ** Apply BCUpdate BC type. **
299  // Force Dirichlet type during the first iteration of the unsteady case.
300  if (switch_dirichlet || eq_data_->force_no_neumann_bc ) {
301  //DebugOut().fmt("x: {}, dirich, bcp: {}\n", b_ele.centre()[0], bc_pressure);
303  } else {
304  //DebugOut()("x: {}, neuman, q: {} bcq: {}\n", b_ele.centre()[0], side_flux_, bc_flux);
306  }
307 
308  } else if (type==DarcyMH::EqFields::river) {
309  eq_data_->is_linear=false;
310 
313  bc_flux_ = -eq_fields_->bc_flux(p_bdr);
315 
317 
318  // Force Robin type during the first iteration of the unsteady case.
320  // Robin BC
321  //DebugOut().fmt("x: {}, robin, bcp: {}\n", b_ele.centre()[0], bc_pressure);
323  -b_ele.measure() * bc_sigma_ * cross_section_,
325  } else {
326  // Neumann BC
327  //DebugOut().fmt("x: {}, neuman, q: {} bcq: {}\n", b_ele.centre()[0], bc_switch_pressure, bc_pressure);
329 
331  }
332  }
333  else {
334  THROW( ExcBCNotSupported() );
335  }
336 
337  eq_data_->balance->add_flux_values(eq_data_->water_balance_idx, cell_side,
338  {eq_data_->loc_system_[bulk_local_idx_].row_dofs[eq_data_->loc_side_dofs[dim-1][sidx_]]},
339  {1}, 0);
340 
341  }
342 
343 
344  /// Assembles the fluxes between elements of different dimensions.
345  inline void dimjoin_intergral(DHCellAccessor cell_lower_dim, DHCellSide neighb_side) {
346  if (dim == 1) return;
347  ASSERT_EQ_DBG(cell_lower_dim.dim(), dim-1).error("Dimension of element mismatch!");
348 
349  unsigned int neigh_idx = ngh_idx(cell_lower_dim, neighb_side); // TODO use better evaluation of neighbour_idx
350  unsigned int loc_dof_higher = (2*(cell_lower_dim.dim()+1) + 1) + neigh_idx; // loc dof of higher ele edge
351  bulk_local_idx_ = cell_lower_dim.local_idx();
352 
353  // Evaluation points
354  auto p_high = *( this->coupling_points(neighb_side).begin() );
355  auto p_low = p_high.lower_dim(cell_lower_dim);
356 
357  fe_values_side_.reinit(neighb_side.side());
359 
360  ngh_value_ = eq_fields_->sigma(p_low) *
361  2*eq_fields_->conductivity(p_low) *
362  arma::dot(eq_fields_->anisotropy(p_low)*nv_, nv_) *
363  eq_fields_->cross_section(p_high) * // cross-section of higher dim. (2d)
364  eq_fields_->cross_section(p_high) /
365  eq_fields_->cross_section(p_low) * // crossection of lower dim.
366  neighb_side.measure();
367 
369  eq_data_->loc_system_[bulk_local_idx_].add_value(eq_data_->loc_ele_dof[dim-2], loc_dof_higher, ngh_value_);
370  eq_data_->loc_system_[bulk_local_idx_].add_value(loc_dof_higher, eq_data_->loc_ele_dof[dim-2], ngh_value_);
371  eq_data_->loc_system_[bulk_local_idx_].add_value(loc_dof_higher, loc_dof_higher, -ngh_value_);
372 
373 // // update matrix for weights in BDDCML
374 // if ( typeid(*eq_data_->lin_sys) == typeid(LinSys_BDDC) ) {
375 // int ind = eq_data_->loc_system_[bulk_local_idx_].row_dofs[p];
376 // // there is -value on diagonal in block C!
377 // static_cast<LinSys_BDDC*>(eq_data_->lin_sys)->diagonal_weights_set_value( ind, -value );
378 // }
379  }
380 
381 
382  /// Implements @p AssemblyBase::begin.
383  void begin() override
384  {
385  // DebugOut() << "assembly_mh_matrix \n";
386  // set auxiliary flag for switchting Dirichlet like BC
388 
389  eq_data_->reset();
390 
391  eq_data_->balance_->start_flux_assembly(eq_data_->water_balance_idx);
392  eq_data_->balance_->start_source_assembly(eq_data_->water_balance_idx);
393  eq_data_->balance_->start_mass_assembly(eq_data_->water_balance_idx);
394 
395  this->set_dofs();
396  }
397 
398 
399  /// Implements @p AssemblyBase::end.
400  void end() override
401  {
402  this->schur_postprocess();
403 
404  eq_data_->balance_->finish_mass_assembly(eq_data_->water_balance_idx);
405  eq_data_->balance_->finish_source_assembly(eq_data_->water_balance_idx);
406  eq_data_->balance_->finish_flux_assembly(eq_data_->water_balance_idx);
407  }
408 
409 protected:
410  void set_dofs() {
411  unsigned int size, loc_size, loc_size_schur, elm_dim;;
412  for ( DHCellAccessor dh_cell : eq_data_->dh_->local_range() ) {
413  const ElementAccessor<3> ele = dh_cell.elm();
414  const DHCellAccessor dh_cr_cell = dh_cell.cell_with_other_dh(eq_data_->dh_cr_.get());
415 
416  elm_dim = ele.dim();
417  size = (elm_dim+1) + 1 + (elm_dim+1); // = n_sides + 1 + n_sides
418  loc_size = size + ele->n_neighs_vb();
419  loc_size_schur = ele->n_sides() + ele->n_neighs_vb();
420  LocDofVec dofs(loc_size);
421  LocDofVec dofs_schur(loc_size_schur);
422 
423  // add full vec indices
424  dofs.head(dh_cell.n_dofs()) = dh_cell.get_loc_dof_indices();
425  // add schur vec indices
426  dofs_schur.head(dh_cr_cell.n_dofs()) = dh_cr_cell.get_loc_dof_indices();
427 
428  if(ele->n_neighs_vb() != 0)
429  {
430  //D, E',E block: compatible connections: element-edge
431  unsigned int i = 0;
432 
433  for ( DHCellSide neighb_side : dh_cell.neighb_sides() ) {
434 
435  // read neighbor dofs (dh dofhandler)
436  // neighbor cell owning neighb_side
437  DHCellAccessor dh_neighb_cell = neighb_side.cell();
438 
439  // read neighbor dofs (dh_cr dofhandler)
440  // neighbor cell owning neighb_side
441  DHCellAccessor dh_neighb_cr_cell = dh_neighb_cell.cell_with_other_dh(eq_data_->dh_cr_.get());
442 
443  // local index of pedge dof in local system
444  const unsigned int p = size+i;
445  // local index of pedge dof on neighboring cell
446  const unsigned int t = dh_neighb_cell.n_dofs() - dh_neighb_cr_cell.n_dofs() + neighb_side.side().side_idx();
447  dofs[p] = dh_neighb_cell.get_loc_dof_indices()[t];
448 
449  // local index of pedge dof in local schur system
450  const unsigned int tt = dh_cr_cell.n_dofs()+i;
451  dofs_schur[tt] = dh_neighb_cr_cell.get_loc_dof_indices()[neighb_side.side().side_idx()];
452  i++;
453  }
454  }
455  eq_data_->loc_system_[dh_cell.local_idx()].reset(dofs, dofs);
456  eq_data_->loc_schur_[dh_cell.local_idx()].reset(dofs_schur, dofs_schur);
457 
458  // Set side-edge (flux-lambda) terms
459  for (DHCellSide dh_side : dh_cell.side_range()) {
460  unsigned int sidx = dh_side.side_idx();
461  // side-edge (flux-lambda) terms
462  eq_data_->loc_system_[dh_cell.local_idx()].add_value(eq_data_->loc_side_dofs[elm_dim-1][sidx], eq_data_->loc_edge_dofs[elm_dim-1][sidx], 1.0);
463  eq_data_->loc_system_[dh_cell.local_idx()].add_value(eq_data_->loc_edge_dofs[elm_dim-1][sidx], eq_data_->loc_side_dofs[elm_dim-1][sidx], 1.0);
464  }
465  }
466  }
467 
468 
469  inline void schur_postprocess() {
470  for ( DHCellAccessor dh_cell : eq_data_->dh_->own_range() ) {
471  eq_data_->loc_system_[dh_cell.local_idx()].compute_schur_complement(
472  eq_data_->schur_offset_[dh_cell.dim()-1], eq_data_->loc_schur_[dh_cell.local_idx()], true);
473 
474  // for seepage BC, save local system
475  if (eq_data_->save_local_system_[dh_cell.local_idx()])
476  eq_data_->seepage_bc_systems[dh_cell.elm_idx()] = eq_data_->loc_system_[dh_cell.local_idx()];
477 
478  eq_data_->loc_schur_[dh_cell.local_idx()].eliminate_solution();
479  eq_data_->lin_sys_schur->set_local_system(eq_data_->loc_schur_[dh_cell.local_idx()], eq_data_->dh_cr_->get_local_to_global_map());
480 
481  // TODO:
482  // if (mortar_assembly)
483  // mortar_assembly->assembly(dh_cell);
484  }
485  }
486 
487 
488  virtual void assemble_source_term(const DHCellAccessor& cell, BulkPoint &p)
489  {
490  // compute lumped source
491  n_sides_ = cell.elm()->n_sides();
492  coef_ = (1.0 / n_sides_) * cell.elm().measure() * eq_fields_->cross_section(p);
494 
495  // in unsteady, compute time term
496  time_term_diag_ = 0.0;
497  time_term_ = 0.0;
498  time_term_rhs_ = 0.0;
499 
501  {
503  }
504 
505  for (unsigned int i=0; i<n_sides_; i++)
506  {
508  {
511 
512  eq_data_->balance->add_mass_values(eq_data_->water_balance_idx, cell,
513  {eq_data_->loc_system_[bulk_local_idx_].row_dofs[eq_data_->loc_edge_dofs[dim-1][i]]}, {time_term_}, 0);
514  }
515  else
516  {
517  // Add zeros explicitely to keep the sparsity pattern.
518  // Otherwise Petsc would compress out the zeros in FinishAssembly.
519  eq_data_->balance->add_mass_values(eq_data_->water_balance_idx, cell,
520  {eq_data_->loc_system_[bulk_local_idx_].row_dofs[eq_data_->loc_edge_dofs[dim-1][i]]}, {0}, 0);
521  }
522 
526 
527  eq_data_->balance->add_source_values(eq_data_->water_balance_idx, cell.elm().region().bulk_idx(),
528  {eq_data_->loc_system_[bulk_local_idx_].row_dofs[eq_data_->loc_edge_dofs[dim-1][i]]}, {0}, {source_term_});
529  }
530  }
531 
532  /// Temporary method find neighbour index in higher-dim cell
533  inline unsigned int ngh_idx(DHCellAccessor &dh_cell, DHCellSide &neighb_side) {
534  for (uint n_i=0; n_i<dh_cell.elm()->n_neighs_vb(); ++n_i) {
535  auto side = dh_cell.elm()->neigh_vb[n_i]->side();
536  if ( (side->elem_idx() == neighb_side.elem_idx()) && (side->side_idx() == neighb_side.side_idx()) ) return n_i;
537  }
538  ASSERT(false)(dh_cell.elm_idx())(neighb_side.side_idx()).error("Side is not a part of neighbour!\n");
539  return 0;
540  }
541 
542 
543  /** Loads the local system from a map: element index -> LocalSystem,
544  * if it exits, or if the full solution is not yet reconstructed,
545  * and reconstructs the full solution on the element.
546  * Currently used only for seepage BC.
547  */
548  void load_local_system(const DHCellAccessor& dh_cell)
549  {
550  // do this only once per element
551  if (eq_data_->bc_fluxes_reconstruted[bulk_local_idx_])
552  return;
553 
554  // possibly find the corresponding local system
555  auto ls = eq_data_->seepage_bc_systems.find(dh_cell.elm_idx());
556  if (ls != eq_data_->seepage_bc_systems.end())
557  {
558  arma::vec schur_solution = eq_data_->p_edge_solution.get_subvec(eq_data_->loc_schur_[bulk_local_idx_].row_dofs);
559  // reconstruct the velocity and pressure
560  ls->second.reconstruct_solution_schur(eq_data_->schur_offset_[dim-1], schur_solution, reconstructed_solution_);
561 
562  unsigned int pos_in_cache = this->element_cache_map_->position_in_cache(dh_cell.elm_idx());
563  postprocess_velocity(dh_cell, pos_in_cache, reconstructed_solution_);
564 
565  eq_data_->bc_fluxes_reconstruted[bulk_local_idx_] = true;
566  }
567  }
568 
569 
570  void postprocess_velocity(const DHCellAccessor& dh_cell, unsigned int element_patch_idx, arma::vec& solution)
571  {
572  auto p = *( this->bulk_points(element_patch_idx).begin() );
573 
574  edge_scale_ = dh_cell.elm().measure()
575  * eq_fields_->cross_section(p)
576  / dh_cell.elm()->n_sides();
577 
578  edge_source_term_ = edge_scale_ *
579  ( eq_fields_->water_source_density(p)
580  + eq_fields_->extra_source(p));
581 
582  postprocess_velocity_specific(dh_cell, p, solution, edge_scale_, edge_source_term_);
583  }
584 
585 
586  virtual void postprocess_velocity_specific(const DHCellAccessor& dh_cell, BulkPoint &p, arma::vec& solution,
587  double edge_scale, double edge_source_term)// override
588  {
589  time_term_ = 0.0;
590  for (unsigned int i=0; i<dh_cell.elm()->n_sides(); i++) {
591 
592  if( ! eq_data_->use_steady_assembly_)
593  {
594  new_pressure_ = eq_data_->p_edge_solution.get(eq_data_->loc_schur_[bulk_local_idx_].row_dofs[i]);
595  old_pressure_ = eq_data_->p_edge_solution_previous_time.get(eq_data_->loc_schur_[bulk_local_idx_].row_dofs[i]);
596  time_term_ = edge_scale * (eq_fields_->storativity(p) + eq_fields_->extra_storativity(p))
597  / eq_data_->time_step_ * (new_pressure_ - old_pressure_);
598  }
599  solution[eq_data_->loc_side_dofs[dim-1][i]] += edge_source_term - time_term_;
600  }
601  }
602 
603 
604  virtual double compute_conductivity(FMT_UNUSED const DHCellAccessor& cell, BulkPoint &p) {
605  return eq_fields_->conductivity(p);
606  }
607 
608  virtual void postprocess_bulk_integral(FMT_UNUSED const DHCellAccessor& cell, FMT_UNUSED unsigned intelement_patch_idx)
609  {}
610 
611  virtual void dirichlet_switch(char & switch_dirichlet, DHCellSide cell_side) {
612  if (switch_dirichlet) {
613  // check and possibly switch to flux BC
614  // The switch raise error on the corresponding edge row.
615  // Magnitude of the error is abs(solution_flux - side_flux).
616 
617  // try reconstructing local system for seepage BC
618  this->load_local_system(cell_side.cell());
619 
620  if ( reconstructed_solution_[side_row_] < side_flux_) {
621  //DebugOut().fmt("x: {}, to neum, p: {} f: {} -> f: {}\n", b_ele.centre()[0], bc_pressure, reconstructed_solution_[side_row_], side_flux);
622  switch_dirichlet = 0;
623  }
624  } else {
625  // check and possibly switch to pressure BC
626  // TODO: What is the appropriate DOF in not local?
627  // The switch raise error on the corresponding side row.
628  // Magnitude of the error is abs(solution_head - bc_pressure)
629  // Since usually K is very large, this error would be much
630  // higher then error caused by the inverse switch, this
631  // cause that a solution with the flux violating the
632  // flux inequality leading may be accepted, while the error
633  // in pressure inequality is always satisfied.
634 
635  solution_head_ = eq_data_->p_edge_solution.get(eq_data_->loc_schur_[bulk_local_idx_].row_dofs[sidx_]);
636 
637  if ( solution_head_ > bc_pressure_) {
638  //DebugOut().fmt("x: {}, to dirich, p: {} -> p: {} f: {}\n",b_ele.centre()[0], solution_head_, bc_pressure, bc_flux);
639  switch_dirichlet=1;
640  }
641  }
642  }
643 
644 
645  /// Sub field set contains fields used in calculation.
647 
648  /// Data objects shared with DarcyFlow
651 
652  /// Assembly volume integrals
656  unsigned int ndofs_; ///< Number of dofs
657  unsigned int qsize_; ///< Size of quadrature of dim-1
658 
659  shared_ptr<FiniteElement<dim>> fe_; ///< Finite element for the solution of the advection-diffusion equation.
660  FEValues<3> fe_values_side_; ///< FEValues of object (of P disc finite element type)
661 
662  /// Vector for reconstructed solution (velocity and pressure on element) from Schur complement.
664 
665  double conductivity_, scale_sides_; ///< Precomputed value (1 / cross_section / conductivity)
666  double rhs_val_, mat_val_; ///< Precomputed RHS and mat value
667  double n_sides_, coef_, source_term_; ///< Variables used in compute lumped source.
668  double time_term_diag_, time_term_, time_term_rhs_; ///< Variables used in compute time term (unsteady)
669  double cross_section_; ///< Precomputed cross-section value
670  unsigned int bulk_local_idx_; ///< Local idx of bulk element
671  unsigned int sidx_, side_row_, edge_row_; ///< Helper indices in boundary assembly
672  double solution_head_; ///< Precomputed value in boundary assembly
673  double bc_total_flux_, bc_flux_, side_flux_; ///< Precomputed values in boundary assembly
674  double bc_pressure_, bc_switch_pressure_, bc_sigma_; ///< Precomputed values in boundary assembly
675  arma::vec3 nv_; ///< Normal vector
676  double ngh_value_; ///< Precomputed ngh value
677  double edge_scale_, edge_source_term_; ///< Precomputed values in postprocess_velocity
678  double new_pressure_, old_pressure_; ///< Precomputed values in postprocess_velocity_specific
679 
680  template < template<IntDim...> class DimAssembly>
681  friend class GenericAssembly;
682 
683 };
684 
685 template <unsigned int dim>
687 {
688 public:
689  typedef typename DarcyLMH::EqFields EqFields;
690  typedef typename DarcyLMH::EqData EqData;
691 
692  static constexpr const char * name() { return "ReconstructSchurAssemblyLMH"; }
693 
694  /// Constructor.
696  : MHMatrixAssemblyLMH<dim>(eq_fields, eq_data) {}
697 
698  /// Implements @p AssemblyBase::begin.
699  void begin() override
700  {
704 
705  this->eq_data_->balance_->start_flux_assembly(this->eq_data_->water_balance_idx);
706  this->eq_data_->balance_->start_source_assembly(this->eq_data_->water_balance_idx);
707  this->eq_data_->balance_->start_mass_assembly(this->eq_data_->water_balance_idx);
708 
709  this->set_dofs();
710  }
711 
712 
713  /// Implements @p AssemblyBase::end.
714  void end() override
715  {
716  this->reconstruct_schur_finish();
717 
720 
721  this->eq_data_->balance_->finish_mass_assembly(this->eq_data_->water_balance_idx);
722  this->eq_data_->balance_->finish_source_assembly(this->eq_data_->water_balance_idx);
723  this->eq_data_->balance_->finish_flux_assembly(this->eq_data_->water_balance_idx);
724  }
725 
726 protected:
727  inline void reconstruct_schur_finish() {
728  for ( DHCellAccessor dh_cell : this->eq_data_->dh_->own_range() ) {
729  this->bulk_local_idx_ = dh_cell.local_idx();
730  arma::vec schur_solution = this->eq_data_->p_edge_solution.get_subvec(this->eq_data_->loc_schur_[this->bulk_local_idx_].row_dofs);
731  // reconstruct the velocity and pressure
732  this->eq_data_->loc_system_[this->bulk_local_idx_].reconstruct_solution_schur(this->eq_data_->schur_offset_[dh_cell.dim()-1],
733  schur_solution, this->reconstructed_solution_);
734 
736 
737  this->eq_data_->full_solution.set_subvec(this->eq_data_->loc_system_[this->bulk_local_idx_].row_dofs.head(
738  this->eq_data_->schur_offset_[dh_cell.dim()-1]), this->reconstructed_solution_);
739  this->eq_data_->full_solution.set_subvec(this->eq_data_->loc_system_[this->bulk_local_idx_].row_dofs.tail(
740  this->eq_data_->loc_schur_[this->bulk_local_idx_].row_dofs.n_elem), schur_solution);
741  }
742  }
743 
744  void postprocess_bulk_integral(const DHCellAccessor& cell, unsigned int element_patch_idx) override {
745  this->eq_data_->postprocess_solution_[this->bulk_local_idx_].zeros(this->eq_data_->schur_offset_[dim-1]);
746  // postprocess the velocity
747  this->postprocess_velocity(cell, element_patch_idx, this->eq_data_->postprocess_solution_[this->bulk_local_idx_]);
748  }
749 
750  void dirichlet_switch(FMT_UNUSED char & switch_dirichlet, FMT_UNUSED DHCellSide cell_side) override
751  {}
752 
753 };
754 
755 #endif /* ASSEMBLY_LMH_HH_ */
756 
DarcyMH::EqFields::bc_pressure
BCField< 3, FieldValue< 3 >::Scalar > bc_pressure
Definition: darcy_flow_mh.hh:176
Element::n_neighs_vb
unsigned int n_neighs_vb() const
Return number of neighbours.
Definition: elements.h:65
ElementAccessor::dim
unsigned int dim() const
Definition: accessors.hh:191
DarcyLMH::EqData::save_local_system_
std::vector< bool > save_local_system_
Flag for saving the local system. Currently used only in case of seepage BC.
Definition: darcy_flow_lmh.hh:202
LocDofVec
arma::Col< IntIdx > LocDofVec
Definition: index_types.hh:28
ReadInitCondAssemblyLMH::l_indices_
LocDofVec l_indices_
Vectors of local DOF indices pre-computed on different DOF handlers.
Definition: assembly_lmh_old.hh:106
FE_RT0
Raviart-Thomas element of order 0.
Definition: fe_rt.hh:60
Side::edge
Edge edge() const
Returns pointer to the edge connected to the side.
Definition: accessors_impl.hh:221
ReadInitCondAssemblyLMH
Definition: assembly_lmh_old.hh:45
ReadInitCondAssemblyLMH::init_value_on_edge_
double init_value_on_edge_
Pre-computed values of init_pressure.
Definition: assembly_lmh_old.hh:108
MHMatrixAssemblyLMH::compute_conductivity
virtual double compute_conductivity(FMT_UNUSED const DHCellAccessor &cell, BulkPoint &p)
Definition: assembly_lmh_old.hh:604
ReconstructSchurAssemblyLMH::begin
void begin() override
Implements AssemblyBase::begin.
Definition: assembly_lmh_old.hh:699
ReconstructSchurAssemblyLMH::EqFields
DarcyLMH::EqFields EqFields
Definition: assembly_lmh_old.hh:689
ReadInitCondAssemblyLMH::eq_fields_
EqFields * eq_fields_
Data objects shared with Flow equation.
Definition: assembly_lmh_old.hh:103
MHMatrixAssemblyLMH::fe_rt_
FE_RT0< dim > fe_rt_
Assembly volume integrals.
Definition: assembly_lmh_old.hh:653
DarcyMH::EqFields::sigma
Field< 3, FieldValue< 3 >::Scalar > sigma
Definition: darcy_flow_mh.hh:173
Armor::vec
ArmaVec< double, N > vec
Definition: armor.hh:885
fe_rt.hh
Definitions of Raviart-Thomas finite elements.
MHMatrixAssemblyLMH::quad_rt_
QGauss quad_rt_
Definition: assembly_lmh_old.hh:654
DarcyLMH::EqData::reset
void reset()
Reset data members.
Definition: darcy_flow_lmh.cc:180
FEValues::vector_view
const FEValuesViews::Vector< spacedim > & vector_view(unsigned int i) const
Accessor to vector values of multicomponent FE.
Definition: fe_values.hh:277
MHMatrixAssemblyLMH::eq_fields_
EqFields * eq_fields_
Data objects shared with DarcyFlow.
Definition: assembly_lmh_old.hh:649
FEValues::n_points
unsigned int n_points() const
Returns the number of quadrature points.
Definition: fe_values.hh:296
DHCellSide::side
Side side() const
Return Side of given cell and side_idx.
Definition: dh_cell_accessor.hh:198
ReconstructSchurAssemblyLMH::reconstruct_schur_finish
void reconstruct_schur_finish()
Definition: assembly_lmh_old.hh:727
ReconstructSchurAssemblyLMH::dirichlet_switch
void dirichlet_switch(FMT_UNUSED char &switch_dirichlet, FMT_UNUSED DHCellSide cell_side) override
Definition: assembly_lmh_old.hh:750
fe_values_views.hh
DarcyLMH::EqData
Definition: darcy_flow_lmh.hh:157
ReconstructSchurAssemblyLMH::end
void end() override
Implements AssemblyBase::end.
Definition: assembly_lmh_old.hh:714
neighbours.h
DarcyLMH::EqData::p_edge_solution
VectorMPI p_edge_solution
Definition: darcy_flow_lmh.hh:175
DarcyMH::EqFields::river
@ river
Definition: darcy_flow_mh.hh:154
MHMatrixAssemblyLMH::side_row_
unsigned int side_row_
Definition: assembly_lmh_old.hh:671
AssemblyBase::quad_low_
Quadrature * quad_low_
Quadrature used in assembling methods (dim-1).
Definition: assembly_base.hh:190
ASSERT
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library.
Definition: asserts.hh:347
DarcyMH::EqFields::bc_robin_sigma
BCField< 3, FieldValue< 3 >::Scalar > bc_robin_sigma
Definition: darcy_flow_mh.hh:178
FEValues::normal_vector
arma::vec::fixed< spacedim > normal_vector(unsigned int point_no)
Returns the normal vector to a side at given quadrature point.
Definition: fe_values.hh:257
ReconstructSchurAssemblyLMH::EqData
DarcyLMH::EqData EqData
Definition: assembly_lmh_old.hh:690
ReadInitCondAssemblyLMH::used_fields_
FieldSet used_fields_
Sub field set contains fields used in calculation.
Definition: assembly_lmh_old.hh:100
DHCellSide::cond
Boundary cond() const
Definition: dh_cell_accessor.hh:231
ReadInitCondAssemblyLMH::p_indices_
LocDofVec p_indices_
Definition: assembly_lmh_old.hh:106
FEValues::JxW
double JxW(const unsigned int point_no)
Return the product of Jacobian determinant and the quadrature weight at given quadrature point.
Definition: fe_values.hh:223
DarcyMH::EqFields::bc_flux
BCField< 3, FieldValue< 3 >::Scalar > bc_flux
Definition: darcy_flow_mh.hh:177
VectorMPI::ghost_to_local_begin
void ghost_to_local_begin()
ghost_to_local_{begin,end} updates the local values by adding ghost values from neighbouring processo...
Definition: vector_mpi.hh:164
Edge::n_sides
unsigned int n_sides() const
Returns number of sides aligned with the edge.
Definition: accessors.hh:335
DarcyLMH::EqData::seepage_bc_systems
std::map< LongIdx, LocalSystem > seepage_bc_systems
Definition: darcy_flow_lmh.hh:179
MHMatrixAssemblyLMH::bc_flux_
double bc_flux_
Definition: assembly_lmh_old.hh:673
VectorMPI::zero_entries
void zero_entries()
Definition: vector_mpi.hh:82
ElementCacheMap
Directing class of FieldValueCache.
Definition: field_value_cache.hh:151
DarcyMH::EqData::dh_cr_
std::shared_ptr< SubDOFHandlerMultiDim > dh_cr_
DOF handler represents DOFs of edges.
Definition: darcy_flow_mh.hh:219
DarcyMH::EqFields::extra_source
Field< 3, FieldValue< 3 >::Scalar > extra_source
Externally added storativity.
Definition: darcy_flow_mh.hh:184
fe_values.hh
Class FEValues calculates finite element data on the actual cells such as shape function values,...
DHCellAccessor::is_own
bool is_own() const
Return true if accessor represents own element (false for ghost element)
Definition: dh_cell_accessor.hh:130
ReadInitCondAssemblyLMH::~ReadInitCondAssemblyLMH
virtual ~ReadInitCondAssemblyLMH()
Destructor.
Definition: assembly_lmh_old.hh:61
ASSERT_DBG
#define ASSERT_DBG(expr)
Definition: include_fadbad.hh:28
MHMatrixAssemblyLMH::end
void end() override
Implements AssemblyBase::end.
Definition: assembly_lmh_old.hh:400
update_values
@ update_values
Shape function values.
Definition: update_flags.hh:87
BulkPoint
Base point accessor class.
Definition: eval_subset.hh:55
MHMatrixAssemblyLMH::postprocess_velocity
void postprocess_velocity(const DHCellAccessor &dh_cell, unsigned int element_patch_idx, arma::vec &solution)
Definition: assembly_lmh_old.hh:570
DarcyLMH::EqData::schur_offset_
std::array< unsigned int, 3 > schur_offset_
Index offset in the local system for the Schur complement (of dim = 1,2,3).
Definition: darcy_flow_lmh.hh:204
DarcyMH::EqFields::init_pressure
Field< 3, FieldValue< 3 >::Scalar > init_pressure
Definition: darcy_flow_mh.hh:181
FEValues::initialize
void initialize(Quadrature &_quadrature, FiniteElement< DIM > &_fe, UpdateFlags _flags)
Initialize structures and calculates cell-independent data.
Definition: fe_values.cc:137
THROW
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
Definition: exceptions.hh:53
ElementAccessor< 3 >
Neighbour::side
SideIter side() const
Definition: neighbours.h:147
MHMatrixAssemblyLMH::dimjoin_intergral
void dimjoin_intergral(DHCellAccessor cell_lower_dim, DHCellSide neighb_side)
Assembles the fluxes between elements of different dimensions.
Definition: assembly_lmh_old.hh:345
MHMatrixAssemblyLMH::bc_total_flux_
double bc_total_flux_
Definition: assembly_lmh_old.hh:673
update_quadrature_points
@ update_quadrature_points
Transformed quadrature points.
Definition: update_flags.hh:102
arma::vec3
Definition: doxy_dummy_defs.hh:17
ASSERT_EQ_DBG
#define ASSERT_EQ_DBG(a, b)
Definition of comparative assert macro (EQual) only for debug mode.
Definition: asserts.hh:332
DarcyLMH::EqData::lin_sys_schur
std::shared_ptr< LinSys > lin_sys_schur
Definition: darcy_flow_lmh.hh:174
MHMatrixAssemblyLMH::boundary_side_integral
void boundary_side_integral(DHCellSide cell_side)
Definition: assembly_lmh_old.hh:258
DHCellAccessor::dim
unsigned int dim() const
Return dimension of element appropriate to cell.
Definition: dh_cell_accessor.hh:101
ReadInitCondAssemblyLMH::p_idx_
unsigned int p_idx_
Definition: assembly_lmh_old.hh:107
DarcyLMH::EqFields
Definition: darcy_flow_lmh.hh:150
update_normal_vectors
@ update_normal_vectors
Normal vectors.
Definition: update_flags.hh:124
uint
unsigned int uint
Definition: mh_dofhandler.hh:101
DHCellSide::dim
unsigned int dim() const
Return dimension of element appropriate to the side.
Definition: dh_cell_accessor.hh:214
ReadInitCondAssemblyLMH::cell_integral
void cell_integral(DHCellAccessor cell, unsigned int element_patch_idx)
Assemble integral over element.
Definition: assembly_lmh_old.hh:70
MHMatrixAssemblyLMH::used_fields_
FieldSet used_fields_
Sub field set contains fields used in calculation.
Definition: assembly_lmh_old.hh:646
Side::cond
Boundary cond() const
Definition: accessors_impl.hh:225
linsys_PETSC.hh
Solver based on the original PETSc solver using MPIAIJ matrix and succesive Schur complement construc...
ReadInitCondAssemblyLMH::initialize
void initialize(ElementCacheMap *element_cache_map)
Initialize auxiliary vectors and other data members.
Definition: assembly_lmh_old.hh:64
darcy_flow_lmh.hh
Lumped mixed-hybrid model of linear Darcy flow, possibly unsteady.
ElementAccessor::element
const Element * element() const
Definition: accessors.hh:196
DarcyMH::EqData::gravity_vec_
arma::vec3 gravity_vec_
Definition: darcy_flow_mh.hh:214
MHMatrixAssemblyLMH::coef_
double coef_
Definition: assembly_lmh_old.hh:667
assembly_base.hh
index_types.hh
fe_system.hh
Class FESystem for compound finite elements.
DarcyMH::EqData::dh_
std::shared_ptr< DOFHandlerMultiDim > dh_
full DOF handler represents DOFs of sides, elements and edges
Definition: darcy_flow_mh.hh:218
Dim
Definition: mixed.hh:25
FEValues< 3 >
MHMatrixAssemblyLMH::ndofs_
unsigned int ndofs_
Number of dofs.
Definition: assembly_lmh_old.hh:656
ReadInitCondAssemblyLMH::init_value_
double init_value_
Definition: assembly_lmh_old.hh:108
MHMatrixAssemblyLMH::old_pressure_
double old_pressure_
Precomputed values in postprocess_velocity_specific.
Definition: assembly_lmh_old.hh:678
fe_p.hh
Definitions of basic Lagrangean finite elements with polynomial shape functions.
ReconstructSchurAssemblyLMH::postprocess_bulk_integral
void postprocess_bulk_integral(const DHCellAccessor &cell, unsigned int element_patch_idx) override
Definition: assembly_lmh_old.hh:744
DHCellSide
Side accessor allows to iterate over sides of DOF handler cell.
Definition: dh_cell_accessor.hh:176
MHMatrixAssemblyLMH::bc_sigma_
double bc_sigma_
Precomputed values in boundary assembly.
Definition: assembly_lmh_old.hh:674
ReadInitCondAssemblyLMH::ReadInitCondAssemblyLMH
ReadInitCondAssemblyLMH(EqFields *eq_fields, EqData *eq_data)
Constructor.
Definition: assembly_lmh_old.hh:54
DarcyMH::EqFields::cross_section
Field< 3, FieldValue< 3 >::Scalar > cross_section
Definition: darcy_flow_mh.hh:171
FEValues::n_dofs
unsigned int n_dofs() const
Returns the number of shape functions.
Definition: fe_values.hh:302
accessors.hh
DarcyLMH::EqData::loc_edge_dofs
std::array< std::vector< unsigned int >, 3 > loc_edge_dofs
Definition: darcy_flow_lmh.hh:197
MHMatrixAssemblyLMH::DECLARE_EXCEPTION
DECLARE_EXCEPTION(ExcBCNotSupported,<< "BC type not supported.\n")
MHMatrixAssemblyLMH::conductivity_
double conductivity_
Definition: assembly_lmh_old.hh:665
DHCellAccessor::cell_with_other_dh
DHCellAccessor cell_with_other_dh(const DOFHandlerMultiDim *dh) const
Create new accessor with same local idx and given DOF handler. Actual and given DOF handler must be c...
Definition: dh_cell_accessor.hh:135
DarcyMH::EqFields::water_source_density
Field< 3, FieldValue< 3 >::Scalar > water_source_density
Definition: darcy_flow_mh.hh:172
DHCellSide::cell
const DHCellAccessor & cell() const
Return DHCellAccessor appropriate to the side.
Definition: dh_cell_accessor.hh:204
ReadInitCondAssemblyLMH::name
static constexpr const char * name()
Definition: assembly_lmh_old.hh:51
DarcyMH::EqData::bc_switch_dirichlet
std::vector< char > bc_switch_dirichlet
Idicator of dirichlet or neumann type of switch boundary conditions.
Definition: darcy_flow_mh.hh:235
MHMatrixAssemblyLMH::assemble_source_term
virtual void assemble_source_term(const DHCellAccessor &cell, BulkPoint &p)
Definition: assembly_lmh_old.hh:488
DarcyMH::EqFields::conductivity
Field< 3, FieldValue< 3 >::Scalar > conductivity
Definition: darcy_flow_mh.hh:170
MHMatrixAssemblyLMH::load_local_system
void load_local_system(const DHCellAccessor &dh_cell)
Definition: assembly_lmh_old.hh:548
DarcyLMH::EqData::postprocess_solution_
std::vector< arma::vec > postprocess_solution_
Definition: darcy_flow_lmh.hh:195
DarcyLMH::EqData::loc_schur_
std::vector< LocalSystem > loc_schur_
Definition: darcy_flow_lmh.hh:194
MHMatrixAssemblyLMH::time_term_diag_
double time_term_diag_
Definition: assembly_lmh_old.hh:668
generic_assembly.hh
quadrature_lib.hh
Definitions of particular quadrature rules on simplices.
DarcyMH::EqData::is_linear
int is_linear
Hack fo BDDC solver.
Definition: darcy_flow_mh.hh:231
DHCellAccessor::local_idx
unsigned int local_idx() const
Return local index to element (index of DOF handler).
Definition: dh_cell_accessor.hh:58
MHMatrixAssemblyLMH::begin
void begin() override
Implements AssemblyBase::begin.
Definition: assembly_lmh_old.hh:383
ReadInitCondAssemblyLMH::end
void end() override
Implements AssemblyBase::end.
Definition: assembly_lmh_old.hh:88
schur.hh
Assembly explicit Schur complement for the given linear system. Provides method for resolution of the...
DarcyLMH::EqData::loc_system_
std::vector< LocalSystem > loc_system_
Following data members are stored in vectors, one item for every cell.
Definition: darcy_flow_lmh.hh:193
MHMatrixAssemblyLMH::postprocess_velocity_specific
virtual void postprocess_velocity_specific(const DHCellAccessor &dh_cell, BulkPoint &p, arma::vec &solution, double edge_scale, double edge_source_term)
Definition: assembly_lmh_old.hh:586
MHMatrixAssemblyLMH::cross_section_
double cross_section_
Precomputed cross-section value.
Definition: assembly_lmh_old.hh:669
DarcyMH::EqFields::bc_switch_pressure
BCField< 3, FieldValue< 3 >::Scalar > bc_switch_pressure
Definition: darcy_flow_mh.hh:179
DHCellAccessor::elm
const ElementAccessor< 3 > elm() const
Return ElementAccessor to element of loc_ele_idx_.
Definition: dh_cell_accessor.hh:71
ReconstructSchurAssemblyLMH::name
static constexpr const char * name()
Definition: assembly_lmh_old.hh:692
MHMatrixAssemblyLMH::schur_postprocess
void schur_postprocess()
Definition: assembly_lmh_old.hh:469
MHMatrixAssemblyLMH::fe_
shared_ptr< FiniteElement< dim > > fe_
Finite element for the solution of the advection-diffusion equation.
Definition: assembly_lmh_old.hh:659
MHMatrixAssemblyLMH::source_term_
double source_term_
Variables used in compute lumped source.
Definition: assembly_lmh_old.hh:667
VectorMPI::get_subvec
arma::vec get_subvec(const LocDofVec &loc_indices)
Definition: vector_mpi.cc:110
MHMatrixAssemblyLMH::postprocess_bulk_integral
virtual void postprocess_bulk_integral(FMT_UNUSED const DHCellAccessor &cell, FMT_UNUSED unsigned intelement_patch_idx)
Definition: assembly_lmh_old.hh:608
local_system.hh
MHMatrixAssemblyLMH::EqFields
DarcyLMH::EqFields EqFields
Definition: assembly_lmh_old.hh:119
MHMatrixAssemblyLMH::time_term_rhs_
double time_term_rhs_
Variables used in compute time term (unsteady)
Definition: assembly_lmh_old.hh:668
VectorMPI::ghost_to_local_end
void ghost_to_local_end()
ghost_to_local_{begin,end} updates the local values by adding ghost values from neighbouring processo...
Definition: vector_mpi.hh:168
DarcyMH::EqData::full_solution
VectorMPI full_solution
Definition: darcy_flow_mh.hh:237
MHMatrixAssemblyLMH::dirichlet_switch
virtual void dirichlet_switch(char &switch_dirichlet, DHCellSide cell_side)
Definition: assembly_lmh_old.hh:611
VectorMPI::local_to_ghost_begin
void local_to_ghost_begin()
local_to_ghost_{begin,end} updates the ghost values on neighbouring processors from local values
Definition: vector_mpi.hh:156
MHMatrixAssemblyLMH::sidx_
unsigned int sidx_
Definition: assembly_lmh_old.hh:671
MHMatrixAssemblyLMH::mat_val_
double mat_val_
Precomputed RHS and mat value.
Definition: assembly_lmh_old.hh:666
MHMatrixAssemblyLMH::scale_sides_
double scale_sides_
Precomputed value (1 / cross_section / conductivity)
Definition: assembly_lmh_old.hh:665
FieldSet
Container for various descendants of FieldCommonBase.
Definition: field_set.hh:159
mesh.h
DHCellAccessor::n_dofs
unsigned int n_dofs() const
Return number of dofs on given cell.
Definition: dh_cell_accessor.hh:420
Boundary::element_accessor
ElementAccessor< 3 > element_accessor()
Definition: accessors_impl.hh:253
DarcyMH::EqFields::bc_type
BCField< 3, FieldValue< 3 >::Enum > bc_type
Definition: darcy_flow_mh.hh:175
MHMatrixAssemblyLMH::eq_data_
EqData * eq_data_
Definition: assembly_lmh_old.hh:650
DarcyMH::EqFields::none
@ none
Definition: darcy_flow_mh.hh:150
DHCellAccessor::elm_idx
unsigned int elm_idx() const
Return serial idx to element of loc_ele_idx_.
Definition: dh_cell_accessor.hh:64
coupling
@ coupling
Definition: generic_assembly.hh:35
DarcyMH::EqData::force_no_neumann_bc
bool force_no_neumann_bc
auxiliary flag for switchting Dirichlet like BC
Definition: darcy_flow_mh.hh:232
DarcyLMH::EqData::nonlinear_iteration_
unsigned int nonlinear_iteration_
Definition: darcy_flow_lmh.hh:184
DarcyMH::EqFields::BC_Type
BC_Type
Definition: darcy_flow_mh.hh:149
VectorMPI::add
void add(unsigned int pos, double val)
Add value to item on given position.
Definition: vector_mpi.hh:125
DarcyLMH::EqData::time_step_
double time_step_
Definition: darcy_flow_lmh.hh:172
QGauss
Symmetric Gauss-Legendre quadrature formulae on simplices.
Definition: quadrature_lib.hh:34
Element::neigh_vb
Neighbour ** neigh_vb
Definition: elements.h:83
DarcyLMH::EqData::use_steady_assembly_
bool use_steady_assembly_
Definition: darcy_flow_lmh.hh:169
ReadInitCondAssemblyLMH::EqFields
DarcyLMH::EqFields EqFields
Definition: assembly_lmh_old.hh:48
DHCellSide::elem_idx
unsigned int elem_idx() const
Definition: dh_cell_accessor.hh:227
AssemblyBase::bulk_points
Range< BulkPoint > bulk_points(unsigned int element_patch_idx) const
Return BulkPoint range of appropriate dimension.
Definition: assembly_base.hh:104
MHMatrixAssemblyLMH::side_flux_
double side_flux_
Precomputed values in boundary assembly.
Definition: assembly_lmh_old.hh:673
MHMatrixAssemblyLMH::reconstructed_solution_
arma::vec reconstructed_solution_
Vector for reconstructed solution (velocity and pressure on element) from Schur complement.
Definition: assembly_lmh_old.hh:663
MHMatrixAssemblyLMH::MHMatrixAssemblyLMH
MHMatrixAssemblyLMH(EqFields *eq_fields, EqData *eq_data)
Constructor.
Definition: assembly_lmh_old.hh:127
MHMatrixAssemblyLMH::fe_values_side_
FEValues< 3 > fe_values_side_
FEValues of object (of P disc finite element type)
Definition: assembly_lmh_old.hh:660
DarcyMH::EqFields::total_flux
@ total_flux
Definition: darcy_flow_mh.hh:152
ReadInitCondAssemblyLMH::l_idx_
unsigned int l_idx_
Local DOF indices extract from previous vectors.
Definition: assembly_lmh_old.hh:107
MHMatrixAssemblyLMH::solution_head_
double solution_head_
Precomputed value in boundary assembly.
Definition: assembly_lmh_old.hh:672
Element::n_sides
unsigned int n_sides() const
Definition: elements.h:131
bulk
@ bulk
Definition: generic_assembly.hh:33
DarcyLMH::EqData::loc_side_dofs
std::array< std::vector< unsigned int >, 3 > loc_side_dofs
Definition: darcy_flow_lmh.hh:196
DHCellAccessor
Cell accessor allow iterate over DOF handler cells.
Definition: dh_cell_accessor.hh:43
VectorMPI::set_subvec
void set_subvec(const LocDofVec &loc_indices, const arma::vec &values)
Definition: vector_mpi.cc:138
DarcyMH::EqData::water_balance_idx
uint water_balance_idx
Definition: darcy_flow_mh.hh:223
MHMatrixAssemblyLMH::~MHMatrixAssemblyLMH
virtual ~MHMatrixAssemblyLMH()
Destructor.
Definition: assembly_lmh_old.hh:146
FESystem::fe_dofs
std::vector< unsigned int > fe_dofs(unsigned int fe_index)
Return dof indices belonging to given sub-FE.
Definition: fe_system.cc:267
MHMatrixAssemblyLMH
Definition: assembly_lmh_old.hh:116
field_value_cache.hh
MHMatrixAssemblyLMH::ngh_idx
unsigned int ngh_idx(DHCellAccessor &dh_cell, DHCellSide &neighb_side)
Temporary method find neighbour index in higher-dim cell.
Definition: assembly_lmh_old.hh:533
AssemblyBase::active_integrals_
int active_integrals_
Holds mask of active integrals.
Definition: assembly_base.hh:191
DarcyMH::EqData::balance
std::shared_ptr< Balance > balance
Definition: darcy_flow_mh.hh:227
MHMatrixAssemblyLMH::nv_
arma::vec3 nv_
Normal vector.
Definition: assembly_lmh_old.hh:675
update_JxW_values
@ update_JxW_values
Transformed quadrature weights.
Definition: update_flags.hh:114
MHMatrixAssemblyLMH::edge_source_term_
double edge_source_term_
Precomputed values in postprocess_velocity.
Definition: assembly_lmh_old.hh:677
MHMatrixAssemblyLMH::bc_pressure_
double bc_pressure_
Definition: assembly_lmh_old.hh:674
VectorMPI::local_to_ghost_end
void local_to_ghost_end()
local_to_ghost_{begin,end} updates the ghost values on neighbouring processors from local values
Definition: vector_mpi.hh:160
MHMatrixAssemblyLMH::fe_values_
FEValues< 3 > fe_values_
Definition: assembly_lmh_old.hh:655
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
MHMatrixAssemblyLMH::n_sides_
double n_sides_
Definition: assembly_lmh_old.hh:667
MHMatrixAssemblyLMH::bulk_local_idx_
unsigned int bulk_local_idx_
Local idx of bulk element.
Definition: assembly_lmh_old.hh:670
DarcyMH::EqFields::seepage
@ seepage
Definition: darcy_flow_mh.hh:153
MHMatrixAssemblyLMH::bc_switch_pressure_
double bc_switch_pressure_
Definition: assembly_lmh_old.hh:674
ElementAccessor::idx
unsigned int idx() const
We need this method after replacing Region by RegionIdx, and movinf RegionDB instance into particular...
Definition: accessors.hh:218
DarcyMH::EqFields::extra_storativity
Field< 3, FieldValue< 3 >::Scalar > extra_storativity
Definition: darcy_flow_mh.hh:183
AssemblyBase
Definition: assembly_base.hh:34
MHMatrixAssemblyLMH::ngh_value_
double ngh_value_
Precomputed ngh value.
Definition: assembly_lmh_old.hh:676
VectorMPI::get
double get(unsigned int pos) const
Return value on given position.
Definition: vector_mpi.hh:105
balance.hh
FEValues::reinit
void reinit(const ElementAccessor< spacedim > &cell)
Update cell-dependent data (gradients, Jacobians etc.)
Definition: fe_values.cc:536
ReconstructSchurAssemblyLMH
Definition: assembly_lmh_old.hh:686
MHMatrixAssemblyLMH::time_term_
double time_term_
Definition: assembly_lmh_old.hh:668
DarcyMH::EqFields::storativity
Field< 3, FieldValue< 3 >::Scalar > storativity
Definition: darcy_flow_mh.hh:182
ReadInitCondAssemblyLMH::EqData
DarcyLMH::EqData EqData
Definition: assembly_lmh_old.hh:49
DarcyLMH::EqData::balance_
std::shared_ptr< Balance > balance_
Shared Balance object.
Definition: darcy_flow_lmh.hh:182
MHMatrixAssemblyLMH::rhs_val_
double rhs_val_
Definition: assembly_lmh_old.hh:666
MHMatrixAssemblyLMH::EqData
DarcyLMH::EqData EqData
Definition: assembly_lmh_old.hh:120
MHMatrixAssemblyLMH::name
static constexpr const char * name()
Definition: assembly_lmh_old.hh:124
boundary
@ boundary
Definition: generic_assembly.hh:36
AssemblyBase::coupling_points
Range< CouplingPoint > coupling_points(const DHCellSide &cell_side) const
Return CouplingPoint range of appropriate dimension.
Definition: assembly_base.hh:115
DarcyMH::EqFields::dirichlet
@ dirichlet
Definition: darcy_flow_mh.hh:151
DHCellSide::side_idx
unsigned int side_idx() const
Definition: dh_cell_accessor.hh:235
MHMatrixAssemblyLMH::set_dofs
void set_dofs()
Definition: assembly_lmh_old.hh:410
MHMatrixAssemblyLMH::initialize
void initialize(ElementCacheMap *element_cache_map)
Initialize auxiliary vectors and other data members.
Definition: assembly_lmh_old.hh:149
ElementAccessor::side
SideIter side(const unsigned int loc_index)
Definition: accessors_impl.hh:139
MHMatrixAssemblyLMH::qsize_
unsigned int qsize_
Size of quadrature of dim-1.
Definition: assembly_lmh_old.hh:657
ReadInitCondAssemblyLMH::eq_data_
EqData * eq_data_
Definition: assembly_lmh_old.hh:104
DarcyLMH::EqData::loc_ele_dof
std::array< unsigned int, 3 > loc_ele_dof
Definition: darcy_flow_lmh.hh:198
DarcyMH::EqFields::anisotropy
Field< 3, FieldValue< 3 >::TensorFixed > anisotropy
Definition: darcy_flow_mh.hh:169
GenericAssembly
Generic class of assemblation.
Definition: generic_assembly.hh:160
FESystem
Compound finite element on dim dimensional simplex.
Definition: fe_system.hh:101
ReconstructSchurAssemblyLMH::ReconstructSchurAssemblyLMH
ReconstructSchurAssemblyLMH(EqFields *eq_fields, EqData *eq_data)
Constructor.
Definition: assembly_lmh_old.hh:695
AssemblyBase::boundary_points
Range< BoundaryPoint > boundary_points(const DHCellSide &cell_side) const
Return BoundaryPoint range of appropriate dimension.
Definition: assembly_base.hh:121
MHMatrixAssemblyLMH::cell_integral
void cell_integral(DHCellAccessor cell, unsigned int element_patch_idx)
Assemble source term (integral over element)
Definition: assembly_lmh_old.hh:179
AssemblyBase::element_cache_map_
ElementCacheMap * element_cache_map_
ElementCacheMap shared with GenericAssembly object.
Definition: assembly_base.hh:193
MHMatrixAssemblyLMH::edge_row_
unsigned int edge_row_
Helper indices in boundary assembly.
Definition: assembly_lmh_old.hh:671
ElementAccessor::measure
double measure() const
Computes the measure of the element.
Definition: accessors_impl.hh:67
FMT_UNUSED
#define FMT_UNUSED
Definition: posix.h:75
DarcyLMH::EqData::p_edge_solution_previous_time
VectorMPI p_edge_solution_previous_time
Definition: darcy_flow_lmh.hh:177
DHCellSide::measure
double measure() const
Definition: dh_cell_accessor.hh:239
IntDim
unsigned int IntDim
A dimension index type.
Definition: mixed.hh:19