Flow123d  3.9.0-960b954f9
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
OutputTime Class Referenceabstract

The class for outputting data during time. More...

#include <output_time.hh>

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

Public Types

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

 OutputTime ()
 Default constructor. Only for testing. More...
 
virtual void init_from_input (const std::string &equation_name, const Input::Record &in_rec, const std::shared_ptr< TimeUnitConversion > &time_unit_conv)
 Constructor of OutputTime object. It opens base file for writing. 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 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...
 

Static Public Attributes

static const unsigned int N_DISCRETE_SPACES = 4
 

Protected Member Functions

void fix_main_file_extension (std::string extension)
 
int get_parallel_current_step ()
 Return unique value current step for parallel or serial output. More...
 
virtual int write_data (void)=0
 Virtual method for writing data to output file. More...
 
void gather_output_data (void)
 Collect data of individual processes to serial data on master (0th) process. More...
 

Protected Attributes

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...
 

Detailed Description

The class for outputting data during time.

This class is descendant of Output class. This class is used for outputting data varying in time. Own output to specific file formats is done at other places to. See output_vtk.cc and output_msh.cc.

Definition at line 51 of file output_time.hh.

Member Typedef Documentation

◆ DiscreteSpaceFlags

typedef std::array<bool,4> OutputTime::DiscreteSpaceFlags

Holds flags if different output types are switched on / switched off.

Output types are in order: NODE_DATA=0, CORNER_DATA=1, ELEM_DATA=2, NATIVE_DATA=3

Definition at line 122 of file output_time.hh.

◆ FieldInterpolationData

typedef std::pair< std::string, unsigned int > OutputTime::FieldInterpolationData

pair of field name and shape (= Scalar 1, Vector 3, Tensor 9)

Definition at line 148 of file output_time.hh.

◆ InterpolationMap

Definition at line 149 of file output_time.hh.

◆ OutputDataFieldVec

Definition at line 145 of file output_time.hh.

◆ OutputDataPtr

Map field name to its OutputData object.

Definition at line 144 of file output_time.hh.

Member Enumeration Documentation

◆ DiscreteSpace

Enumerator
NODE_DATA 
CORNER_DATA 
ELEM_DATA 
NATIVE_DATA 
MESH_DEFINITION 
UNDEFINED 

Definition at line 108 of file output_time.hh.

Constructor & Destructor Documentation

◆ OutputTime()

OutputTime::OutputTime ( )

Default constructor. Only for testing.

Definition at line 72 of file output_time.cc.

◆ ~OutputTime()

OutputTime::~OutputTime ( )
virtual

Destructor of OutputTime. It doesn't do anything, because all necessary destructors will be called in destructor of Output.

Definition at line 109 of file output_time.cc.

Member Function Documentation

◆ clear_data()

void OutputTime::clear_data ( void  )

Clear data for output computed by method compute_field_data.

Definition at line 249 of file output_time.cc.

Here is the caller graph for this function:

◆ create_output_stream()

std::shared_ptr< OutputTime > OutputTime::create_output_stream ( const std::string &  equation_name,
const Input::Record in_rec,
const std::shared_ptr< TimeUnitConversion > &  time_unit_conv 
)
static

This method delete all object instances of class OutputTime stored in output_streams vector.

This method tries to create new instance of OutputTime according record in configuration file.

Definition at line 187 of file output_time.cc.

Here is the caller graph for this function:

◆ discrete_flags_defined()

static bool OutputTime::discrete_flags_defined ( DiscreteSpaceFlags dsf)
inlinestatic

Check if at least one of discrete space flag is set to true.

Definition at line 125 of file output_time.hh.

◆ empty_discrete_flags()

static DiscreteSpaceFlags OutputTime::empty_discrete_flags ( )
inlinestatic

Check if at least one of discrete space flag is set to true.

Definition at line 130 of file output_time.hh.

Here is the caller graph for this function:

◆ enable_refinement()

bool OutputTime::enable_refinement ( )
inline

Return auxiliary flag enable_refinement_.

Definition at line 188 of file output_time.hh.

◆ fix_main_file_extension()

void OutputTime::fix_main_file_extension ( std::string  extension)
protected

Change main filename to have prescribed extension.

Definition at line 153 of file output_time.cc.

◆ gather_output_data()

void OutputTime::gather_output_data ( void  )
protected

