Flow123d  JS_before_hm-2087-gb06a8f5d8
darcy_flow_lmh.cc
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 darcy_flow_lmh.cc
15  * @ingroup flow
16  * @brief Setup and solve linear system of mixed-hybrid discretization of the linear
17  * porous media flow with possible preferential flow in fractures and chanels.
18  */
19 
20 //#include <limits>
21 #include <vector>
22 //#include <iostream>
23 //#include <iterator>
24 //#include <algorithm>
25 #include <armadillo>
26 
27 #include "petscmat.h"
28 #include "petscviewer.h"
29 #include "petscerror.h"
30 #include "mpi.h"
31 
32 #include "system/system.hh"
33 #include "system/sys_profiler.hh"
34 #include "system/index_types.hh"
35 #include "input/factory.hh"
36 
37 #include "mesh/mesh.h"
38 #include "mesh/bc_mesh.hh"
39 #include "mesh/partitioning.hh"
40 #include "mesh/accessors.hh"
41 #include "mesh/range_wrapper.hh"
42 #include "la/distribution.hh"
43 #include "la/linsys.hh"
44 #include "la/linsys_PETSC.hh"
45 // #include "la/linsys_BDDC.hh"
46 #include "la/schur.hh"
47 //#include "la/sparse_graph.hh"
49 #include "la/vector_mpi.hh"
50 
51 #include "flow/assembly_lmh_old.hh"
52 #include "flow/darcy_flow_lmh.hh"
54 #include "flow/assembly_models.hh"
55 
56 #include "tools/time_governor.hh"
58 #include "fields/field.hh"
59 #include "fields/field_values.hh"
61 #include "fields/field_fe.hh"
62 #include "fields/field_model.hh"
63 #include "fields/field_constant.hh"
64 
65 #include "coupling/balance.hh"
66 
69 
70 #include "fem/fe_p.hh"
71 
72 
73 FLOW123D_FORCE_LINK_IN_CHILD(darcy_flow_lmh)
74 
75 
76 
77 
78 namespace it = Input::Type;
79 
81  return it::Selection("MH_MortarMethod")
82  .add_value(NoMortar, "None", "No Mortar method is applied.")
83  .add_value(MortarP0, "P0", "Mortar space: P0 on elements of lower dimension.")
84  .add_value(MortarP1, "P1", "Mortar space: P1 on intersections, using non-conforming pressures.")
85  .close();
86 }
87 
89 
90  const it::Record &field_descriptor =
91  it::Record("Flow_Darcy_LMH_Data",FieldCommon::field_descriptor_record_description("Flow_Darcy_LMH_Data") )
92  .copy_keys( DarcyLMH::EqFields().make_field_descriptor_type("Flow_Darcy_LMH_Data_aux") )
93  .declare_key("bc_piezo_head", FieldAlgorithmBase< 3, FieldValue<3>::Scalar >::get_input_type_instance(),
94  "Boundary piezometric head for BC types: dirichlet, robin, and river." )
95  .declare_key("bc_switch_piezo_head", FieldAlgorithmBase< 3, FieldValue<3>::Scalar >::get_input_type_instance(),
96  "Boundary switch piezometric head for BC types: seepage, river." )
97  .declare_key("init_piezo_head", FieldAlgorithmBase< 3, FieldValue<3>::Scalar >::get_input_type_instance(),
98  "Initial condition for the pressure given as the piezometric head." )
99  .close();
100  return field_descriptor;
101 }
102 
104 
105  it::Record ns_rec = Input::Type::Record("NonlinearSolver", "Non-linear solver settings.")
106  .declare_key("linear_solver", LinSys::get_input_type(), it::Default("{}"),
107  "Linear solver for MH problem.")
108  .declare_key("tolerance", it::Double(0.0), it::Default("1E-6"),
109  "Residual tolerance.")
110  .declare_key("min_it", it::Integer(0), it::Default("1"),
111  "Minimum number of iterations (linear solutions) to use.\nThis is usefull if the convergence criteria "
112  "does not characterize your goal well enough so it converges prematurely, possibly even without a single linear solution."
113  "If greater then 'max_it' the value is set to 'max_it'.")
114  .declare_key("max_it", it::Integer(0), it::Default("100"),
115  "Maximum number of iterations (linear solutions) of the non-linear solver.")
116  .declare_key("converge_on_stagnation", it::Bool(), it::Default("false"),
117  "If a stagnation of the nonlinear solver is detected the solver stops. "
118  "A divergence is reported by default, forcing the end of the simulation. By setting this flag to 'true', the solver "
119  "ends with convergence success on stagnation, but it reports warning about it.")
120  .close();
121 
123 
124  return it::Record("Flow_Darcy_LMH", "Lumped Mixed-Hybrid solver for saturated Darcy flow.")
127  .declare_key("gravity", it::Array(it::Double(), 3,3), it::Default("[ 0, 0, -1]"),
128  "Vector of the gravity force. Dimensionless.")
130  "Input data for Darcy flow model.")
131  .declare_key("nonlinear_solver", ns_rec, it::Default("{}"),
132  "Non-linear solver for MH problem.")
133  .declare_key("output_stream", OutputTime::get_input_type(), it::Default("{}"),
134  "Output stream settings.\n Specify file format, precision etc.")
135 
136  .declare_key("output", DarcyFlowMHOutput::get_input_type(eq_fields, "Flow_Darcy_LMH"),
137  IT::Default("{ \"fields\": [ \"pressure_p0\", \"velocity_p0\" ] }"),
138  "Specification of output fields and output times.")
140  "Output settings specific to Darcy flow model.\n"
141  "Includes raw output and some experimental functionality.")
142  .declare_key("balance", Balance::get_input_type(), it::Default("{}"),
143  "Settings for computing mass balance.")
144  .declare_key("mortar_method", get_mh_mortar_selection(), it::Default("\"None\""),
145  "Method for coupling Darcy flow between dimensions on incompatible meshes. [Experimental]" )
146  .close();
147 }
148 
149 
150 const int DarcyLMH::registrar =
151  Input::register_class< DarcyLMH, Mesh &, const Input::Record >("Flow_Darcy_LMH") +
153 
154 
155 
158 {
159 }
160 
161 
162 
164 : DarcyMH::EqData::EqData()
165 {
166 }
167 
168 
169 
170 
171 
172 
173 //=============================================================================
174 // CREATE AND FILL GLOBAL MH MATRIX OF THE WATER MODEL
175 // - do it in parallel:
176 // - initial distribution of elements, edges
177 //
178 /*! @brief CREATE AND FILL GLOBAL MH MATRIX OF THE WATER MODEL
179  *
180  * Parameters {Solver,NSchurs} number of performed Schur
181  * complements (0,1,2) for water flow MH-system
182  *
183  */
184 //=============================================================================
185 DarcyLMH::DarcyLMH(Mesh &mesh_in, const Input::Record in_rec, TimeGovernor *tm)
186 : DarcyFlowInterface(mesh_in, in_rec),
187  output_object(nullptr),
188  data_changed_(false)
189 {
190 
191  START_TIMER("Darcy constructor");
192  {
193  auto time_record = input_record_.val<Input::Record>("time");
194  if (tm == nullptr)
195  {
196  time_ = new TimeGovernor(time_record);
197  }
198  else
199  {
200  TimeGovernor tm_from_rec(time_record);
201  if (!tm_from_rec.is_default()) // is_default() == false when time record is present in input file
202  {
203  MessageOut() << "Duplicate key 'time', time in flow equation is already initialized from parent class!";
204  ASSERT(false);
205  }
206  time_ = tm;
207  }
208  }
209 
210  eq_fields_ = make_shared<EqFields>();
211  eq_data_ = make_shared<EqData>();
212  this->eq_fieldset_ = eq_fields_.get();
213 
214  eq_data_->is_linear=true;
215 
216  size = mesh_->n_elements() + mesh_->n_sides() + mesh_->n_edges();
217  eq_data_->mortar_method_= in_rec.val<MortarMethod>("mortar_method");
218  if (eq_data_->mortar_method_ != NoMortar) {
220  }
221 
222 
223 
224  //side_ds->view( std::cout );
225  //el_ds->view( std::cout );
226  //edge_ds->view( std::cout );
227  //rows_ds->view( std::cout );
228 
229 }
230 
231 
232 
234 //connecting data fields with mesh
235 {
236 
237  START_TIMER("data init");
238  eq_data_->mesh = mesh_;
239  eq_fields_->set_mesh(*mesh_);
240 
241  auto gravity_array = input_record_.val<Input::Array>("gravity");
242  std::vector<double> gvec;
243  gravity_array.copy_to(gvec);
244  gvec.push_back(0.0); // zero pressure shift
245  eq_data_->gravity_ = arma::vec(gvec);
246  eq_data_->gravity_vec_ = eq_data_->gravity_.subvec(0,2);
247 
248  FieldValue<3>::VectorFixed gvalue(eq_data_->gravity_vec_);
249  auto field_algo=std::make_shared<FieldConstant<3, FieldValue<3>::VectorFixed>>();
250  field_algo->set_value(gvalue);
251  eq_fields_->gravity_field.set(field_algo, 0.0);
252  eq_fields_->bc_gravity.set(field_algo, 0.0);
253 
254  eq_fields_->bc_pressure.add_factory(
255  std::make_shared<AddPotentialFactory<3, FieldValue<3>::Scalar> >
256  (eq_fields_->bc_gravity, eq_fields_->X(), eq_fields_->bc_piezo_head) );
257  eq_fields_->bc_switch_pressure.add_factory(
258  std::make_shared<AddPotentialFactory<3, FieldValue<3>::Scalar> >
259  (eq_fields_->bc_gravity, eq_fields_->X(), eq_fields_->bc_switch_piezo_head) );
260  eq_fields_->init_pressure.add_factory(
261  std::make_shared<AddPotentialFactory<3, FieldValue<3>::Scalar> >
262  (eq_fields_->gravity_field, eq_fields_->X(), eq_fields_->init_piezo_head) );
263 
264 
265  eq_fields_->set_input_list( this->input_record_.val<Input::Array>("input_fields"), *time_ );
266  // Check that the time step was set for the transient simulation.
267  if (! zero_time_term(true) && time_->is_default() ) {
268  //THROW(ExcAssertMsg());
269  //THROW(ExcMissingTimeGovernor() << input_record_.ei_address());
270  MessageOut() << "Missing the key 'time', obligatory for the transient problems." << endl;
271  ASSERT(false);
272  }
273 
274  eq_fields_->mark_input_times(*time_);
275 }
276 
278 
279  { // init DOF handler for pressure fields
280 // std::shared_ptr< FiniteElement<0> > fe0_rt = std::make_shared<FE_RT0_disc<0>>();
281  std::shared_ptr< FiniteElement<1> > fe1_rt = std::make_shared<FE_RT0_disc<1>>();
282  std::shared_ptr< FiniteElement<2> > fe2_rt = std::make_shared<FE_RT0_disc<2>>();
283  std::shared_ptr< FiniteElement<3> > fe3_rt = std::make_shared<FE_RT0_disc<3>>();
284  std::shared_ptr< FiniteElement<0> > fe0_disc = std::make_shared<FE_P_disc<0>>(0);
285  std::shared_ptr< FiniteElement<1> > fe1_disc = std::make_shared<FE_P_disc<1>>(0);
286  std::shared_ptr< FiniteElement<2> > fe2_disc = std::make_shared<FE_P_disc<2>>(0);
287  std::shared_ptr< FiniteElement<3> > fe3_disc = std::make_shared<FE_P_disc<3>>(0);
288  std::shared_ptr< FiniteElement<0> > fe0_cr = std::make_shared<FE_CR<0>>();
289  std::shared_ptr< FiniteElement<1> > fe1_cr = std::make_shared<FE_CR<1>>();
290  std::shared_ptr< FiniteElement<2> > fe2_cr = std::make_shared<FE_CR<2>>();
291  std::shared_ptr< FiniteElement<3> > fe3_cr = std::make_shared<FE_CR<3>>();
292 // static FiniteElement<0> fe0_sys = FE_P_disc<0>(0); //TODO fix and use solution with FESystem<0>( {fe0_rt, fe0_disc, fe0_cr} )
293  FESystem<0> fe0_sys( {fe0_disc, fe0_disc, fe0_cr} );
294  FESystem<1> fe1_sys( {fe1_rt, fe1_disc, fe1_cr} );
295  FESystem<2> fe2_sys( {fe2_rt, fe2_disc, fe2_cr} );
296  FESystem<3> fe3_sys( {fe3_rt, fe3_disc, fe3_cr} );
297  MixedPtr<FESystem> fe_sys( std::make_shared<FESystem<0>>(fe0_sys), std::make_shared<FESystem<1>>(fe1_sys),
298  std::make_shared<FESystem<2>>(fe2_sys), std::make_shared<FESystem<3>>(fe3_sys) );
299  std::shared_ptr<DiscreteSpace> ds = std::make_shared<EqualOrderDiscreteSpace>( mesh_, fe_sys);
300  eq_data_->dh_ = std::make_shared<DOFHandlerMultiDim>(*mesh_);
301  eq_data_->dh_->distribute_dofs(ds);
302  }
303 
304  init_eq_data();
306 
307  eq_fields_->add_coords_field();
308 
309  { // construct pressure, velocity and piezo head fields
310  uint rt_component = 0;
311  eq_data_->full_solution = eq_data_->dh_->create_vector();
312  auto ele_flux_ptr = create_field_fe<3, FieldValue<3>::VectorFixed>(eq_data_->dh_, &eq_data_->full_solution, rt_component);
313  eq_fields_->flux.set(ele_flux_ptr, 0.0);
314 
315  eq_fields_->field_ele_velocity.set(Model<3, FieldValue<3>::VectorFixed>::create(fn_mh_velocity(), eq_fields_->flux, eq_fields_->cross_section), 0.0);
316 
317  uint p_ele_component = 1;
318  auto ele_pressure_ptr = create_field_fe<3, FieldValue<3>::Scalar>(eq_data_->dh_, &eq_data_->full_solution, p_ele_component);
319  eq_fields_->field_ele_pressure.set(ele_pressure_ptr, 0.0);
320 
321  uint p_edge_component = 2;
322  auto edge_pressure_ptr = create_field_fe<3, FieldValue<3>::Scalar>(eq_data_->dh_, &eq_data_->full_solution, p_edge_component);
323  eq_fields_->field_edge_pressure.set(edge_pressure_ptr, 0.0);
324 
325  eq_fields_->field_ele_piezo_head.set(
326  Model<3, FieldValue<3>::Scalar>::create(fn_mh_piezohead(), eq_fields_->gravity_field, eq_fields_->X(), eq_fields_->field_ele_pressure),
327  0.0
328  );
329  }
330 
331  { // init DOF handlers represents element pressure DOFs
332  uint p_element_component = 1;
333  eq_data_->dh_p_ = std::make_shared<SubDOFHandlerMultiDim>(eq_data_->dh_,p_element_component);
334  }
335 
336  { // init DOF handlers represents edge DOFs
337  uint p_edge_component = 2;
338  eq_data_->dh_cr_ = std::make_shared<SubDOFHandlerMultiDim>(eq_data_->dh_,p_edge_component);
339  }
340 
341  { // init DOF handlers represents side DOFs
342  MixedPtr<FE_CR_disc> fe_cr_disc;
343  std::shared_ptr<DiscreteSpace> ds_cr_disc = std::make_shared<EqualOrderDiscreteSpace>( mesh_, fe_cr_disc);
344  eq_data_->dh_cr_disc_ = std::make_shared<DOFHandlerMultiDim>(*mesh_);
345  eq_data_->dh_cr_disc_->distribute_dofs(ds_cr_disc);
346  }
347 
348  // create solution vector for 2. Schur complement linear system
349 // p_edge_solution = new VectorMPI(eq_data_->dh_cr_->distr()->lsize());
350 // full_solution = new VectorMPI(eq_data_->dh_->distr()->lsize());
351  // this creates mpi vector from DoFHandler, including ghost values
352  eq_data_->p_edge_solution = eq_data_->dh_cr_->create_vector();
353  eq_data_->p_edge_solution_previous = eq_data_->dh_cr_->create_vector();
354  eq_data_->p_edge_solution_previous_time = eq_data_->dh_cr_->create_vector();
355 
356  // Initialize bc_switch_dirichlet to size of global boundary.
357  eq_data_->bc_switch_dirichlet.resize(mesh_->n_elements()+mesh_->bc_mesh()->n_elements(), 1);
358 
359 
362  .val<Input::Record>("nonlinear_solver")
363  .val<Input::AbstractRecord>("linear_solver");
364 
366 
367  // auxiliary set_time call since allocation assembly evaluates fields as well
370 
371 
372  // initialization of balance object
373  balance_ = std::make_shared<Balance>("water", mesh_);
374  balance_->init_from_input(input_record_.val<Input::Record>("balance"), time());
375  eq_data_->water_balance_idx = balance_->add_quantity("water_volume");
376  balance_->allocate(eq_data_->dh_, 1);
377  balance_->units(UnitSI().m(3));
378 
379  eq_data_->balance = balance_;
380 }
381 
383 {
384  eq_data_->multidim_assembler = AssemblyFlowBase::create< AssemblyLMH >(eq_fields_, eq_data_);
385 }
386 
387 // void DarcyLMH::read_initial_condition()
388 // {
389 // DebugOut().fmt("Read initial condition\n");
390 
391 // std::vector<LongIdx> l_indices(eq_data_->dh_cr_->max_elem_dofs());
392 
393 // for ( DHCellAccessor dh_cell : eq_data_->dh_cr_->own_range() ) {
394 
395 // dh_cell.get_loc_dof_indices(l_indices);
396 // ElementAccessor<3> ele = dh_cell.elm();
397 
398 // // set initial condition
399 // double init_value = eq_fields_->init_pressure.value(ele.centre(),ele);
400 
401 // for (unsigned int i=0; i<ele->n_sides(); i++) {
402 // uint n_sides_of_edge = ele.side(i)->edge()->n_sides;
403 // eq_data_->p_edge_solution[l_indices[i]] += init_value/n_sides_of_edge;
404 // }
405 // }
406 
407 // eq_data_->p_edge_solution.ghost_to_local_begin();
408 // eq_data_->p_edge_solution.ghost_to_local_end();
409 // eq_data_->p_edge_solution_previous_time.copy_from(eq_data_->p_edge_solution);
410 
411 // initial_condition_postprocess();
412 // }
413 
415 {
416  DebugOut().fmt("Read initial condition\n");
417 
418  for ( DHCellAccessor dh_cell : eq_data_->dh_->own_range() ) {
419 
420  LocDofVec p_indices = dh_cell.cell_with_other_dh(eq_data_->dh_p_.get()).get_loc_dof_indices();
421  ASSERT_DBG(p_indices.n_elem == 1);
422  LocDofVec l_indices = dh_cell.cell_with_other_dh(eq_data_->dh_cr_.get()).get_loc_dof_indices();
423  ElementAccessor<3> ele = dh_cell.elm();
424 
425  // set initial condition
426  double init_value = eq_fields_->init_pressure.value(ele.centre(),ele);
427  unsigned int p_idx = eq_data_->dh_p_->parent_indices()[p_indices[0]];
428  eq_data_->full_solution.set(p_idx, init_value);
429 
430  for (unsigned int i=0; i<ele->n_sides(); i++) {
431  uint n_sides_of_edge = ele.side(i)->edge().n_sides();
432  unsigned int l_idx = eq_data_->dh_cr_->parent_indices()[l_indices[i]];
433  eq_data_->full_solution.add(l_idx, init_value/n_sides_of_edge);
434 
435  eq_data_->p_edge_solution.add(l_indices[i], init_value/n_sides_of_edge);
436  }
437  }
438 
439  eq_data_->full_solution.ghost_to_local_begin();
440  eq_data_->full_solution.ghost_to_local_end();
441 
442  eq_data_->p_edge_solution.ghost_to_local_begin();
443  eq_data_->p_edge_solution.ghost_to_local_end();
444  eq_data_->p_edge_solution_previous_time.copy_from(eq_data_->p_edge_solution);
445 
447 }
448 
450 {}
451 
453 {
454 
455  /* TODO:
456  * - Allow solution reconstruction (pressure and velocity) from initial condition on user request.
457  * - Steady solution as an intitial condition may be forced by setting inti_time =-1, and set data for the steady solver in that time.
458  * Solver should be able to switch from and to steady case depending on the zero time term.
459  */
460 
462 
463  // zero_time_term means steady case
464  eq_data_->use_steady_assembly_ = zero_time_term();
465 
466  eq_data_->p_edge_solution.zero_entries();
467 
468  if (eq_data_->use_steady_assembly_) { // steady case
469  //read_initial_condition(); // Possible solution guess for steady case.
470  solve_nonlinear(); // with right limit data
471  } else {
473 
474  // we reconstruct the initial solution here
475 
476  // during the reconstruction assembly:
477  // - the balance objects are actually allocated
478  // - the full solution vector is computed
479  // - to not changing the ref data in the tests at the moment, we need zero velocities,
480  // so we keep only the pressure in the full solution (reason for the temp vector)
481  // Once we want to change the ref data including nonzero velocities,
482  // we can remove the temp vector and also remove the settings of full_solution vector
483  // in the read_initial_condition(). (use the commented out version read_initial_condition() above)
484  VectorMPI temp = eq_data_->dh_->create_vector();
485  temp.copy_from(eq_data_->full_solution);
486  reconstruct_solution_from_schur(eq_data_->multidim_assembler);
487  eq_data_->full_solution.copy_from(temp);
488 
489  // print_matlab_matrix("matrix_zero");
490  accept_time_step(); // accept zero time step, i.e. initial condition
491  }
492  //solution_output(T,right_limit); // data for time T in any case
493  output_data();
494 }
495 
496 //=============================================================================
497 // COMPOSE and SOLVE WATER MH System possibly through Schur complements
498 //=============================================================================
500 {
501  START_TIMER("Solving MH system");
502 
503  time_->next_time();
504 
505  time_->view("DARCY"); //time governor information output
506 
507  solve_time_step();
508 
509  eq_data_->full_solution.local_to_ghost_begin();
510  eq_data_->full_solution.local_to_ghost_end();
511 }
512 
513 void DarcyLMH::solve_time_step(bool output)
514 {
516  bool zero_time_term_from_left=zero_time_term();
517 
518  bool jump_time = eq_fields_->storativity.is_jump_time();
519  if (! zero_time_term_from_left) {
520  // time term not treated as zero
521  // Unsteady solution up to the T.
522 
523  // this flag is necesssary for switching BC to avoid setting zero neumann on the whole boundary in the steady case
524  eq_data_->use_steady_assembly_ = false;
525 
526  solve_nonlinear(); // with left limit data
527  if(output)
529  if (jump_time) {
530  WarningOut() << "Output of solution discontinuous in time not supported yet.\n";
531  //solution_output(T, left_limit); // output use time T- delta*dt
532  //output_data();
533  }
534  }
535 
536  if (time_->is_end()) {
537  // output for unsteady case, end_time should not be the jump time
538  // but rether check that
539  if (! zero_time_term_from_left && ! jump_time && output)
540  output_data();
541  return;
542  }
543 
545  bool zero_time_term_from_right=zero_time_term();
546  if (zero_time_term_from_right) {
547  // this flag is necesssary for switching BC to avoid setting zero neumann on the whole boundary in the steady case
548  eq_data_->use_steady_assembly_ = true;
549  solve_nonlinear(); // with right limit data
550  if(output)
552 
553  } else if (! zero_time_term_from_left && jump_time) {
554  WarningOut() << "Discontinuous time term not supported yet.\n";
555  //solution_transfer(); // internally call set_time(T, left) and set_time(T,right) again
556  //solve_nonlinear(); // with right limit data
557  }
558  //solution_output(T,right_limit); // data for time T in any case
559  if (output)
560  output_data();
561 }
562 
563 bool DarcyLMH::zero_time_term(bool time_global) {
564  if (time_global) {
565  return (eq_fields_->storativity.input_list_size() == 0);
566  } else {
567  return eq_fields_->storativity.field_result(mesh_->region_db().get_region_set("BULK")) == result_zeros;
568  }
569 }
570 
571 
573 {
574 
576  double residual_norm = lin_sys_schur().compute_residual();
578  MessageOut().fmt("[nonlinear solver] norm of initial residual: {}\n", residual_norm);
579 
580  // Reduce is_linear flag.
581  int is_linear_common;
582  MPI_Allreduce(&(eq_data_->is_linear), &is_linear_common,1, MPI_INT ,MPI_MIN,PETSC_COMM_WORLD);
583 
584  Input::Record nl_solver_rec = input_record_.val<Input::Record>("nonlinear_solver");
585  this->tolerance_ = nl_solver_rec.val<double>("tolerance");
586  this->max_n_it_ = nl_solver_rec.val<unsigned int>("max_it");
587  this->min_n_it_ = nl_solver_rec.val<unsigned int>("min_it");
588  if (this->min_n_it_ > this->max_n_it_) this->min_n_it_ = this->max_n_it_;
589 
590  if (! is_linear_common) {
591  // set tolerances of the linear solver unless they are set by user.
592  lin_sys_schur().set_tolerances(0.1*this->tolerance_, 0.01*this->tolerance_, 100);
593  }
594  vector<double> convergence_history;
595 
596  while (nonlinear_iteration_ < this->min_n_it_ ||
597  (residual_norm > this->tolerance_ && nonlinear_iteration_ < this->max_n_it_ )) {
598  OLD_ASSERT_EQUAL( convergence_history.size(), nonlinear_iteration_ );
599  convergence_history.push_back(residual_norm);
600 
601  // print_matlab_matrix("matrix_" + std::to_string(time_->step().index()) + "_it_" + std::to_string(nonlinear_iteration_));
602  // stagnation test
603  if (convergence_history.size() >= 5 &&
604  convergence_history[ convergence_history.size() - 1]/convergence_history[ convergence_history.size() - 2] > 0.9 &&
605  convergence_history[ convergence_history.size() - 1]/convergence_history[ convergence_history.size() - 5] > 0.8) {
606  // stagnation
607  if (input_record_.val<Input::Record>("nonlinear_solver").val<bool>("converge_on_stagnation")) {
608  WarningOut().fmt("Accept solution on stagnation. Its: {} Residual: {}\n", nonlinear_iteration_, residual_norm);
609  break;
610  } else {
611  THROW(ExcSolverDiverge() << EI_Reason("Stagnation."));
612  }
613  }
614 
615  if (! is_linear_common){
616  eq_data_->p_edge_solution_previous.copy_from(eq_data_->p_edge_solution);
617  eq_data_->p_edge_solution_previous.local_to_ghost_begin();
618  eq_data_->p_edge_solution_previous.local_to_ghost_end();
619  }
620 
622  MessageOut().fmt("[schur solver] lin. it: {}, reason: {}, residual: {}\n",
623  si.n_iterations, si.converged_reason, lin_sys_schur().compute_residual());
624 
626 
627  // hack to make BDDC work with empty compute_residual
628  if (is_linear_common){
629  // we want to print this info in linear (and steady) case
630  residual_norm = lin_sys_schur().compute_residual();
631  MessageOut().fmt("[nonlinear solver] lin. it: {}, reason: {}, residual: {}\n",
632  si.n_iterations, si.converged_reason, residual_norm);
633  break;
634  }
635  data_changed_=true; // force reassembly for non-linear case
636 
637  double alpha = 1; // how much of new solution
638  VecAXPBY(eq_data_->p_edge_solution.petsc_vec(), (1-alpha), alpha, eq_data_->p_edge_solution_previous.petsc_vec());
639 
640  //LogOut().fmt("Linear solver ended with reason: {} \n", si.converged_reason );
641  //OLD_ASSERT( si.converged_reason >= 0, "Linear solver failed to converge. Convergence reason %d \n", si.converged_reason );
643 
644  residual_norm = lin_sys_schur().compute_residual();
645  MessageOut().fmt("[nonlinear solver] it: {} lin. it: {}, reason: {}, residual: {}\n",
646  nonlinear_iteration_, si.n_iterations, si.converged_reason, residual_norm);
647  }
648 
649  reconstruct_solution_from_schur(eq_data_->multidim_assembler);
650 
651  // adapt timestep
652  if (! this->zero_time_term()) {
653  double mult = 1.0;
654  if (nonlinear_iteration_ < 3) mult = 1.6;
655  if (nonlinear_iteration_ > 7) mult = 0.7;
656  time_->set_upper_constraint(time_->dt() * mult, "Darcy adaptivity.");
657  // int result = time_->set_upper_constraint(time_->dt() * mult, "Darcy adaptivity.");
658  //DebugOut().fmt("time adaptivity, res: {} it: {} m: {} dt: {} edt: {}\n", result, nonlinear_iteration_, mult, time_->dt(), time_->estimate_dt());
659  }
660 }
661 
662 
664 {
665  eq_data_->p_edge_solution_previous_time.copy_from(eq_data_->p_edge_solution);
666  eq_data_->p_edge_solution_previous_time.local_to_ghost_begin();
667  eq_data_->p_edge_solution_previous_time.local_to_ghost_end();
668 }
669 
670 
672  START_TIMER("Darcy output data");
673 
674  // print_matlab_matrix("matrix_" + std::to_string(time_->step().index()));
675 
676  //time_->view("DARCY"); //time governor information output
677  this->output_object->output();
678 
679 
680  START_TIMER("Darcy balance output");
681  balance_->calculate_cumulative(eq_data_->water_balance_idx, eq_data_->full_solution.petsc_vec());
682  balance_->calculate_instant(eq_data_->water_balance_idx, eq_data_->full_solution.petsc_vec());
683  balance_->output();
684 }
685 
686 
688 {
689  return eq_data_->lin_sys_schur->get_solution_precision();
690 }
691 
692 
693 // ===========================================================================================
694 //
695 // MATRIX ASSEMBLY - we use abstract assembly routine, where LS Mat/Vec SetValues
696 // are in fact pointers to allocating or filling functions - this is governed by Linsystem roitunes
697 //
698 // =======================================================================================
700 {
701  START_TIMER("DarcyLMH::assembly_steady_mh_matrix");
702 
703  // DebugOut() << "assembly_mh_matrix \n";
704  // set auxiliary flag for switchting Dirichlet like BC
705  eq_data_->force_no_neumann_bc = eq_data_->use_steady_assembly_ && (nonlinear_iteration_ == 0);
706 
707  balance_->start_flux_assembly(eq_data_->water_balance_idx);
708  balance_->start_source_assembly(eq_data_->water_balance_idx);
709  balance_->start_mass_assembly(eq_data_->water_balance_idx);
710 
711  // TODO: try to move this into balance, or have it in the generic assembler class, that should perform the cell loop
712  // including various pre- and post-actions
713  for ( DHCellAccessor dh_cell : eq_data_->dh_->own_range() ) {
714  unsigned int dim = dh_cell.dim();
715  assembler[dim-1]->assemble(dh_cell);
716  }
717 
718 
719  balance_->finish_mass_assembly(eq_data_->water_balance_idx);
720  balance_->finish_source_assembly(eq_data_->water_balance_idx);
721  balance_->finish_flux_assembly(eq_data_->water_balance_idx);
722 
723 }
724 
725 
727 {
728  START_TIMER("DarcyLMH::allocate_mh_matrix");
729 
730  // to make space for second schur complement, max. 10 neighbour edges of one el.
731  double zeros[100000];
732  for(int i=0; i<100000; i++) zeros[i] = 0.0;
733 
734  std::vector<LongIdx> tmp_rows;
735  tmp_rows.reserve(200);
736 
737  std::vector<LongIdx> dofs, dofs_ngh;
738  dofs.reserve(eq_data_->dh_cr_->max_elem_dofs());
739  dofs_ngh.reserve(eq_data_->dh_cr_->max_elem_dofs());
740 
741  // DebugOut() << "Allocate new schur\n";
742  for ( DHCellAccessor dh_cell : eq_data_->dh_cr_->own_range() ) {
743  ElementAccessor<3> ele = dh_cell.elm();
744 
745  const uint ndofs = dh_cell.n_dofs();
746  dofs.resize(dh_cell.n_dofs());
747  dh_cell.get_dof_indices(dofs);
748 
749  int* dofs_ptr = dofs.data();
750  lin_sys_schur().mat_set_values(ndofs, dofs_ptr, ndofs, dofs_ptr, zeros);
751 
752  tmp_rows.clear();
753 
754  // compatible neighborings rows
755  unsigned int n_neighs = ele->n_neighs_vb();
756  for ( DHCellSide neighb_side : dh_cell.neighb_sides() ) {
757  // every compatible connection adds a 2x2 matrix involving
758  // current element pressure and a connected edge pressure
759 
760  // read neighbor dofs (dh_cr dofhandler)
761  // neighbor cell owning neighb_side
762  DHCellAccessor dh_neighb_cell = neighb_side.cell();
763 
764  const uint ndofs_ngh = dh_neighb_cell.n_dofs();
765  dofs_ngh.resize(ndofs_ngh);
766  dh_neighb_cell.get_dof_indices(dofs_ngh);
767 
768  // local index of pedge dof on neighboring cell
769  tmp_rows.push_back(dofs_ngh[neighb_side.side().side_idx()]);
770  }
771 
772  lin_sys_schur().mat_set_values(ndofs, dofs_ptr, n_neighs, tmp_rows.data(), zeros); // (edges) x (neigh edges)
773  lin_sys_schur().mat_set_values(n_neighs, tmp_rows.data(), ndofs, dofs_ptr, zeros); // (neigh edges) x (edges)
774  lin_sys_schur().mat_set_values(n_neighs, tmp_rows.data(), n_neighs, tmp_rows.data(), zeros); // (neigh edges) x (neigh edges)
775 
776  tmp_rows.clear();
777  if (eq_data_->mortar_method_ != NoMortar) {
778  auto &isec_list = mesh_->mixed_intersections().element_intersections_[ele.idx()];
779  for(auto &isec : isec_list ) {
780  IntersectionLocalBase *local = isec.second;
781  DHCellAccessor dh_cell_slave = eq_data_->dh_cr_->cell_accessor_from_element(local->bulk_ele_idx());
782 
783  const uint ndofs_slave = dh_cell_slave.n_dofs();
784  dofs_ngh.resize(ndofs_slave);
785  dh_cell_slave.get_dof_indices(dofs_ngh);
786 
787  //DebugOut().fmt("Alloc: {} {}", ele.idx(), local->bulk_ele_idx());
788  for(unsigned int i_side=0; i_side < dh_cell_slave.elm()->n_sides(); i_side++) {
789  tmp_rows.push_back( dofs_ngh[i_side] );
790  //DebugOut() << "aedge" << print_var(tmp_rows[tmp_rows.size()-1]);
791  }
792  }
793  }
794 
795  lin_sys_schur().mat_set_values(ndofs, dofs_ptr, tmp_rows.size(), tmp_rows.data(), zeros); // master edges x slave edges
796  lin_sys_schur().mat_set_values(tmp_rows.size(), tmp_rows.data(), ndofs, dofs_ptr, zeros); // slave edges x master edges
797  lin_sys_schur().mat_set_values(tmp_rows.size(), tmp_rows.data(), tmp_rows.size(), tmp_rows.data(), zeros); // slave edges x slave edges
798  }
799  // DebugOut() << "end Allocate new schur\n";
800 
801  // int local_dofs[10];
802  // unsigned int nsides;
803  // for ( DHCellAccessor dh_cell : eq_data_->dh_->own_range() ) {
804  // LocalElementAccessorBase<3> ele_ac(dh_cell);
805  // nsides = ele_ac.n_sides();
806 
807  // //allocate at once matrix [sides,ele,edges]x[sides,ele,edges]
808  // loc_size = 1 + 2*nsides;
809  // unsigned int i_side = 0;
810 
811  // for (; i_side < nsides; i_side++) {
812  // local_dofs[i_side] = ele_ac.side_row(i_side);
813  // local_dofs[i_side+nsides] = ele_ac.edge_row(i_side);
814  // }
815  // local_dofs[i_side+nsides] = ele_ac.ele_row();
816  // int * edge_rows = local_dofs + nsides;
817  // //int ele_row = local_dofs[0];
818 
819  // // whole local MH matrix
820  // ls->mat_set_values(loc_size, local_dofs, loc_size, local_dofs, zeros);
821 
822 
823  // // compatible neighborings rows
824  // unsigned int n_neighs = ele_ac.element_accessor()->n_neighs_vb();
825  // unsigned int i=0;
826  // for ( DHCellSide neighb_side : dh_cell.neighb_sides() ) {
827  // //for (unsigned int i = 0; i < n_neighs; i++) {
828  // // every compatible connection adds a 2x2 matrix involving
829  // // current element pressure and a connected edge pressure
830  // Neighbour *ngh = ele_ac.element_accessor()->neigh_vb[i];
831  // DHCellAccessor cell_higher_dim = eq_data_->dh_->cell_accessor_from_element(neighb_side.elem_idx());
832  // LocalElementAccessorBase<3> acc_higher_dim( cell_higher_dim );
833  // for (unsigned int j = 0; j < neighb_side.element().dim()+1; j++)
834  // if (neighb_side.element()->edge_idx(j) == ngh->edge_idx()) {
835  // int neigh_edge_row = acc_higher_dim.edge_row(j);
836  // tmp_rows.push_back(neigh_edge_row);
837  // break;
838  // }
839  // //DebugOut() << "CC" << print_var(tmp_rows[i]);
840  // ++i;
841  // }
842 
843  // // allocate always also for schur 2
844  // ls->mat_set_values(nsides+1, edge_rows, n_neighs, tmp_rows.data(), zeros); // (edges, ele) x (neigh edges)
845  // ls->mat_set_values(n_neighs, tmp_rows.data(), nsides+1, edge_rows, zeros); // (neigh edges) x (edges, ele)
846  // ls->mat_set_values(n_neighs, tmp_rows.data(), n_neighs, tmp_rows.data(), zeros); // (neigh edges) x (neigh edges)
847 
848  // tmp_rows.clear();
849 
850  // if (eq_data_->mortar_method_ != NoMortar) {
851  // auto &isec_list = mesh_->mixed_intersections().element_intersections_[ele_ac.ele_global_idx()];
852  // for(auto &isec : isec_list ) {
853  // IntersectionLocalBase *local = isec.second;
854  // LocalElementAccessorBase<3> slave_acc( eq_data_->dh_->cell_accessor_from_element(local->bulk_ele_idx()) );
855  // //DebugOut().fmt("Alloc: {} {}", ele_ac.ele_global_idx(), local->bulk_ele_idx());
856  // for(unsigned int i_side=0; i_side < slave_acc.dim()+1; i_side++) {
857  // tmp_rows.push_back( slave_acc.edge_row(i_side) );
858  // //DebugOut() << "aedge" << print_var(tmp_rows[tmp_rows.size()-1]);
859  // }
860  // }
861  // }
862  // /*
863  // for(unsigned int i_side=0; i_side < ele_ac.element_accessor()->n_sides(); i_side++) {
864  // DebugOut() << "aedge:" << print_var(edge_rows[i_side]);
865  // }*/
866 
867  // ls->mat_set_values(nsides, edge_rows, tmp_rows.size(), tmp_rows.data(), zeros); // master edges x neigh edges
868  // ls->mat_set_values(tmp_rows.size(), tmp_rows.data(), nsides, edge_rows, zeros); // neigh edges x master edges
869  // ls->mat_set_values(tmp_rows.size(), tmp_rows.data(), tmp_rows.size(), tmp_rows.data(), zeros); // neigh edges x neigh edges
870 
871  // }
872 /*
873  // alloc edge diagonal entries
874  if(rank == 0)
875  for( vector<Edge>::iterator edg = mesh_->edges.begin(); edg != mesh_->edges.end(); ++edg) {
876  int edg_idx = mh_dh.row_4_edge[edg->side(0)->edge_idx()];
877 
878 // for( vector<Edge>::iterator edg2 = mesh_->edges.begin(); edg2 != mesh_->edges.end(); ++edg2){
879 // int edg_idx2 = mh_dh.row_4_edge[edg2->side(0)->edge_idx()];
880 // if(edg_idx == edg_idx2){
881 // DBGCOUT(<< "P[ " << rank << " ] " << "edg alloc: " << edg_idx << " " << edg_idx2 << "\n");
882  ls->mat_set_value(edg_idx, edg_idx, 0.0);
883 // }
884 // }
885  }
886  */
887  /*
888  if (mortar_method_ == MortarP0) {
889  P0_CouplingAssembler(*this).assembly(*ls);
890  } else if (mortar_method_ == MortarP1) {
891  P1_CouplingAssembler(*this).assembly(*ls);
892  }*/
893 }
894 
895 
896 
897 /*******************************************************************************
898  * COMPOSE WATER MH MATRIX WITHOUT SCHUR COMPLEMENT
899  ******************************************************************************/
900 
902 
903  START_TIMER("preallocation");
904 
905  // if (schur0 == NULL) { // create Linear System for MH matrix
906 
907 // if (in_rec.type() == LinSys_BDDC::get_input_type()) {
908 // #ifdef FLOW123D_HAVE_BDDCML
909 // WarningOut() << "For BDDC no Schur complements are used.";
910 // n_schur_compls = 0;
911 // LinSys_BDDC *ls = new LinSys_BDDC(&(*eq_data_->dh_->distr()),
912 // true); // swap signs of matrix and rhs to make the matrix SPD
913 // ls->set_from_input(in_rec);
914 // ls->set_solution( eq_data_->full_solution.petsc_vec() );
915 // // possible initialization particular to BDDC
916 // START_TIMER("BDDC set mesh data");
917 // set_mesh_data_for_bddc(ls);
918 // schur0=ls;
919 // END_TIMER("BDDC set mesh data");
920 // #else
921 // Exception
922 // THROW( ExcBddcmlNotSupported() );
923 // #endif // FLOW123D_HAVE_BDDCML
924 // }
925 // else
926  if (in_rec.type() == LinSys_PETSC::get_input_type()) {
927  // use PETSC for serial case even when user wants BDDC
928 
929  eq_data_->lin_sys_schur = std::make_shared<LinSys_PETSC>( &(*eq_data_->dh_cr_->distr()) );
930  lin_sys_schur().set_from_input(in_rec);
932  lin_sys_schur().set_solution( eq_data_->p_edge_solution.petsc_vec() );
934 
935 // LinSys_PETSC *schur1, *schur2;
936 
937 // if (n_schur_compls == 0) {
938 // LinSys_PETSC *ls = new LinSys_PETSC( &(*eq_data_->dh_->distr()) );
939 
940 // // temporary solution; we have to set precision also for sequantial case of BDDC
941 // // final solution should be probably call of direct solver for oneproc case
942 // // if (in_rec.type() != LinSys_BDDC::get_input_type()) ls->set_from_input(in_rec);
943 // // else {
944 // // ls->LinSys::set_from_input(in_rec); // get only common options
945 // // }
946 // ls->set_from_input(in_rec);
947 
948 // // ls->set_solution( eq_data_->full_solution.petsc_vec() );
949 // schur0=ls;
950 // } else {
951 // IS is;
952 // auto side_dofs_vec = get_component_indices_vec(0);
953 
954 // ISCreateGeneral(PETSC_COMM_SELF, side_dofs_vec.size(), &(side_dofs_vec[0]), PETSC_COPY_VALUES, &is);
955 // //ISView(is, PETSC_VIEWER_STDOUT_SELF);
956 // //OLD_ASSERT(err == 0,"Error in ISCreateStride.");
957 
958 // SchurComplement *ls = new SchurComplement(&(*eq_data_->dh_->distr()), is);
959 
960 // // make schur1
961 // Distribution *ds = ls->make_complement_distribution();
962 // if (n_schur_compls==1) {
963 // schur1 = new LinSys_PETSC(ds);
964 // schur1->set_positive_definite();
965 // } else {
966 // IS is;
967 // auto elem_dofs_vec = get_component_indices_vec(1);
968 
969 // const PetscInt *b_indices;
970 // ISGetIndices(ls->IsB, &b_indices);
971 // uint b_size = ls->loc_size_B;
972 // for(uint i_b=0, i_bb=0; i_b < b_size && i_bb < elem_dofs_vec.size(); i_b++) {
973 // if (b_indices[i_b] == elem_dofs_vec[i_bb])
974 // elem_dofs_vec[i_bb++] = i_b + ds->begin();
975 // }
976 // ISRestoreIndices(ls->IsB, &b_indices);
977 
978 
979 // ISCreateGeneral(PETSC_COMM_SELF, elem_dofs_vec.size(), &(elem_dofs_vec[0]), PETSC_COPY_VALUES, &is);
980 // //ISView(is, PETSC_VIEWER_STDOUT_SELF);
981 // //OLD_ASSERT(err == 0,"Error in ISCreateStride.");
982 // SchurComplement *ls1 = new SchurComplement(ds, is); // is is deallocated by SchurComplement
983 // ls1->set_negative_definite();
984 
985 // // make schur2
986 // schur2 = new LinSys_PETSC( ls1->make_complement_distribution() );
987 // schur2->set_positive_definite();
988 // ls1->set_complement( schur2 );
989 // schur1 = ls1;
990 // }
991 // ls->set_complement( schur1 );
992 // ls->set_from_input(in_rec);
993 // // ls->set_solution( eq_data_->full_solution.petsc_vec() );
994 // schur0=ls;
995  // }
996 
997  START_TIMER("PETSC PREALLOCATION");
999 
1001 
1002  eq_data_->full_solution.zero_entries();
1003  eq_data_->p_edge_solution.zero_entries();
1004  END_TIMER("PETSC PREALLOCATION");
1005  }
1006  else {
1007  THROW( ExcUnknownSolver() );
1008  }
1009 
1010  END_TIMER("preallocation");
1011 }
1012 
1014 {}
1015 
1017 {
1018  START_TIMER("DarcyFlowMH::reconstruct_solution_from_schur");
1019 
1020  eq_data_->full_solution.zero_entries();
1021  eq_data_->p_edge_solution.local_to_ghost_begin();
1022  eq_data_->p_edge_solution.local_to_ghost_end();
1023 
1024  balance_->start_flux_assembly(eq_data_->water_balance_idx);
1025  balance_->start_source_assembly(eq_data_->water_balance_idx);
1026  balance_->start_mass_assembly(eq_data_->water_balance_idx);
1027 
1028  for ( DHCellAccessor dh_cell : eq_data_->dh_->own_range() ) {
1029  unsigned int dim = dh_cell.dim();
1030  assembler[dim-1]->assemble_reconstruct(dh_cell);
1031  }
1032 
1033  eq_data_->full_solution.local_to_ghost_begin();
1034  eq_data_->full_solution.local_to_ghost_end();
1035 
1036  balance_->finish_mass_assembly(eq_data_->water_balance_idx);
1037  balance_->finish_source_assembly(eq_data_->water_balance_idx);
1038  balance_->finish_flux_assembly(eq_data_->water_balance_idx);
1039 }
1040 
1042  START_TIMER("DarcyFlowMH::assembly_linear_system");
1043 // DebugOut() << "DarcyLMH::assembly_linear_system\n";
1044 
1045  eq_data_->p_edge_solution.local_to_ghost_begin();
1046  eq_data_->p_edge_solution.local_to_ghost_end();
1047 
1048  eq_data_->is_linear=true;
1049  //DebugOut() << "Assembly linear system\n";
1050 // if (data_changed_) {
1051 // data_changed_ = false;
1052  {
1053  //DebugOut() << "Data changed\n";
1054  // currently we have no optimization for cases when just time term data or RHS data are changed
1055  START_TIMER("full assembly");
1056 // if (typeid(*schur0) != typeid(LinSys_BDDC)) {
1057 // schur0->start_add_assembly(); // finish allocation and create matrix
1058 // schur_compl->start_add_assembly();
1059 // }
1060 
1062 
1065 
1066  eq_data_->time_step_ = time_->dt();
1067 
1068  assembly_mh_matrix( eq_data_->multidim_assembler ); // fill matrix
1069 
1072 
1073  // print_matlab_matrix("matrix");
1074  }
1075 }
1076 
1077 
1078 void DarcyLMH::print_matlab_matrix(std::string matlab_file)
1079 {
1080  std::string output_file;
1081 
1082  // compute h_min for different dimensions
1083  double d_max = std::numeric_limits<double>::max();
1084  double h1 = d_max, h2 = d_max, h3 = d_max;
1085  double he2 = d_max, he3 = d_max;
1086  for (auto ele : mesh_->elements_range()) {
1087  switch(ele->dim()){
1088  case 1: h1 = std::min(h1,ele.measure()); break;
1089  case 2: h2 = std::min(h2,ele.measure()); break;
1090  case 3: h3 = std::min(h3,ele.measure()); break;
1091  }
1092 
1093  for (unsigned int j=0; j<ele->n_sides(); j++) {
1094  switch(ele->dim()){
1095  case 2: he2 = std::min(he2, ele.side(j)->measure()); break;
1096  case 3: he3 = std::min(he3, ele.side(j)->measure()); break;
1097  }
1098  }
1099  }
1100  if(h1 == d_max) h1 = 0;
1101  if(h2 == d_max) h2 = 0;
1102  if(h3 == d_max) h3 = 0;
1103  if(he2 == d_max) he2 = 0;
1104  if(he3 == d_max) he3 = 0;
1105 
1106  FILE * file;
1107  file = fopen(output_file.c_str(),"a");
1108  fprintf(file, "nA = %d;\n", eq_data_->dh_cr_disc_->distr()->size());
1109  fprintf(file, "nB = %d;\n", eq_data_->dh_->mesh()->get_el_ds()->size());
1110  fprintf(file, "nBF = %d;\n", eq_data_->dh_cr_->distr()->size());
1111  fprintf(file, "h1 = %e;\nh2 = %e;\nh3 = %e;\n", h1, h2, h3);
1112  fprintf(file, "he2 = %e;\nhe3 = %e;\n", he2, he3);
1113  fclose(file);
1114 
1115  {
1116  output_file = FilePath(matlab_file + "_sch_new.m", FilePath::output_file);
1117  PetscViewer viewer;
1118  PetscViewerASCIIOpen(PETSC_COMM_WORLD, output_file.c_str(), &viewer);
1119  PetscViewerSetFormat(viewer, PETSC_VIEWER_ASCII_MATLAB);
1120  MatView( *const_cast<Mat*>(lin_sys_schur().get_matrix()), viewer);
1121  VecView( *const_cast<Vec*>(lin_sys_schur().get_rhs()), viewer);
1122  VecView( *const_cast<Vec*>(&(lin_sys_schur().get_solution())), viewer);
1123  VecView( *const_cast<Vec*>(&(eq_data_->full_solution.petsc_vec())), viewer);
1124  }
1125 }
1126 
1127 
1128 //template <int dim>
1129 //std::vector<arma::vec3> dof_points(DHCellAccessor cell, const Mapping<dim, 3> &mapping) {
1130 //
1131 //
1132 // vector<arma::vec::fixed<dim+1>> bary_dof_points = cell->fe()->dof_points();
1133 //
1134 // std::vector<arma::vec3> points(20);
1135 // points.resize(0);
1136 //
1137 //}
1138 //
1139 
1140 // void DarcyLMH::set_mesh_data_for_bddc(LinSys_BDDC * bddc_ls) {
1141 // START_TIMER("DarcyFlowMH_Steady::set_mesh_data_for_bddc");
1142 // // prepare mesh for BDDCML
1143 // // initialize arrays
1144 // // auxiliary map for creating coordinates of local dofs and global-to-local numbering
1145 // std::map<int, arma::vec3> localDofMap;
1146 // // connectivity for the subdomain, i.e. global dof numbers on element, stored element-by-element
1147 // // Indices of Nodes on Elements
1148 // std::vector<int> inet;
1149 // // number of degrees of freedom on elements - determines elementwise chunks of INET array
1150 // // Number of Nodes on Elements
1151 // std::vector<int> nnet;
1152 // // Indices of Subdomain Elements in Global Numbering - for local elements, their global indices
1153 // std::vector<int> isegn;
1154 //
1155 // // This array is currently not used in BDDCML, it was used as an interface scaling alternative to scaling
1156 // // by diagonal. It corresponds to the rho-scaling.
1157 // std::vector<double> element_permeability;
1158 //
1159 // // maximal and minimal dimension of elements
1160 // uint elDimMax = 1;
1161 // uint elDimMin = 3;
1162 // std::vector<LongIdx> cell_dofs_global(10);
1163 //
1164 //
1165 //
1166 // for ( DHCellAccessor dh_cell : eq_data_->dh_->own_range() ) {
1167 // // LocalElementAccessorBase<3> ele_ac(dh_cell);
1168 // // for each element, create local numbering of dofs as fluxes (sides), pressure (element centre), Lagrange multipliers (edges), compatible connections
1169 //
1170 // dh_cell.get_dof_indices(cell_dofs_global);
1171 //
1172 // inet.insert(inet.end(), cell_dofs_global.begin(), cell_dofs_global.end());
1173 // uint n_inet = cell_dofs_global.size();
1174 //
1175 //
1176 // uint dim = dh_cell.elm().dim();
1177 // elDimMax = std::max( elDimMax, dim );
1178 // elDimMin = std::min( elDimMin, dim );
1179 //
1180 // // TODO: this is consistent with previous implementation, but may be wrong as it use global element numbering
1181 // // used in sequential mesh, do global numbering of distributed elements.
1182 // isegn.push_back( dh_cell.elm_idx());
1183 //
1184 // // TODO: use FiniteElement::dof_points
1185 // for (unsigned int si=0; si<dh_cell.elm()->n_sides(); si++) {
1186 // arma::vec3 coord = dh_cell.elm().side(si)->centre();
1187 // // flux dof points
1188 // localDofMap.insert( std::make_pair( cell_dofs_global[si], coord ) );
1189 // // pressure trace dof points
1190 // localDofMap.insert( std::make_pair( cell_dofs_global[si+dim+2], coord ) );
1191 // }
1192 // // pressure dof points
1193 // arma::vec3 elm_centre = dh_cell.elm().centre();
1194 // localDofMap.insert( std::make_pair( cell_dofs_global[dim+1], elm_centre ) );
1195 //
1196 // // insert dofs related to compatible connections
1197 // //const Element *ele = dh_cell.elm().element();
1198 // for(DHCellSide side : dh_cell.neighb_sides()) {
1199 // uint neigh_dim = side.cell().elm().dim();
1200 // side.cell().get_dof_indices(cell_dofs_global);
1201 // int edge_row = cell_dofs_global[neigh_dim+2+side.side_idx()];
1202 // localDofMap.insert( std::make_pair( edge_row, side.centre() ) );
1203 // inet.push_back( edge_row );
1204 // n_inet++;
1205 // }
1206 // nnet.push_back(n_inet);
1207 //
1208 //
1209 // // version for rho scaling
1210 // // trace computation
1211 // double conduct = eq_fields_->conductivity.value( elm_centre , dh_cell.elm() );
1212 // auto aniso = eq_fields_->anisotropy.value( elm_centre , dh_cell.elm() );
1213 //
1214 // // compute mean on the diagonal
1215 // double coef = 0.;
1216 // for ( int i = 0; i < 3; i++) {
1217 // coef = coef + aniso.at(i,i);
1218 // }
1219 // // Maybe divide by cs
1220 // coef = conduct*coef / 3;
1221 //
1222 // OLD_ASSERT( coef > 0.,
1223 // "Zero coefficient of hydrodynamic resistance %f . \n ", coef );
1224 // element_permeability.push_back( 1. / coef );
1225 // }
1226 // // uint i_inet = 0;
1227 // // for(int n_dofs : nnet) {
1228 // // DebugOut() << "nnet: " << n_dofs;
1229 // // for(int j=0; j < n_dofs; j++, i_inet++) {
1230 // // DebugOut() << "inet: " << inet[i_inet];
1231 // // }
1232 // // }
1233 //
1234 // auto distr = eq_data_->dh_->distr();
1235 // // for(auto pair : localDofMap) {
1236 // // DebugOut().every_proc() << "r: " << distr->myp() << " gi: " << pair.first << "xyz: " << pair.second[0];
1237 // //
1238 // // }
1239 //
1240 //
1241 // //convert set of dofs to vectors
1242 // // number of nodes (= dofs) on the subdomain
1243 // int numNodeSub = localDofMap.size();
1244 // //ASSERT_EQ( (unsigned int)numNodeSub, eq_data_->dh_->lsize() );
1245 // // Indices of Subdomain Nodes in Global Numbering - for local nodes, their global indices
1246 // std::vector<int> isngn( numNodeSub );
1247 // // pseudo-coordinates of local nodes (i.e. dofs)
1248 // // they need not be exact, they are used just for some geometrical considerations in BDDCML,
1249 // // such as selection of corners maximizing area of a triangle, bounding boxes fro subdomains to
1250 // // find candidate neighbours etc.
1251 // std::vector<double> xyz( numNodeSub * 3 ) ;
1252 // int ind = 0;
1253 // std::map<int,arma::vec3>::iterator itB = localDofMap.begin();
1254 // for ( ; itB != localDofMap.end(); ++itB ) {
1255 // isngn[ind] = itB -> first;
1256 //
1257 // arma::vec3 coord = itB -> second;
1258 // for ( int j = 0; j < 3; j++ ) {
1259 // xyz[ j*numNodeSub + ind ] = coord[j];
1260 // }
1261 //
1262 // ind++;
1263 // }
1264 // localDofMap.clear();
1265 //
1266 // // Number of Nodal Degrees of Freedom
1267 // // nndf is trivially one - dofs coincide with nodes
1268 // std::vector<int> nndf( numNodeSub, 1 );
1269 //
1270 // // prepare auxiliary map for renumbering nodes
1271 // typedef std::map<int,int> Global2LocalMap_; //! type for storage of global to local map
1272 // Global2LocalMap_ global2LocalNodeMap;
1273 // for ( unsigned ind = 0; ind < isngn.size(); ++ind ) {
1274 // global2LocalNodeMap.insert( std::make_pair( static_cast<unsigned>( isngn[ind] ), ind ) );
1275 // }
1276 //
1277 // // renumber nodes in the inet array to locals
1278 // int indInet = 0;
1279 // for ( unsigned int iEle = 0; iEle < isegn.size(); iEle++ ) {
1280 // int nne = nnet[ iEle ];
1281 // for ( int ien = 0; ien < nne; ien++ ) {
1282 //
1283 // int indGlob = inet[indInet];
1284 // // map it to local node
1285 // Global2LocalMap_::iterator pos = global2LocalNodeMap.find( indGlob );
1286 // OLD_ASSERT( pos != global2LocalNodeMap.end(),
1287 // "Cannot remap node index %d to local indices. \n ", indGlob );
1288 // int indLoc = static_cast<int> ( pos -> second );
1289 //
1290 // // store the node
1291 // inet[ indInet++ ] = indLoc;
1292 // }
1293 // }
1294 //
1295 // int numNodes = size;
1296 // int numDofsInt = size;
1297 // int spaceDim = 3; // TODO: what is the proper value here?
1298 // int meshDim = elDimMax;
1299 //
1300 // /**
1301 // * We need:
1302 // * - local to global element map (possibly mesh->el_4_loc
1303 // * - inet, nnet - local dof numbers per element, local numbering of only those dofs that are on owned elements
1304 // * 1. collect DH local dof indices on elements, manage map from DH local indices to BDDC local dof indices
1305 // * 2. map collected DH indices to BDDC indices using the map
1306 // * - local BDDC dofs to global dofs, use DH to BDDC map with DH local to global map
1307 // * - XYZ - permuted, collect in main loop into array of size of all DH local dofs, compress and rearrange latter
1308 // * - element_permeability - in main loop
1309 // */
1310 // bddc_ls -> load_mesh( LinSys_BDDC::BDDCMatrixType::SPD_VIA_SYMMETRICGENERAL, spaceDim, numNodes, numDofsInt, inet, nnet, nndf, isegn, isngn, isngn, xyz, element_permeability, meshDim );
1311 // }
1312 
1313 
1314 
1315 
1316 //=============================================================================
1317 // DESTROY WATER MH SYSTEM STRUCTURE
1318 //=============================================================================
1320  if (output_object) delete output_object;
1321 
1322  if(time_ != nullptr)
1323  delete time_;
1324 
1325 }
1326 
1327 
1329  ASSERT_LT_DBG(component, 3).error("Invalid component!");
1330  unsigned int i, n_dofs, min, max;
1331  std::vector<int> dof_vec;
1332  std::vector<LongIdx> dof_indices(eq_data_->dh_->max_elem_dofs());
1333  for ( DHCellAccessor dh_cell : eq_data_->dh_->own_range() ) {
1334  n_dofs = dh_cell.get_dof_indices(dof_indices);
1335  dofs_range(n_dofs, min, max, component);
1336  for (i=min; i<max; ++i) dof_vec.push_back(dof_indices[i]);
1337  }
1338  return dof_vec;
1339 }
1340 
1341 
1342 //-----------------------------------------------------------------------------
1343 // vim: set cindent:
LimitSide::right
@ right
OLD_ASSERT_EQUAL
#define OLD_ASSERT_EQUAL(a, b)
Definition: global_defs.h:110
Element::n_neighs_vb
unsigned int n_neighs_vb() const
Return number of neighbours.
Definition: elements.h:65
LocDofVec
arma::Col< IntIdx > LocDofVec
Definition: index_types.hh:28
Side::edge
Edge edge() const
Returns pointer to the edge connected to the side.
Definition: accessors_impl.hh:221
EquationBase::mesh_
Mesh * mesh_
Definition: equation.hh:218
Input::Type::Bool
Class for declaration of the input of type Bool.
Definition: type_base.hh:452
result_zeros
@ result_zeros
Definition: field_algo_base.hh:74
MPI_MIN
#define MPI_MIN
Definition: mpi.h:198
DarcyLMH::print_matlab_matrix
void print_matlab_matrix(string matlab_file)
Print darcy flow matrix in matlab format into a file.
Definition: darcy_flow_lmh.cc:1078
LinSys::SolveInfo::n_iterations
int n_iterations
Definition: linsys.hh:110
DarcyLMH::zero_time_term
virtual bool zero_time_term(bool time_global=false)
Definition: darcy_flow_lmh.cc:563
Armor::vec
ArmaVec< double, N > vec
Definition: armor.hh:885
DarcyLMH::reconstruct_solution_from_schur
void reconstruct_solution_from_schur(MultidimAssembly &assembler)
Definition: darcy_flow_lmh.cc:1016
DarcyFlowMHOutput::output
void output()
Calculate values for output.
Definition: darcy_flow_mh_output.cc:245
TimeGovernor::dt
double dt() const
Definition: time_governor.hh:558
factory.hh
field_constant.hh
vector_mpi.hh
DarcyLMH::output_object
DarcyFlowMHOutput * output_object
Definition: darcy_flow_lmh.hh:293
time_governor.hh
Basic time management class.
field_add_potential.hh
DarcyLMH::EqData
Definition: darcy_flow_lmh.hh:152
field_algo_base.hh
MeshBase::region_db
const RegionDB & region_db() const
Definition: mesh.h:171
DarcyLMH::accept_time_step
virtual void accept_time_step()
postprocess velocity field (add sources)
Definition: darcy_flow_lmh.cc:663
LinSys::SolveInfo
Definition: linsys.hh:105
ASSERT
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library.
Definition: asserts.hh:347
LinSys::set_symmetric
void set_symmetric(bool flag=true)
Definition: linsys.hh:561
DarcyLMH::create_linear_system
void create_linear_system(Input::AbstractRecord rec)
Definition: darcy_flow_lmh.cc:901
Mesh::n_sides
unsigned int n_sides() const
Definition: mesh.cc:308
DarcyFlowInterface::MortarP1
@ MortarP1
Definition: darcy_flow_interface.hh:33
EquationBase::time_
TimeGovernor * time_
Definition: equation.hh:219
distribution.hh
Support classes for parallel programing.
bc_mesh.hh
Edge::n_sides
unsigned int n_sides() const
Returns number of sides aligned with the edge.
Definition: accessors.hh:335
DarcyLMH::DarcyFlowMHOutput
friend class DarcyFlowMHOutput
Definition: darcy_flow_lmh.hh:308
Input::Type::Integer
Class for declaration of the integral input data.
Definition: type_base.hh:483
DarcyLMH::init_eq_data
void init_eq_data()
Definition: darcy_flow_lmh.cc:233
Input::Record::val
const Ret val(const string &key) const
Definition: accessors_impl.hh:31
DHCellAccessor::get_dof_indices
unsigned int get_dof_indices(std::vector< LongIdx > &indices) const
Fill vector of the global indices of dofs associated to the cell.
Definition: dh_cell_accessor.hh:80
TimeGovernor::set_upper_constraint
int set_upper_constraint(double upper, std::string message)
Sets upper constraint for the next time step estimating.
Definition: time_governor.cc:552
EquationBase::time
TimeGovernor & time()
Definition: equation.hh:149
Input::Type::Selection::close
const Selection & close() const
Close the Selection, no more values can be added.
Definition: type_selection.cc:65
DarcyLMH::EqFields::EqFields
EqFields()
Definition: darcy_flow_lmh.cc:156
fmt::fprintf
FMT_FUNC int fprintf(std::ostream &os, CStringRef format, ArgList args)
Definition: ostream.cc:56
FilePath
Dedicated class for storing path to input and output files.
Definition: file_path.hh:54
ASSERT_DBG
#define ASSERT_DBG(expr)
Definition: include_fadbad.hh:28
linsys.hh
Wrappers for linear systems based on MPIAIJ and MATIS format.
Input::Type::Double
Class for declaration of the input data that are floating point numbers.
Definition: type_base.hh:534
LinSys::rhs_zero_entries
virtual PetscErrorCode rhs_zero_entries()
Definition: linsys.hh:273
FLOW123D_FORCE_LINK_IN_CHILD
#define FLOW123D_FORCE_LINK_IN_CHILD(x)
Definition: global_defs.h:157
MeshBase::n_edges
unsigned int n_edges() const
Definition: mesh.h:114
LinSys::mat_zero_entries
virtual PetscErrorCode mat_zero_entries()
Definition: linsys.hh:264
DarcyLMH::max_n_it_
unsigned int max_n_it_
Definition: darcy_flow_lmh.hh:302
THROW
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
Definition: exceptions.hh:53
DarcyLMH::nonlinear_iteration_
unsigned int nonlinear_iteration_
Definition: darcy_flow_lmh.hh:303
LinSys::SolveInfo::converged_reason
int converged_reason
Definition: linsys.hh:109
std::vector< double >
ElementAccessor< 3 >
DarcyLMH::data_changed_
bool data_changed_
Definition: darcy_flow_lmh.hh:297
system.hh
fn_mh_velocity
Definition: assembly_models.hh:29
assembly_models.hh
Functors of FieldModels used in Darcy flow module.
DarcyLMH::solve_time_step
void solve_time_step(bool output=true)
Solve the problem without moving to next time and without output.
Definition: darcy_flow_lmh.cc:513
DarcyLMH::update_solution
void update_solution() override
Definition: darcy_flow_lmh.cc:499
DarcyLMH::EqFields
Definition: darcy_flow_lmh.hh:146
LinSys::solve
virtual SolveInfo solve()=0
field_fe.hh
uint
unsigned int uint
Definition: mh_dofhandler.hh:101
DarcyLMH::get_input_type
static const Input::Type::Record & get_input_type()
Definition: darcy_flow_lmh.cc:103
Input::AbstractRecord::type
Input::Type::Record type() const
Definition: accessors.cc:273
linsys_PETSC.hh
Solver based on the original PETSc solver using MPIAIJ matrix and succesive Schur complement construc...
darcy_flow_lmh.hh
Lumped mixed-hybrid model of linear Darcy flow, possibly unsteady.
DarcyLMH::postprocess
virtual void postprocess()
Definition: darcy_flow_lmh.cc:1013
dofs_range
void dofs_range(unsigned int n_dofs, unsigned int &min, unsigned int &max, unsigned int component)
Helper method fills range (min and max) of given component.
Definition: darcy_flow_mh.cc:1553
DarcyLMH::assembly_linear_system
virtual void assembly_linear_system()
Definition: darcy_flow_lmh.cc:1041
MeshBase::elements_range
Range< ElementAccessor< 3 > > elements_range() const
Returns range of mesh elements.
Definition: mesh.cc:1168
index_types.hh
LinSys::set_positive_definite
void set_positive_definite(bool flag=true)
Definition: linsys.hh:576
DarcyLMH::min_n_it_
unsigned int min_n_it_
Definition: darcy_flow_lmh.hh:301
LinSys::set_matrix_changed
void set_matrix_changed()
Definition: linsys.hh:212
fe_p.hh
Definitions of basic Lagrangean finite elements with polynomial shape functions.
DarcyLMH::type_field_descriptor
static const Input::Type::Record & type_field_descriptor()
Definition: darcy_flow_lmh.cc:88
DarcyLMH::zero_time_step
void zero_time_step() override
Definition: darcy_flow_lmh.cc:452
LinSys::start_allocation
virtual void start_allocation()
Definition: linsys.hh:333
DarcyFlowMHOutput::get_input_type
static const Input::Type::Instance & get_input_type(FieldSet &eq_data, const std::string &equation_name)
Definition: darcy_flow_mh_output.cc:62
Input::Type::Record::size
unsigned int size() const
Returns number of keys in the Record.
Definition: type_record.hh:602
TimeGovernor::is_end
bool is_end() const
Returns true if the actual time is greater than or equal to the end time.
Definition: time_governor.hh:588
Input::Type::Default
Class Input::Type::Default specifies default value of keys of a Input::Type::Record.
Definition: type_record.hh:61
DHCellSide
Side accessor allows to iterate over sides of DOF handler cell.
Definition: dh_cell_accessor.hh:176
Input::Type::Record::derive_from
virtual Record & derive_from(Abstract &parent)
Method to derive new Record from an AbstractRecord parent.
Definition: type_record.cc:196
Mesh::bc_mesh
BCMesh * bc_mesh() const override
Implement MeshBase::bc_mesh(), getter of boundary mesh.
Definition: mesh.h:559
AddPotentialFactory
Definition: field_add_potential.hh:49
LimitSide::left
@ left
LinSys::compute_residual
virtual double compute_residual()=0
DarcyFlowInterface::NoMortar
@ NoMortar
Definition: darcy_flow_interface.hh:31
VectorMPI::copy_from
void copy_from(VectorMPI &other)
Definition: vector_mpi.cc:103
accessors.hh
DarcyLMH::assembly_mh_matrix
void assembly_mh_matrix(MultidimAssembly &assembler)
Definition: darcy_flow_lmh.cc:699
LinSys::set_tolerances
virtual void set_tolerances(double r_tol, double a_tol, unsigned int max_it)=0
DarcyLMH::eq_fields
EqFields & eq_fields()
Definition: darcy_flow_lmh.hh:201
Input::Record
Accessor to the data with type Type::Record.
Definition: accessors.hh:291
sys_profiler.hh
darcy_flow_mh_output.hh
Output class for darcy_flow_mh model.
field_model.hh
DarcyLMH::solve_nonlinear
void solve_nonlinear()
Solve method common to zero_time_step and update solution.
Definition: darcy_flow_lmh.cc:572
mpi.h
mixed_mesh_intersections.hh
schur.hh
Assembly explicit Schur complement for the given linear system. Provides method for resolution of the...
DarcyLMH::balance_
std::shared_ptr< Balance > balance_
Definition: darcy_flow_lmh.hh:291
DarcyLMH::registrar
static const int registrar
Registrar of class to factory.
Definition: darcy_flow_lmh.hh:314
TimeGovernor
Basic time management functionality for unsteady (and steady) solvers (class Equation).
Definition: time_governor.hh:310
DarcyLMH::EqData::EqData
EqData()
Definition: darcy_flow_lmh.cc:163
TimeGovernor::step
const TimeStep & step(int index=-1) const
Definition: time_governor.cc:753
DHCellAccessor::elm
const ElementAccessor< 3 > elm() const
Return ElementAccessor to element of loc_ele_idx_.
Definition: dh_cell_accessor.hh:71
field_values.hh
Input::AbstractRecord
Accessor to the polymorphic input data of a type given by an AbstracRecord object.
Definition: accessors.hh:458
Input::Type::Default::obligatory
static Default obligatory()
The factory function to make an empty default value which is obligatory.
Definition: type_record.hh:110
UnitSI
Class for representation SI units of Fields.
Definition: unit_si.hh:40
fn_mh_piezohead
Definition: assembly_models.hh:37
EquationBase::input_record_
Input::Record input_record_
Definition: equation.hh:220
RegionDB::get_region_set
RegionSet get_region_set(const std::string &set_name) const
Definition: region.cc:328
FieldCommon::field_descriptor_record_description
static const std::string field_descriptor_record_description(const string &record_name)
Definition: field_common.cc:73
Input::Type::Record::declare_key
Record & declare_key(const string &key, std::shared_ptr< TypeBase > type, const Default &default_value, const string &description, TypeBase::attribute_map key_attributes=TypeBase::attribute_map())
Declares a new key of the Record.
Definition: type_record.cc:503
MPI_INT
#define MPI_INT
Definition: mpi.h:160
DarcyFlowMHOutput::get_input_type_specific
static const Input::Type::Instance & get_input_type_specific()
Definition: darcy_flow_mh_output.cc:69
mesh.h
DHCellAccessor::n_dofs
unsigned int n_dofs() const
Return number of dofs on given cell.
Definition: dh_cell_accessor.hh:420
Input::Type::Selection
Template for classes storing finite set of named values.
Definition: type_selection.hh:65
DarcyLMH::initialize_specific
virtual void initialize_specific()
Definition: darcy_flow_lmh.cc:382
DarcyFlowInterface::MortarMethod
MortarMethod
Type of experimental Mortar-like method for non-compatible 1d-2d interaction.
Definition: darcy_flow_interface.hh:30
DarcyFlowInterface::get_input_type
static Input::Type::Abstract & get_input_type()
Definition: darcy_flow_interface.hh:23
LinSys::start_add_assembly
virtual void start_add_assembly()
Definition: linsys.hh:341
DarcyLMH::solution_precision
virtual double solution_precision() const
Definition: darcy_flow_lmh.cc:687
DarcyLMH::eq_data_
std::shared_ptr< EqData > eq_data_
Definition: darcy_flow_lmh.hh:306
TimeGovernor::view
void view(const char *name="") const
Definition: time_governor.cc:769
DarcyLMH::~DarcyLMH
virtual ~DarcyLMH() override
Definition: darcy_flow_lmh.cc:1319
Input::Type::Record::close
Record & close() const
Close the Record for further declarations of keys.
Definition: type_record.cc:304
Input::Type
Definition: balance.hh:41
MixedMeshIntersections::element_intersections_
std::vector< std::vector< ILpair > > element_intersections_
Definition: mixed_mesh_intersections.hh:83
partitioning.hh
DarcyLMH::initialize
void initialize() override
Definition: darcy_flow_lmh.cc:277
Input::Type::Record
Record type proxy class.
Definition: type_record.hh:182
DarcyLMH::get_component_indices_vec
std::vector< int > get_component_indices_vec(unsigned int component) const
Get vector of all DOF indices of given component (0..side, 1..element, 2..edge)
Definition: darcy_flow_lmh.cc:1328
DarcyLMH::lin_sys_schur
LinSys & lin_sys_schur()
Getter for the linear system of the 2. Schur complement.
Definition: darcy_flow_lmh.hh:288
LinSys::set_from_input
virtual void set_from_input(const Input::Record in_rec)
Definition: linsys.hh:641
Mesh
Definition: mesh.h:355
OutputTime::get_input_type
static const Input::Type::Record & get_input_type()
The specification of output stream.
Definition: output_time.cc:38
Element::n_sides
unsigned int n_sides() const
Definition: elements.h:131
DarcyLMH::tolerance_
double tolerance_
Definition: darcy_flow_lmh.hh:300
Input::Type::Record::copy_keys
Record & copy_keys(const Record &other)
Copy keys from other record.
Definition: type_record.cc:216
FieldAlgorithmBase
Definition: field_algo_base.hh:112
Input::Type::Array
Class for declaration of inputs sequences.
Definition: type_base.hh:339
Model
Definition: field_model.hh:338
DHCellAccessor
Cell accessor allow iterate over DOF handler cells.
Definition: dh_cell_accessor.hh:43
LinSys::finish_assembly
virtual void finish_assembly()=0
DarcyLMH::get_mh_mortar_selection
static const Input::Type::Selection & get_mh_mortar_selection()
Selection for enum MortarMethod.
Definition: darcy_flow_lmh.cc:80
MPI_Allreduce
#define MPI_Allreduce(sendbuf, recvbuf, count, datatype, op, comm)
Definition: mpi.h:612
Input::Array
Accessor to input data conforming to declared Array.
Definition: accessors.hh:566
WarningOut
#define WarningOut()
Macro defining 'warning' record of log.
Definition: logger.hh:278
DarcyLMH::allocate_mh_matrix
void allocate_mh_matrix()
Definition: darcy_flow_lmh.cc:726
EquationBase::record_template
static Input::Type::Record & record_template()
Template Record with common keys for derived equations.
Definition: equation.cc:35
MixedPtr
Definition: mixed.hh:247
TimeGovernor::is_default
bool is_default()
Definition: time_governor.hh:381
LinSys::set_solution
void set_solution(Vec sol_vec)
Definition: linsys.hh:290
DarcyLMH::initial_condition_postprocess
virtual void initial_condition_postprocess()
Definition: darcy_flow_lmh.cc:449
ASSERT_LT_DBG
#define ASSERT_LT_DBG(a, b)
Definition of comparative assert macro (Less Than) only for debug mode.
Definition: asserts.hh:300
assembly_lmh_old.hh
std::vector::data
T data
Definition: doxy_dummy_defs.hh:7
LinSys::get_input_type
static Input::Type::Abstract & get_input_type()
Definition: linsys.cc:29
DarcyLMH::size
int size
Definition: darcy_flow_lmh.hh:295
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
FilePath::output_file
@ output_file
Definition: file_path.hh:69
EquationBase::eq_fieldset_
FieldSet * eq_fieldset_
Definition: equation.hh:227
DarcyFlowInterface::MortarP0
@ MortarP0
Definition: darcy_flow_interface.hh:32
balance.hh
local_to_global_map.hh
MeshBase::n_elements
unsigned int n_elements() const
Definition: mesh.h:111
VectorMPI
Definition: vector_mpi.hh:43
IntersectionLocalBase::bulk_ele_idx
unsigned int bulk_ele_idx() const
Returns index of bulk element.
Definition: intersection_local.hh:77
Mesh::mixed_intersections
MixedMeshIntersections & mixed_intersections()
Definition: mesh.cc:849
DebugOut
#define DebugOut()
Macro defining 'debug' record of log.
Definition: logger.hh:284
Input::Type::Selection::add_value
Selection & add_value(const int value, const std::string &key, const std::string &description="", TypeBase::attribute_map attributes=TypeBase::attribute_map())
Adds one new value with name given by key to the Selection.
Definition: type_selection.cc:50
ElementAccessor::side
SideIter side(const unsigned int loc_index)
Definition: accessors_impl.hh:139
TimeGovernor::next_time
void next_time()
Proceed to the next time according to current estimated time step.
Definition: time_governor.cc:667
DarcyLMH::eq_fields_
std::shared_ptr< EqFields > eq_fields_
Definition: darcy_flow_lmh.hh:305
Input::Type::Default::optional
static Default optional()
The factory function to make an empty default value which is optional.
Definition: type_record.hh:124
DarcyMH
Mixed-hybrid model of linear Darcy flow, possibly unsteady.
Definition: darcy_flow_mh.hh:125
DarcyLMH::output_data
virtual void output_data() override
Write computed fields.
Definition: darcy_flow_lmh.cc:671
START_TIMER
#define START_TIMER(tag)
Starts a timer with specified tag.
Definition: sys_profiler.hh:115
FESystem
Compound finite element on dim dimensional simplex.
Definition: fe_system.hh:101
DarcyLMH::DarcyLMH
DarcyLMH(Mesh &mesh, const Input::Record in_rec, TimeGovernor *tm=nullptr)
CREATE AND FILL GLOBAL MH MATRIX OF THE WATER MODEL.
Definition: darcy_flow_lmh.cc:185
LinSys_PETSC::get_input_type
static const Input::Type::Record & get_input_type()
Definition: linsys_PETSC.cc:32
field.hh
DarcyFlowInterface
Definition: darcy_flow_interface.hh:15
Balance::get_input_type
static const Input::Type::Record & get_input_type()
Main balance input record type.
Definition: balance.cc:53
END_TIMER
#define END_TIMER(tag)
Ends a timer with specified tag.
Definition: sys_profiler.hh:149
DarcyLMH::read_initial_condition
void read_initial_condition()
Definition: darcy_flow_lmh.cc:414
FieldValue
Definition: field_values.hh:645
range_wrapper.hh
Implementation of range helper class.
ElementAccessor::centre
arma::vec::fixed< spacedim > centre() const
Computes the barycenter.
Definition: accessors_impl.hh:89
IntersectionLocalBase
Common base for intersection object.
Definition: intersection_local.hh:48
MessageOut
#define MessageOut()
Macro defining 'message' record of log.
Definition: logger.hh:275
LinSys::mat_set_values
virtual void mat_set_values(int nrow, int *rows, int ncol, int *cols, double *vals)=0
intersection_local.hh
Classes with algorithms for computation of intersections of meshes.