Flow123d  master-ae9ffcc
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
OutputVTK Class Reference

This class is used for output data to VTK file format. More...

#include <output_vtk.hh>

Inheritance diagram for OutputVTK:
Inheritance graph
[legend]
Collaboration diagram for OutputVTK:
Collaboration graph
[legend]

Public Types

typedef OutputTime FactoryBaseType
 
typedef uLong zlib_ulong
 
- Public Types inherited from OutputTime
enum  DiscreteSpace {
  NODE_DATA = 0 , CORNER_DATA = 1 , ELEM_DATA = 2 , NATIVE_DATA = 3 ,
  MESH_DEFINITION = 9 , UNDEFINED = 10
}
 
typedef std::array< bool, 4 > DiscreteSpaceFlags
 
typedef std::shared_ptr< ElementDataCacheBaseOutputDataPtr
 
typedef std::vector< OutputDataPtrOutputDataFieldVec
 
typedef std::pair< std::string, unsigned int > FieldInterpolationData
 pair of field name and shape (= Scalar 1, Vector 3, Tensor 9) More...
 
typedef std::map< DiscreteSpace, std::vector< FieldInterpolationData > > InterpolationMap
 

Public Member Functions

 OutputVTK ()
 The constructor of this class. The head of file is written, when constructor is called. More...
 
 ~OutputVTK ()
 The destructor of this class. It writes tail of the file too. More...
 
int write_data (void)
 This function write data to VTK (.pvd) file format for curent time. More...
 
int write_head (void)
 This function writes header of VTK (.pvd) file format. More...
 
int write_tail (void)
 This function writes tail of VTK (.pvd) file format. More...
 
void init_from_input (const std::string &equation_name, const Input::Record &in_rec, const std::shared_ptr< TimeUnitConversion > &time_unit_conv) override
 Override OutputTime::init_from_input. More...
 
- Public Member Functions inherited from OutputTime
 OutputTime ()
 Default constructor. Only for testing. More...
 
void set_stream_precision (std::ofstream &stream)
 
virtual ~OutputTime ()
 Destructor of OutputTime. It doesn't do anything, because all necessary destructors will be called in destructor of Output. More...
 
Input::Iterator< Input::Arrayget_time_set_array ()
 
Input::Iterator< Input::Recordget_output_mesh_record ()
 
void write_time_frame ()
 
std::shared_ptr< Observeobserve (Mesh *mesh)
 
void clear_data (void)
 Clear data for output computed by method compute_field_data. More...
 
bool is_output_data_caches_init ()
 
bool enable_refinement ()
 Return auxiliary flag enable_refinement_. More...
 
virtual void set_output_data_caches (std::shared_ptr< OutputMeshBase > mesh_ptr)
 
std::shared_ptr< OutputMeshBaseget_output_mesh_ptr ()
 
void update_time (double field_time)
 
template<typename T >
OutputDataPtr prepare_compute_data (std::string field_name, DiscreteSpace space_type, unsigned int n_rows, unsigned int n_cols, std::string fe_type="", unsigned int n_dofs_per_element=1)
 
bool is_parallel () const
 
int rank () const
 
int n_proc () const
 
double registered_time () const
 Getter to registered time. More...
 

Static Public Member Functions

static const Input::Type::Recordget_input_type ()
 The definition of input record for vtk file format. More...
 
static const Input::Type::Selectionget_input_type_variant ()
 The definition of input record for selection of variant of file format. More...
 
- Static Public Member Functions inherited from OutputTime
static const Input::Type::Recordget_input_type ()
 The specification of output stream. More...
 
static Input::Type::Abstractget_input_format_type ()
 The specification of output file format. More...
 
static bool discrete_flags_defined (DiscreteSpaceFlags &dsf)
 Check if at least one of discrete space flag is set to true. More...
 
static DiscreteSpaceFlags empty_discrete_flags ()
 Check if at least one of discrete space flag is set to true. More...
 
static void set_discrete_flag (DiscreteSpaceFlags &dsf, DiscreteSpace d_space)
 
static std::shared_ptr< OutputTimecreate_output_stream (const std::string &equation_name, const Input::Record &in_rec, const std::shared_ptr< TimeUnitConversion > &time_unit_conv)
 This method delete all object instances of class OutputTime stored in output_streams vector. More...
 

Protected Types

