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