Flow123d  release_3.0.0-955-g4db4b48
output_vtk.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 output_vtk.cc
15  * @brief The functions for outputs to VTK files.
16  */
17 
18 #include "output_vtk.hh"
20 #include "element_data_cache.hh"
21 #include "output_mesh.hh"
22 #include "mesh/mesh.h"
23 
24 #include <limits.h>
25 #include "input/factory.hh"
27 #include "system/file_path.hh"
28 #include "tools/unit_si.hh"
29 #include "la/distribution.hh"
30 
31 #include "config.h"
32 #include <zlib.h>
33 
35 
36 
37 using namespace Input::Type;
38 
39 const Record & OutputVTK::get_input_type() {
40  return Record("vtk", "Parameters of vtk output format.")
41  // It is derived from abstract class
43  .declare_key("variant", OutputVTK::get_input_type_variant(), Default("\"ascii\""),
44  "Variant of output stream file format.")
45  // The parallel or serial variant
46  .declare_key("parallel", Bool(), Default("false"),
47  "Parallel or serial version of file format.")
48  .close();
49 }
50 
51 
53  return Selection("VTK variant (ascii or binary)")
55  "ASCII variant of VTK file format")
57  "Uncompressed appended binary XML VTK format without usage of base64 encoding of appended data.")
58 #ifdef FLOW123D_HAVE_ZLIB
60  "Appended binary XML VTK format without usage of base64 encoding of appended data. Compressed with ZLib.")
61 #endif // FLOW123D_HAVE_ZLIB
62  .close();
63 }
64 
65 
66 const int OutputVTK::registrar = Input::register_class< OutputVTK >("vtk") +
68 
69 
70 const std::vector<std::string> OutputVTK::formats = { "ascii", "appended", "appended" };
71 
72 
73 
75 {
76  this->enable_refinement_ = true;
77 }
78 
79 
80 
82 {
83  this->write_tail();
84 }
85 
86 
87 
88 void OutputVTK::init_from_input(const std::string &equation_name, const Input::Record &in_rec, std::string unit_str)
89 {
90  OutputTime::init_from_input(equation_name, in_rec, unit_str);
91 
92  auto format_rec = (Input::Record)(input_record_.val<Input::AbstractRecord>("format"));
93  variant_type_ = format_rec.val<VTKVariant>("variant");
94  this->parallel_ = format_rec.val<bool>("parallel");
95  this->fix_main_file_extension(".pvd");
96 
97  if(this->rank_ == 0) {
98  try {
99  this->_base_filename.open_stream( this->_base_file );
100  this->set_stream_precision(this->_base_file);
101  } INPUT_CATCH(FilePath::ExcFileOpen, FilePath::EI_Address_String, input_record_)
102 
103  LogOut() << "Writing flow output file: " << this->_base_filename << " ... ";
104  }
105 
106  this->make_subdirectory();
107  this->write_head();
108 
109 }
110 
111 string OutputVTK::form_vtu_filename_(string basename, int i_step, int rank) {
112  ostringstream ss;
113  if (this->parallel_) {
114  // parallel file
115  ss << main_output_basename_ << "/" << main_output_basename_ << "-"
116  << std::setw(6) << std::setfill('0') << current_step << "." << rank << ".vtu";
117  } else {
118  // serial file
119  ss << main_output_basename_ << "/" << main_output_basename_ << "-"
120  << std::setw(6) << std::setfill('0') << current_step << ".vtu";
121  }
122  return ss.str();
123 }
124 
125 string pvd_dataset_line(double step, int rank, string file) {
126  ostringstream ss;
127  ss
128  << "<DataSet timestep=\"" << step
129  << "\" group=\"\" part=\"" << rank
130  << "\" file=\"" << file
131  << "\"/>\n";
132  return ss.str();
133 }
134 
136 {
137  ASSERT_PTR(this->nodes_).error();
138 
139  /* Output of serial format is implemented only in the first process */
140  if ( (this->rank_ != 0) && (!parallel_) ) {
141  return 0;
142  }
143 
144  /**
145  * TODO:
146  * - common creation of the VTU filename
147  * - names of parallel file: <base name>_<frame>.<rank>.vtu
148  * - for serial case use rank=0
149  */
150 
151  /* Write DataSets to the PVD file only in the first process */
152  if (this->rank_ == 0) {
153  ASSERT(this->_base_file.is_open())(this->_base_filename).error();
154 
155  /* Set floating point precision to max */
156  //this->_base_file.precision(std::numeric_limits<double>::digits10);
157  //int current_step = this->get_parallel_current_step();
158 
159  /* Write dataset lines to the PVD file. */
160  double corrected_time = (isfinite(this->time)?this->time:0);
161  corrected_time /= UnitSI().s().convert_unit_from(this->unit_string_);
162  if (parallel_) {
163  for (int i_rank=0; i_rank<n_proc_; ++i_rank) {
164  string file = this->form_vtu_filename_(main_output_basename_, current_step, i_rank);
165  this->_base_file << pvd_dataset_line(corrected_time, i_rank, file);
166  }
167  } else {
168  string file = this->form_vtu_filename_(main_output_basename_, current_step, -1);
169  this->_base_file << pvd_dataset_line(corrected_time, 0, file);
170  }
171  }
172 
173  /* write VTU file */
174  {
175  /* Open VTU file */
176  std::string frame_file_name = this->form_vtu_filename_(main_output_basename_, current_step, this->rank_);
177  FilePath frame_file_path({main_output_dir_, frame_file_name}, FilePath::output_file);
178  try {
179  frame_file_path.open_stream(_data_file);
181  } INPUT_CATCH(FilePath::ExcFileOpen, FilePath::EI_Address_String, input_record_)
182 
183  LogOut() << __func__ << ": Writing output (frame: " << this->current_step
184  << ", rank: " << this->rank_
185  << ") file: " << frame_file_name << " ... ";
186 
187  this->write_vtk_vtu();
188 
189  /* Close stream for file of current frame */
190  _data_file.close();
191  //delete data_file;
192  //this->_data_file = NULL;
193 
194  LogOut() << "O.K.";
195 
196  }
197 
198  return 1;
199 }
200 
201 
202 
203 
205 {
206  ASSERT_EQ(this->_base_filename.extension(), ".pvd").error();
209 
210  if(this->rank_ == 0) {
211  vector<string> sub_path = { main_output_dir_, main_output_basename_, "__tmp__" };
212  FilePath fp(sub_path, FilePath::output_file);
213  fp.create_output_dir();
214  }
215 }
216 
217 
218 
219 
221 {
222  ofstream &file = this->_data_file;
223 
224  file << "<?xml version=\"1.0\"?>" << endl;
225  // TODO: test endianess of platform (this would be important, when raw
226  // data will be saved to the VTK file)
227  file << "<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\"";
228  if ( this->variant_type_ != VTKVariant::VARIANT_ASCII ) {
229  file << " header_type=\"UInt64\"";
230  }
231  if ( this->variant_type_ == VTKVariant::VARIANT_BINARY_ZLIB ) {
232  file << " compressor=\"vtkZLibDataCompressor\"";
233  }
234  file << ">" << endl;
235  file << "<UnstructuredGrid>" << endl;
236 }
237 
238 
239 
240 std::shared_ptr<ElementDataCache<unsigned int>> OutputVTK::fill_element_types_data()
241 {
242  auto &offsets = *( this->offsets_->get_component_data(0).get() );
243  unsigned int n_elements = offsets.size();
244 
245  auto types = std::make_shared<ElementDataCache<unsigned int>>("types", (unsigned int)ElementDataCacheBase::N_SCALAR, n_elements);
246  std::vector< unsigned int >& data = *( types->get_component_data(0).get() );
247  int n_nodes;
248 
249  n_nodes = offsets[0];
250  switch(n_nodes) {
251  case 2:
252  data[0] = (unsigned int)VTK_LINE;
253  break;
254  case 3:
255  data[0] = (unsigned int)VTK_TRIANGLE;
256  break;
257  case 4:
258  data[0] = (unsigned int)VTK_TETRA;
259  break;
260  }
261 
262  for(unsigned int i=1; i < n_elements; i++)
263  {
264  n_nodes = offsets[i]-offsets[i-1];
265  switch(n_nodes) {
266  case 2:
267  data[i] = (unsigned int)VTK_LINE;
268  break;
269  case 3:
270  data[i] = (unsigned int)VTK_TRIANGLE;
271  break;
272  case 4:
273  data[i] = (unsigned int)VTK_TETRA;
274  break;
275  }
276  }
277 
278  return types;
279 }
280 
281 
282 
284 {
285  // names of types in DataArray section
286  static const std::vector<std::string> types = {
287  "Int8", "UInt8", "Int16", "UInt16", "Int32", "UInt32", "Float32", "Float64" };
288 
289  ofstream &file = this->_data_file;
290 
291  file << "<DataArray type=\"" << types[output_data->vtk_type()] << "\" ";
292  // possibly write name
293  if( ! output_data->field_input_name().empty())
294  file << "Name=\"" << output_data->field_input_name() <<"\" ";
295  // write number of components
296  if (output_data->n_comp() > 1)
297  {
298  file
299  << "NumberOfComponents=\"" << output_data->n_comp() << "\" ";
300  }
301  file << "format=\"" << formats[this->variant_type_] << "\"";
302 
303  if ( this->variant_type_ == VTKVariant::VARIANT_ASCII ) {
304  // ascii output
305  file << ">" << endl;
306  //file << std::fixed << std::setprecision(10); // Set precision to max
307  output_data->print_ascii_all(file);
308  file << "\n</DataArray>" << endl;
309  } else {
310  // binary output is stored to appended_data_ stream
311  double range_min, range_max;
312  output_data->get_min_max_range(range_min, range_max);
313  file << " offset=\"" << appended_data_.tellp() << "\" ";
314  file << "RangeMin=\"" << range_min << "\" RangeMax=\"" << range_max << "\"/>" << endl;
315  if ( this->variant_type_ == VTKVariant::VARIANT_BINARY_UNCOMPRESSED ) {
316  output_data->print_binary_all( appended_data_ );
317  } else { // ZLib compression
318  stringstream uncompressed_data, compressed_data;
319  output_data->print_binary_all( uncompressed_data, false );
320  this->compress_data(uncompressed_data, compressed_data);
321  appended_data_ << compressed_data.str();
322  }
323  }
324 
325 }
326 
327 
328 void OutputVTK::compress_data(stringstream &uncompressed_stream, stringstream &compressed_stream) {
329  // size of block of compressed data.
330  static const size_t BUF_SIZE = 32 * 1024;
331 
332  string uncompressed_string = uncompressed_stream.str(); // full uncompressed string
333  uLong uncompressed_size = uncompressed_string.size(); // size of uncompressed string
334  stringstream compressed_data; // helper stream stores blocks of compress data
335 
336  uLong count_of_blocks = (uncompressed_size + BUF_SIZE - 1) / BUF_SIZE;
337  uLong last_block_size = (uncompressed_size % BUF_SIZE);
338  compressed_stream.write(reinterpret_cast<const char*>(&count_of_blocks), sizeof(unsigned long long int));
339  compressed_stream.write(reinterpret_cast<const char*>(&BUF_SIZE), sizeof(unsigned long long int));
340  compressed_stream.write(reinterpret_cast<const char*>(&last_block_size), sizeof(unsigned long long int));
341 
342  for (uLong i=0; i<count_of_blocks; ++i) {
343  // get block of data for compression
344  std::string data_block = uncompressed_string.substr(i*BUF_SIZE, BUF_SIZE);
345  uLong data_block_size = data_block.size();
346 
347  std::vector<uint8_t> buffer;
348  uint8_t temp_buffer[BUF_SIZE];
349 
350  // set zlib object
351  z_stream strm;
352  strm.zalloc = 0;
353  strm.zfree = 0;
354  strm.next_in = reinterpret_cast<uint8_t *>(&data_block[0]);
355  strm.avail_in = data_block_size;
356  strm.next_out = temp_buffer;
357  strm.avail_out = BUF_SIZE;
358 
359  // compression of data
360  deflateInit(&strm, Z_BEST_COMPRESSION);
361  while (strm.avail_in != 0) {
362  int res = deflate(&strm, Z_NO_FLUSH);
363  ASSERT_EQ(res, Z_OK).error();
364  if (strm.avail_out == 0) {
365  buffer.insert(buffer.end(), temp_buffer, temp_buffer + BUF_SIZE);
366  strm.next_out = temp_buffer;
367  strm.avail_out = BUF_SIZE;
368  }
369  }
370  int deflate_res = Z_OK;
371  while (deflate_res == Z_OK) {
372  if (strm.avail_out == 0) {
373  buffer.insert(buffer.end(), temp_buffer, temp_buffer + BUF_SIZE);
374  strm.next_out = temp_buffer;
375  strm.avail_out = BUF_SIZE;
376  }
377  deflate_res = deflate(&strm, Z_FINISH);
378  }
379  ASSERT_EQ(deflate_res, Z_STREAM_END).error();
380  buffer.insert(buffer.end(), temp_buffer, temp_buffer + BUF_SIZE - strm.avail_out);
381  deflateEnd(&strm);
382 
383  // store compress data and its size to streams
384  std::string str(buffer.begin(), buffer.end());
385  uLong compressed_data_size = str.size();
386  compressed_stream.write(reinterpret_cast<const char*>(&compressed_data_size), sizeof(unsigned long long int));
387  compressed_data << str;
388  }
389  // push compress data to returned stream
390  compressed_stream << compressed_data.str();
391 }
392 
393 
395 {
396  for(OutputDataPtr data : output_data_vec)
397  if( ! data->is_dummy())
398  write_vtk_data(data);
399 }
400 
401 
402 
403 
405  OutputDataFieldVec &output_data_vec)
406 {
407  if (output_data_vec.empty()) return;
408 
409  file << "Scalars=\"";
410  for(OutputDataPtr data : output_data_vec )
411  if (data->n_comp() == ElementDataCacheBase::N_SCALAR
412  && ! data->is_dummy())
413  file << data->field_input_name() << ",";
414  file << "\" ";
415 
416  file << "Vectors=\"";
417  for(OutputDataPtr data : output_data_vec )
418  if (data->n_comp() == ElementDataCacheBase::N_VECTOR
419  && ! data->is_dummy())
420  file << data->field_input_name() << ",";
421  file << "\" ";
422 
423  file << "Tensors=\"";
424  for(OutputDataPtr data : output_data_vec )
425  if (data->n_comp() == ElementDataCacheBase::N_TENSOR
426  && ! data->is_dummy())
427  file << data->field_input_name() << ",";
428  file << "\"";
429 }
430 
431 
433 {
434  ofstream &file = this->_data_file;
435 
436  // merge node and corner data
437  OutputDataFieldVec node_corner_data(output_data_vec_[NODE_DATA]);
438  node_corner_data.insert(node_corner_data.end(),
440 
441  if( ! node_corner_data.empty() ) {
442  /* Write <PointData begin */
443  file << "<PointData ";
444  write_vtk_data_names(file, node_corner_data);
445  file << ">" << endl;
446 
447  /* Write data on nodes */
448  this->write_vtk_field_data(output_data_vec_[NODE_DATA]);
449 
450  /* Write data in corners of elements */
452 
453  /* Write PointData end */
454  file << "</PointData>" << endl;
455  }
456 }
457 
458 
460 {
461  ofstream &file = this->_data_file;
462 
463  auto &data_map = this->output_data_vec_[ELEM_DATA];
464  if (data_map.empty()) return;
465 
466  /* Write CellData begin */
467  file << "<CellData ";
468  write_vtk_data_names(file, data_map);
469  file << ">" << endl;
470 
471  /* Write own data */
472  this->write_vtk_field_data(data_map);
473 
474  /* Write PointData end */
475  file << "</CellData>" << endl;
476 }
477 
478 
480 {
481  ofstream &file = this->_data_file;
482 
483  auto &data_map = this->output_data_vec_[NATIVE_DATA];
484  if (data_map.empty()) return;
485 
486  /* Write Flow123dData begin */
487  file << "<Flow123dData ";
488  write_vtk_data_names(file, data_map);
489  file << ">" << endl;
490 
491  /* Write own data */
492  for(OutputDataPtr output_data : data_map) {
493  file << "<DataArray type=\"Float64\" ";
494  file << "Name=\"" << output_data->field_input_name() <<"\" ";
495  file << "format=\"" << formats[this->variant_type_] << "\" ";
496  file << "dof_handler_hash=\"" << output_data->dof_handler_hash() << "\" ";
497  file << "n_dofs_per_element=\"" << output_data->n_comp() << "\"";
498 
499  if ( this->variant_type_ == VTKVariant::VARIANT_ASCII ) {
500  // ascii output
501  file << ">" << endl;
502  file << std::fixed << std::setprecision(10); // Set precision to max
503  output_data->print_ascii_all(file);
504  file << "\n</DataArray>" << endl;
505  } else {
506  // binary output is stored to appended_data_ stream
507  double range_min, range_max;
508  output_data->get_min_max_range(range_min, range_max);
509  file << " offset=\"" << appended_data_.tellp() << "\" ";
510  file << "RangeMin=\"" << range_min << "\" RangeMax=\"" << range_max << "\"/>" << endl;
511  if ( this->variant_type_ == VTKVariant::VARIANT_BINARY_UNCOMPRESSED ) {
512  output_data->print_binary_all( appended_data_ );
513  } else { // ZLib compression
514  stringstream uncompressed_data, compressed_data;
515  output_data->print_binary_all( uncompressed_data, false );
516  this->compress_data(uncompressed_data, compressed_data);
517  appended_data_ << compressed_data.str();
518  }
519  }
520  }
521 
522  /* Write Flow123dData end */
523  file << "</Flow123dData>" << endl;
524 }
525 
526 
528 {
529  ofstream &file = this->_data_file;
530 
531  file << "</UnstructuredGrid>" << endl;
532  if ( this->variant_type_ != VTKVariant::VARIANT_ASCII ) {
533  // appended data of binary compressed output
534  file << "<AppendedData encoding=\"raw\">" << endl;
535  // appended data starts with '_' character
536  file << "_" << appended_data_.str() << endl;
537  file << "</AppendedData>" << endl;
538  }
539  file << "</VTKFile>" << endl;
540 }
541 
542 
544 {
545  ofstream &file = this->_data_file;
546 
547  /* Write header */
548  this->write_vtk_vtu_head();
549 
550  /* Write Piece begin */
551  file << "<Piece NumberOfPoints=\"" << this->nodes_->n_values()
552  << "\" NumberOfCells=\"" << this->offsets_->n_values() <<"\">" << endl;
553 
554  /* Write VTK Geometry */
555  file << "<Points>" << endl;
556  write_vtk_data(this->nodes_);
557  file << "</Points>" << endl;
558 
559  /* Write VTK Topology */
560  file << "<Cells>" << endl;
562  write_vtk_data(this->offsets_);
563  auto types = fill_element_types_data();
564  write_vtk_data( types );
565  file << "</Cells>" << endl;
566 
567  /* Write VTK scalar and vector data on nodes to the file */
568  this->write_vtk_node_data();
569 
570  /* Write VTK data on elements */
571  this->write_vtk_element_data();
572 
573  /* Write own VTK native data (skipped by Paraview) */
574  this->write_vtk_native_data();
575 
576  /* Write Piece end */
577  file << "</Piece>" << endl;
578 
579  /* Write tail */
580  this->write_vtk_vtu_tail();
581 }
582 
583 
584 
586 {
587  /* Output to PVD file is implemented only in the first process */
588  if(this->rank_ != 0) {
589  return 0;
590  }
591 
592  LogOut() << __func__ << ": Writing output file (head) " << this->_base_filename << " ... ";
593 
594  this->_base_file << "<?xml version=\"1.0\"?>" << endl;
595  this->_base_file << "<VTKFile type=\"Collection\" version=\"0.1\" byte_order=\"LittleEndian\">" << endl;
596  this->_base_file << "<Collection>" << endl;
597 
598  LogOut() << "O.K.";
599 
600  return 1;
601 }
602 
603 
605 {
606  /* Output to PVD file is implemented only in the first process */
607  if(this->rank_ != 0) {
608  return 0;
609  }
610 
611  LogOut() << __func__ << ": Writing output file (tail) " << this->_base_filename << " ... ";
612 
613  this->_base_file << "</Collection>" << endl;
614  this->_base_file << "</VTKFile>" << endl;
615 
616  LogOut() << "O.K.";
617 
618  return 1;
619 }
620 
621 
622 
623 
624 
625 
Classes for auxiliary output mesh.
string stem() const
Definition: file_path.cc:193
double time
Definition: output_time.hh:275
Input::Record input_record_
Definition: output_time.hh:285
void fix_main_file_extension(std::string extension)
Definition: output_time.cc:151
unsigned int size() const
Returns number of keys in the Record.
Definition: type_record.hh:598
void make_subdirectory()
Definition: output_vtk.cc:204
static const std::vector< std::string > formats
Formats of DataArray section.
Definition: output_vtk.hh:135
std::shared_ptr< ElementDataCache< unsigned int > > connectivity_
Vector maps the nodes to their coordinates in vector nodes_.
Definition: output_time.hh:325
static const Input::Type::Record & get_input_type()
The definition of input record for vtk file format.
Definition: output_vtk.cc:39
void create_output_dir()
Definition: file_path.cc:176
void write_vtk_field_data(OutputDataFieldVec &output_data_map)
Definition: output_vtk.cc:394
std::shared_ptr< ElementDataCache< unsigned int > > fill_element_types_data()
Fills the data cache with VTK element types indicators.
Definition: output_vtk.cc:240
void write_vtk_vtu(void)
This function write all scalar and vector data on nodes and elements to the VTK file (...
Definition: output_vtk.cc:543
Class Input::Type::Default specifies default value of keys of a Input::Type::Record.
Definition: type_record.hh:61
Class for declaration of the input of type Bool.
Definition: type_base.hh:459
std::shared_ptr< ElementDataCache< unsigned int > > offsets_
Vector of offsets of node indices of elements. Maps elements to their nodes in connectivity_.
Definition: output_time.hh:327
FilePath _base_filename
Definition: output_time.hh:295
void write_vtk_data(OutputDataPtr output_data)
Definition: output_vtk.cc:283
double convert_unit_from(std::string actual_unit) const
Convert and check user-defined unit.
Definition: unit_si.cc:217
Abstract linear system class.
Definition: balance.hh:37
static const int registrar
Registrar of class to factory.
Definition: output_vtk.hh:132
#define INPUT_CATCH(ExceptionType, AddressEITag, input_accessor)
Definition: accessors.hh:64
static Input::Type::Abstract & get_input_format_type()
The specification of output file format.
Definition: output_time.cc:65
std::shared_ptr< ElementDataCacheBase > OutputDataPtr
Definition: output_time.hh:122
std::shared_ptr< ElementDataCache< double > > nodes_
Vector of node coordinates. [spacedim x n_nodes].
Definition: output_time.hh:323
string main_output_basename_
Basename of main output file (without extension)
Definition: output_vtk.hh:227
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library...
Definition: asserts.hh:346
int write_head(void)
This function writes header of VTK (.pvd) file format.
Definition: output_vtk.cc:585
string main_output_dir_
Main output file directory.
Definition: output_vtk.hh:230
void write_vtk_element_data(void)
Write data on elements to the VTK file (.vtu)
Definition: output_vtk.cc:459
#define LogOut()
Macro defining &#39;log&#39; record of log.
Definition: logger.hh:249
Record & close() const
Close the Record for further declarations of keys.
Definition: type_record.cc:303
VTKVariant
The declaration enumeration used for variant of file VTK format.
Definition: output_vtk.hh:95
virtual Record & derive_from(Abstract &parent)
Method to derive new Record from an AbstractRecord parent.
Definition: type_record.cc:195
bool parallel_
Parallel or serial version of file format (parallel has effect only for VTK)
Definition: output_time.hh:317
int rank() const
Definition: output_time.hh:211
void open_stream(Stream &stream) const
Definition: file_path.cc:211
int write_data(void)
This function write data to VTK (.pvd) file format for curent time.
Definition: output_vtk.cc:135
ofstream _data_file
Definition: output_vtk.hh:214
int current_step
Definition: output_time.hh:270
ostringstream appended_data_
Definition: output_vtk.hh:219
Accessor to the data with type Type::Record.
Definition: accessors.hh:292
const Ret val(const string &key) const
UnitSI & s(int exp=1)
Definition: unit_si.cc:76
void write_vtk_vtu_tail(void)
Write tail of VTK file (.vtu)
Definition: output_vtk.cc:527
This class is used for output data to VTK file format.
Definition: output_vtk.hh:42
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.
string parent_path() const
Definition: file_path.cc:183
Record & declare_key(const string &key, std::shared_ptr< TypeBase > type, const Default &default_value, const string &description, TypeBase::attribute_map key_attributes=TypeBase::attribute_map())
Declares a new key of the Record.
Definition: type_record.cc:501
int write_tail(void)
This function writes tail of VTK (.pvd) file format.
Definition: output_vtk.cc:604
void set_stream_precision(std::ofstream &stream)
Definition: output_time.cc:100
string unit_string_
String representation of time unit.
Definition: output_time.hh:320
ofstream _base_file
Definition: output_time.hh:290
~OutputVTK()
The destructor of this class. It writes tail of the file too.
Definition: output_vtk.cc:81
string extension() const
Definition: file_path.cc:198
Accessor to the polymorphic input data of a type given by an AbstracRecord object.
Definition: accessors.hh:459
void write_vtk_native_data(void)
Write native data (part of our own data skipped by Paraview) to the VTK file (.vtu) ...
Definition: output_vtk.cc:479
Dedicated class for storing path to input and output files.
Definition: file_path.hh:54
virtual void init_from_input(const std::string &equation_name, const Input::Record &in_rec, std::string unit_str)
Constructor of OutputTime object. It opens base file for writing.
Definition: output_time.cc:84
Support classes for parallel programing.
OutputVTK()
The constructor of this class. The head of file is written, when constructor is called.
Definition: output_vtk.cc:74
#define ASSERT_PTR(ptr)
Definition of assert macro checking non-null pointer (PTR)
Definition: asserts.hh:335
const Selection & close() const
Close the Selection, no more values can be added.
string form_vtu_filename_(string basename, int i_step, int rank)
Definition: output_vtk.cc:111
VTKVariant variant_type_
Output format (ascii, binary or binary compressed)
Definition: output_vtk.hh:233
void write_vtk_node_data(void)
Write data on nodes to the VTK file (.vtu)
Definition: output_vtk.cc:432
string pvd_dataset_line(double step, int rank, string file)
Definition: output_vtk.cc:125
OutputDataFieldVec output_data_vec_[N_DISCRETE_SPACES]
Definition: output_time.hh:265
void compress_data(stringstream &uncompressed_stream, stringstream &compressed_stream)
Definition: output_vtk.cc:328
Record type proxy class.
Definition: type_record.hh:182
bool enable_refinement_
Auxiliary flag for refinement enabling, due to gmsh format.
Definition: output_time.hh:314
void write_vtk_vtu_head(void)
Write header of VTK file (.vtu)
Definition: output_vtk.cc:220
Class for representation SI units of Fields.
Definition: unit_si.hh:40
Template for classes storing finite set of named values.
void init_from_input(const std::string &equation_name, const Input::Record &in_rec, std::string unit_str) override
Override OutputTime::init_from_input.
Definition: output_vtk.cc:88
#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:327
static const Input::Type::Selection & get_input_type_variant()
The definition of input record for selection of variant of file format.
Definition: output_vtk.cc:52
void write_vtk_data_names(ofstream &file, OutputDataFieldVec &output_data_map)
Write names of data sets in output_data vector that have value type equal to type. Output is done into stream file.
Definition: output_vtk.cc:404