Collect data of individual processes to serial data on master (0th) process.

Definition at line 265 of file output_time.cc.

Here is the caller graph for this function:

◆ get_input_format_type()

IT::Abstract & OutputTime::get_input_format_type ( )
static

The specification of output file format.

Definition at line 65 of file output_time.cc.

Here is the caller graph for this function:

◆ get_input_type()

const IT::Record & OutputTime::get_input_type ( )
static

The specification of output stream.

Returns
This variable defines record for output stream

Definition at line 38 of file output_time.cc.

Here is the caller graph for this function:

◆ get_output_mesh_ptr()

std::shared_ptr< OutputMeshBase > OutputTime::get_output_mesh_ptr ( )

Get shared pointer of output_mesh_.

Definition at line 141 of file output_time.cc.

◆ get_output_mesh_record()

Input::Iterator< Input::Record > OutputTime::get_output_mesh_record ( )

Return the input record for the output mesh of the output stream.

Definition at line 128 of file output_time.cc.

◆ get_parallel_current_step()

int OutputTime::get_parallel_current_step ( )
protected

Return unique value current step for parallel or serial output.

Respect value of parallel_ flag:

  • for serial output return actual value of current_step
  • for parallel output take unique value with account rank and number of processes

Definition at line 258 of file output_time.cc.

◆ get_time_set_array()

Input::Iterator< Input::Array > OutputTime::get_time_set_array ( )

Return the input array for the output time set of the output stream.

Definition at line 123 of file output_time.cc.

◆ init_from_input()

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

Constructor of OutputTime object. It opens base file for writing.

Parameters
[in]equation_nameThe name of equation, used for forming output file name.
[in]in_recThe reference on the input record.
[in]time_unit_convTime unit convertor (converts time unit of the output data).

Reimplemented in OutputVTK.

Definition at line 84 of file output_time.cc.

Here is the caller graph for this function:

◆ is_output_data_caches_init()

bool OutputTime::is_output_data_caches_init ( )
inline

Return if shared pointer to output data caches are created.

Definition at line 183 of file output_time.hh.

◆ is_parallel()

bool OutputTime::is_parallel ( ) const
inline

Return if output is serial or parallel

Definition at line 231 of file output_time.hh.

◆ n_proc()

int OutputTime::n_proc ( ) const
inline

Return number of processes

Definition at line 245 of file output_time.hh.

◆ observe()

std::shared_ptr< Observe > OutputTime::observe ( Mesh mesh)

Getter of the observe object.

Definition at line 234 of file output_time.cc.

◆ prepare_compute_data()

template<typename T >
OutputTime::OutputDataPtr OutputTime::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 
)

Prepare data for computing field values.

Method:

  • compute discontinuous mesh if CORNER_DATA is calculated
  • find and return ElementDataCache of given field_name, create its if doesn't exist
Parameters
field_nameQuantity name of founding ElementDataCache
space_typeOutput discrete space
n_rowsCount of rows of data cache (used only if new cache is created)
n_colsCount of columns of data cache (used only if new cache is created)
sizeSize of data cache (used only if new cache is created and only for native data)
fe_typeFinite element type (used only for native data)
n_dofs_per_elementNumber of DOFs per element (used only for native data)

supposing that everything is output at the first step !

  • if(current_step == 0) push_back all the non-existing fields shared<ElementDataCache<T>>
  • else just set the correct shared<ElementDataCache<T>>
  • when clearing output_data_vec, set all to shared<DummyElementCache>
  • this can be done in many equations sharing the same OutputTime stream

Definition at line 78 of file output_time.impl.hh.

◆ rank()

int OutputTime::rank ( ) const
inline

Return rank of actual process

Definition at line 238 of file output_time.hh.

◆ registered_time()

double OutputTime::registered_time ( ) const
inline

Getter to registered time.

Definition at line 250 of file output_time.hh.

◆ set_discrete_flag()

static void OutputTime::set_discrete_flag ( DiscreteSpaceFlags dsf,
DiscreteSpace  d_space 
)
inlinestatic

Definition at line 135 of file output_time.hh.

Here is the caller graph for this function:

◆ set_output_data_caches()

void OutputTime::set_output_data_caches ( std::shared_ptr< OutputMeshBase mesh_ptr)
virtual

Set shared pointers of output data caches.

Set shared pointer of output_mesh_ (temporary solution).

Reimplemented in OutputMSH.

