37 using namespace Input::Type;
40 =
Record(
"vtk",
"Parameters of vtk output format.")
44 "Variant of output stream file format.")
47 "Parallel or serial version of file format.")
50 "Compression used in output stream file format.");
54 =
Selection(
"VTK variant (ascii or binary)")
56 "ASCII variant of VTK file format")
58 "Binary variant of VTK file format (not supported yet)");
62 =
Selection(
"Type of compression of VTK file format")
64 "Data in VTK file format are not compressed")
66 "Data in VTK file format are compressed using zlib (not supported yet)");
103 if(this->
rank != 0) {
110 << std::setw(6) << std::setfill(
'0') << this->
current_step
114 std::string frame_file_name = ss.str();
119 xprintf(
Err,
"Could not write output to the file: %s\n", frame_file_path.c_str());
129 this->
_base_file.precision(std::numeric_limits<double>::digits10);
133 this->
_base_file << scientific <<
"<DataSet timestep=\"" << (isfinite(this->
time)?this->
time:0)
134 <<
"\" group=\"\" part=\"0\" file=\"" << relative_frame_file <<
"\"/>" << endl;
138 xprintf(
MsgLog,
"%s: Writing output (frame %d) file %s ... ", __func__,
139 this->current_step, relative_frame_file.c_str());
160 ASSERT( main_file.substr( main_file.size() - 4) ==
".pvd" ,
"none");
161 unsigned int last_sep_pos=main_file.find_last_of(
DIR_DELIMITER);
178 file <<
"<?xml version=\"1.0\"?>" << endl;
181 file <<
"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">" << endl;
182 file <<
"<UnstructuredGrid>" << endl;
193 file <<
"<Points>" << endl;
195 file <<
"<DataArray type=\"Float64\" NumberOfComponents=\"3\" format=\"ascii\">" << endl;
199 file.precision(std::numeric_limits<double>::digits10);
203 file << scientific << node->getX() <<
" ";
204 file << scientific << node->getY() <<
" ";
205 file << scientific << node->getZ() <<
" ";
210 file << endl <<
"</DataArray>" << endl;
212 file <<
"</Points>" << endl;
226 file <<
"<Cells>" << endl;
228 file <<
"<DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">" << endl;
232 node = ele->node[li];
233 file << node->
aux <<
" ";
237 file << endl <<
"</DataArray>" << endl;
240 file <<
"<DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">" << endl;
258 file << endl <<
"</DataArray>" << endl;
261 file <<
"<DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">" << endl;
277 file << endl <<
"</DataArray>" << endl;
280 file <<
"</Cells>" << endl;
292 file <<
"<Points>" << endl;
294 file <<
"<DataArray type=\"Float64\" NumberOfComponents=\"3\" format=\"ascii\">" << endl;
296 file.precision(std::numeric_limits<double>::digits10);
299 node = ele->node[li];
301 file << scientific << node->
getX() <<
" ";
302 file << scientific << node->
getY() <<
" ";
303 file << scientific << node->
getZ() <<
" ";
307 file << endl <<
"</DataArray>" << endl;
309 file <<
"</Points>" << endl;
319 unsigned int li, tmp;
322 file <<
"<Cells>" << endl;
324 file <<
"<DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">" << endl;
334 file << endl <<
"</DataArray>" << endl;
337 file <<
"<DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">" << endl;
355 file << endl <<
"</DataArray>" << endl;
358 file <<
"<DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">" << endl;
374 file << endl <<
"</DataArray>" << endl;
377 file <<
"</Cells>" << endl;
389 file <<
"<DataArray type=\"Float64\" "
390 <<
"Name=\"" << data->output_field_name <<
"\" ";
391 if (data->n_elem_ > 1)
394 <<
"NumberOfComponents=\"" << data->n_elem_ <<
"\" ";
396 file <<
"format=\"ascii\">"
400 file.precision(std::numeric_limits<double>::digits10);
402 data->print_all(file);
404 file <<
"\n</DataArray>" << endl;
414 if (output_data_vec.empty())
return;
416 file <<
"Scalars=\"";
421 file <<
"Vectors=\"";
426 file <<
"Tensors=\"";
439 node_corner_data.insert(node_corner_data.end(),
442 if( ! node_corner_data.empty() ) {
444 file <<
"<PointData ";
455 file <<
"</PointData>" << endl;
465 if (data_map.empty())
return;
468 file <<
"<CellData ";
476 file <<
"</CellData>" << endl;
484 file <<
"</UnstructuredGrid>" << endl;
485 file <<
"</VTKFile>" << endl;
501 file <<
"<Piece NumberOfPoints=\"" << mesh->
n_nodes() <<
"\" NumberOfCells=\"" << mesh->
n_elements() <<
"\">" << endl;
516 file <<
"</Piece>" << endl;
520 file <<
"<Piece NumberOfPoints=\"" << mesh->
n_corners() <<
"\" NumberOfCells=\"" << mesh->
n_elements() <<
"\">" << endl;
535 file <<
"</Piece>" << endl;
547 if(this->
rank != 0) {
552 xprintf(
MsgLog,
"%s: Writing output file (head) %s ... ", __func__,
555 this->
_base_file <<
"<?xml version=\"1.0\"?>" << endl;
556 this->
_base_file <<
"<VTKFile type=\"Collection\" version=\"0.1\" byte_order=\"LittleEndian\">" << endl;
568 if(this->
rank != 0) {
573 xprintf(
MsgLog,
"%s: Writing output file (tail) %s ... ", __func__,
static Input::Type::AbstractRecord input_format_type
The specification of output file format.
void write_vtk_discont_topology(void)
Write topology (connection of nodes) to the VTK file (.vtu)
#define FOR_ELEMENT_NODES(i, j)
void fix_main_file_extension(std::string extension)
static Input::Type::Selection input_type_variant
The definition of input record for selection of variant of 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)
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)
static Input::Type::Record input_type
The definition of input record for vtk file format.
int write_data(void)
This function write data to VTK (.pvd) file format for curent time.
unsigned int n_elements() const
static Input::Type::Selection 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)
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)
#define INPUT_CHECK(i,...)
Debugging macros.
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)
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.