Flow123d  release_3.0.0-680-gbed5aba
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Attributes | List of all members
ElementDataCache< T > Class Template Reference

#include <element_data_cache.hh>

Inheritance diagram for ElementDataCache< T >:
Inheritance graph
[legend]
Collaboration diagram for ElementDataCache< T >:
Collaboration graph
[legend]

Public Types

typedef std::shared_ptr< std::vector< T > > ComponentDataPtr
 
typedef std::vector< ComponentDataPtrCacheData
 
- Public Types inherited from ElementDataCacheBase
enum  NumCompValueType { N_SCALAR = 1, N_VECTOR = 3, N_TENSOR = 9 }
 
enum  VTKValueType {
  VTK_INT8, VTK_UINT8, VTK_INT16, VTK_UINT16,
  VTK_INT32, VTK_UINT32, VTK_FLOAT32, VTK_FLOAT64
}
 Types of VTK value. More...
 

Public Member Functions

 ElementDataCache ()
 Default constructor. More...
 
 ElementDataCache (std::string field_name, double time, unsigned int size_of_cache, unsigned int row_vec_size)
 Constructor of input ElementDataCache (allow read data from GMSH or VTK file) More...
 
 ElementDataCache (std::string field_name, unsigned int n_rows, unsigned int n_cols, unsigned int size)
 Constructor of output ElementDataCache (allow write data) More...
 
virtual ~ElementDataCache () override
 Destructor of ElementDataCache. More...
 
ComponentDataPtr get_component_data (unsigned int component_idx)
 Return vector of element data for get component. More...
 
void read_ascii_data (Tokenizer &tok, unsigned int n_components, unsigned int i_row) override
 Implements ElementDataCacheBase::read_ascii_data. More...
 
void read_binary_data (std::istream &data_stream, unsigned int n_components, unsigned int i_row) override
 Implements ElementDataCacheBase::read_binary_data. More...
 
void print_ascii (ostream &out_stream, unsigned int idx) override
 
void print_ascii_all (ostream &out_stream) override
 Print all data stored in output data ro ascii format. More...
 
void print_binary_all (ostream &out_stream, bool print_data_size=true) override
 Print all data stored in output data to appended binary format. More...
 
void print_all_yaml (ostream &out_stream, unsigned int precision) override
 
void store_value (unsigned int idx, const T *value)
 
void add (unsigned int idx, const T *value)
 
void zero (unsigned int idx)
 
void normalize (unsigned int idx, unsigned int divisor)
 
void get_min_max_range (double &min, double &max) override
 
CheckResult check_values (double default_val, double lower_bound, double upper_bound)
 
void scale_data (double coef)
 
T & operator[] (unsigned int i)
 Access i-th element in the data vector of 0th component. More...
 
 TYPEDEF_ERR_INFO (EI_FieldName, std::string)
 
 DECLARE_EXCEPTION (ExcOutputVariableVector,<< "Can not output field "<< EI_FieldName::qval<< " returning variable size vectors. Try convert to MultiField.\n")
 
- Public Member Functions inherited from ElementDataCacheBase
 ElementDataCacheBase ()
 Constructor. More...
 
virtual ~ElementDataCacheBase ()
 Destructor. More...
 
double get_time ()
 Getter for time of cache. More...
 
std::string field_input_name ()
 Getter for quantity name of cache. More...
 
bool is_actual (double time, std::string field_name)
 Check if cache stored actual data. More...
 
void set_field_units (std::string unit_string)
 
void set_n_values (unsigned int n_values)
 
std::string field_units ()
 
unsigned int n_values ()
 
NumCompValueType n_elem ()
 
VTKValueType vtk_type ()
 Get type of stored data. More...
 
std::size_t dof_handler_hash () const
 
void set_dof_handler_hash (std::size_t hash)
 

Static Public Member Functions

static CacheData create_data_cache (unsigned int size_of_cache, unsigned int row_vec_size)
 

Protected Types

enum  CheckScaleData { none, check, scale }
 Allow to hold sign, if data in cache is checked and scale (both can be executed only once) More...
 

Protected Attributes

CheckScaleData check_scale_data_
 Sign, if data in cache is checked and scale. More...
 
