Flow123d  release_3.0.0-506-g34af125
darcy_flow_mh_output.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_mh_output.cc
15  * @ingroup flow
16  * @brief Output class for darcy_flow_mh model.
17  * @author Jan Brezina
18  */
19 
20 #include <vector>
21 #include <iostream>
22 #include <sstream>
23 #include <string>
24 
25 #include <system/global_defs.h>
26 
27 #include "flow/darcy_flow_mh.hh"
30 
31 #include "io/output_time.hh"
32 #include "io/observe.hh"
33 #include "system/system.hh"
34 #include "system/sys_profiler.hh"
35 
36 #include "fields/field_set.hh"
37 #include "fem/dofhandler.hh"
38 #include "fem/fe_values.hh"
39 #include "fem/fe_rt.hh"
40 #include "fem/fe_values_views.hh"
42 #include "fields/field_fe.hh"
44 #include "fields/generic_field.hh"
45 
46 #include "mesh/long_idx.hh"
47 #include "mesh/mesh.h"
48 #include "mesh/partitioning.hh"
49 #include "mesh/accessors.hh"
50 #include "mesh/node_accessor.hh"
51 #include "mesh/range_wrapper.hh"
52 
53 // #include "coupling/balance.hh"
56 
57 namespace it = Input::Type;
58 
59 
62  DarcyMH::EqData eq_data;
63  output_fields += eq_data;
64  return output_fields.make_output_type("Flow_Darcy_MH", "");
65 }
66 
67 
69 
70  static it::Record& rec = it::Record("Output_DarcyMHSpecific", "Specific Darcy flow MH output.")
72  .declare_key("compute_errors", it::Bool(), it::Default("false"),
73  "SPECIAL PURPOSE. Computing errors pro non-compatible coupling.")
75  "Output file with raw data from MH module.")
76  .close();
77 
79  return output_fields.make_output_type_from_record(rec,
80  "Flow_Darcy_MH_specific",
81  "");
82 }
83 
84 
87 {
88 
89  *this += field_ele_pressure.name("pressure_p0").units(UnitSI().m());
90  *this += field_node_pressure.name("pressure_p1").units(UnitSI().m());
91  *this += field_ele_piezo_head.name("piezo_head_p0").units(UnitSI().m());
92  *this += field_ele_flux.name("velocity_p0").units(UnitSI().m().s(-1));
93  *this += subdomain.name("subdomain")
96  *this += region_id.name("region_id")
99 }
100 
101 
103 : EquationOutput()
104 {
105  *this += pressure_diff.name("pressure_diff").units(UnitSI().m());
106  *this += velocity_diff.name("velocity_diff").units(UnitSI().m().s(-1));
107  *this += div_diff.name("div_diff").units(UnitSI().s(-1));
108 }
109 
111 : darcy_flow(flow),
112  mesh_(&darcy_flow->mesh()),
113  compute_errors_(false),
114  fe0(1),
116 {
117  Input::Record in_rec_output = main_mh_in_rec.val<Input::Record>("output");
118 
120  main_mh_in_rec.val<Input::Record>("output_stream"),
122  prepare_output(in_rec_output);
123 
124  auto in_rec_specific = main_mh_in_rec.find<Input::Record>("output_specific");
125  if (in_rec_specific) {
126  in_rec_specific->opt_val("compute_errors", compute_errors_);
127 
128  // raw output
129  int rank;
131  if (rank == 0) {
132  // optionally open raw output file
133  FilePath raw_output_file_path;
134  if (in_rec_specific->opt_val("raw_flow_output", raw_output_file_path)) {
135  MessageOut() << "Opening raw flow output: " << raw_output_file_path << "\n";
136  try {
137  raw_output_file_path.open_stream(raw_output_file);
138  } INPUT_CATCH(FilePath::ExcFileOpen, FilePath::EI_Address_String, (*in_rec_specific))
139  }
140  }
141 
142  auto fields_array = in_rec_specific->val<Input::Array>("fields");
143  if(fields_array.size() > 0){
145  prepare_specific_output(*in_rec_specific);
146  }
147  }
148 }
149 
151 {
152  // we need to add data from the flow equation at this point, not in constructor of OutputFields
155 
156  all_element_idx_.resize(mesh_->n_elements());
157  for(unsigned int i=0; i<all_element_idx_.size(); i++) all_element_idx_[i] = i;
158 
159  // create shared pointer to a FieldFE and push this Field to output_field on all regions
162  output_fields.field_ele_pressure.set_field(mesh_->region_db().get_region_set("ALL"), ele_pressure_ptr);
163 
164  ds = std::make_shared<EqualOrderDiscreteSpace>(mesh_, &fe0, &fe_data_1d.fe_p1, &fe_data_2d.fe_p1, &fe_data_3d.fe_p1);
165  dh_ = make_shared<DOFHandlerMultiDim>(*mesh_);
166  dh_->distribute_dofs(ds, true);
167  corner_pressure.resize(dh_->n_global_dofs());
168 
169  auto corner_ptr = make_shared< FieldFE<3, FieldValue<3>::Scalar> >();
170  corner_ptr->set_fe_data(dh_, &fe_data_1d.mapp, &fe_data_2d.mapp, &fe_data_3d.mapp, &corner_pressure);
171 
172  output_fields.field_node_pressure.set_field(mesh_->region_db().get_region_set("ALL"), corner_ptr);
174 
175  ele_piezo_head.resize(mesh_->n_elements());
177  output_fields.field_ele_piezo_head.set_field(mesh_->region_db().get_region_set("ALL"), ele_piezo_head_ptr);
178 
179  ele_flux.resize(3*mesh_->n_elements());
181  output_fields.field_ele_flux.set_field(mesh_->region_db().get_region_set("ALL"), ele_flux_ptr);
182 
185 
186  //output_stream->add_admissible_field_names(in_rec_output.val<Input::Array>("fields"));
187  //output_stream->mark_output_times(darcy_flow->time());
189 }
190 
192 {
194  diff_data.data_ = darcy_flow->data_.get();
195 
196  // mask 2d elements crossing 1d
200  diff_data.velocity_mask[ isec.bulk_ele_idx() ]++;
201  }
202  }
203 
207 
209 
211  output_specific_fields.velocity_diff.set_field(mesh_->region_db().get_region_set("ALL"), diff_data.vel_diff_ptr, 0);
213  output_specific_fields.pressure_diff.set_field(mesh_->region_db().get_region_set("ALL"), diff_data.pressure_diff_ptr, 0);
215  output_specific_fields.div_diff.set_field(mesh_->region_db().get_region_set("ALL"), diff_data.div_diff_ptr, 0);
216 
219 }
220 
222 {};
223 
224 
225 
226 
227 
228 //=============================================================================
229 // CONVERT SOLUTION, CALCULATE BALANCES, ETC...
230 //=============================================================================
231 
232 
234 {
235  START_TIMER("Darcy fields output");
236 
237  ElementSetRef observed_elements = output_stream->observe(mesh_)->observed_elements();
238  {
239  START_TIMER("post-process output fields");
240 
242 
246  else
247  make_element_scalar(observed_elements);
248 
251  else
252  make_element_vector(observed_elements);
253 
256  //else
257  // make_node_scalar_param(observed_elements);
258 
262 
263  // Internal output only if both ele_pressure and ele_flux are output.
266  {
268  }
269  }
270 
271  {
272  START_TIMER("evaluate output fields");
274  }
275 
276  if (compute_errors_)
277  {
278  START_TIMER("compute specific output fields");
280  }
281 
283  {
284  START_TIMER("evaluate output fields");
290  }
291 
292  {
293  START_TIMER("write time frame");
294  output_stream->write_time_frame();
295  }
296 
297 
298 }
299 
300 
301 //=============================================================================
302 // FILL TH "SCALAR" FIELD FOR ALL ELEMENTS IN THE MESH
303 //=============================================================================
304 
306 {
307  START_TIMER("DarcyFlowMHOutput::make_element_scalar");
308  unsigned int sol_size;
309  double *sol;
310 
311  darcy_flow->get_solution_vector(sol, sol_size);
312  unsigned int soi = mesh_->n_sides();
313  for(unsigned int i_ele : element_indices) {
315  ele_pressure[i_ele] = sol[ soi + i_ele];
316  ele_piezo_head[i_ele] = sol[soi + i_ele ]
317  - (darcy_flow->data_->gravity_[3] + arma::dot(darcy_flow->data_->gravity_vec_,ele.centre()));
318  }
319 }
320 
321 
322 
323 /****
324  * compute Darcian velocity in centre of elements
325  *
326  */
328  START_TIMER("DarcyFlowMHOutput::make_element_vector");
329  // need to call this to create mh solution vector
331 
332  auto multidim_assembler = AssemblyBase::create< AssemblyMH >(darcy_flow->data_);
333  arma::vec3 flux_in_center;
334  for(unsigned int i_ele : element_indices) {
336 
337  flux_in_center = multidim_assembler[ele->dim() -1]->make_element_vector(ele);
338 
339  // place it in the sequential vector
340  for(unsigned int j=0; j<3; j++) ele_flux[3*i_ele + j]=flux_in_center[j];
341  }
342 }
343 
344 
346 {
347  START_TIMER("DarcyFlowMHOutput::make_corner_scalar");
348  unsigned int ndofs = dh_->max_elem_dofs();
349  std::vector<LongIdx> indices(ndofs);
350  unsigned int i_node;
351  for (auto ele : mesh_->elements_range()) {
352  dh_->get_dof_indices(ele, indices);
353  for (i_node=0; i_node<ele->n_nodes(); i_node++)
354  {
355  corner_pressure[indices[i_node]] = node_scalar[ ele.node_accessor(i_node).idx() ];
356  }
357  }
358 }
359 
360 
361 //=============================================================================
362 // pressure interpolation
363 //
364 // some sort of weighted average over elements and sides/edges of an node
365 //
366 // TODO:
367 // questions:
368 // - explain details of averaging and motivation for this type
369 // - edge scalars are stronger since thay are computed twice by each side
370 // - why division by (nod.aux-1)
371 // - ?implement without TED, TSD global arrays with single loop over elements, sides and one loop over nodes for normalization
372 //
373 //=============================================================================
374 
376  START_TIMER("DarcyFlowMHOutput::make_node_scalar_param");
377 
378  vector<double> scalars(mesh_->n_nodes());
379 
380  double dist; //!< tmp variable for storing particular distance node --> element, node --> side*/
381 
382  /** Accessors */
383  NodeAccessor<3> node;
384 
385  int n_nodes = mesh_->n_nodes(); //!< number of nodes in the mesh */
386  int node_index = 0; //!< index of each node */
387 
388  int* sum_elements = new int [n_nodes]; //!< sum elements joined to node */
389  int* sum_sides = new int [n_nodes]; //!< sum sides joined to node */
390  double* sum_ele_dist = new double [n_nodes]; //!< sum distances to all joined elements */
391  double* sum_side_dist = new double [n_nodes]; //!< Sum distances to all joined sides */
392 
393  /** tmp variables, will be replaced by ini keys
394  * TODO include them into ini file*/
395  bool count_elements = true; //!< scalar is counted via elements*/
396  bool count_sides = true; //!< scalar is counted via sides */
397 
398 
400 
401  /** init arrays */
402  for (int i = 0; i < n_nodes; i++){
403  sum_elements[i] = 0;
404  sum_sides[i] = 0;
405  sum_ele_dist[i] = 0.0;
406  sum_side_dist[i] = 0.0;
407  scalars[i] = 0.0;
408  };
409 
410  /**first pass - calculate sums (weights)*/
411  if (count_elements){
412  for (auto ele : mesh_->elements_range())
413  for (unsigned int li = 0; li < ele->n_nodes(); li++) {
414  node = ele.node_accessor(li); //!< get NodeAccessor from element */
415  node_index = node.idx(); //!< get nod index from mesh */
416 
417  dist = sqrt(
418  ((node->getX() - ele.centre()[ 0 ])*(node->getX() - ele.centre()[ 0 ])) +
419  ((node->getY() - ele.centre()[ 1 ])*(node->getY() - ele.centre()[ 1 ])) +
420  ((node->getZ() - ele.centre()[ 2 ])*(node->getZ() - ele.centre()[ 2 ]))
421  );
422  sum_ele_dist[node_index] += dist;
423  sum_elements[node_index]++;
424  }
425  }
426  if (count_sides){
427  for (auto ele : mesh_->elements_range())
428  for(SideIter side = ele.side(0); side->side_idx() < ele->n_sides(); ++side) {
429  for (unsigned int li = 0; li < side->n_nodes(); li++) {
430  node = side->node(li);//!< get NodeAccessor from element */
431  node_index = node.idx(); //!< get nod index from mesh */
432  dist = sqrt(
433  ((node->getX() - side->centre()[ 0 ])*(node->getX() - side->centre()[ 0 ])) +
434  ((node->getY() - side->centre()[ 1 ])*(node->getY() - side->centre()[ 1 ])) +
435  ((node->getZ() - side->centre()[ 2 ])*(node->getZ() - side->centre()[ 2 ]))
436  );
437 
438  sum_side_dist[node_index] += dist;
439  sum_sides[node_index]++;
440  }
441  }
442  }
443 
444  /**second pass - calculate scalar */
445  if (count_elements){
446  for (auto ele : mesh_->elements_range())
447  for (unsigned int li = 0; li < ele->n_nodes(); li++) {
448  node = ele.node_accessor(li);//!< get NodeAccessor from element */
449  node_index = ele.node_accessor(li).idx(); //!< get nod index from mesh */
450 
451  /**TODO - calculate it again or store it in prior pass*/
452  dist = sqrt(
453  ((node->getX() - ele.centre()[ 0 ])*(node->getX() - ele.centre()[ 0 ])) +
454  ((node->getY() - ele.centre()[ 1 ])*(node->getY() - ele.centre()[ 1 ])) +
455  ((node->getZ() - ele.centre()[ 2 ])*(node->getZ() - ele.centre()[ 2 ]))
456  );
457  scalars[node_index] += ele_pressure[ ele.idx() ] *
458  (1 - dist / (sum_ele_dist[node_index] + sum_side_dist[node_index])) /
459  (sum_elements[node_index] + sum_sides[node_index] - 1);
460  }
461  }
462  if (count_sides) {
463  for (auto ele : mesh_->elements_range())
464  for(SideIter side = ele.side(0); side->side_idx() < ele->n_sides(); ++side) {
465  for (unsigned int li = 0; li < side->n_nodes(); li++) {
466  node = side->node(li);//!< get NodeAccessor from element */
467  node_index = node.idx(); //!< get nod index from mesh */
468 
469  /**TODO - calculate it again or store it in prior pass*/
470  dist = sqrt(
471  ((node->getX() - side->centre()[ 0 ])*(node->getX() - side->centre()[ 0 ])) +
472  ((node->getY() - side->centre()[ 1 ])*(node->getY() - side->centre()[ 1 ])) +
473  ((node->getZ() - side->centre()[ 2 ])*(node->getZ() - side->centre()[ 2 ]))
474  );
475 
476 
477  scalars[node_index] += dh.side_scalar( *side ) *
478  (1 - dist / (sum_ele_dist[node_index] + sum_side_dist[node_index])) /
479  (sum_sides[node_index] + sum_elements[node_index] - 1);
480  }
481  }
482  }
483 
484  /** free memory */
485  delete [] sum_elements;
486  delete [] sum_sides;
487  delete [] sum_ele_dist;
488  delete [] sum_side_dist;
489 
490  make_corner_scalar(scalars);
491 }
492 
493 
494 /*
495  * Output of internal flow data.
496  */
498 {
499  START_TIMER("DarcyFlowMHOutput::output_internal_flow_data");
501 
502  if (! raw_output_file.is_open()) return;
503 
504  //char dbl_fmt[ 16 ]= "%.8g ";
505  // header
506  raw_output_file << "// fields:\n//ele_id ele_presure flux_in_barycenter[3] n_sides side_pressures[n] side_fluxes[n]\n";
507  raw_output_file << fmt::format("$FlowField\nT={}\n", darcy_flow->time().t());
508  raw_output_file << fmt::format("{}\n" , mesh_->n_elements() );
509 
510  int cit = 0;
511  for (auto ele : mesh_->elements_range()) {
512  raw_output_file << fmt::format("{} {} ", ele.index(), ele_pressure[cit]);
513  for (unsigned int i = 0; i < 3; i++)
514  raw_output_file << ele_flux[3*cit+i] << " ";
515 
516  raw_output_file << ele->n_sides() << " ";
517 
518  for (unsigned int i = 0; i < ele->n_sides(); i++) {
519  raw_output_file << dh.side_scalar( *(ele.side(i) ) ) << " ";
520  }
521  for (unsigned int i = 0; i < ele->n_sides(); i++) {
522  raw_output_file << dh.side_flux( *(ele.side(i) ) ) << " ";
523  }
524 
525  raw_output_file << endl;
526  cit ++;
527  }
528  raw_output_file << "$EndFlowField\n" << endl;
529 }
530 
531 
533 #include "fem/fe_p.hh"
534 #include "fem/fe_values.hh"
535 #include "fem/mapping_p1.hh"
536 #include "fields/field_python.hh"
537 #include "fields/field_values.hh"
538 
540 
541 /*
542 * Calculate approximation of L2 norm for:
543  * 1) difference between regularized pressure and analytical solution (using FunctionPython)
544  * 2) difference between RT velocities and analytical solution
545  * 3) difference of divergence
546  * */
547 
548 template <int dim>
550  FEValues<dim,3> &fe_values, FEValues<dim,3> &fv_rt,
551  ExactSolution &anal_sol, DarcyFlowMHOutput::DiffData &result) {
552 
553  fv_rt.reinit(ele);
554  fe_values.reinit(ele);
555 
556  double conductivity = result.data_->conductivity.value(ele.centre(), ele );
557  double cross = result.data_->cross_section.value(ele.centre(), ele );
558 
559 
560  // get coefficients on the current element
561  vector<double> fluxes(dim+1);
562 // vector<double> pressure_traces(dim+1);
563 
564  for (unsigned int li = 0; li < ele->n_sides(); li++) {
565  fluxes[li] = result.dh->side_flux( *(ele.side( li ) ) );
566 // pressure_traces[li] = result.dh->side_scalar( *(ele->side( li ) ) );
567  }
568  double pressure_mean = result.dh->element_scalar(ele);
569 
570  arma::vec analytical(5);
571  arma::vec3 flux_in_q_point;
572  arma::vec3 anal_flux;
573 
574  double velocity_diff=0, divergence_diff=0, pressure_diff=0, diff;
575 
576  // 1d: mean_x_squared = 1/6 (v0^2 + v1^2 + v0*v1)
577  // 2d: mean_x_squared = 1/12 (v0^2 + v1^2 +v2^2 + v0*v1 + v0*v2 + v1*v2)
578  double mean_x_squared=0;
579  for(unsigned int i_node=0; i_node < ele->n_nodes(); i_node++ )
580  for(unsigned int j_node=0; j_node < ele->n_nodes(); j_node++ )
581  {
582  mean_x_squared += (i_node == j_node ? 2.0 : 1.0) / ( 6 * dim ) // multiply by 2 on diagonal
583  * arma::dot( ele.node(i_node)->point(), ele.node(j_node)->point());
584  }
585 
586  for(unsigned int i_point=0; i_point < fe_values.n_points(); i_point++) {
587  arma::vec3 q_point = fe_values.point(i_point);
588 
589 
590  analytical = anal_sol.value(q_point, ele );
591  for(unsigned int i=0; i< 3; i++) anal_flux[i] = analytical[i+1];
592 
593  // compute postprocesed pressure
594  diff = 0;
595  for(unsigned int i_shape=0; i_shape < ele->n_sides(); i_shape++) {
596  unsigned int oposite_node = RefElement<dim>::oposite_node(i_shape);
597 
598  diff += fluxes[ i_shape ] *
599  ( arma::dot( q_point, q_point )/ 2
600  - mean_x_squared / 2
601  - arma::dot( q_point, ele.node(oposite_node)->point() )
602  + arma::dot( ele.centre(), ele.node(oposite_node)->point() )
603  );
604  }
605 
606  diff = - (1.0 / conductivity) * diff / dim / ele.measure() / cross + pressure_mean ;
607  diff = ( diff - analytical[0]);
608  pressure_diff += diff * diff * fe_values.JxW(i_point);
609 
610 
611  // velocity difference
612  flux_in_q_point.zeros();
613  for(unsigned int i_shape=0; i_shape < ele->n_sides(); i_shape++) {
614  flux_in_q_point += fluxes[ i_shape ]
615  * fv_rt.vector_view(0).value(i_shape, i_point)
616  / cross;
617  }
618 
619  flux_in_q_point -= anal_flux;
620  velocity_diff += dot(flux_in_q_point, flux_in_q_point) * fe_values.JxW(i_point);
621 
622  // divergence diff
623  diff = 0;
624  for(unsigned int i_shape=0; i_shape < ele->n_sides(); i_shape++) diff += fluxes[ i_shape ];
625  diff = ( diff / ele.measure() / cross - analytical[4]);
626  divergence_diff += diff * diff * fe_values.JxW(i_point);
627 
628  }
629 
630 
631  result.velocity_diff[ ele.idx() ] = sqrt(velocity_diff);
632  result.velocity_error[dim-1] += velocity_diff;
633  if (dim == 2 && result.velocity_mask.size() != 0 ) {
634  result.mask_vel_error += (result.velocity_mask[ ele.idx() ])? 0 : velocity_diff;
635  }
636 
637  result.pressure_diff[ ele.idx() ] = sqrt(pressure_diff);
638  result.pressure_error[dim-1] += pressure_diff;
639 
640  result.div_diff[ ele.idx() ] = sqrt(divergence_diff);
641  result.div_error[dim-1] += divergence_diff;
642 
643 }
644 
646 : fe_p0(0), fe_p1(1), order(4), quad(order),
647  fe_values(mapp,quad,fe_p0,update_JxW_values | update_quadrature_points),
648  fv_rt(mapp,quad,fe_rt,update_values | update_quadrature_points)
649 {}
650 
651 
653  DebugOut() << "l2 norm output\n";
654  ofstream os( FilePath("solution_error", FilePath::output_file) );
655 
656  FilePath source_file( "analytical_module.py", FilePath::input_file);
657  ExactSolution anal_sol_1d(5); // components: pressure, flux vector 3d, divergence
658  anal_sol_1d.set_python_field_from_file( source_file, "all_values_1d");
659 
660  ExactSolution anal_sol_2d(5);
661  anal_sol_2d.set_python_field_from_file( source_file, "all_values_2d");
662 
663  ExactSolution anal_sol_3d(5);
664  anal_sol_3d.set_python_field_from_file( source_file, "all_values_3d");
665 
668  for(unsigned int j=0; j<3; j++){
669  diff_data.pressure_error[j] = 0;
670  diff_data.velocity_error[j] = 0;
671  diff_data.div_error[j] = 0;
672  }
673 
674  //diff_data.ele_flux = &( ele_flux );
675 
676  unsigned int solution_size;
678 
679 
680  for (auto ele : mesh_->elements_range()) {
681 
682  switch (ele->dim()) {
683  case 1:
684 
685  l2_diff_local<1>( ele, fe_data_1d.fe_values, fe_data_1d.fv_rt, anal_sol_1d, diff_data);
686  break;
687  case 2:
688  l2_diff_local<2>( ele, fe_data_2d.fe_values, fe_data_2d.fv_rt, anal_sol_2d, diff_data);
689  break;
690  case 3:
691  l2_diff_local<3>( ele, fe_data_3d.fe_values, fe_data_3d.fv_rt, anal_sol_3d, diff_data);
692  break;
693  }
694  }
695 
696  // square root for L2 norm
697  for(unsigned int j=0; j<3; j++){
700  diff_data.div_error[j] = sqrt(diff_data.div_error[j]);
701  }
703 
704  os << "l2 norm output\n\n"
705  << "pressure error 1d: " << diff_data.pressure_error[0] << endl
706  << "pressure error 2d: " << diff_data.pressure_error[1] << endl
707  << "pressure error 3d: " << diff_data.pressure_error[2] << endl
708  << "velocity error 1d: " << diff_data.velocity_error[0] << endl
709  << "velocity error 2d: " << diff_data.velocity_error[1] << endl
710  << "velocity error 3d: " << diff_data.velocity_error[2] << endl
711  << "masked velocity error 2d: " << diff_data.mask_vel_error <<endl
712  << "div error 1d: " << diff_data.div_error[0] << endl
713  << "div error 2d: " << diff_data.div_error[1] << endl
714  << "div error 3d: " << diff_data.div_error[2];
715 }
716 
717 
TimeGovernor & time()
Definition: equation.hh:148
FieldSet & data()
Definition: equation.hh:193
void set_python_field_from_file(const FilePath &file_name, const string &func_name)
void get_solution_vector(double *&vec, unsigned int &vec_size) override
Field< 3, FieldValue< 3 >::VectorFixed > field_ele_flux
Class MappingP1 implements the affine transformation of the unit cell onto the actual cell...
Shape function values.
Definition: update_flags.hh:87
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > vel_diff_ptr
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:336
VectorSeqDouble ele_pressure
static auto subdomain(Mesh &mesh) -> IndexField
struct DarcyFlowMHOutput::DiffData diff_data
Declaration of class which handles the ordering of degrees of freedom (dof) and mappings between loca...
Output class for darcy_flow_mh model.
unsigned int n_nodes() const
Definition: elements.h:129
virtual void prepare_specific_output(Input::Record in_rec)
Accessor to input data conforming to declared Array.
Definition: accessors.hh:567
Classes with algorithms for computation of intersections of meshes.
double getY() const
Definition: nodes.hh:58
virtual void prepare_output(Input::Record in_rec)
unsigned int side_idx() const
Definition: side_impl.hh:82
OutputSpecificFields output_specific_fields
Specific quantities for output in DarcyFlowMH - error estimates etc.
Field< 3, FieldValue< 3 >::Scalar > field_node_pressure
MixedMeshIntersections & mixed_intersections()
Definition: mesh.cc:702
Class Input::Type::Default specifies default value of keys of a Input::Type::Record.
Definition: type_record.hh:61
Class for declaration of the input of type Bool.
Definition: type_base.hh:459
#define MessageOut()
Macro defining &#39;message&#39; record of log.
Definition: logger.hh:243
void output(TimeStep step)
const Input::Type::Instance & make_output_type_from_record(Input::Type::Record &in_rec, const string &equation_name, const string &aditional_description="")
void make_element_vector(ElementSetRef element_indices)
std::string format(CStringRef format_str, ArgList args)
Definition: format.h:3141
#define INPUT_CATCH(ExceptionType, AddressEITag, input_accessor)
Definition: accessors.hh:64
static std::shared_ptr< OutputTime > create_output_stream(const std::string &equation_name, const Input::Record &in_rec, std::string unit_str)
This method delete all object instances of class OutputTime stored in output_streams vector...
Definition: output_time.cc:185
bool is_output_specific_fields
Output specific field stuff.
void l2_diff_local(ElementAccessor< 3 > &ele, FEValues< dim, 3 > &fe_values, FEValues< dim, 3 > &fv_rt, FieldPython< 3, FieldValue< 3 >::Vector > &anal_sol, DiffData &result)
Computes L2 error on an element.
Standard quantities for output in DarcyFlowMH.
Fields computed from the mesh data.
Iterator< Ret > find(const string &key) const
void make_corner_scalar(vector< double > &node_scalar)
Helper class that stores data of generic types.
Definition: type_generic.hh:89
Class FEValues calculates finite element data on the actual cells such as shape function values...
FieldPython< 3, FieldValue< 3 >::Vector > ExactSolution
SideIter side(const unsigned int loc_index)
Definition: accessors.hh:137
std::shared_ptr< FieldFE< spacedim, Value > > create_field(Mesh &mesh, unsigned int n_comp)
Create and return shared pointer to FieldFE object.
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > ele_pressure_ptr
Field of pressure head in barycenters of elements.
void fill_output_data(std::shared_ptr< FieldFE< spacedim, Value > > field_ptr)
virtual unsigned int n_nodes() const
Definition: mesh.h:133
const TimeStep & step(int index=-1) const
std::shared_ptr< DOFHandlerMultiDim > dh_
double t() const
Field< 3, FieldValue< 3 >::Scalar > subdomain
FieldCommon & units(const UnitSI &units)
Set basic units of the field.
std::vector< unsigned int > all_element_idx_
std::shared_ptr< OutputTime > output_stream
std::shared_ptr< EqData > data_
Field< 3, FieldValue< 3 >::Scalar > pressure_diff
unsigned int n_points()
Returns the number of quadrature points.
Definition: fe_values.hh:407
Record & close() const
Close the Record for further declarations of keys.
Definition: type_record.cc:303
std::shared_ptr< DiscreteSpace > ds
virtual ElementAccessor< 3 > element_accessor(unsigned int idx) const
Create and return ElementAccessor to element of given idx.
Definition: mesh.cc:719
void make_node_scalar_param(ElementSetRef element_indices)
Calculate nodes scalar, store it in double* node_scalars instead of node->scalar. ...
static unsigned int oposite_node(unsigned int sid)
Definition: ref_element.cc:308
double getZ() const
Definition: nodes.hh:60
arma::vec::fixed< spacedim > centre() const
Computes the barycenter.
Definition: accessors.hh:285
unsigned int dim() const
Definition: elements.h:124
Field< 3, FieldValue< 3 >::Scalar > velocity_diff
static Default optional()
The factory function to make an empty default value which is optional.
Definition: type_record.hh:124
double element_scalar(ElementAccessor< 3 > &ele) const
temporary replacement for DofHandler accessor, scalar (pressure) on element
void open_stream(Stream &stream) const
Definition: file_path.cc:211
bool opt_val(const string &key, Ret &value) const
Field< 3, FieldValue< 3 >::Scalar > field_ele_pressure
Transformed quadrature points.
Global macros to enhance readability and debugging, general constants.
static const Input::Type::Instance & get_input_type_specific()
VectorSeqDouble ele_piezo_head
Definitions of basic Lagrangean finite elements with polynomial shape functions.
static constexpr Mask equation_external_output
Match an output field, that can be also copy of other field.
Definition: field_flag.hh:58
Accessor to the data with type Type::Record.
Definition: accessors.hh:292
const Ret val(const string &key) const
unsigned int n_sides() const
Definition: elements.h:135
static auto region_id(Mesh &mesh) -> IndexField
void resize(unsigned int size)
Create shared pointer and PETSC vector with given size.
double getX() const
Definition: nodes.hh:56
#define START_TIMER(tag)
Starts a timer with specified tag.
virtual Value::return_type const & value(const Point &p, const ElementAccessor< spacedim > &elm) const
Definition: field.hh:389
static const Input::Type::Instance & get_input_type()
Field< 3, FieldValue< 3 >::Scalar > div_diff
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:501
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > pressure_diff_ptr
virtual Range< ElementAccessor< 3 > > elements_range() const
Returns range of bulk elements.
Definition: mesh.cc:1033
VectorSeqDouble ele_flux
ofstream raw_output_file
Raw data output file.
double measure() const
Computes the measure of the element.
Definition: accessors.hh:254
unsigned int n_sides() const
Definition: mesh.cc:221
const FEValuesViews::Vector< dim, spacedim > & vector_view(unsigned int i) const
Accessor to vector values of multicomponent FE.
Definition: fe_values.hh:388
#define MPI_Comm_rank
Definition: mpi.h:236
Record & copy_keys(const Record &other)
Copy keys from other record.
Definition: type_record.cc:215
Dedicated class for storing path to input and output files.
Definition: file_path.hh:54
Field< 3, FieldValue< 3 >::Scalar > field_ele_piezo_head
double side_flux(const Side &side) const
temporary replacement for DofHandler accessor, flux through given side
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > ele_piezo_head_ptr
Field of piezo-metric head in barycenters of elements.
std::string get_unit_string() const
virtual unsigned int n_elements(bool boundary=false) const
Returns count of boundary or bulk elements.
Definition: mesh.h:346
void initialize(std::shared_ptr< OutputTime > stream, Mesh *mesh, Input::Record in_rec, const TimeGovernor &tg)
Field< 3, FieldValue< 3 >::Scalar > region_id
bool compute_errors_
Specific experimental error computing.
static Input::Type::Record & get_input_type()
void set_field(const RegionSet &domain, FieldBasePtr field, double time=0.0)
Definition: field.impl.hh:198
bool set_time(const TimeStep &time, LimitSide limit_side)
Definition: field_set.cc:157
Definitions of particular quadrature rules on simplices.
FieldCommon & name(const string &name)
#define MPI_COMM_WORLD
Definition: mpi.h:123
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > div_diff_ptr
mixed-hybrid model of linear Darcy flow, possibly unsteady.
void set_mesh(const Mesh &mesh)
Definition: field_set.hh:183
Record type proxy class.
Definition: type_record.hh:182
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::VectorFixed > > ele_flux_ptr
Field of flux in barycenter of every element.
bool is_field_output_time(const FieldCommon &field, TimeStep step) const
const Input::Type::Instance & make_output_type(const string &equation_name, const string &aditional_description="")
Field< 3, FieldValue< 3 >::Scalar > cross_section
Field< 3, FieldValue< 3 >::Scalar > conductivity
FieldCommon & flags(FieldFlag::Flags::Mask mask)
double side_scalar(const Side &side) const
temporary replacement for DofHandler accessor, scalar (pressure) on edge of the side ...
Class for representation SI units of Fields.
Definition: unit_si.hh:40
DarcyFlowMHOutput(DarcyMH *flow, Input::Record in_rec)
arma::vec3 & point()
Definition: nodes.hh:67
static FileName output()
The factory function for declaring type FileName for input files.
Definition: type_base.cc:533
static UnitSI & dimensionless()
Returns dimensionless unit.
Definition: unit_si.cc:55
#define DebugOut()
Macro defining &#39;debug&#39; record of log.
Definition: logger.hh:252
unsigned int idx() const
Return local idx of element in boundary / bulk part of element vector.
Definition: accessors.hh:111
void make_element_scalar(ElementSetRef element_indices)
std::vector< IntersectionLocal< 1, 2 > > intersection_storage12_
Stores 1D-2D intersections.
VectorSeqDouble corner_pressure
Implementation of range helper class.
unsigned int idx() const
Definitions of Raviart-Thomas finite elements.
MortarMethod mortar_method_
virtual Value::return_type const & value(const Point &p, const ElementAccessor< spacedim > &elm)
FieldCommon & output_type(OutputTime::DiscreteSpace rt)
void output()
Calculate values for output.
void reinit(ElementAccessor< 3 > &cell)
Update cell-dependent data (gradients, Jacobians etc.)
Definition: fe_values.cc:528
Transformed quadrature weights.
const MH_DofHandler & get_mh_dofhandler() override
Mixed-hybrid model of linear Darcy flow, possibly unsteady.
const Node * node(unsigned int ni) const
Definition: accessors.hh:145
arma::vec::fixed< spacedim > point(const unsigned int point_no)
Return coordinates of the quadrature point in the actual cell system.
Definition: fe_values.hh:347