Flow123d  JS_before_hm-2154-g185f171e0
element_data_cache.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 element_data_cache.cc
15  * @brief
16  */
17 
18 
19 #include <limits>
20 #include <ostream>
21 #include "io/element_data_cache.hh"
22 #include "io/msh_basereader.hh"
23 #include "la/distribution.hh"
25 #include "system/system.hh"
26 #include "system/tokenizer.hh"
27 #include "boost/lexical_cast.hpp"
28 
29 
30 
31 template <typename T>
34  check_scale_data_(CheckScaleData::none) {}
35 
36 
37 template <typename T>
38 ElementDataCache<T>::ElementDataCache(std::string field_name, double time, unsigned int size_of_cache, unsigned int row_vec_size)
39 : check_scale_data_(CheckScaleData::none)
40 {
41  this->time_ = time;
42  this->field_input_name_ = field_name;
43  this->data_ = create_data_cache(size_of_cache, row_vec_size);
44  this->n_dofs_per_element_ = 1;
45 }
46 
47 
48 template <typename T>
49 ElementDataCache<T>::ElementDataCache(std::string field_name, unsigned int n_comp, unsigned int size, std::string fe_type, unsigned int n_dofs_per_element)
50 : check_scale_data_(CheckScaleData::none)
51 {
52  this->set_vtk_type<T>();
53  this->field_name_ = field_name;
54  this->field_input_name_ = this->field_name_;
55 
56  this->n_values_ = size;
57  ASSERT_GT(n_comp, 0)(field_name).error("Output field returning variable size vectors. Try convert to MultiField.");
58  this->n_comp_ = n_comp;
59  this->fe_type_ = fe_type;
61 
63 }
64 
65 
66 template <typename T>
68 
69 
70 template <typename T>
72  ASSERT_LT(component_idx, data_.size()).error("Index of component is out of range.\n");
73  return data_[component_idx];
74 }
75 
76 
77 template <typename T>
78 typename ElementDataCache<T>::CacheData ElementDataCache<T>::create_data_cache(unsigned int size_of_cache, unsigned int row_vec_size) {
79  typename ElementDataCache<T>::CacheData data_cache(size_of_cache);
80  for (unsigned int i=0; i<size_of_cache; ++i) {
81  typename ElementDataCache<T>::ComponentDataPtr row_vec = std::make_shared<std::vector<T>>();
82  row_vec->resize(row_vec_size, numeric_limits<T>::signaling_NaN());
83  data_cache[i] = row_vec;
84  }
85 
86  return data_cache;
87 }
88 
89 
90 template <typename T>
91 void ElementDataCache<T>::read_ascii_data(Tokenizer &tok, unsigned int n_components, unsigned int i_row) {
92  unsigned int idx;
93  for (unsigned int i_vec=0; i_vec<data_.size(); ++i_vec) {
94  idx = i_row * n_components;
95  std::vector<T> &vec = *( data_[i_vec].get() );
96  for (unsigned int i_col=0; i_col < n_components; ++i_col, ++idx) {
97  ASSERT_DBG(idx < vec.size());
98  vec[idx] = boost::lexical_cast<T>(*tok);
99  ++tok;
100  }
101  }
102 }
103 
104 
105 template <typename T>
106 void ElementDataCache<T>::read_binary_data(std::istream &data_stream, unsigned int n_components, unsigned int i_row) {
107  unsigned int idx;
108  for (unsigned int i_vec=0; i_vec<data_.size(); ++i_vec) {
109  idx = i_row * n_components;
110  std::vector<T> &vec = *( data_[i_vec].get() );
111  for (unsigned int i_col=0; i_col < n_components; ++i_col, ++idx) {
112  data_stream.read(reinterpret_cast<char *>(&vec[idx]), sizeof(T));
113  }
114  }
115 }
116 
117 
118 /**
119  * Output data element on given index @p idx. Method for writing data
120  * to output stream.
121  *
122  * \note This method is used only by MSH file format.
123  */
124 template <typename T>
125 void ElementDataCache<T>::print_ascii(ostream &out_stream, unsigned int idx)
126 {
127  ASSERT_LT(idx, this->n_values_).error();
128  std::vector<T> &vec = *( this->data_[0].get() );
129  for(unsigned int i = n_comp_*n_dofs_per_element_*idx; i < n_comp_*n_dofs_per_element_*(idx+1); ++i )
130  out_stream << vec[i] << " ";
131 }
132 
133 /**
134  * \brief Print all data stored in output data
135  *
136  * TODO: indicate if the tensor data are output in column-first or raw-first order
137  * and possibly implement transposition. Set such property for individual file formats.
138  * Class OutputData stores always in raw-first order.
139  */
140 template <typename T>
141 void ElementDataCache<T>::print_ascii_all(ostream &out_stream, unsigned int start)
142 {
143  std::vector<T> &vec = *( this->data_[0].get() );
144  for(unsigned int idx = start; idx < this->n_values_; idx++) {
145  for(unsigned int i = n_comp_*n_dofs_per_element_*idx; i < n_comp_*n_dofs_per_element_*(idx+1); ++i )
146  out_stream << vec[i] << " ";
147  }
148 }
149 
150 
151 /// Prints the whole data vector into stream.
152 template <typename T>
153 void ElementDataCache<T>::print_binary_all(ostream &out_stream, bool print_data_size, unsigned int start)
154 {
155  if (print_data_size) {
156  // write size of data
157  unsigned long long int data_byte_size = this->n_values_ * n_comp_ * sizeof(T);
158  out_stream.write(reinterpret_cast<const char*>(&data_byte_size), sizeof(unsigned long long int));
159  }
160  // write data
161  std::vector<T> &vec = *( this->data_[0].get() );
162  for(unsigned int idx = start; idx < this->n_values_; idx++) {
163  for(unsigned int i = n_comp_*idx; i < n_comp_*(idx+1); ++i )
164  out_stream.write(reinterpret_cast<const char*>(&(vec[i])), sizeof(T));
165  }
166 }
167 
168 
169 template <typename T>
170 void ElementDataCache<T>::print_yaml_subarray(ostream &out_stream, unsigned int precision, unsigned int begin, unsigned int end)
171 {
172  out_stream << "[ ";
173  std::vector<T> &vec = *( this->data_[0].get() );
174  for(unsigned int idx = begin; idx < end; idx++) {
175  if (idx != begin) out_stream << " , ";
176  unsigned int vec_pos = n_comp_ * idx; // position of element value in data cache
177  switch (this->n_comp_) {
178  case NumCompValueType::N_SCALAR: {
179  out_stream << field_value_to_yaml( vec[vec_pos], precision );
180  break;
181  }
182  case NumCompValueType::N_VECTOR: {
183  typename arma::Col<T>::template fixed<3> vec_val;
184  for (unsigned int i=0; i<3; ++i, ++vec_pos)
185  vec_val(i) = vec[vec_pos];
186  out_stream << field_value_to_yaml( vec_val, precision );
187  break;
188  }
189  case NumCompValueType::N_TENSOR: {
190  typename arma::Mat<T>::template fixed<3,3> mat_val;
191  for (unsigned int i=0; i<3; ++i)
192  for (unsigned int j=0; j<3; ++j, ++vec_pos)
193  mat_val(i,j) = vec[vec_pos];
194  out_stream << field_value_to_yaml( mat_val, precision );
195  break;
196  }
197  }
198  }
199  out_stream << " ]";
200 }
201 
202 
203 template <typename T>
204 void ElementDataCache<T>::get_min_max_range(double &min, double &max)
205 {
206  min = std::numeric_limits<double>::max();
207  max = std::numeric_limits<double>::min();
208  std::vector<T> &vec = *( this->data_[0].get() );
209  for(unsigned int idx = 0; idx < this->n_values_; idx++) {
210  for(unsigned int i = n_comp_*n_dofs_per_element_*idx; i < n_comp_*n_dofs_per_element_*(idx+1); ++i ) {
211  if (vec[i] < min) min = vec[i];
212  if (vec[i] > max) max = vec[i];
213  }
214  }
215 }
216 
217 
218 /**
219  * Store data element of given data value under given index.
220  */
221 template <typename T>
222 void ElementDataCache<T>::store_value(unsigned int idx, const T * value) {
223  ASSERT_LT_DBG(idx, this->n_values_)(this->field_name_);
224  std::vector<T> &vec = *( this->data_[0].get() );
225  unsigned int vec_idx = idx*this->n_comp_*n_dofs_per_element_;
226  for(unsigned int i = 0; i < this->n_comp_*n_dofs_per_element_; i++, vec_idx++) {
227  vec[vec_idx] = value[i];
228  }
229 }
230 
231 /**
232  * Add value to given index
233  */
234 template <typename T>
235 void ElementDataCache<T>::add(unsigned int idx, const T * value) {
236  ASSERT_LT_DBG(idx, this->n_values_);
237  std::vector<T> &vec = *( this->data_[0].get() );
238  unsigned int vec_idx = idx*this->n_comp_*n_dofs_per_element_;
239  for(unsigned int i = 0; i < this->n_comp_*n_dofs_per_element_; i++, vec_idx++) {
240  vec[vec_idx] += value[i];
241  }
242 }
243 
244 /**
245  * Reset values at given index
246  */
247 template <typename T>
248 void ElementDataCache<T>::zero(unsigned int idx) {
249  ASSERT_LT_DBG(idx, this->n_values_);
250  std::vector<T> &vec = *( this->data_[0].get() );
251  unsigned int vec_idx = idx*this->n_comp_*n_dofs_per_element_;
252  for(unsigned int i = 0; i < this->n_comp_*n_dofs_per_element_; i++, vec_idx++) {
253  vec[vec_idx] = 0;
254  }
255 }
256 
257 /**
258  * Normalize values at given index
259  */
260 template <typename T>
261 void ElementDataCache<T>::normalize(unsigned int idx, unsigned int divisor) {
262  ASSERT_LT_DBG(idx, this->n_values_);
263  std::vector<T> &vec = *( this->data_[0].get() );
264  unsigned int vec_idx = idx*this->n_comp_*n_dofs_per_element_;
265  for(unsigned int i = 0; i < this->n_comp_*n_dofs_per_element_; i++, vec_idx++) {
266  vec[vec_idx] /= divisor;
267  }
268 }
269 
270 template <typename T>
271 CheckResult ElementDataCache<T>::check_values(double default_val, double lower_bound, double upper_bound) {
272  if (check_scale_data_ != CheckScaleData::none) return CheckResult::ok; // method is executed only once
273  check_scale_data_ = CheckScaleData::check;
274 
275  bool is_nan = false, out_of_limit = false;
276  for (unsigned int j=0; j<data_.size(); ++j) {
277  std::vector<T> &vec = *( this->data_[j].get() );
278  for(unsigned int i=0; i<vec.size(); ++i) {
279  if ( std::isnan(vec[i]) ) {
280  if ( std::isnan(default_val) ) is_nan = true;
281  else vec[i] = default_val;
282  }
283  if ( (vec[i] < lower_bound) || (vec[i] > upper_bound) ) out_of_limit = true;
284  }
285  }
286 
287  if (is_nan) return CheckResult::not_a_number;
288  else if (out_of_limit) return CheckResult::out_of_limits;
289  else return CheckResult::ok;
290 }
291 
292 template <typename T>
294  if (check_scale_data_ == CheckScaleData::scale) return; // method is executed only once
295  ASSERT_DBG(check_scale_data_ == CheckScaleData::check).warning("Data should be checked before scaling. Rather call 'check_values'!\n");
296 
297  for (unsigned int j=0; j<data_.size(); ++j) {
298  std::vector<T> &vec = *( this->data_[j].get() );
299  for(unsigned int i=0; i<vec.size(); ++i) {
300  vec[i] *= coef;
301  }
302  }
303 
304  check_scale_data_ = CheckScaleData::scale;
305 }
306 
307 
308 template <typename T>
309 std::shared_ptr< ElementDataCacheBase > ElementDataCache<T>::gather(Distribution *distr, LongIdx *local_to_global) {
310  std::shared_ptr< ElementDataCache<T> > gather_cache;
311  int rank = distr->myp();
312  int n_proc = distr->np();
313 
314  unsigned int n_global_data; // global number of data
315  int rec_starts[n_proc]; // displacement of first value that is received from each process
316  int rec_counts[n_proc]; // number of values that are received from each process
317  int *rec_indices_ids = nullptr; // collective values of local to global indexes map of data
318  T *rec_data = nullptr; // collective values of data
319 
320  // collects values of data vectors and local to global indexes map on each process
321  if (rank==0) {
322  for (int i=0; i<n_proc; ++i) {
323  rec_starts[i] = distr->begin(i);
324  rec_counts[i] = distr->lsize(i);
325  }
326  n_global_data = distr->size();
327  rec_indices_ids = new int [ n_global_data ];
328  }
329  MPI_Gatherv( local_to_global, distr->lsize(), MPI_INT, rec_indices_ids, rec_counts, rec_starts, MPI_INT, 0, MPI_COMM_WORLD);
330  if (rank==0) {
331  for (int i=0; i<n_proc; ++i) {
332  rec_starts[i] = this->n_comp()*this->n_dofs_per_element()*rec_starts[i];
333  rec_counts[i] = this->n_comp()*this->n_dofs_per_element()*rec_counts[i];
334  }
335  rec_data = new T [ this->n_comp() * this->n_dofs_per_element() * n_global_data ];
336  }
337  auto &local_cache_vec = *( this->get_component_data(0).get() );
338  MPI_Gatherv( &local_cache_vec[0], this->n_comp()*this->n_dofs_per_element()*distr->lsize(), this->mpi_data_type(), rec_data, rec_counts, rec_starts, this->mpi_data_type(), 0, MPI_COMM_WORLD) ;
339 
340  // create and fill serial cache
341  if (rank==0) {
342  gather_cache = std::make_shared<ElementDataCache<T>>(this->field_input_name_, (unsigned int)this->n_comp(), n_global_data, this->fe_type_, this->n_dofs_per_element_);
343  auto &gather_vec = *( gather_cache->get_component_data(0).get() );
344  unsigned int i_global_coord; // counter over serial_mesh->nodes_ cache
345  for (unsigned int i=0; i<n_global_data; ++i) {
346  i_global_coord = this->n_comp() * this->n_dofs_per_element() * rec_indices_ids[i];
347  for (unsigned int j=0; j<this->n_comp() * this->n_dofs_per_element(); ++j) { //loop over coords
348  ASSERT_LT(i_global_coord+j, gather_vec.size());
349  gather_vec[ i_global_coord+j ] = rec_data[ this->n_comp()*this->n_dofs_per_element()*i+j ];
350  }
351  }
352 
353  delete[] rec_indices_ids;
354  delete[] rec_data;
355  }
356 
357  return gather_cache;
358 }
359 
360 
361 template <typename T>
362 std::shared_ptr< ElementDataCacheBase > ElementDataCache<T>::element_node_cache_fixed_size(std::vector<unsigned int> &offset_vec) {
363  unsigned int n_elem = offset_vec.size()-1;
364  std::shared_ptr< ElementDataCache<T> > elem_node_cache = std::make_shared<ElementDataCache<T>>(this->field_input_name_, 4*this->n_comp(), n_elem, this->fe_type_, this->n_dofs_per_element_);
365  auto &data_out_vec = *( elem_node_cache->get_component_data(0).get() );
366  std::fill( data_out_vec.begin(), data_out_vec.end(), (T)0 );
367  auto &data_in_vec = *( this->get_component_data(0).get() );
368 
369  unsigned int i_node, i_old, i_new;
370  for (unsigned int i_el=0, i_conn=0; i_el<offset_vec.size()-1; i_el++) {
371  for(i_node=4*i_el; i_conn<offset_vec[i_el+1]; i_conn++, i_node++) {
372  i_old = i_conn*this->n_comp_*this->n_dofs_per_element_;
373  i_new = i_node*this->n_comp_*this->n_dofs_per_element_;
374  for(unsigned int i = 0; i < this->n_comp_*this->n_dofs_per_element_; i++) {
375  ASSERT_LT(i_new+i, data_out_vec.size());
376  ASSERT_LT(i_old+i, data_in_vec.size());
377  data_out_vec[i_new+i] = data_in_vec[i_old+i];
378  }
379  }
380  }
381 
382  return elem_node_cache;
383 }
384 
385 
386 template <typename T>
387 std::shared_ptr< ElementDataCacheBase > ElementDataCache<T>::element_node_cache_optimize_size(std::vector<unsigned int> &offset_vec) {
388  std::shared_ptr< ElementDataCache<T> > elem_node_cache = std::make_shared<ElementDataCache<T>>(this->field_input_name_,
389  this->n_comp()/4, offset_vec[offset_vec.size()-1], this->fe_type_, this->n_dofs_per_element_);
390  auto &data_out_vec = *( elem_node_cache->get_component_data(0).get() );
391  auto &data_in_vec = *( this->get_component_data(0).get() );
392 
393  unsigned int i_node, i_old, i_new;
394  for (unsigned int i_el=0, i_conn=0; i_el<offset_vec.size()-1; i_el++) {
395  for(i_node=4*i_el; i_conn<offset_vec[i_el+1]; i_conn++, i_node++) {
396  i_old = i_node*elem_node_cache->n_comp_*this->n_dofs_per_element_;
397  i_new = i_conn*elem_node_cache->n_comp_*this->n_dofs_per_element_;
398  for(unsigned int i = 0; i < elem_node_cache->n_comp_*this->n_dofs_per_element_; i++) {
399  ASSERT_LT(i_new+i, data_out_vec.size());
400  ASSERT_LT(i_old+i, data_in_vec.size());
401  data_out_vec[i_new+i] = data_in_vec[i_old+i];
402  }
403  }
404  }
405  return elem_node_cache;
406 }
407 
408 
409 template <typename T>
410 std::shared_ptr< ElementDataCacheBase > ElementDataCache<T>::compute_node_data(std::vector<unsigned int> &conn_vec, unsigned int data_size) {
411  ASSERT_EQ(conn_vec.size(), this->n_values());
412  unsigned int idx;
413 
414  // set output data to zero
415  std::shared_ptr< ElementDataCache<T> > node_cache = std::make_shared<ElementDataCache<T>>(this->field_input_name_, this->n_comp(), data_size, this->fe_type_, this->n_dofs_per_element_);
416  std::vector<unsigned int> count(data_size, 0);
417  for (idx=0; idx < node_cache->n_values(); idx++)
418  node_cache->zero(idx);
419 
420  auto &data_in_vec = *( this->get_component_data(0).get() );
421  for (idx=0; idx < conn_vec.size(); idx++) {
422  ASSERT_LT(conn_vec[idx], node_cache->n_values());
423  ASSERT_LT(this->n_comp()*this->n_dofs_per_element()*idx, data_in_vec.size());
424  node_cache->add( conn_vec[idx], &(data_in_vec[this->n_comp() * this->n_dofs_per_element() * idx]) );
425  count[ conn_vec[idx] ]++;
426  }
427 
428  // Compute mean values at nodes
429  for(idx=0; idx < node_cache->n_values(); idx++)
430  node_cache->normalize(idx, count[idx]);
431 
432  return node_cache;
433 }
434 
435 
436 template<>
438  return MPI_DOUBLE;
439 }
440 
441 template<>
443  return MPI_INT;
444 }
445 
446 template<>
448  return MPI_UNSIGNED;
449 }
450 
451 
452 /// Access i-th element in the data vector.
453 template <class T>
455 {
456  std::vector<T> &vec = *( this->data_[0].get() );
457  ASSERT_DBG(i < vec.size());
458  return vec[i];
459 }
460 
461 
462 
463 // explicit instantiation of template class
464 template class ElementDataCache<unsigned int>;
465 template class ElementDataCache<int>;
466 template class ElementDataCache<double>;
Distribution::np
unsigned int np() const
get num of processors
Definition: distribution.hh:105
ElementDataCache::ElementDataCache
ElementDataCache()
Default constructor.
Definition: element_data_cache.cc:32
ElementDataCache::read_ascii_data
void read_ascii_data(Tokenizer &tok, unsigned int n_components, unsigned int i_row) override
Implements ElementDataCacheBase::read_ascii_data.
Definition: element_data_cache.cc:91
element_data_cache.hh
ASSERT_GT
#define ASSERT_GT(a, b)
Definition of comparative assert macro (Greater Than)
Definition: asserts.hh:312
Armor::vec
ArmaVec< double, N > vec
Definition: armor.hh:885
Distribution::lsize
unsigned int lsize(int proc) const
get local size
Definition: distribution.hh:115
msh_basereader.hh
ElementDataCacheBase::time_
double time_
time step stored in cache
Definition: element_data_cache_base.hh:241
Distribution::myp
unsigned int myp() const
get my processor
Definition: distribution.hh:107
ElementDataCache
Definition: element_data_cache.hh:44
ElementDataCache::get_component_data
ComponentDataPtr get_component_data(unsigned int component_idx)
Return vector of element data for get component.
Definition: element_data_cache.cc:71
ElementDataCacheBase::n_dofs_per_element_
unsigned int n_dofs_per_element_
Definition: element_data_cache_base.hh:276
ElementDataCacheBase::n_comp_
unsigned int n_comp_
Definition: element_data_cache_base.hh:260
distribution.hh
Support classes for parallel programing.
ElementDataCache::print_yaml_subarray
void print_yaml_subarray(ostream &out_stream, unsigned int precision, unsigned int begin, unsigned int end) override
Definition: element_data_cache.cc:170
ok
@ ok
All values are not NaN and are in limits.
Definition: element_data_cache.hh:37
ElementDataCache::gather
std::shared_ptr< ElementDataCacheBase > gather(Distribution *distr, LongIdx *local_to_global) override
Implements ElementDataCacheBase::gather.
Definition: element_data_cache.cc:309
value
static constexpr bool value
Definition: json.hpp:87
ASSERT_DBG
#define ASSERT_DBG(expr)
Definition: include_fadbad.hh:28
none
@ none
Definition: mixed_mesh_intersections.hh:38
ElementDataCacheBase::n_comp
unsigned int n_comp() const
Definition: element_data_cache_base.hh:145
MPI_DOUBLE
#define MPI_DOUBLE
Definition: mpi.h:156
std::vector< ComponentDataPtr >
Distribution::size
unsigned int size() const
get global size
Definition: distribution.hh:118
MPI_Gatherv
#define MPI_Gatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs, recvtype, root, comm)
Definition: mpi.h:549
system.hh
field_value_to_yaml
string field_value_to_yaml(const T &mat, unsigned int prec)
Definition: armadillo_tools.cc:138
ElementDataCache::scale_data
void scale_data(double coef)
Definition: element_data_cache.cc:293
ElementDataCacheBase::n_values_
unsigned int n_values_
Definition: element_data_cache_base.hh:255
ElementDataCacheBase::n_dofs_per_element
unsigned int n_dofs_per_element() const
Definition: element_data_cache_base.hh:152
ElementDataCache::CheckScaleData
CheckScaleData
Allow to hold sign, if data in cache is checked and scale (both can be executed only once)
Definition: element_data_cache.hh:189
ASSERT_LT
#define ASSERT_LT(a, b)
Definition of comparative assert macro (Less Than)
Definition: asserts.hh:296
fmt::internal::check
T check(T value)
Definition: format.h:312
ElementDataCacheBase::fe_type_
std::string fe_type_
Definition: element_data_cache_base.hh:271
Distribution
Definition: distribution.hh:50
armadillo_tools.hh
ElementDataCache::print_ascii
void print_ascii(ostream &out_stream, unsigned int idx) override
Definition: element_data_cache.cc:125
ElementDataCache::compute_node_data
std::shared_ptr< ElementDataCacheBase > compute_node_data(std::vector< unsigned int > &conn_vec, unsigned int data_size) override
Implements ElementDataCacheBase::compute_node_data.
Definition: element_data_cache.cc:410
ElementDataCache::element_node_cache_fixed_size
std::shared_ptr< ElementDataCacheBase > element_node_cache_fixed_size(std::vector< unsigned int > &offset_vec) override
Implements ElementDataCacheBase::element_node_cache_fixed_size.
Definition: element_data_cache.cc:362
CheckResult
CheckResult
Return type of method that checked data stored in ElementDataCache (NaN values, limits)
Definition: element_data_cache.hh:36
ElementDataCache::element_node_cache_optimize_size
std::shared_ptr< ElementDataCacheBase > element_node_cache_optimize_size(std::vector< unsigned int > &offset_vec) override
Implements ElementDataCacheBase::element_node_cache_optimize_size.
Definition: element_data_cache.cc:387
ASSERT_EQ
#define ASSERT_EQ(a, b)
Definition of comparative assert macro (EQual)
Definition: asserts.hh:328
ElementDataCache::mpi_data_type
MPI_Datatype mpi_data_type()
Return MPI data type corresponding with template parameter of cache. Needs template specialization.
ElementDataCacheBase
Definition: element_data_cache_base.hh:33
MPI_INT
#define MPI_INT
Definition: mpi.h:160
fmt::internal::isnan
DummyInt isnan(...)
Definition: format.h:306
ElementDataCache::print_binary_all
void print_binary_all(ostream &out_stream, bool print_data_size=true, unsigned int start=0) override
Print all data stored in output data to appended binary format.
Definition: element_data_cache.cc:153
not_a_number
@ not_a_number
Some value(s) is set to NaN.
Definition: element_data_cache.hh:39
ElementDataCache::read_binary_data
void read_binary_data(std::istream &data_stream, unsigned int n_components, unsigned int i_row) override
Implements ElementDataCacheBase::read_binary_data.
Definition: element_data_cache.cc:106
MPI_Datatype
#define MPI_Datatype
Definition: mpi.h:154
LongIdx
int LongIdx
Define type that represents indices of large arrays (elements, nodes, dofs etc.)
Definition: index_types.hh:24
ElementDataCache::add
void add(unsigned int idx, const T *value)
Definition: element_data_cache.cc:235
ElementDataCache::ComponentDataPtr
std::shared_ptr< std::vector< T > > ComponentDataPtr
Definition: element_data_cache.hh:52
ElementDataCache::data_
CacheData data_
Definition: element_data_cache.hh:207
ElementDataCacheBase::field_input_name_
std::string field_input_name_
name of field stored in cache
Definition: element_data_cache_base.hh:244
ElementDataCache::~ElementDataCache
virtual ~ElementDataCache() override
Destructor of ElementDataCache.
Definition: element_data_cache.cc:67
ElementDataCache::get_min_max_range
void get_min_max_range(double &min, double &max) override
Definition: element_data_cache.cc:204
out_of_limits
@ out_of_limits
Some value(s) is out of limits.
Definition: element_data_cache.hh:38
MPI_COMM_WORLD
#define MPI_COMM_WORLD
Definition: mpi.h:123
ASSERT_LT_DBG
#define ASSERT_LT_DBG(a, b)
Definition of comparative assert macro (Less Than) only for debug mode.
Definition: asserts.hh:300
ElementDataCacheBase::field_name_
std::string field_name_
Definition: element_data_cache_base.hh:245
ElementDataCache::create_data_cache
static CacheData create_data_cache(unsigned int size_of_cache, unsigned int row_vec_size)
Definition: element_data_cache.cc:78
MPI_UNSIGNED
#define MPI_UNSIGNED
Definition: mpi.h:165
ElementDataCache::zero
void zero(unsigned int idx)
Definition: element_data_cache.cc:248
ElementDataCache::check_values
CheckResult check_values(double default_val, double lower_bound, double upper_bound)
Definition: element_data_cache.cc:271
ElementDataCache::normalize
void normalize(unsigned int idx, unsigned int divisor)
Definition: element_data_cache.cc:261
ElementDataCache::print_ascii_all
void print_ascii_all(ostream &out_stream, unsigned int start=0) override
Print all data stored in output data ro ascii format.
Definition: element_data_cache.cc:141
ElementDataCache::store_value
void store_value(unsigned int idx, const T *value)
Definition: element_data_cache.cc:222
ElementDataCacheBase::fe_type
std::string fe_type() const
Definition: element_data_cache_base.hh:178
tokenizer.hh
Distribution::begin
unsigned int begin(int proc) const
get starting local index
Definition: distribution.hh:109
ElementDataCache::operator[]
T & operator[](unsigned int i)
Access i-th element in the data vector of 0th component.
Definition: element_data_cache.cc:454