29 using namespace
Input::Type;
32 return Record(
"vtk",
"Parameters of vtk output format.")
36 "Variant of output stream file format.")
39 "Parallel or serial version of file format.")
42 "Compression used in output stream file format.")
48 return Selection(
"VTK variant (ascii or binary)")
50 "ASCII variant of VTK file format")
52 "Binary variant of VTK file format (not supported yet)")
58 return Selection(
"Type of compression of VTK file format")
60 "Data in VTK file format are not compressed")
62 "Data in VTK file format are compressed using zlib (not supported yet)")
67 const int OutputVTK::registrar = Input::register_class< OutputVTK, const Input::Record & >(
"vtk") +
105 if(this->
rank != 0) {
112 << std::setw(6) << std::setfill(
'0') << this->
current_step 116 std::string frame_file_name = ss.str();
121 xprintf(
Err,
"Could not write output to the file: %s\n", frame_file_path.c_str());
131 this->
_base_file.precision(std::numeric_limits<double>::digits10);
135 this->
_base_file << scientific <<
"<DataSet timestep=\"" << (isfinite(this->
time)?this->
time:0)
136 <<
"\" group=\"\" part=\"0\" file=\"" << relative_frame_file <<
"\"/>" << endl;
140 xprintf(
MsgLog,
"%s: Writing output (frame %d) file %s ... ", __func__,
141 this->current_step, relative_frame_file.c_str());
162 OLD_ASSERT( main_file.substr( main_file.size() - 4) ==
".pvd" ,
"none");
163 unsigned int last_sep_pos=main_file.find_last_of(
DIR_DELIMITER);
179 file <<
"<?xml version=\"1.0\"?>" << endl;
182 file <<
"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">" << endl;
183 file <<
"<UnstructuredGrid>" << endl;
194 file <<
"<Points>" << endl;
196 file <<
"<DataArray type=\"Float64\" NumberOfComponents=\"3\" format=\"ascii\">" << endl;
200 file.precision(std::numeric_limits<double>::digits10);
204 file << scientific << node->getX() <<
" ";
205 file << scientific << node->getY() <<
" ";
206 file << scientific << node->getZ() <<
" ";
211 file << endl <<
"</DataArray>" << endl;
213 file <<
"</Points>" << endl;
227 file <<
"<Cells>" << endl;
229 file <<
"<DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">" << endl;
233 node = ele->node[li];
234 file << node->
aux <<
" ";
238 file << endl <<
"</DataArray>" << endl;
241 file <<
"<DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">" << endl;
259 file << endl <<
"</DataArray>" << endl;
262 file <<
"<DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">" << endl;
278 file << endl <<
"</DataArray>" << endl;
281 file <<
"</Cells>" << endl;
293 file <<
"<Points>" << endl;
295 file <<
"<DataArray type=\"Float64\" NumberOfComponents=\"3\" format=\"ascii\">" << endl;
297 file.precision(std::numeric_limits<double>::digits10);
300 node = ele->node[li];
302 file << scientific << node->
getX() <<
" ";
303 file << scientific << node->
getY() <<
" ";
304 file << scientific << node->
getZ() <<
" ";
308 file << endl <<
"</DataArray>" << endl;
310 file <<
"</Points>" << endl;
320 unsigned int li, tmp;
323 file <<
"<Cells>" << endl;
325 file <<
"<DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">" << endl;
335 file << endl <<
"</DataArray>" << endl;
338 file <<
"<DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">" << endl;
356 file << endl <<
"</DataArray>" << endl;
359 file <<
"<DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">" << endl;
375 file << endl <<
"</DataArray>" << endl;
378 file <<
"</Cells>" << endl;
390 file <<
"<DataArray type=\"Float64\" " 391 <<
"Name=\"" << data->output_field_name <<
"\" ";
392 if (data->n_elem_ > 1)
395 <<
"NumberOfComponents=\"" << data->n_elem_ <<
"\" ";
397 file <<
"format=\"ascii\">" 401 file.precision(std::numeric_limits<double>::digits10);
403 data->print_all(file);
405 file <<
"\n</DataArray>" << endl;
415 if (output_data_vec.empty())
return;
417 file <<
"Scalars=\"";
422 file <<
"Vectors=\"";
427 file <<
"Tensors=\"";
440 node_corner_data.insert(node_corner_data.end(),
443 if( ! node_corner_data.empty() ) {
445 file <<
"<PointData ";
456 file <<
"</PointData>" << endl;
466 if (data_map.empty())
return;
469 file <<
"<CellData ";
477 file <<
"</CellData>" << endl;
485 file <<
"</UnstructuredGrid>" << endl;
486 file <<
"</VTKFile>" << endl;
502 file <<
"<Piece NumberOfPoints=\"" << mesh->
n_nodes() <<
"\" NumberOfCells=\"" << mesh->
n_elements() <<
"\">" << endl;
517 file <<
"</Piece>" << endl;
521 file <<
"<Piece NumberOfPoints=\"" << mesh->
n_corners() <<
"\" NumberOfCells=\"" << mesh->
n_elements() <<
"\">" << endl;
536 file <<
"</Piece>" << endl;
548 if(this->
rank != 0) {
553 xprintf(
MsgLog,
"%s: Writing output file (head) %s ... ", __func__,
556 this->
_base_file <<
"<?xml version=\"1.0\"?>" << endl;
557 this->
_base_file <<
"<VTKFile type=\"Collection\" version=\"0.1\" byte_order=\"LittleEndian\">" << endl;
569 if(this->
rank != 0) {
574 xprintf(
MsgLog,
"%s: Writing output file (tail) %s ... ", __func__,
void write_vtk_discont_topology(void)
Write topology (connection of nodes) to the VTK file (.vtu)
#define FOR_ELEMENT_NODES(i, j)
static Input::Type::Abstract & get_input_format_type()
The specification of output file format.
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_vtu(void)
This function write all scalar and vector data on nodes and elements to the VTK file (...
#define FOR_ELEMENTS(_mesh_, __i)
static const int registrar
Registrar of class to factory.
#define INPUT_CHECK(i,...)
Debugging macros.
void write_vtk_geometry(void)
Write geometry (position of nodes) to the VTK file (.vtu)
string main_output_basename_
int write_head(void)
This function writes header of VTK (.pvd) file format.
void write_vtk_element_data(void)
Write data on elements to the VTK file (.vtu)
void write_vtk_discont_geometry(void)
Write geometry (position of nodes) to the VTK file (.vtu)
int write_data(void)
This function write data to VTK (.pvd) file format for curent time.
unsigned int n_elements() const
static const Input::Type::Selection & get_input_type_compression()
The definition of input record for selection of compression type.
void write_vtk_vtu_tail(void)
Write tail of VTK file (.vtu)
This class is used for output data to VTK file format.
int write_tail(void)
This function writes tail of VTK (.pvd) file format.
The class for outputting data during time.
~OutputVTK()
The destructor of this class. It writes tail of the file too.
#define FOR_NODES(_mesh_, i)
Dedicated class for storing path to input and output files.
void write_vtk_data_ascii(OutputDataFieldVec &output_data_map)
OutputVTK()
The constructor of this class. The head of file is written, when constructor is called.
void write_vtk_node_data(void)
Write data on nodes to the VTK file (.vtu)
OutputDataFieldVec output_data_vec_[N_DISCRETE_SPACES]
unsigned int n_nodes() const
std::shared_ptr< OutputDataBase > OutputDataPtr
void write_vtk_vtu_head(void)
Write header of VTK file (.vtu)
#define FLOW123D_FORCE_LINK_IN_CHILD(x)
static const Input::Type::Selection & get_input_type_variant()
The definition of input record for selection of variant of file format.
void write_vtk_topology(void)
Write topology (connection of nodes) to the VTK file (.vtu)
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.