enum  VTKVariant { VARIANT_ASCII = 0 , VARIANT_BINARY_UNCOMPRESSED = 1 , VARIANT_BINARY_ZLIB = 2 }
 The declaration enumeration used for variant of file VTK format. More...
 
enum  VTKElemType {
  VTK_VERTEX = 1 , VTK_POLY_VERTEX = 2 , VTK_LINE = 3 , VTK_POLY_LINE = 4 ,
  VTK_TRIANGLE = 5 , VTK_TRIANGLE_STRIP = 6 , VTK_POLYGON = 7 , VTK_PIXEL = 8 ,
  VTK_QUAD = 9 , VTK_TETRA = 10 , VTK_VOXEL = 11 , VTK_HEXAHEDRON = 12 ,
  VTK_WEDGE = 13 , VTK_PYRAMID = 14 , VTK_QUADRIC_EDGE = 21 , VTK_QUADRIC_TRIANGLE = 22 ,
  VTK_QUADRIC_QUAD = 23 , VTK_QUADRIC_TETRA = 24 , VTK_QUADRIC_HEXAHEDRON = 25
}
 
enum  VTKElemSize { VTK_LINE_SIZE = 2 , VTK_TRIANGLE_SIZE = 3 , VTK_TETRA_SIZE = 4 }
 

Protected Member Functions

string form_vtu_filename_ (string basename, int i_step, int rank)
 
void write_vtk_vtu_head (void)
 Write header of VTK file (.vtu) More...
 
std::shared_ptr< ElementDataCache< unsigned int > > fill_element_types_data ()
 Fills the data cache with VTK element types indicators. More...
 
void write_vtk_field_data (OutputDataFieldVec &output_data_map)
 
void write_vtk_data (OutputDataPtr output_data, unsigned int start=0)
 
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. More...
 
void write_vtk_node_data (void)
 Write data on nodes to the VTK file (.vtu) More...
 
void write_vtk_element_data (void)
 Write data on elements to the VTK file (.vtu) More...
 
void write_vtk_native_data (void)
 Write native data (part of our own data skipped by Paraview) to the VTK file (.vtu) More...
 
void write_vtk_vtu_tail (void)
 Write tail of VTK file (.vtu) More...
 
void write_vtk_vtu (void)
 This function write all scalar and vector data on nodes and elements to the VTK file (.vtu) More...
 
void make_subdirectory ()
 
void compress_data (stringstream &uncompressed_stream, stringstream &compressed_stream)
 
- Protected Member Functions inherited from OutputTime
void fix_main_file_extension (std::string extension)
 
int get_parallel_current_step ()
 Return unique value current step for parallel or serial output. More...
 
void gather_output_data (void)
 Collect data of individual processes to serial data on master (0th) process. More...
 

Protected Attributes

ofstream _data_file
 
ostringstream appended_data_
 
string subdir_name_
 
string main_output_basename_
 Basename of main output file (without extension) More...
 
string main_output_dir_
 Main output file directory. More...
 
VTKVariant variant_type_
 Output format (ascii, binary or binary compressed) More...
 
- Protected Attributes inherited from OutputTime
int rank_
 
int n_proc_
 
OutputDataFieldVec output_data_vec_ [N_DISCRETE_SPACES]
 
int current_step
 
double registered_time_
 
double write_time
 
Input::Record input_record_
 
ofstream _base_file
 
FilePath _base_filename
 
std::string equation_name_
 
int precision_
 
std::shared_ptr< OutputMeshBaseoutput_mesh_
 Output mesh. More...
 
std::shared_ptr< Observeobserve_
 
bool enable_refinement_
 Auxiliary flag for refinement enabling, due to gmsh format. More...
 
bool parallel_
 Parallel or serial version of file format (parallel has effect only for VTK) More...
 
std::shared_ptr< TimeUnitConversiontime_unit_converter
 Time unit conversion object from the equation time governor. More...
 
std::shared_ptr< ElementDataCache< double > > nodes_
 Vector of node coordinates. [spacedim x n_nodes]. More...
 
std::shared_ptr< ElementDataCache< unsigned int > > connectivity_
 Vector maps the nodes to their coordinates in vector nodes_. More...
 
std::shared_ptr< ElementDataCache< unsigned int > > offsets_
 Vector of offsets of node indices of elements. Maps elements to their nodes in connectivity_. More...
 