Definition at line 133 of file output_time.cc.

Here is the caller graph for this function:

◆ set_stream_precision()

void OutputTime::set_stream_precision ( std::ofstream &  stream)

Common method to set scientific format and precision for output of floating point values to ASCII streams.

Definition at line 102 of file output_time.cc.

◆ update_time()

void OutputTime::update_time ( double  field_time)

Update the last time is actual time is less than field_time

Definition at line 146 of file output_time.cc.

◆ write_data()

virtual int OutputTime::write_data ( void  )
protectedpure virtual

Virtual method for writing data to output file.

Implemented in OutputVTK, and OutputMSH.

Here is the caller graph for this function:

◆ write_time_frame()

void OutputTime::write_time_frame ( )

Write all data registered as a new time frame.

Definition at line 203 of file output_time.cc.

Member Data Documentation

◆ _base_file

ofstream OutputTime::_base_file
protected

Base output stream

Definition at line 322 of file output_time.hh.

◆ _base_filename

FilePath OutputTime::_base_filename
protected

Name of base output file

Definition at line 327 of file output_time.hh.

◆ connectivity_

std::shared_ptr<ElementDataCache<unsigned int> > OutputTime::connectivity_
protected

Vector maps the nodes to their coordinates in vector nodes_.

Definition at line 357 of file output_time.hh.

◆ current_step

int OutputTime::current_step
protected

Current step

Definition at line 302 of file output_time.hh.

◆ enable_refinement_

bool OutputTime::enable_refinement_
protected

Auxiliary flag for refinement enabling, due to gmsh format.

Definition at line 346 of file output_time.hh.

◆ equation_name_

std::string OutputTime::equation_name_
protected

Name of the equation owning the output stream. Usually the balance equation. Used for forming default output file name and the name of observe output file.

Definition at line 333 of file output_time.hh.

◆ input_record_

Input::Record OutputTime::input_record_
protected

Record for current output stream

Definition at line 317 of file output_time.hh.

◆ N_DISCRETE_SPACES

const unsigned int OutputTime::N_DISCRETE_SPACES = 4
static

Types of reference data

NATIVE_DATA represents output of FieldFE in our own format, Paraview ignores this format.

Definition at line 107 of file output_time.hh.

◆ n_proc_

int OutputTime::n_proc_
protected

Cached MPI number of processes (is tested in methods)

Definition at line 291 of file output_time.hh.

◆ nodes_

std::shared_ptr<ElementDataCache<double> > OutputTime::nodes_
protected

Vector of node coordinates. [spacedim x n_nodes].

Definition at line 355 of file output_time.hh.

◆ observe_

std::shared_ptr<Observe> OutputTime::observe_
protected

Definition at line 343 of file output_time.hh.

◆ offsets_

std::shared_ptr<ElementDataCache<unsigned int> > OutputTime::offsets_
protected

Vector of offsets of node indices of elements. Maps elements to their nodes in connectivity_.

Definition at line 359 of file output_time.hh.

◆ output_data_vec_

OutputDataFieldVec OutputTime::output_data_vec_[N_DISCRETE_SPACES]
protected

Registered output data. Single map for every value of DiscreteSpace corresponding to nodes, elements and corners.

Definition at line 297 of file output_time.hh.

◆ output_mesh_

std::shared_ptr<OutputMeshBase> OutputTime::output_mesh_
protected

Output mesh.

Definition at line 341 of file output_time.hh.

◆ parallel_

bool OutputTime::parallel_
protected

Parallel or serial version of file format (parallel has effect only for VTK)

Definition at line 349 of file output_time.hh.

◆ precision_

int OutputTime::precision_
protected

Number of decimal digits used for output of double values.

Definition at line 338 of file output_time.hh.

◆ rank_

int OutputTime::rank_
protected

Cached MPI rank of process (is tested in methods)

Definition at line 286 of file output_time.hh.

◆ registered_time_

double OutputTime::registered_time_
protected

The newest time of registered data

Definition at line 307 of file output_time.hh.

◆ time_unit_converter

std::shared_ptr<TimeUnitConversion> OutputTime::time_unit_converter
protected

Time unit conversion object from the equation time governor.

Definition at line 352 of file output_time.hh.

◆ write_time

double OutputTime::write_time
protected

The last time, when data was wrote to this stream

Definition at line 312 of file output_time.hh.


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