31 using namespace
Input::Type;
34 return Record(
"vtk",
"Parameters of vtk output format.")
38 "Variant of output stream file format.")
47 return Selection(
"VTK variant (ascii or binary)")
49 "ASCII variant of VTK file format")
51 "Uncompressed appended binary XML VTK format without usage of base64 encoding of appended data.")
53 "Appended binary XML VTK format without usage of base64 encoding of appended data. Compressed with ZLib. (Not supported yet)")
105 << std::setw(6) << std::setfill(
'0') << this->
current_step 109 std::string frame_file_name = ss.str();
121 this->
_base_file.precision(std::numeric_limits<double>::digits10);
125 this->
_base_file << scientific <<
"<DataSet timestep=\"" << (isfinite(this->
time)?this->
time:0)
126 <<
"\" group=\"\" part=\"0\" file=\"" << relative_frame_file <<
"\"/>" << endl;
130 LogOut() << __func__ <<
": Writing output (frame " << this->current_step <<
") file " << relative_frame_file <<
" ... ";
165 file <<
"<?xml version=\"1.0\"?>" << endl;
168 file <<
"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">" << endl;
169 file <<
"<UnstructuredGrid>" << endl;
177 unsigned int n_elements = offsets.size();
179 data.resize(n_elements);
182 n_nodes = offsets[0];
195 for(
unsigned int i=1; i < n_elements; i++)
197 n_nodes = offsets[i]-offsets[i-1];
218 "Int8",
"UInt8",
"Int16",
"UInt16",
"Int32",
"UInt32",
"Float32",
"Float64" };
224 file <<
"<DataArray type=\"" << types[output_data->vtk_type_] <<
"\" ";
226 if( ! output_data->output_field_name.empty())
227 file <<
"Name=\"" << output_data->output_field_name <<
"\" ";
229 if (output_data->n_elem_ > 1)
232 <<
"NumberOfComponents=\"" << output_data->n_elem_ <<
"\" ";
239 file << std::fixed << std::setprecision(10);
240 output_data->print_ascii_all(file);
241 file <<
"\n</DataArray>" << endl;
244 double range_min, range_max;
245 output_data->get_min_max_range(range_min, range_max);
247 file <<
"RangeMin=\"" << range_min <<
"\" RangeMax=\"" << range_max <<
"\"/>" << endl;
266 if (output_data_vec.empty())
return;
268 file <<
"Scalars=\"";
273 file <<
"Vectors=\"";
278 file <<
"Tensors=\"";
291 node_corner_data.insert(node_corner_data.end(),
294 if( ! node_corner_data.empty() ) {
296 file <<
"<PointData ";
307 file <<
"</PointData>" << endl;
317 if (data_map.empty())
return;
320 file <<
"<CellData ";
328 file <<
"</CellData>" << endl;
336 file <<
"</UnstructuredGrid>" << endl;
339 if ( this->
variant_type_ == VTKVariant::VARIANT_BINARY_ZLIB )
340 WarningOut() <<
"Zlib library is not supported yet. Appended output is not compressed." << endl;
341 file <<
"<AppendedData encoding=\"raw\">" << endl;
344 file <<
"</AppendedData>" << endl;
346 file <<
"</VTKFile>" << endl;
361 file <<
"<Piece NumberOfPoints=\"" <<
output_mesh_->n_nodes()
362 <<
"\" NumberOfCells=\"" <<
output_mesh_->n_elements() <<
"\">" << endl;
365 file <<
"<Points>" << endl;
367 file <<
"</Points>" << endl;
371 file <<
"<Cells>" << endl;
374 auto types = std::make_shared<MeshData<unsigned int>>(
"types");
377 file <<
"</Cells>" << endl;
386 file <<
"</Piece>" << endl;
391 <<
"\" NumberOfCells=\"" <<
output_mesh_->n_elements() <<
"\">" << endl;
394 file <<
"<Points>" << endl;
396 file <<
"</Points>" << endl;
399 file <<
"<Cells>" << endl;
402 auto types = std::make_shared<MeshData<unsigned int>>(
"types");
405 file <<
"</Cells>" << endl;
414 file <<
"</Piece>" << endl;
426 if(this->
rank != 0) {
433 this->
_base_file <<
"<?xml version=\"1.0\"?>" << endl;
434 this->
_base_file <<
"<VTKFile type=\"Collection\" version=\"0.1\" byte_order=\"LittleEndian\">" << endl;
446 if(this->
rank != 0) {
Classes for auxiliary output mesh.
std::shared_ptr< OutputMesh > output_mesh_
Output mesh.
Input::Record input_record_
std::shared_ptr< OutputMeshDiscontinuous > output_mesh_discont_
Discontinuous (non-conforming) mesh. Used for CORNER_DATA.
void fix_main_file_extension(std::string extension)
static const Input::Type::Record & get_input_type()
The definition of input record for vtk file format.
void write_vtk_field_data(OutputDataFieldVec &output_data_map)
void write_vtk_vtu(void)
This function write all scalar and vector data on nodes and elements to the VTK file (...
void write_vtk_data(OutputDataPtr output_data)
static const int registrar
Registrar of class to factory.
static Input::Type::Abstract & get_input_format_type()
The specification of output file format.
void fill_element_types_vector(std::vector< unsigned int > &data)
Fills the given vector with VTK element types indicators.
string main_output_basename_
Basename of main output file (without extension)
int write_head(void)
This function writes header of VTK (.pvd) file format.
string main_output_dir_
Main output file directory.
void write_vtk_element_data(void)
Write data on elements to the VTK file (.vtu)
#define LogOut()
Macro defining 'log' record of log.
VTKVariant
The declaration enumeration used for variant of file VTK format.
void open_stream(Stream &stream) const
int write_data(void)
This function write data to VTK (.pvd) file format for curent time.
ostringstream appended_data_
void write_vtk_vtu_tail(void)
Write tail of VTK file (.vtu)
This class is used for output data to VTK file format.
string parent_path() const
int write_tail(void)
This function writes tail of VTK (.pvd) file format.
~OutputVTK()
The destructor of this class. It writes tail of the file too.
Dedicated class for storing path to input and output files.
OutputVTK()
The constructor of this class. The head of file is written, when constructor is called.
#define ASSERT_PTR(ptr)
Definition of assert macro checking non-null pointer (PTR)
VTKVariant variant_type_
Output format (ascii, binary or binary compressed)
void write_vtk_node_data(void)
Write data on nodes to the VTK file (.vtu)
OutputDataFieldVec output_data_vec_[N_DISCRETE_SPACES]
#define WarningOut()
Macro defining 'warning' record of log.
std::shared_ptr< OutputDataBase > OutputDataPtr
bool enable_refinement_
Auxliary flag for refinement enabling, due to gmsh format.
void write_vtk_vtu_head(void)
Write header of VTK file (.vtu)
#define FLOW123D_FORCE_LINK_IN_CHILD(x)
#define ASSERT_EQ(a, b)
Definition of comparative assert macro (EQual)
static const Input::Type::Selection & get_input_type_variant()
The definition of input record for selection of variant of file format.
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.