Static Protected Attributes

static const int registrar
 Registrar of class to factory. More...
 
static const std::vector< std::string > formats = { "ascii", "appended", "appended" }
 Formats of DataArray section. More...
 

Additional Inherited Members

- Static Public Attributes inherited from OutputTime
static const unsigned int N_DISCRETE_SPACES = 4
 

Detailed Description

This class is used for output data to VTK file format.

Definition at line 44 of file output_vtk.hh.

Member Typedef Documentation

◆ FactoryBaseType

Definition at line 47 of file output_vtk.hh.

◆ zlib_ulong

typedef uLong OutputVTK::zlib_ulong

Definition at line 48 of file output_vtk.hh.

Member Enumeration Documentation

◆ VTKElemSize

enum OutputVTK::VTKElemSize
protected
Enumerator
VTK_LINE_SIZE 
VTK_TRIANGLE_SIZE 
VTK_TETRA_SIZE 

Definition at line 130 of file output_vtk.hh.

◆ VTKElemType

enum OutputVTK::VTKElemType
protected
Enumerator
VTK_VERTEX 
VTK_POLY_VERTEX 
VTK_LINE 
VTK_POLY_LINE 
VTK_TRIANGLE 
VTK_TRIANGLE_STRIP 
VTK_POLYGON 
VTK_PIXEL 
VTK_QUAD 
VTK_TETRA 
VTK_VOXEL 
VTK_HEXAHEDRON 
VTK_WEDGE 
VTK_PYRAMID 
VTK_QUADRIC_EDGE 
VTK_QUADRIC_TRIANGLE 
VTK_QUADRIC_QUAD 
VTK_QUADRIC_TETRA 
VTK_QUADRIC_HEXAHEDRON 

Definition at line 107 of file output_vtk.hh.

◆ VTKVariant

enum OutputVTK::VTKVariant
protected

The declaration enumeration used for variant of file VTK format.

Enumerator
VARIANT_ASCII 
VARIANT_BINARY_UNCOMPRESSED 
VARIANT_BINARY_ZLIB 

Definition at line 100 of file output_vtk.hh.

Constructor & Destructor Documentation

◆ OutputVTK()

OutputVTK::OutputVTK ( )

The constructor of this class. The head of file is written, when constructor is called.

Definition at line 73 of file output_vtk.cc.

◆ ~OutputVTK()

OutputVTK::~OutputVTK ( )

The destructor of this class. It writes tail of the file too.

Definition at line 80 of file output_vtk.cc.

Member Function Documentation

◆ compress_data()

void OutputVTK::compress_data ( stringstream &  uncompressed_stream,
stringstream &  compressed_stream 
)
protected

Compress data stored in uncompressed_stream to compressed_stream.

Use ZLib compression.

Definition at line 319 of file output_vtk.cc.

◆ fill_element_types_data()

std::shared_ptr< ElementDataCache< unsigned int > > OutputVTK::fill_element_types_data ( )
protected

Fills the data cache with VTK element types indicators.

Definition at line 244 of file output_vtk.cc.

◆ form_vtu_filename_()

string OutputVTK::form_vtu_filename_ ( string  basename,
int  i_step,
int  rank 
)
protected

Used internally by write_data.

Definition at line 115 of file output_vtk.cc.

◆ get_input_type()

const Record & OutputVTK::get_input_type ( )
static

The definition of input record for vtk file format.

Definition at line 38 of file output_vtk.cc.

◆ get_input_type_variant()

const Selection & OutputVTK::get_input_type_variant ( )
static

The definition of input record for selection of variant of file format.

Definition at line 51 of file output_vtk.cc.

Here is the caller graph for this function:

◆ init_from_input()

void OutputVTK::init_from_input ( const std::string &  equation_name,
const Input::Record in_rec,
const std::shared_ptr< TimeUnitConversion > &  time_unit_conv 
)
overridevirtual

Override OutputTime::init_from_input.

Reimplemented from OutputTime.

Definition at line 90 of file output_vtk.cc.

◆ make_subdirectory()

void OutputVTK::make_subdirectory ( )
protected

Set appropriate file path substrings. Make subdirectory for VTU time frames.

Definition at line 208 of file output_vtk.cc.

◆ write_data()

int OutputVTK::write_data ( void  )
virtual

This function write data to VTK (.pvd) file format for curent time.

