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