CacheData data_
 
- Protected Attributes inherited from ElementDataCacheBase
double time_
 time step stored in cache More...
 
std::string field_input_name_
 name of field stored in cache More...
 
std::string field_name_
 
std::string field_units_
 
unsigned int n_values_
 
NumCompValueType n_elem_
 
VTKValueType vtk_type_
 Type of stored data. More...
 
std::size_t dof_handler_hash_
 Hash of DOF handler (attribute of native VTK data) More...
 

Additional Inherited Members

- Protected Member Functions inherited from ElementDataCacheBase
template<class T >
void set_vtk_type ()
 

Detailed Description

template<typename T>
class ElementDataCache< T >

Definition at line 42 of file element_data_cache.hh.

Member Typedef Documentation

template<typename T>
typedef std::vector< ComponentDataPtr > ElementDataCache< T >::CacheData

Definition at line 45 of file element_data_cache.hh.

template<typename T>
typedef std::shared_ptr< std::vector<T> > ElementDataCache< T >::ComponentDataPtr

Definition at line 44 of file element_data_cache.hh.

Member Enumeration Documentation

template<typename T>
enum ElementDataCache::CheckScaleData
protected

Allow to hold sign, if data in cache is checked and scale (both can be executed only once)

Enumerator
none 

Data is neither checked nor scaled.

check 

Data is only checked.

scale 

Data is scaled.

Definition at line 179 of file element_data_cache.hh.

Constructor & Destructor Documentation

template<typename T >
ElementDataCache< T >::ElementDataCache ( )

Default constructor.

Definition at line 31 of file element_data_cache.cc.

template<typename T >
ElementDataCache< T >::ElementDataCache ( std::string  field_name,
double  time,
unsigned int  size_of_cache,
unsigned int  row_vec_size 
)

Constructor of input ElementDataCache (allow read data from GMSH or VTK file)

Allows set variable size of cache.

Parameters
field_nameField name thas is read
timeActual time of data
size_of_cacheCount of columns of data cache
row_vec_sizeCount of rows of data cache

Definition at line 37 of file element_data_cache.cc.

template<typename T >
ElementDataCache< T >::ElementDataCache ( std::string  field_name,
unsigned int  n_rows,
unsigned int  n_cols,
unsigned int  size 
)

Constructor of output ElementDataCache (allow write data)

Has fix size of cache.

Parameters
field_nameField name is written as parameter to output stream
n_rowsGiven from shape of field
n_colsGiven from shape of field
sizeCount of rows of data cache

Definition at line 47 of file element_data_cache.cc.

template<typename T >
ElementDataCache< T >::~ElementDataCache ( )
overridevirtual

Destructor of ElementDataCache.

Definition at line 81 of file element_data_cache.cc.

Member Function Documentation

template<typename T>
void ElementDataCache< T >::add ( unsigned int  idx,
const T *  value 
)

Add value to given index

Definition at line 248 of file element_data_cache.cc.

Here is the caller graph for this function:

template<typename T >
CheckResult ElementDataCache< T >::check_values ( double  default_val,
double  lower_bound,
double  upper_bound 
)

Make full check of data stored in cache.

Method iterates through data and

  • checks NaN data values, default_val replaces NaN
  • if default_val==NaN and some value(s) is not replaced with valid value return CheckResult::nan
  • if some value(s) is out of limits )lower_bound, upper_bound) return CheckResult::out_of_limits
  • in other cases return CheckResult::ok

Method is executed only once.

Definition at line 284 of file element_data_cache.cc.

template<typename T >
ElementDataCache< T >::CacheData ElementDataCache< T >::create_data_cache ( unsigned int  size_of_cache,
unsigned int  row_vec_size 
)
static

Create data cache with given count of columns (size_of_cache) and rows (row_vec_size).

Definition at line 92 of file element_data_cache.cc.

Here is the caller graph for this function:

template<typename T>
ElementDataCache< T >::DECLARE_EXCEPTION ( ExcOutputVariableVector  ,
<< "Can not output field "<< EI_FieldName::qval<< " returning variable size vectors. Try convert to MultiField.\n"   
)

Declaration of exception

template<typename T >
ElementDataCache< T >::ComponentDataPtr ElementDataCache< T >::get_component_data ( unsigned int  component_idx)

Return vector of element data for get component.

Definition at line 85 of file element_data_cache.cc.

Here is the caller graph for this function:

template<typename T >
void ElementDataCache< T >::get_min_max_range ( double &  min,
double &  max 
)
overridevirtual

Find minimal and maximal range of stored data

Implements ElementDataCacheBase.

Definition at line 217 of file element_data_cache.cc.

template<typename T >
void ElementDataCache< T >::normalize ( unsigned int  idx,
unsigned int  divisor 
)

Normalize values at given index

Definition at line 274 of file element_data_cache.cc.

Here is the caller graph for this function:

template<class T >
T & ElementDataCache< T >::operator[] ( unsigned int  i)

Access i-th element in the data vector of 0th component.

Access i-th element in the data vector.

Definition at line 322 of file element_data_cache.cc.

template<typename T >
void ElementDataCache< T >::print_all_yaml ( ostream &  out_stream,
unsigned int  precision 
)
overridevirtual

Print stored values in the YAML format (using JSON like arrays). Used for output of observe values.

Implements ElementDataCacheBase.

Definition at line 183 of file element_data_cache.cc.

template<typename T >
void ElementDataCache< T >::print_ascii ( ostream &  out_stream,
unsigned int  idx 
)
overridevirtual

Output data element on given index idx. Method for writing data to output stream.

Note
This method is used only by MSH file format.

Implements ElementDataCacheBase.

Definition at line 138 of file element_data_cache.cc.

template<typename T >
void ElementDataCache< T >::print_ascii_all ( ostream &  out_stream)
overridevirtual

Print all data stored in output data ro ascii format.

Print all data stored in output data.

TODO: indicate if the tensor data are output in column-first or raw-first order and possibly implement transposition. Set such property for individual file formats. Class OutputData stores always in raw-first order.

Implements ElementDataCacheBase.

Definition at line 154 of file element_data_cache.cc.

template<typename T >
void ElementDataCache< T >::print_binary_all ( ostream &  out_stream,
bool  print_data_size = true 
)
overridevirtual

Print all data stored in output data to appended binary format.

Prints the whole data vector into stream.

Implements ElementDataCacheBase.

Definition at line 166 of file element_data_cache.cc.

template<typename T >
void ElementDataCache< T >::read_ascii_data ( Tokenizer &  tok,
unsigned int  n_components,
unsigned int  i_row 
)
overridevirtual

Implements ElementDataCacheBase::read_ascii_data.

Implements ElementDataCacheBase.

Definition at line 105 of file element_data_cache.cc.

template<typename T >
void ElementDataCache< T >::read_binary_data ( std::istream &  data_stream,
unsigned int  n_components,
unsigned int  i_row 
)
overridevirtual

Implements ElementDataCacheBase::read_binary_data.

Implements ElementDataCacheBase.

Definition at line 119 of file element_data_cache.cc.

template<typename T >
void ElementDataCache< T >::scale_data ( double  coef)

Scale data vector of given 'component_idx' with scale 'coef'.

Method is executed only once and should be called after check_values method. Method can be used e. g. for convert between units.

Definition at line 306 of file element_data_cache.cc.

template<typename T>
void ElementDataCache< T >::store_value ( unsigned int  idx,
const T *  value 
)

Store data element of given data value under given index.

Definition at line 235 of file element_data_cache.cc.

Here is the caller graph for this function:

template<typename T>
ElementDataCache< T >::TYPEDEF_ERR_INFO ( EI_FieldName  ,
std::string   
)

Declaration of new exception info used in following exception

template<typename T >
void ElementDataCache< T >::zero ( unsigned int  idx)

Reset values at given index

Definition at line 261 of file element_data_cache.cc.

Here is the caller graph for this function:

Member Data Documentation

template<typename T>
CheckScaleData ElementDataCache< T >::check_scale_data_
protected

Sign, if data in cache is checked and scale.

Definition at line 186 of file element_data_cache.hh.

template<typename T>
CacheData ElementDataCache< T >::data_
protected

Table of element data.

For every components contains vector of element data.

Definition at line 193 of file element_data_cache.hh.


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