TODO:

  • common creation of the VTU filename
  • names of parallel file: <base name>_<frame>.<rank>.vtu
  • for serial case use rank=0

Implements OutputTime.

Definition at line 139 of file output_vtk.cc.

◆ write_head()

int OutputVTK::write_head ( void  )

This function writes header of VTK (.pvd) file format.

Definition at line 577 of file output_vtk.cc.

◆ write_tail()

int OutputVTK::write_tail ( void  )

This function writes tail of VTK (.pvd) file format.

Definition at line 596 of file output_vtk.cc.

◆ write_vtk_data()

void OutputVTK::write_vtk_data ( OutputTime::OutputDataPtr  output_data,
unsigned int  start = 0 
)
protected

Write output data stored in OutputData vector to output stream

Definition at line 274 of file output_vtk.cc.

◆ write_vtk_data_names()

void OutputVTK::write_vtk_data_names ( ofstream &  file,
OutputDataFieldVec output_data_map 
)
protected

Write names of data sets in output_data vector that have value type equal to type. Output is done into stream file.

Definition at line 395 of file output_vtk.cc.

◆ write_vtk_element_data()

void OutputVTK::write_vtk_element_data ( void  )
protected

Write data on elements to the VTK file (.vtu)

Definition at line 450 of file output_vtk.cc.

◆ write_vtk_field_data()

void OutputVTK::write_vtk_field_data ( OutputDataFieldVec output_data_map)
protected

Write registered data of all components of given Field to output stream

Definition at line 385 of file output_vtk.cc.

◆ write_vtk_native_data()

void OutputVTK::write_vtk_native_data ( void  )
protected

Write native data (part of our own data skipped by Paraview) to the VTK file (.vtu)

Tags of native data are subtags of 'Flow123dData' tag, that is subtag of 'Piece' tag

Definition at line 470 of file output_vtk.cc.

◆ write_vtk_node_data()

void OutputVTK::write_vtk_node_data ( void  )
protected

Write data on nodes to the VTK file (.vtu)

Definition at line 423 of file output_vtk.cc.

◆ write_vtk_vtu()

void OutputVTK::write_vtk_vtu ( void  )
protected

This function write all scalar and vector data on nodes and elements to the VTK file (.vtu)

Definition at line 535 of file output_vtk.cc.

◆ write_vtk_vtu_head()

void OutputVTK::write_vtk_vtu_head ( void  )
protected

Write header of VTK file (.vtu)

Definition at line 224 of file output_vtk.cc.

◆ write_vtk_vtu_tail()

void OutputVTK::write_vtk_vtu_tail ( void  )
protected

Write tail of VTK file (.vtu)

Definition at line 519 of file output_vtk.cc.

Member Data Documentation

◆ _data_file

ofstream OutputVTK::_data_file
protected

Data output stream (could be same as base_file)

Definition at line 219 of file output_vtk.hh.

◆ appended_data_

ostringstream OutputVTK::appended_data_
protected

Stream of appended data (used only for binary appended output)

Definition at line 224 of file output_vtk.hh.

◆ formats

const std::vector< std::string > OutputVTK::formats = { "ascii", "appended", "appended" }
staticprotected

Formats of DataArray section.

Definition at line 140 of file output_vtk.hh.

◆ main_output_basename_

string OutputVTK::main_output_basename_
protected

Basename of main output file (without extension)

Definition at line 232 of file output_vtk.hh.

◆ main_output_dir_

string OutputVTK::main_output_dir_
protected

Main output file directory.

Definition at line 235 of file output_vtk.hh.

◆ registrar

const int OutputVTK::registrar
staticprotected
Initial value:
= Input::register_class< OutputVTK >("vtk") +
unsigned int size() const
Returns number of keys in the Record.
Definition: type_record.hh:602
static const Input::Type::Record & get_input_type()
The definition of input record for vtk file format.
Definition: output_vtk.cc:38

Registrar of class to factory.

Definition at line 137 of file output_vtk.hh.

◆ subdir_name_

string OutputVTK::subdir_name_
protected

Path to time frame VTU data subdirectory

Definition at line 229 of file output_vtk.hh.

◆ variant_type_

VTKVariant OutputVTK::variant_type_
protected

Output format (ascii, binary or binary compressed)

Definition at line 238 of file output_vtk.hh.


The documentation for this class was generated from the following files: