Flow123d  master-7bf36fe
field_fe.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 field_fe.cc
15  * @brief
16  */
17 
18 
19 #include <limits>
20 
21 #include "fields/field_fe.hh"
22 #include "la/vector_mpi.hh"
23 #include "fields/field_instances.hh" // for instantiation macros
25 #include "input/input_type.hh"
26 #include "fem/fe_p.hh"
27 #include "fem/fe_system.hh"
28 #include "fem/dh_cell_accessor.hh"
29 #include "fem/mapping_p1.hh"
30 #include "io/reader_cache.hh"
31 #include "io/msh_gmshreader.h"
32 #include "mesh/accessors.hh"
33 #include "mesh/range_wrapper.hh"
34 #include "mesh/bc_mesh.hh"
36 
37 #include "system/sys_profiler.hh"
38 #include "tools/unit_converter.hh"
42 
43 
44 
45 
46 /// Implementation.
47 
48 namespace it = Input::Type;
49 
50 
51 
52 
54 
55 
56 
57 /************************************************************************************
58  * Implementation of FieldFE methods
59  */
60 template <int spacedim, class Value>
62 {
63  return it::Record("FieldFE", FieldAlgorithmBase<spacedim,Value>::template_name()+" Field given by finite element approximation.")
67  "GMSH mesh with data. Can be different from actual computational mesh.")
69  "Section where to find the field.\n Some sections are specific to file format: "
70  "point_data/node_data, cell_data/element_data, -/element_node_data, native/-.\n"
71  "If not given by a user, we try to find the field in all sections, but we report an error "
72  "if it is found in more than one section.")
74  "The values of the Field are read from the ```$ElementData``` section with field name given by this key.")
75  .declare_key("default_value", IT::Double(), IT::Default::optional(),
76  "Default value is set on elements which values have not been listed in the mesh data file.")
78  "Definition of the unit of all times defined in the mesh data file.")
79  .declare_key("read_time_shift", TimeGovernor::get_input_time_type(), IT::Default("0.0"),
80  "This key allows reading field data from the mesh data file shifted in time. Considering the time 't', field descriptor with time 'T', "
81  "time shift 'S', then if 't > T', we read the time frame 't + S'.")
83  IT::Default("\"equivalent_mesh\""), "Type of interpolation applied to the input spatial data.\n"
84  "The default value 'equivalent_mesh' assumes the data being constant on elements living on the same mesh "
85  "as the computational mesh, but possibly with different numbering. In the case of the same numbering, "
86  "the user can set 'identical_mesh' to omit algorithm for guessing node and element renumbering. "
87  "Alternatively, in case of different input mesh, several interpolation algorithms are available.")
88  .close();
89 }
90 
91 template <int spacedim, class Value>
93 {
94  return it::Selection("FE_discretization",
95  "Specify the section in mesh input file where field data is listed.\nSome sections are specific to file format.")
96  //.add_value(OutputTime::DiscreteSpace::NODE_DATA, "node_data", "point_data (VTK) / node_data (GMSH)")
97  .add_value(OutputTime::DiscreteSpace::ELEM_DATA, "element_data", "cell_data (VTK) / element_data (GMSH)")
98  //.add_value(OutputTime::DiscreteSpace::CORNER_DATA, "element_node_data", "element_node_data (only for GMSH)")
99  .add_value(OutputTime::DiscreteSpace::NATIVE_DATA, "native_data", "native_data (only for VTK)")
100  .close();
101 }
102 
103 template <int spacedim, class Value>
105 {
106  return it::Selection("interpolation", "Specify interpolation of the input data from its input mesh to the computational mesh.")
107  .add_value(DataInterpolation::identic_msh, "identic_mesh", "Topology and indices of nodes and elements of"
108  "the input mesh and the computational mesh are identical. "
109  "This interpolation is typically used for GMSH input files containing only the field values without "
110  "explicit mesh specification.")
111  .add_value(DataInterpolation::equivalent_msh, "equivalent_mesh", "Topologies of the input mesh and the computational mesh "
112  "are the same, the node and element numbering may differ. "
113  "This interpolation can be used also for VTK input data.") // default value
114  .add_value(DataInterpolation::gauss_p0, "P0_gauss", "Topologies of the input mesh and the computational mesh may differ. "
115  "Constant values on the elements of the computational mesh are evaluated using the Gaussian quadrature of the fixed order 4, "
116  "where the quadrature points and their values are found in the input mesh and input data using the BIH tree search."
117  )
118  .add_value(DataInterpolation::interp_p0, "P0_intersection", "Topologies of the input mesh and the computational mesh may differ. "
119  "Can be applied only for boundary fields. For every (boundary) element of the computational mesh the "
120  "intersection with the input mesh is computed. Constant values on the elements of the computational mesh "
121  "are evaluated as the weighted average of the (constant) values on the intersecting elements of the input mesh.")
122  .close();
123 }
124 
125 template <int spacedim, class Value>
127  Input::register_class< FieldFE<spacedim, Value>, unsigned int >("FieldFE") +
129 
130 
131 
132 template <int spacedim, class Value>
134 : FieldAlgorithmBase<spacedim, Value>(n_comp),
135  dh_(nullptr), field_name_(""), discretization_(OutputTime::DiscreteSpace::UNDEFINED), fe_values_(4)
136 {
137  this->is_constant_in_space_ = false;
138 }
139 
140 
141 template<int spacedim, class Value>
143  Input::Array multifield_arr;
144  if (rec.opt_val(field.input_name(), multifield_arr))
145  {
146  unsigned int position = 0;
147  auto it = multifield_arr.begin<Input::AbstractRecord>();
148  if (multifield_arr.size() > 1)
149  while (index_ != position) {
150  ++it; ++position;
151  }
152 
153  Input::Record field_rec = (Input::Record)(*it);
154  if (field_rec.val<std::string>("TYPE") == "FieldFE") {
155  OutputTime::DiscreteSpace discretization;
156  if (field_rec.opt_val<OutputTime::DiscreteSpace>("input_discretization", discretization)) {
157  if (discretization == OutputTime::DiscreteSpace::NATIVE_DATA) {
158  std::shared_ptr< FieldFE<spacedim, Value> > field_fe = std::make_shared< FieldFE<spacedim, Value> >(field.n_comp());
159  FieldAlgoBaseInitData init_data(field.input_name(), field.n_comp(), field.units(), field.limits(), field.get_flags());
160  field_fe->init_from_input( *it, init_data );
161  field_fe->set_fe_data(conc_dof_handler_, dof_vector_);
162  return field_fe;
163  }
164  }
165  }
166  }
167 
168  return NULL;
169 }
170 
171 
172 template <int spacedim, class Value>
173 VectorMPI FieldFE<spacedim, Value>::set_fe_data(std::shared_ptr<DOFHandlerMultiDim> dh, VectorMPI dof_values, unsigned int block_index)
174 {
175  dh_ = dh;
176  if (dof_values.size()==0) { //create data vector according to dof handler - Warning not tested yet
177  data_vec_ = dh_->create_vector();
179  } else {
180  data_vec_ = dof_values;
181  }
182 
183  if ( block_index == FieldFE<spacedim, Value>::undef_uint ) {
184  this->fill_fe_item<0>();
185  this->fill_fe_item<1>();
186  this->fill_fe_item<2>();
187  this->fill_fe_item<3>();
188  this->fe_ = dh_->ds()->fe();
189  } else {
190  this->fill_fe_system_data<0>(block_index);
191  this->fill_fe_system_data<1>(block_index);
192  this->fill_fe_system_data<2>(block_index);
193  this->fill_fe_system_data<3>(block_index);
195  std::dynamic_pointer_cast<FESystem<0>>( dh_->ds()->fe()[Dim<0>{}] )->fe()[block_index],
196  std::dynamic_pointer_cast<FESystem<1>>( dh_->ds()->fe()[Dim<1>{}] )->fe()[block_index],
197  std::dynamic_pointer_cast<FESystem<2>>( dh_->ds()->fe()[Dim<2>{}] )->fe()[block_index],
198  std::dynamic_pointer_cast<FESystem<3>>( dh_->ds()->fe()[Dim<3>{}] )->fe()[block_index]
199  );
200  }
201 
202  unsigned int ndofs = dh_->max_elem_dofs();
203 
204  // initialization data of value handlers
205  FEValueInitData init_data;
206  init_data.dh = dh_;
207  init_data.data_vec = data_vec_;
208  init_data.ndofs = ndofs;
209  init_data.n_comp = this->n_comp();
210  init_data.mixed_fe = this->fe_;
211 
212  // initialize value handler objects
213  init_data.range_begin = this->fe_item_[0].range_begin_;
214  init_data.range_end = this->fe_item_[0].range_end_;
215  value_handler0_.initialize(init_data);
216  init_data.range_begin = this->fe_item_[1].range_begin_;
217  init_data.range_end = this->fe_item_[1].range_end_;
218  value_handler1_.initialize(init_data);
219  init_data.range_begin = this->fe_item_[2].range_begin_;
220  init_data.range_end = this->fe_item_[2].range_end_;
221  value_handler2_.initialize(init_data);
222  init_data.range_begin = this->fe_item_[3].range_begin_;
223  init_data.range_end = this->fe_item_[3].range_end_;
224  value_handler3_.initialize(init_data);
225 
226  // set interpolation
227  interpolation_ = DataInterpolation::equivalent_msh;
228 
229  region_value_err_.resize(dh_->mesh()->region_db().size());
230 
231  return data_vec_;
232 }
233 
234 
235 
236 template <int spacedim, class Value>
238  ElementCacheMap &cache_map, unsigned int region_patch_idx)
239 {
241 
242  unsigned int reg_chunk_begin = cache_map.region_chunk_begin(region_patch_idx);
243  unsigned int reg_chunk_end = cache_map.region_chunk_end(region_patch_idx);
244  unsigned int last_element_idx = -1;
245  DHCellAccessor cell = *( dh_->local_range().begin() ); //needs set variable for correct compiling
246  LocDofVec loc_dofs;
247  unsigned int range_bgn=0, range_end=0;
248 
249  // Throws exception if any element value of processed region is NaN
250  unsigned int r_idx = cache_map.eval_point_data(reg_chunk_begin).i_reg_;
251  if (region_value_err_[r_idx].is_invalid_)
252  THROW( ExcUndefElementValue() << EI_Field(field_name_) << EI_File(reader_file_.filename()) );
253 
254  for (unsigned int i_data = reg_chunk_begin; i_data < reg_chunk_end; ++i_data) { // i_eval_point_data
255  unsigned int elm_idx = cache_map.eval_point_data(i_data).i_element_;
256  if (elm_idx != last_element_idx) {
257  ElementAccessor<spacedim> elm(dh_->mesh(), elm_idx);
258  fe_values_[elm.dim()].reinit( elm );
259  cell = dh_->cell_accessor_from_element( elm_idx );
260  loc_dofs = cell.get_loc_dof_indices();
261  last_element_idx = elm_idx;
262  range_bgn = this->fe_item_[elm.dim()].range_begin_;
263  range_end = this->fe_item_[elm.dim()].range_end_;
264  }
265 
266  unsigned int i_ep=cache_map.eval_point_data(i_data).i_eval_point_;
267  //DHCellAccessor cache_cell = cache_map(cell);
268  mat_value.fill(0.0);
269  for (unsigned int i_dof=range_bgn, i_cdof=0; i_dof<range_end; i_dof++, i_cdof++) {
270  mat_value += data_vec_.get(loc_dofs[i_dof]) * this->handle_fe_shape(cell.dim(), i_cdof, i_ep);
271  }
272  data_cache.set(i_data) = mat_value;
273  }
274 }
275 
276 
277 template <int spacedim, class Value>
279 {
280  std::shared_ptr<EvalPoints> eval_points = cache_map.eval_points();
281  std::array<Quadrature, 4> quads{QGauss(0, 1), this->init_quad<1>(eval_points), this->init_quad<2>(eval_points), this->init_quad<3>(eval_points)};
282  fe_values_[0].initialize(quads[0], *this->fe_[0_d], update_values);
283  fe_values_[1].initialize(quads[1], *this->fe_[1_d], update_values);
284  fe_values_[2].initialize(quads[2], *this->fe_[2_d], update_values);
285  fe_values_[3].initialize(quads[3], *this->fe_[3_d], update_values);
286 }
287 
288 
289 template <int spacedim, class Value>
290 template <unsigned int dim>
291 Quadrature FieldFE<spacedim, Value>::init_quad(std::shared_ptr<EvalPoints> eval_points)
292 {
293  Quadrature quad(dim, eval_points->size(dim));
294  for (unsigned int k=0; k<eval_points->size(dim); k++)
295  quad.set(k) = eval_points->local_point<dim>(k);
296  return quad;
297 }
298 
299 
300 template <int spacedim, class Value>
302  this->init_unit_conversion_coefficient(rec, init_data);
303  this->in_rec_ = rec;
304  flags_ = init_data.flags_;
305 
306 
307  // read data from input record
308  reader_file_ = FilePath( rec.val<FilePath>("mesh_data_file") );
309  field_name_ = rec.val<std::string>("field_name");
310  if (! rec.opt_val<OutputTime::DiscreteSpace>("input_discretization", discretization_) ) {
311  discretization_ = OutputTime::DiscreteSpace::UNDEFINED;
312  }
313  if (! rec.opt_val<DataInterpolation>("interpolation", interpolation_) ) {
314  interpolation_ = DataInterpolation::equivalent_msh;
315  }
316  if (! rec.opt_val("default_value", default_value_) ) {
317  default_value_ = numeric_limits<double>::signaling_NaN();
318  }
319 }
320 
321 
322 
323 template <int spacedim, class Value>
324 void FieldFE<spacedim, Value>::set_mesh(const Mesh *mesh, bool boundary_domain) {
325  // Mesh can be set only for field initialized from input.
327  ASSERT(field_name_ != "").error("Uninitialized FieldFE, did you call init_from_input()?\n");
328  this->boundary_domain_ = boundary_domain;
329  if (this->interpolation_ == DataInterpolation::identic_msh) {
330  //DebugOut() << "Identic mesh branch\n";
332  } else {
333  //auto source_mesh = ReaderCache::get_mesh(reader_file_);
334  // TODO: move the call into equivalent_mesh_map, get rd of get_element_ids method.
336  if (this->interpolation_ == DataInterpolation::equivalent_msh) {
337  if (source_target_mesh_elm_map_->empty()) { // incompatible meshes
338  this->interpolation_ = DataInterpolation::gauss_p0;
339  WarningOut().fmt("Source mesh of FieldFE '{}' is not compatible with target mesh.\nInterpolation of input data will be changed to 'P0_gauss'.\n",
340  field_name_);
341  }
342  } else if (this->interpolation_ == DataInterpolation::interp_p0) {
343  if (!boundary_domain) {
344  this->interpolation_ = DataInterpolation::gauss_p0;
345  WarningOut().fmt("Interpolation 'P0_intersection' of FieldFE '{}' can't be used on bulk region.\nIt will be changed to 'P0_gauss'.\n",
346  field_name_);
347  }
348  }
349  }
350  if (dh_ == nullptr) {
351  if (boundary_domain) this->make_dof_handler( mesh->bc_mesh() );
352  else this->make_dof_handler( mesh );
353  }
354  region_value_err_.resize(mesh->region_db().size());
355  }
356 }
357 
358 
359 
360 template <int spacedim, class Value>
362 
363  // temporary solution - these objects will be set through FieldCommon
365  switch (this->value_.n_rows() * this->value_.n_cols()) { // by number of components
366  case 1: { // scalar
367  fe = MixedPtr<FE_P_disc>(0);
368  break;
369  }
370  case 3: { // vector
371  MixedPtr<FE_P_disc> fe_base(0) ;
372  fe = mixed_fe_system(fe_base, FEType::FEVector, 3);
373  break;
374  }
375  case 9: { // tensor
376  MixedPtr<FE_P_disc> fe_base(0) ;
377  fe = mixed_fe_system(fe_base, FEType::FETensor, 9);
378  break;
379  }
380  default:
381  ASSERT_PERMANENT(false).error("Should not happen!\n");
382  }
383 
384  std::shared_ptr<DOFHandlerMultiDim> dh_par = std::make_shared<DOFHandlerMultiDim>( const_cast<MeshBase &>(*mesh) );
385  std::shared_ptr<DiscreteSpace> ds = std::make_shared<EqualOrderDiscreteSpace>( &const_cast<MeshBase &>(*mesh), fe);
386  dh_par->distribute_dofs(ds);
387  dh_ = dh_par;
388  unsigned int ndofs = dh_->max_elem_dofs();
389 
390  this->fill_fe_item<0>();
391  this->fill_fe_item<1>();
392  this->fill_fe_item<2>();
393  this->fill_fe_item<3>();
394  this->fe_ = dh_->ds()->fe();
395 
396  data_vec_ = VectorMPI::sequential( dh_->lsize() ); // allocate data_vec_
397 
398  // initialization data of value handlers
399  FEValueInitData init_data;
400  init_data.dh = dh_;
401  init_data.data_vec = data_vec_;
402  init_data.ndofs = ndofs;
403  init_data.n_comp = this->n_comp();
404  init_data.mixed_fe = this->fe_;
405 
406  // initialize value handler objects
407  init_data.range_begin = this->fe_item_[0].range_begin_;
408  init_data.range_end = this->fe_item_[0].range_end_;
409  value_handler0_.initialize(init_data);
410  init_data.range_begin = this->fe_item_[1].range_begin_;
411  init_data.range_end = this->fe_item_[1].range_end_;
412  value_handler1_.initialize(init_data);
413  init_data.range_begin = this->fe_item_[2].range_begin_;
414  init_data.range_end = this->fe_item_[2].range_end_;
415  value_handler2_.initialize(init_data);
416  init_data.range_begin = this->fe_item_[3].range_begin_;
417  init_data.range_end = this->fe_item_[3].range_end_;
418  value_handler3_.initialize(init_data);
419 }
420 
421 
422 
423 template <int spacedim, class Value>
425  // Time can be set only for field initialized from input.
427  ASSERT(field_name_ != "").error("Uninitialized FieldFE, did you call init_from_input()?\n");
428  ASSERT_PTR(dh_)(field_name_).error("Null target mesh pointer of finite element field, did you call set_mesh()?\n");
429  if ( reader_file_ == FilePath() ) return false;
430 
431  unsigned int n_components = this->value_.n_rows() * this->value_.n_cols();
432  double time_unit_coef = time.read_coef(in_rec_.find<Input::Record>("time_unit"));
433  double time_shift = time.read_time( in_rec_.find<Input::Tuple>("read_time_shift") );
434  double read_time = (time.end()+time_shift) / time_unit_coef;
435 
436  unsigned int n_entities, bdr_shift;
437  bool is_native = (this->discretization_ == OutputTime::DiscreteSpace::NATIVE_DATA);
438  if (is_native) {
439  n_components *= dh_->max_elem_dofs();
440  }
441  if (this->interpolation_==DataInterpolation::identic_msh) {
442  n_entities = source_target_mesh_elm_map_->bulk.size() + source_target_mesh_elm_map_->boundary.size();
443  bdr_shift = source_target_mesh_elm_map_->bulk.size();
444  } else {
445  auto reader_mesh = ReaderCache::get_mesh(reader_file_);
446  n_entities = reader_mesh->n_elements() + reader_mesh->bc_mesh()->n_elements();
447  bdr_shift = reader_mesh->n_elements();
448  }
449 
450  BaseMeshReader::HeaderQuery header_query(field_name_, read_time, this->discretization_, dh_->hash());
451  auto reader = ReaderCache::get_reader(reader_file_);
452  auto header = reader->find_header(header_query);
453  this->input_data_cache_ = reader->template get_element_data<double>(
454  header, n_entities, n_components, bdr_shift);
455 
456  if (is_native) {
457  this->calculate_element_values();
458  } else if (this->interpolation_==DataInterpolation::identic_msh) {
459  this->calculate_element_values();
460  } else if (this->interpolation_==DataInterpolation::equivalent_msh) {
461  this->calculate_element_values();
462  } else if (this->interpolation_==DataInterpolation::gauss_p0) {
463  this->interpolate_gauss();
464  } else { // DataInterpolation::interp_p0
465  this->interpolate_intersection();
466  }
467 
468  return true;
469  } else return false;
470 
471 }
472 
473 
474 template <int spacedim, class Value>
476 {
477  static const unsigned int quadrature_order = 4; // parameter of quadrature
478  std::shared_ptr<Mesh> source_mesh = ReaderCache::get_mesh(reader_file_);
479  std::vector<unsigned int> searched_elements; // stored suspect elements in calculating the intersection
480  std::vector<arma::vec::fixed<3>> q_points; // real coordinates of quadrature points
481  std::vector<double> q_weights; // weights of quadrature points
482  unsigned int quadrature_size=0; // size of quadrature point and weight vector
483  std::vector<double> sum_val(dh_->max_elem_dofs()); // sum of value of one quadrature point
484  unsigned int elem_count; // count of intersect (source) elements of one quadrature point
485  std::vector<double> elem_value(dh_->max_elem_dofs()); // computed value of one (target) element
486  bool contains; // sign if source element contains quadrature point
487 
488  {
489  // set size of vectors to maximal count of quadrature points
490  QGauss quad(3, quadrature_order);
491  q_points.resize(quad.size());
492  q_weights.resize(quad.size());
493  }
494 
495  for (auto cell : dh_->own_range()) {
496  auto ele = cell.elm();
497  std::fill(elem_value.begin(), elem_value.end(), 0.0);
498  switch (cell.dim()) {
499  case 0:
500  quadrature_size = 1;
501  q_points[0] = *ele.node(0);
502  q_weights[0] = 1.0;
503  break;
504  case 1:
505  quadrature_size = value_handler1_.compute_quadrature(q_points, q_weights, ele, quadrature_order);
506  break;
507  case 2:
508  quadrature_size = value_handler2_.compute_quadrature(q_points, q_weights, ele, quadrature_order);
509  break;
510  case 3:
511  quadrature_size = value_handler3_.compute_quadrature(q_points, q_weights, ele, quadrature_order);
512  break;
513  }
514  searched_elements.clear();
515  source_mesh->get_bih_tree().find_bounding_box(ele.bounding_box(), searched_elements);
516 
517  auto r_idx = cell.elm().region_idx().idx();
518  std::string reg_name = cell.elm().region().label();
519  for (unsigned int i=0; i<quadrature_size; ++i) {
520  std::fill(sum_val.begin(), sum_val.end(), 0.0);
521  elem_count = 0;
522  for (std::vector<unsigned int>::iterator it = searched_elements.begin(); it!=searched_elements.end(); it++) {
523  ElementAccessor<3> elm = source_mesh->element_accessor(*it);
524  contains=false;
525  switch (elm->dim()) {
526  case 0:
527  contains = arma::norm(*elm.node(0) - q_points[i], 2) < 4*std::numeric_limits<double>::epsilon();
528  break;
529  case 1:
530  contains = MappingP1<1,3>::contains_point(q_points[i], elm);
531  break;
532  case 2:
533  contains = MappingP1<2,3>::contains_point(q_points[i], elm);
534  break;
535  case 3:
536  contains = MappingP1<3,3>::contains_point(q_points[i], elm);
537  break;
538  default:
539  ASSERT_PERMANENT(false).error("Invalid element dimension!");
540  }
541  if ( contains ) {
542  // projection point in element
543  unsigned int index = sum_val.size() * (*it);
544  for (unsigned int j=0; j < sum_val.size(); j++) {
545  sum_val[j] += get_scaled_value(index+j, dh_->mesh()->elem_index( cell.elm_idx() ), reg_name, region_value_err_[r_idx]);
546  }
547  ++elem_count;
548  }
549  }
550 
551  if (elem_count > 0) {
552  for (unsigned int j=0; j < sum_val.size(); j++) {
553  elem_value[j] += (sum_val[j] / elem_count) * q_weights[i];
554  }
555  }
556  }
557 
558  LocDofVec loc_dofs;
559  loc_dofs = cell.get_loc_dof_indices();
560 
561  ASSERT_LE(loc_dofs.n_elem, elem_value.size());
562  for (unsigned int i=0; i < elem_value.size(); i++) {
563  ASSERT_LT( loc_dofs[i], (int)data_vec_.size());
564  data_vec_.set( loc_dofs[i], elem_value[i] );
565  }
566  }
567 }
568 
569 
570 template <int spacedim, class Value>
572 {
573  std::shared_ptr<Mesh> source_mesh = ReaderCache::get_mesh(reader_file_);
574  std::vector<unsigned int> searched_elements; // stored suspect elements in calculating the intersection
575  std::vector<double> value(dh_->max_elem_dofs());
576  double total_measure;
577  double measure = 0;
578 
579  for (auto elm : dh_->mesh()->elements_range()) {
580  if (elm.dim() == 3) {
581  THROW( ExcInvalidElemeDim() << EI_ElemIdx(elm.idx()) );
582  }
583 
584  double epsilon = 4* numeric_limits<double>::epsilon() * elm.measure();
585  auto r_idx = elm.region_idx().idx();
586  std::string reg_name = elm.region().label();
587 
588  // gets suspect elements
589  if (elm.dim() == 0) {
590  searched_elements.clear();
591  source_mesh->get_bih_tree().find_point(*elm.node(0), searched_elements);
592  } else {
593  BoundingBox bb = elm.bounding_box();
594  searched_elements.clear();
595  source_mesh->get_bih_tree().find_bounding_box(bb, searched_elements);
596  }
597 
598  // set zero values of value object
599  std::fill(value.begin(), value.end(), 0.0);
600  total_measure=0.0;
601 
602  START_TIMER("compute_pressure");
603  ADD_CALLS(searched_elements.size());
604 
605 
606  for (std::vector<unsigned int>::iterator it = searched_elements.begin(); it!=searched_elements.end(); it++)
607  {
608  ElementAccessor<3> source_elm = source_mesh->element_accessor(*it);
609  if (source_elm->dim() == 3) {
610  // get intersection (set measure = 0 if intersection doesn't exist)
611  switch (elm.dim()) {
612  case 0: {
613  arma::vec::fixed<3> real_point = *elm.node(0);
614  arma::mat::fixed<3, 4> elm_map = MappingP1<3,3>::element_map(source_elm);
615  arma::vec::fixed<4> unit_point = MappingP1<3,3>::project_real_to_unit(real_point, elm_map);
616 
617  measure = (std::fabs(arma::sum( unit_point )-1) <= 1e-14
618  && arma::min( unit_point ) >= 0)
619  ? 1.0 : 0.0;
620  break;
621  }
622  case 1: {
623  IntersectionAux<1,3> is(elm.idx(), source_elm.idx());
624  ComputeIntersection<1,3> CI(elm, source_elm);
625  CI.init();
626  CI.compute(is);
627 
628  IntersectionLocal<1,3> ilc(is);
629  measure = ilc.compute_measure() * elm.measure();
630  break;
631  }
632  case 2: {
633  IntersectionAux<2,3> is(elm.idx(), source_elm.idx());
634  ComputeIntersection<2,3> CI(elm, source_elm);
635  CI.init();
636  CI.compute(is);
637 
638  IntersectionLocal<2,3> ilc(is);
639  measure = 2 * ilc.compute_measure() * elm.measure();
640  break;
641  }
642  }
643 
644  //adds values to value_ object if intersection exists
645  if (measure > epsilon) {
646  unsigned int index = value.size() * (*it);
647  for (unsigned int i=0; i < value.size(); i++) {
648  value[i] += get_scaled_value(index+i, dh_->mesh()->elem_index( elm.idx() ), reg_name, region_value_err_[r_idx]) * measure;
649  }
650  total_measure += measure;
651  }
652  }
653  }
654 
655  // computes weighted average, store it to data vector
656  if (total_measure > epsilon) {
657  DHCellAccessor cell = dh_->cell_accessor_from_element(elm.idx());
658  LocDofVec loc_dofs = cell.get_loc_dof_indices();
659 
660  ASSERT_LE(loc_dofs.n_elem, value.size());
661  for (unsigned int i=0; i < value.size(); i++) {
662  data_vec_.set(loc_dofs[i], value[i] / total_measure);
663  }
664  } else {
665  WarningOut().fmt("Processed element with idx {} is out of source mesh!\n", elm.idx());
666  }
667  END_TIMER("compute_pressure");
668 
669  }
670 }
671 
672 
673 template <int spacedim, class Value>
675 {
676  // Same algorithm as in output of Node_data. Possibly code reuse.
677  unsigned int data_vec_i, vec_inc;
678  std::vector<unsigned int> count_vector(data_vec_.size(), 0);
680  std::vector<LongIdx> &source_target_vec = (dynamic_cast<BCMesh*>(dh_->mesh()) != nullptr) ? source_target_mesh_elm_map_->boundary : source_target_mesh_elm_map_->bulk;
681 
682  unsigned int shift;
683  if (this->boundary_domain_) {
684  if (this->interpolation_==DataInterpolation::identic_msh) shift = source_target_mesh_elm_map_->bulk.size();
685  else shift = ReaderCache::get_mesh(reader_file_)->n_elements();
686  } else {
687  shift = 0;
688  }
689 
690  ASSERT_GT(region_value_err_.size(), 0)(field_name_).error("Vector of region isNaN flags is not initialized. Did you call set_mesh or set_fe_data?\n");
691  for (auto r : region_value_err_)
692  r = RegionValueErr();
693 
694  for (auto cell : dh_->own_range()) {
695  LocDofVec loc_dofs = cell.get_loc_dof_indices();
696  //DebugOut() << cell.elm_idx() << " < " << source_target_vec.size() << "\n";
697  int source_idx = source_target_vec[cell.elm_idx()];
698 
699  if (source_idx == (int)(Mesh::undef_idx)) {
700  data_vec_i = source_idx;
701  vec_inc = 0;
702  } else {
703  data_vec_i = (source_idx + shift) * dh_->max_elem_dofs();
704  vec_inc = 1;
705  }
706  auto r_idx = cell.elm().region_idx().idx();
707  std::string reg_name = cell.elm().region().label();
708  for (unsigned int i=0; i<loc_dofs.n_elem; ++i) {
709  ASSERT_LT(loc_dofs[i], (LongIdx)data_vec_.size());
710  data_vec_.add( loc_dofs[i], get_scaled_value(data_vec_i, dh_->mesh()->elem_index( cell.elm_idx() ), reg_name, region_value_err_[r_idx]) );
711  ++count_vector[ loc_dofs[i] ];
712  data_vec_i += vec_inc;
713  }
714  }
715 
716  // compute averages of values
717  for (unsigned int i=0; i<data_vec_.size(); ++i) {
718  if (count_vector[i]>0) data_vec_.normalize(i, count_vector[i]);
719  }
720 }
721 
722 
723 //template <int spacedim, class Value>
724 //void FieldFE<spacedim, Value>::calculate_native_values(ElementDataCache<double>::CacheData data_cache)
725 //{
726 // // Same algorithm as in output of Node_data. Possibly code reuse.
727 // unsigned int data_vec_i;
728 // std::vector<unsigned int> count_vector(data_vec_.size(), 0);
729 // data_vec_.zero_entries();
730 // std::vector<LongIdx> &source_target_vec = (dynamic_cast<BCMesh*>(dh_->mesh()) != nullptr) ? source_target_mesh_elm_map_->boundary : source_target_mesh_elm_map_->bulk;
731 //
732 // // iterate through cells, assembly MPIVector
733 // for (auto cell : dh_->own_range()) {
734 // LocDofVec loc_dofs = cell.get_loc_dof_indices();
735 // data_vec_i = source_target_vec[cell.elm_idx()] * loc_dofs.n_elem;
736 // for (unsigned int i=0; i<loc_dofs.n_elem; ++i, ++data_vec_i) {
737 // data_vec_.add( loc_dofs[i], (*data_cache)[ data_vec_i ] );
738 // ++count_vector[ loc_dofs[i] ];
739 // }
740 // }
741 //
742 // // compute averages of values
743 // for (unsigned int i=0; i<data_vec_.size(); ++i) {
744 // if (count_vector[i]>0) data_vec_.normalize(i, count_vector[i]);
745 // }
746 //}
747 //
748 //
749 //template <int spacedim, class Value>
750 //void FieldFE<spacedim, Value>::calculate_equivalent_values(ElementDataCache<double>::CacheData data_cache)
751 //{
752 // // Same algorithm as in output of Node_data. Possibly code reuse.
753 // unsigned int data_vec_i;
754 // std::vector<unsigned int> count_vector(data_vec_.size(), 0);
755 // data_vec_.zero_entries();
756 // std::vector<LongIdx> &source_target_vec = (dynamic_cast<BCMesh*>(dh_->mesh()) != nullptr) ? source_target_mesh_elm_map_->boundary : source_target_mesh_elm_map_->bulk;
757 // unsigned int shift;
758 // if (this->boundary_domain_) {
759 // if (this->interpolation_==DataInterpolation::identic_msh) shift = this->comp_mesh_->n_elements();
760 // else shift = ReaderCache::get_mesh(reader_file_)->n_elements();
761 // } else {
762 // shift = 0;
763 // }
764 //
765 // // iterate through elements, assembly global vector and count number of writes
766 // for (auto cell : dh_->own_range()) {
767 // LocDofVec loc_dofs = cell.get_loc_dof_indices();
768 // //DebugOut() << cell.elm_idx() << " < " << source_target_vec.size() << "\n";
769 // int source_idx = source_target_vec[cell.elm_idx()];
770 // if (source_idx == (int)(Mesh::undef_idx)) { // undefined value in input data mesh
771 // if ( std::isnan(default_value_) )
772 // THROW( ExcUndefElementValue() << EI_Field(field_name_) );
773 // for (unsigned int i=0; i<loc_dofs.n_elem; ++i) {
774 // ASSERT_LT(loc_dofs[i], (LongIdx)data_vec_.size());
775 // data_vec_.add( loc_dofs[i], default_value_ * this->unit_conversion_coefficient_ );
776 // ++count_vector[ loc_dofs[i] ];
777 // }
778 // } else {
779 // data_vec_i = (source_idx + shift) * dh_->max_elem_dofs();
780 // for (unsigned int i=0; i<loc_dofs.n_elem; ++i, ++data_vec_i) {
781 // ASSERT_LT(loc_dofs[i], (LongIdx)data_vec_.size());
782 // data_vec_.add( loc_dofs[i], (*data_cache)[data_vec_i] );
783 // ++count_vector[ loc_dofs[i] ];
784 // }
785 // }
786 // }
787 //
788 // // compute averages of values
789 // for (unsigned int i=0; i<data_vec_.size(); ++i) {
790 // if (count_vector[i]>0) data_vec_.normalize(i, count_vector[i]);
791 // }
792 //}
793 //
794 //
795 template <int spacedim, class Value>
797  //ASSERT_EQ(output_data_cache.n_values() * output_data_cache.n_comp(), dh_->distr()->lsize()).error();
798  unsigned int n_vals = output_data_cache.n_comp() * output_data_cache.n_dofs_per_element();
799  double loc_values[n_vals];
800  unsigned int i;
801 
802  for (auto dh_cell : dh_->own_range()) {
803  LocDofVec loc_dofs = dh_cell.get_loc_dof_indices();
804  for (i=0; i<loc_dofs.n_elem; ++i) loc_values[i] = data_vec_.get( loc_dofs[i] );
805  for ( ; i<n_vals; ++i) loc_values[i] = numeric_limits<double>::signaling_NaN();
806  output_data_cache.store_value( dh_cell.local_idx(), loc_values );
807  }
808 
809  output_data_cache.set_dof_handler_hash( dh_->hash() );
810 }
811 
812 
813 
814 template <int spacedim, class Value>
815 inline unsigned int FieldFE<spacedim, Value>::data_size() const {
816  return data_vec_.size();
817 }
818 
819 
820 
821 template <int spacedim, class Value>
824 }
825 
826 
827 
828 template <int spacedim, class Value>
831 }
832 
833 
834 
835 template <int spacedim, class Value>
836 double FieldFE<spacedim, Value>::get_scaled_value(int i_cache_el, unsigned int elm_idx, const std::string &region_name,
837  RegionValueErr &actual_compute_region_error) {
838  double return_val;
839  if (i_cache_el == (int)(Mesh::undef_idx))
840  return_val = default_value_;
841  else if ( std::isnan((*input_data_cache_)[i_cache_el]) )
842  return_val = default_value_;
843  else
844  return_val = (*input_data_cache_)[i_cache_el];
845 
846  if ( std::isnan(return_val) ) {
847  actual_compute_region_error = RegionValueErr(region_name, elm_idx, return_val);
848  } else
849  return_val *= this->unit_conversion_coefficient_;
850 
851  return return_val;
852 }
853 
854 
855 
856 /*template <int spacedim, class Value>
857 Armor::ArmaMat<typename Value::element_type, Value::NRows_, Value::NCols_> FieldFE<spacedim, Value>::handle_fe_shape(unsigned int dim,
858  unsigned int i_dof, unsigned int i_qp, unsigned int comp_index)
859 {
860  Armor::ArmaMat<typename Value::element_type, Value::NCols_, Value::NRows_> v;
861  for (unsigned int c=0; c<Value::NRows_*Value::NCols_; ++c)
862  v(c/spacedim,c%spacedim) = fe_values_[dim].shape_value_component(i_dof, i_qp, comp_index+c);
863  if (Value::NRows_ == Value::NCols_)
864  return v;
865  else
866  return v.t();
867 }*/
868 
869 
870 
871 template <int spacedim, class Value>
873 {}
874 
875 
876 // Instantiations of FieldFE
FieldCommon::units
FieldCommon & units(const UnitSI &units)
Set basic units of the field.
Definition: field_common.hh:153
EvalPointData::i_element_
unsigned int i_element_
mesh_idx of ElementAccessor appropriate to element
Definition: field_value_cache.hh:75
FieldFE::data_size
unsigned int data_size() const
Definition: field_fe.cc:815
TimeStep::read_coef
double read_coef(Input::Iterator< Input::Record > unit_it) const
Definition: time_governor.cc:265
ElementAccessor::dim
unsigned int dim() const
Definition: accessors.hh:188
LocDofVec
arma::Col< IntIdx > LocDofVec
Definition: index_types.hh:28
FieldFE::field_name_
std::string field_name_
field name read from input
Definition: field_fe.hh:318
FlagArray::match
constexpr bool match(Mask mask) const
Definition: flag_array.hh:163
FEValueInitData::range_end
unsigned int range_end
Holds end of component range of evaluation.
Definition: fe_value_handler.hh:48
FieldFE::source_target_mesh_elm_map_
std::shared_ptr< EquivalentMeshMap > source_target_mesh_elm_map_
Maps element indices from computational mesh to the source (data).
Definition: field_fe.hh:342
FieldFE::flags_
FieldFlag::Flags flags_
Field flags.
Definition: field_fe.hh:327
EvalPointData::i_eval_point_
unsigned int i_eval_point_
index of point in EvalPoint object
Definition: field_value_cache.hh:76
FieldFE::FieldFE
FieldFE(unsigned int n_comp=0)
Definition: field_fe.cc:133
ReaderCache::identic_mesh_map
static std::shared_ptr< EquivalentMeshMap > identic_mesh_map(const FilePath &file_path, Mesh *computational_mesh)
Definition: reader_cache.cc:94
ASSERT_GT
#define ASSERT_GT(a, b)
Definition of comparative assert macro (Greater Than) only for debug mode.
Definition: asserts.hh:317
ReaderCache::eqivalent_mesh_map
static std::shared_ptr< EquivalentMeshMap > eqivalent_mesh_map(const FilePath &file_path, Mesh *computational_mesh)
Definition: reader_cache.cc:118
FieldFE::NativeFactory::conc_dof_handler_
std::shared_ptr< DOFHandlerMultiDim > conc_dof_handler_
Definition: field_fe.hh:119
TimeUnitConversion::get_input_default
static Input::Type::Default get_input_default()
Definition: time_governor.hh:66
vector_mpi.hh
ComputeIntersection< 2, 3 >
Class for 2D-2D intersections.
Definition: compute_intersection.hh:465
FieldFE::local_to_ghost_data_scatter_end
void local_to_ghost_data_scatter_end()
Call end scatter functions (local to ghost) on data vector.
Definition: field_fe.cc:829
FieldFE::value_handler0_
FEValueHandler< 0, spacedim, Value > value_handler0_
Value handler that allows get value of 0D elements.
Definition: field_fe.hh:306
FieldFE::cache_update
void cache_update(FieldValueCache< typename Value::element_type > &data_cache, ElementCacheMap &cache_map, unsigned int region_patch_idx) override
Definition: field_fe.cc:237
FEValueHandler::initialize
void initialize(FEValueInitData init_data)
Initialize data members.
Definition: fe_value_handler.cc:93
MeshBase::region_db
const RegionDB & region_db() const
Definition: mesh.h:175
FieldFE::handle_fe_shape
Armor::ArmaMat< typename Value::element_type, Value::NRows_, Value::NCols_ > handle_fe_shape(unsigned int dim, unsigned int i_dof, unsigned int i_qp)
Definition: field_fe.hh:259
ElementDataCache< double >
ASSERT
#define ASSERT(expr)
Definition: asserts.hh:351
FieldFE::DataInterpolation
DataInterpolation
Definition: field_fe.hh:60
Element::dim
unsigned int dim() const
Definition: elements.h:120
FieldFE::RegionValueErr
Definition: field_fe.hh:218
bc_mesh.hh
VectorMPI::zero_entries
void zero_entries()
Definition: vector_mpi.hh:82
ComputeIntersection< 1, 3 >
Definition: compute_intersection.hh:343
ElementCacheMap
Directing class of FieldValueCache.
Definition: field_value_cache.hh:152
Input::Record::val
const Ret val(const string &key) const
Definition: accessors_impl.hh:31
Input::Type::Selection::close
const Selection & close() const
Close the Selection, no more values can be added.
Definition: type_selection.cc:65
value
static constexpr bool value
Definition: json.hpp:87
FieldFE::input_data_cache_
ElementDataCache< double >::CacheData input_data_cache_
Input ElementDataCache is stored in set_time and used in all evaluation and interpolation methods.
Definition: field_fe.hh:352
IntersectionLocal::compute_measure
double compute_measure() const override
Computes the relative measure of intersection object.
Definition: intersection_local.cc:52
FilePath
Dedicated class for storing path to input and output files.
Definition: file_path.hh:54
RegionDB::size
unsigned int size() const
Definition: region.cc:254
ElementDataCacheBase::n_comp
unsigned int n_comp() const
Definition: element_data_cache_base.hh:145
Input::Type::Double
Class for declaration of the input data that are floating point numbers.
Definition: type_base.hh:534
update_values
@ update_values
Shape function values.
Definition: update_flags.hh:87
MeshBase::undef_idx
static const unsigned int undef_idx
Definition: mesh.h:105
Quadrature::size
unsigned int size() const
Returns number of quadrature points.
Definition: quadrature.hh:86
FLOW123D_FORCE_LINK_IN_CHILD
#define FLOW123D_FORCE_LINK_IN_CHILD(x)
Definition: global_defs.h:104
THROW
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
Definition: exceptions.hh:53
std::vector< unsigned int >
MappingP1::project_real_to_unit
static BaryPoint project_real_to_unit(const RealPoint &point, const ElementMap &map)
Definition: mapping_p1.cc:69
ElementAccessor
Definition: dh_cell_accessor.hh:32
FieldFE::in_rec_
Input::Record in_rec_
Accessor to Input::Record.
Definition: field_fe.hh:333
FieldFE::region_value_err_
std::vector< RegionValueErr > region_value_err_
Set holds data of valid / invalid element values on all regions.
Definition: field_fe.hh:349
FieldFE::NativeFactory::dof_vector_
VectorMPI dof_vector_
Definition: field_fe.hh:120
reader_cache.hh
DHCellAccessor::dim
unsigned int dim() const
Return dimension of element appropriate to cell.
Definition: dh_cell_accessor.hh:101
FieldFE::local_to_ghost_data_scatter_begin
void local_to_ghost_data_scatter_begin()
Call begin scatter functions (local to ghost) on data vector.
Definition: field_fe.cc:822
field_fe.hh
VectorMPI::normalize
void normalize(unsigned int pos, double divisor)
Normalize value on given position.
Definition: vector_mpi.hh:118
FieldFE::boundary_domain_
bool boundary_domain_
Is set in set_mesh method. Value true means, that we accept only boundary element accessors in the va...
Definition: field_fe.hh:336
TimeStep::read_time
double read_time(Input::Iterator< Input::Tuple > time_it, double default_time=std::numeric_limits< double >::quiet_NaN()) const
Definition: time_governor.cc:259
ElementDataCacheBase::set_dof_handler_hash
void set_dof_handler_hash(std::size_t hash)
Definition: element_data_cache_base.hh:171
Input::Array::begin
Iterator< ValueType > begin() const
Definition: accessors_impl.hh:145
msh_gmshreader.h
ElementDataCacheBase::n_dofs_per_element
unsigned int n_dofs_per_element() const
Definition: element_data_cache_base.hh:152
fe_system.hh
Class FESystem for compound finite elements.
FieldFE::data_vec_
VectorMPI data_vec_
Store data of Field.
Definition: field_fe.hh:303
ASSERT_LT
#define ASSERT_LT(a, b)
Definition of comparative assert macro (Less Than) only for debug mode.
Definition: asserts.hh:301
FieldFE::interpolate_gauss
void interpolate_gauss()
Interpolate data (use Gaussian distribution) over all elements of target mesh.
Definition: field_fe.cc:475
Dim
Definition: mixed.hh:25
FieldFE::cache_reinit
void cache_reinit(const ElementCacheMap &cache_map) override
Definition: field_fe.cc:278
ElementCacheMap::eval_point_data
const EvalPointData & eval_point_data(unsigned int point_idx) const
Return item of eval_point_data_ specified by its position.
Definition: field_value_cache.hh:286
FEValueInitData::mixed_fe
MixedPtr< FiniteElement > mixed_fe
FiniteElement objects of all dimensions.
Definition: fe_value_handler.hh:50
fe_p.hh
Definitions of basic Lagrangean finite elements with polynomial shape functions.
BoundingBox
Bounding box in 3d ambient space.
Definition: bounding_box.hh:53
ComputeIntersection< 2, 3 >::init
void init()
Initializes lower dimensional objects. Sets correctly the pointers to Plucker coordinates and product...
Definition: compute_intersection.cc:1063
FieldFE::init_from_input
virtual void init_from_input(const Input::Record &rec, const struct FieldAlgoBaseInitData &init_data)
Definition: field_fe.cc:301
VectorMPI::set
void set(unsigned int pos, double val)
Set value on given position.
Definition: vector_mpi.hh:111
FieldFE::fe_
MixedPtr< FiniteElement > fe_
Definition: field_fe.hh:346
ElementCacheMap::region_chunk_end
unsigned int region_chunk_end(unsigned int region_patch_idx) const
Return end position of region chunk in FieldValueCache.
Definition: field_value_cache.hh:269
FieldFE::dh_
std::shared_ptr< DOFHandlerMultiDim > dh_
DOF handler object.
Definition: field_fe.hh:301
Input::Type::Default
Class Input::Type::Default specifies default value of keys of a Input::Type::Record.
Definition: type_record.hh:61
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
FieldFE::NativeFactory::index_
unsigned int index_
Definition: field_fe.hh:118
FESystem::fe
const std::vector< std::shared_ptr< FiniteElement< dim > > > & fe() const
Definition: fe_system.hh:147
Mesh::bc_mesh
BCMesh * bc_mesh() const override
Implement MeshBase::bc_mesh(), getter of boundary mesh.
Definition: mesh.h:567
FieldFE::calculate_element_values
void calculate_element_values()
Calculate data of equivalent_mesh interpolation or native data on input over all elements of target m...
Definition: field_fe.cc:674
dh_cell_accessor.hh
FieldFE::get_interp_selection_input_type
static const Input::Type::Selection & get_interp_selection_input_type()
Definition: field_fe.cc:104
EvalPointData::i_reg_
unsigned int i_reg_
region_idx of element
Definition: field_value_cache.hh:74
accessors.hh
FieldFE::set_mesh
void set_mesh(const Mesh *mesh, bool boundary_domain) override
Definition: field_fe.cc:324
TimeStep::end
double end() const
Definition: time_governor.hh:161
Input::Record
Accessor to the data with type Type::Record.
Definition: accessors.hh:291
FieldFE::default_value_
double default_value_
Default value of element if not set in mesh data file.
Definition: field_fe.hh:330
FieldFE::value_handler3_
FEValueHandler< 3, spacedim, Value > value_handler3_
Value handler that allows get value of 3D elements.
Definition: field_fe.hh:312
sys_profiler.hh
FEValueInitData::dh
std::shared_ptr< DOFHandlerMultiDim > dh
DOF handler object.
Definition: fe_value_handler.hh:38
ASSERT_PERMANENT
#define ASSERT_PERMANENT(expr)
Allow use shorter versions of macro names if these names is not used with external library.
Definition: asserts.hh:348
quadrature_lib.hh
Definitions of particular quadrature rules on simplices.
FieldAlgoBaseInitData
Helper struct stores data for initizalize descentants of FieldAlgorithmBase.
Definition: field_algo_base.hh:81
Quadrature::set
Armor::Array< double >::ArrayMatSet set(uint i)
Definition: quadrature.hh:93
TimeStep
Representation of one time step..
Definition: time_governor.hh:123
ElementCacheMap::eval_points
std::shared_ptr< EvalPoints > eval_points() const
Getter of eval_points object.
Definition: field_value_cache.hh:190
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
FieldCommon
Common abstract parent of all Field<...> classes.
Definition: field_common.hh:77
FETensor
@ FETensor
Definition: finite_element.hh:204
MappingP1::contains_point
static bool contains_point(arma::vec point, ElementAccessor< 3 > elm)
Test if element contains given point.
Definition: mapping_p1.cc:96
OutputTime
The class for outputting data during time.
Definition: output_time.hh:51
FEValueInitData::ndofs
unsigned int ndofs
number of dofs
Definition: fe_value_handler.hh:42
Input::Record::opt_val
bool opt_val(const string &key, Ret &value) const
Definition: accessors_impl.hh:107
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
FieldFE::interpolation_
DataInterpolation interpolation_
Specify type of FE data interpolation.
Definition: field_fe.hh:324
Input::Array::size
unsigned int size() const
Definition: accessors_impl.hh:163
mixed_fe_system
MixedPtr< FESystem > mixed_fe_system(MixedPtr< FiniteElement > fe, Args &&... args)
Definition: fe_system.hh:176
FieldFE::fe_item_
std::array< FEItem, 4 > fe_item_
Holds specific data of field evaluation over all dimensions.
Definition: field_fe.hh:345
FieldFE::discretization_
OutputTime::DiscreteSpace discretization_
Specify section where to find the field data in input mesh file.
Definition: field_fe.hh:321
ComputeIntersection< 1, 3 >::init
void init()
Initializes lower dimensional objects. Sets correctly the pointers to Plucker coordinates and product...
Definition: compute_intersection.cc:811
VectorMPI::local_to_ghost_begin
void local_to_ghost_begin()
local_to_ghost_{begin,end} updates the ghost values on neighbouring processors from local values
Definition: vector_mpi.hh:156
FEVector
@ FEVector
Definition: finite_element.hh:201
fmt::internal::isnan
DummyInt isnan(...)
Definition: format.h:306
Input::Type::Selection
Template for classes storing finite set of named values.
Definition: type_selection.hh:65
Input::Record::find
Iterator< Ret > find(const string &key) const
Definition: accessors_impl.hh:91
FEValueHandler::compute_quadrature
unsigned int compute_quadrature(std::vector< arma::vec::fixed< 3 >> &q_points, std::vector< double > &q_weights, const ElementAccessor< spacedim > &elm, unsigned int order=3)
Compute real coordinates and weights (use QGauss) for given element.
Definition: fe_value_handler.cc:108
ElementAccessor::node
NodeAccessor< 3 > node(unsigned int ni) const
Definition: accessors.hh:230
Input::Type::FileName::input
static FileName input()
The factory function for declaring type FileName for input files.
Definition: type_base.cc:524
Armor::Array::set
ArrayMatSet set(uint index)
Definition: armor.hh:838
UnitConverter::get_input_type
static const Input::Type::Record & get_input_type()
Definition: unit_converter.cc:101
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
VectorMPI::add
void add(unsigned int pos, double val)
Add value to item on given position.
Definition: vector_mpi.hh:125
Input::Type::Record
Record type proxy class.
Definition: type_record.hh:182
FEValueInitData
Initialization structure of FEValueHandler class.
Definition: fe_value_handler.hh:35
ComputeIntersection< 1, 3 >::compute
unsigned int compute(std::vector< IPAux > &IP13s)
Computes intersection points for 1D-3D intersection. Computes lower dimensional CIs abscissa vs tetra...
Definition: compute_intersection.cc:833
QGauss
Symmetric Gauss-Legendre quadrature formulae on simplices.
Definition: quadrature_lib.hh:34
Value
@ Value
Definition: finite_element.hh:43
Field::FieldBasePtr
std::shared_ptr< FieldBaseType > FieldBasePtr
Definition: field.hh:96
FieldAlgoBaseInitData::flags_
FieldFlag::Flags flags_
Definition: field_algo_base.hh:95
intersection_aux.hh
Internal class representing intersection object.
FieldFE::native_data_to_cache
void native_data_to_cache(ElementDataCache< double > &output_data_cache)
Definition: field_fe.cc:796
LongIdx
int LongIdx
Define type that represents indices of large arrays (elements, nodes, dofs etc.)
Definition: index_types.hh:24
MappingP1::element_map
static ElementMap element_map(ElementAccessor< 3 > elm)
Definition: mapping_p1.cc:48
FEValueHandler< 0, spacedim, Value >::initialize
void initialize(FEValueInitData init_data)
Initialize data members.
Definition: fe_value_handler.cc:126
input_type.hh
FieldFE
Definition: field.hh:60
ElementCacheMap::region_chunk_begin
unsigned int region_chunk_begin(unsigned int region_patch_idx) const
Return begin position of region chunk in FieldValueCache.
Definition: field_value_cache.hh:263
Mesh
Definition: mesh.h:362
FieldFE::value_handler2_
FEValueHandler< 2, spacedim, Value > value_handler2_
Value handler that allows get value of 2D elements.
Definition: field_fe.hh:310
Input::Type::Record::copy_keys
Record & copy_keys(const Record &other)
Copy keys from other record.
Definition: type_record.cc:216
FilePath::filename
string filename() const
Definition: file_path.cc:188
FieldAlgorithmBase
Definition: field_algo_base.hh:105
Input::Type::String
Class for declaration of the input data that are in string format.
Definition: type_base.hh:582
DHCellAccessor
Cell accessor allow iterate over DOF handler cells.
Definition: dh_cell_accessor.hh:43
FieldFE::set_fe_data
VectorMPI set_fe_data(std::shared_ptr< DOFHandlerMultiDim > dh, VectorMPI dof_values=VectorMPI::sequential(0), unsigned int block_index=FieldFE< spacedim, Value >::undef_uint)
Definition: field_fe.cc:173
Input::Array
Accessor to input data conforming to declared Array.
Definition: accessors.hh:566
FieldFE::interpolate_intersection
void interpolate_intersection()
Interpolate data (use intersection library) over all elements of target mesh.
Definition: field_fe.cc:571
WarningOut
#define WarningOut()
Macro defining 'warning' record of log.
Definition: logger.hh:278
IntersectionAux
Internal auxiliary class representing intersection object of simplex<dimA> and simplex<dimB>.
Definition: compute_intersection.hh:47
INSTANCE_ALL
#define INSTANCE_ALL(field)
Definition: field_instances.hh:43
unit_converter.hh
Input::Tuple
Accessor to the data with type Type::Tuple.
Definition: accessors.hh:411
fe_value_handler.hh
FieldFE::reader_file_
FilePath reader_file_
mesh reader file
Definition: field_fe.hh:315
ASSERT_LE
#define ASSERT_LE(a, b)
Definition of comparative assert macro (Less or Equal) only for debug mode.
Definition: asserts.hh:309
MeshBase
Base class for Mesh and BCMesh.
Definition: mesh.h:96
compute_intersection.hh
Fundamental simplicial intersections.
field_instances.hh
BCMesh
Class represents boundary part of mesh.
Definition: bc_mesh.hh:37
FieldFlag::equation_input
static constexpr Mask equation_input
The field is data parameter of the owning equation. (default on)
Definition: field_flag.hh:33
MixedPtr< FiniteElement >
IntersectionLocal< 1, 3 >
FieldCommon::get_flags
FieldFlag::Flags get_flags() const
Definition: field_common.hh:293
FieldFE::get_input_type
static const Input::Type::Record & get_input_type()
Implementation.
Definition: field_fe.cc:61
VectorMPI::local_to_ghost_end
void local_to_ghost_end()
local_to_ghost_{begin,end} updates the ghost values on neighbouring processors from local values
Definition: vector_mpi.hh:160
DHCellAccessor::get_loc_dof_indices
LocDofVec get_loc_dof_indices() const
Returns the local indices of dofs associated to the cell on the local process.
Definition: dh_cell_accessor.hh:88
ReaderCache::get_mesh
static std::shared_ptr< Mesh > get_mesh(const FilePath &file_path)
Definition: reader_cache.cc:41
ADD_CALLS
#define ADD_CALLS(n_calls)
Increase number of calls in actual timer.
Definition: sys_profiler.hh:186
Armor::Array
Definition: armor.hh:597
FEValueInitData::data_vec
VectorMPI data_vec
Store data of Field.
Definition: fe_value_handler.hh:40
FieldFlag::declare_input
static constexpr Mask declare_input
The field can be set from input. The key in input field descriptor is declared. (default on)
Definition: field_flag.hh:35
FieldFE::fe_values_
std::vector< FEValues< spacedim > > fe_values_
List of FEValues objects of dimensions 0,1,2,3 used for value calculation.
Definition: field_fe.hh:339
VectorMPI::sequential
static VectorMPI sequential(unsigned int size)
Definition: vector_mpi.cc:44
FieldFE::get_disc_selection_input_type
static const Input::Type::Selection & get_disc_selection_input_type()
Definition: field_fe.cc:92
FieldCommon::n_comp
unsigned int n_comp() const
Definition: field_common.hh:272
ElementAccessor::idx
unsigned int idx() const
We need this method after replacing Region by RegionIdx, and movinf RegionDB instance into particular...
Definition: accessors.hh:215
FieldFE::set_time
bool set_time(const TimeStep &time) override
Definition: field_fe.cc:424
OutputTime::DiscreteSpace
DiscreteSpace
Definition: output_time.hh:108
DiscreteSpace
Definition: discrete_space.hh:41
mapping_p1.hh
Class MappingP1 implements the affine transformation of the unit cell onto the actual cell.
VectorMPI::get
double get(unsigned int pos) const
Return value on given position.
Definition: vector_mpi.hh:105
ReaderCache::get_reader
static std::shared_ptr< BaseMeshReader > get_reader(const FilePath &file_path)
Definition: reader_cache.cc:37
TimeGovernor::get_input_time_type
static const Input::Type::Tuple & get_input_time_type(double lower_bound=-std::numeric_limits< double >::max(), double upper_bound=std::numeric_limits< double >::max())
Definition: time_governor.cc:47
FieldCommon::input_name
const std::string & input_name() const
Definition: field_common.hh:243
FEValueInitData::range_begin
unsigned int range_begin
Holds begin of component range of evaluation.
Definition: fe_value_handler.hh:46
FieldCommon::limits
std::pair< double, double > limits() const
Definition: field_common.hh:261
VectorMPI
Definition: vector_mpi.hh:43
FieldFE::NativeFactory::create_field
Field< spacedim, Value >::FieldBasePtr create_field(Input::Record rec, const FieldCommon &field) override
Definition: field_fe.cc:142
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
FieldFE::~FieldFE
virtual ~FieldFE()
Destructor.
Definition: field_fe.cc:872
ASSERT_PTR
#define ASSERT_PTR(ptr)
Definition of assert macro checking non-null pointer (PTR) only for debug mode.
Definition: asserts.hh:341
Quadrature
Base class for quadrature rules on simplices in arbitrary dimensions.
Definition: quadrature.hh:48
FieldFE::make_dof_handler
void make_dof_handler(const MeshBase *mesh)
Create DofHandler object.
Definition: field_fe.cc:361
Input::Type::Default::optional
static Default optional()
The factory function to make an empty default value which is optional.
Definition: type_record.hh:124
Armor::ArmaMat
typename arma::Mat< Type >::template fixed< nr, nc > ArmaMat
Definition: armor.hh:502
FieldFE::get_scaled_value
double get_scaled_value(int i_cache_el, unsigned int elm_idx, const std::string &region_name, RegionValueErr &actual_compute_region_error)
Definition: field_fe.cc:836
START_TIMER
#define START_TIMER(tag)
Starts a timer with specified tag.
Definition: sys_profiler.hh:115
ComputeIntersection< 2, 3 >::compute
void compute(IntersectionAux< 2, 3 > &intersection)
Computes intersection points for 2D-3D intersection. Computes lower dimensional CIs: 1) 3x triangle s...
Definition: compute_intersection.cc:1130
FESystem
Compound finite element on dim dimensional simplex.
Definition: fe_system.hh:101
BaseMeshReader::HeaderQuery
Definition: msh_basereader.hh:136
ElementDataCache::store_value
void store_value(unsigned int idx, const T *value)
Definition: element_data_cache.cc:212
VectorMPI::size
unsigned int size() const
Return size of output data.
Definition: vector_mpi.hh:98
FieldFE::value_handler1_
FEValueHandler< 1, spacedim, Value > value_handler1_
Value handler that allows get value of 1D elements.
Definition: field_fe.hh:308
FieldFE::init_quad
Quadrature init_quad(std::shared_ptr< EvalPoints > eval_points)
Initialize FEValues object of given dimension.
Definition: field_fe.cc:291
END_TIMER
#define END_TIMER(tag)
Ends a timer with specified tag.
Definition: sys_profiler.hh:149
FEValueInitData::n_comp
unsigned int n_comp
number of components
Definition: fe_value_handler.hh:44
range_wrapper.hh
Implementation of range helper class.
intersection_local.hh
Classes with algorithms for computation of intersections of meshes.