26#ifndef __BITPIT_VTK_HPP__
27#define __BITPIT_VTK_HPP__
35#include <unordered_map>
37#include "bitpit_common.hpp"
38#include "GenericIO.hpp"
126 QUADRATIC_TRIANGLE = 22,
128 QUADRATIC_TETRA = 24,
129 QUADRATIC_HEXAHEDRON = 25,
159 static std::unordered_map<std::type_index, VTKDataType> m_types;
172 template<typename T, int nesting=0, typename std::enable_if<std::is_pod<T>::value && !utils::is_iterable<T>::value>::type* =
nullptr>
175 template<typename T, int nesting=0, typename std::enable_if<utils::is_iterable<T>::value>::type* =
nullptr>
189 virtual void flushData( std::fstream &,
VTKFormat) =0 ;
190 virtual void absorbData( std::fstream &,
VTKFormat, uint64_t, uint8_t) =0 ;
196 std::vector<T>* m_ptr ;
205 void resize( std::true_type, uint64_t , uint8_t) ;
206 void resize( std::false_type, uint64_t , uint8_t) ;
229 std::unordered_map<std::string,std::unique_ptr<VTKBaseContainer> > m_field ;
240 void addData(
const std::string &, std::vector<T> & ) ;
242 bool hasData(
const std::string & )
const ;
271 const std::string &
getName()
const;
283 void setName(
const std::string & ) ;
294 void read( std::fstream&, uint64_t, uint8_t )
const ;
295 void write( std::fstream& )
const ;
319 VTK(
const std::string &,
const std::string & );
320 virtual ~VTK( ) =
default;
329 void setNames(
const std::string & ,
const std::string & ) ;
330 void setName(
const std::string & ) ;
360 bool hasData(
const std::string & )
const ;
362 std::vector<VTKField>::const_iterator
getDataBegin( )
const ;
363 std::vector<VTKField>::const_iterator
getDataEnd( )
const ;
375 virtual void readMetaInformation() = 0 ;
381 void write(
const std::string &,
VTKWriteMode writeMode=VTKWriteMode::NO_INCREMENT ) ;
385 virtual void writeCollection(
const std::string &outputName,
const std::string &collectionName )
const = 0;
388 void writeTimeSeries(
const std::string &outputName,
double time )
const ;
389 void writeTimeSeries(
const std::string &outputName,
const std::string &seriesName,
double time )
const ;
393 virtual void writeMetaInformation()
const = 0 ;
407 std::vector<std::string>
getFieldNames(
const std::vector<VTKField> &fields )
const;
417 int _findFieldIndex(
const std::string &name,
const std::vector<VTKField> &fields )
const;
423 virtual uint64_t calcFieldSize(
const VTKField &)
const = 0;
424 virtual uint64_t calcFieldEntries(
const VTKField &)
const = 0;
425 virtual uint8_t calcFieldComponents(
const VTKField &)
const = 0;
428 virtual std::string getExtension()
const = 0 ;
443 void flushData( std::fstream &,
const std::string &,
VTKFormat)
override ;
474 void writeCollection(
const std::string &outputName,
const std::string &collectionName )
const override ;
476 void setDimensions( uint64_t , uint64_t , uint64_t nconn = 0 , uint64_t nfacestream = 0 ) ;
497 typedef std::array<std::array<int,2>,2> extension2D_t ;
498 typedef std::array<std::array<int,2>,3> extension3D_t ;
523 void writeCollection(
const std::string &outputName,
const std::string &collectionName )
const override ;
569 void allocate( std::vector<T> &,
int) ;
578#include"VTKTypes.tpp"
579#include"VTKStreamer.tpp"
580#include"VTKUtils.tpp"
Creates file names and checks status.
An interface class to all containers that are batively supported by VTK.
The base class to be used to derive VTK streamers form.
void flushValue(std::fstream &, VTKFormat, const T &value) const
virtual void flushData(std::fstream &, const std::string &, VTKFormat)
virtual void absorbData(std::fstream &, const std::string &, VTKFormat, uint64_t, uint8_t, VTKDataType)
VTKField handles geometry and data field information for the VTK format.
const std::string & getName() const
VTKFormat getCodification() const
std::fstream::pos_type getPosition() const
const VTKBaseStreamer & getStreamer() const
uint64_t getOffset() const
void setDataType(VTKDataType)
VTKBaseStreamer * m_streamer
VTKFieldType getFieldType() const
VTKLocation getLocation() const
unsigned getComponentCount() const
void setStreamer(VTKBaseStreamer &)
void setCodification(VTKFormat)
void write(std::fstream &) const
void setFieldType(VTKFieldType)
bool hasAllMetaData() const
void read(std::fstream &, uint64_t, uint8_t) const
VTKDataType getDataType() const
std::fstream::pos_type m_position
void setName(const std::string &)
void setPosition(std::fstream::pos_type)
void setLocation(VTKLocation)
In VTKNativeStreamer all instances of classes derived from VTKBaseConatiner are stored....
void absorbData(std::fstream &, const std::string &, VTKFormat, uint64_t, uint8_t, VTKDataType) override
bool hasData(const std::string &) const
void flushData(std::fstream &, const std::string &, VTKFormat) override
VTKNativeStreamer & operator=(const VTKNativeStreamer &other)
void addData(const std::string &, std::vector< T > &)
void removeData(const std::string &)
VTK input output for Rectilinear Meshes.
std::vector< extension3D_t > m_procIndex
void setGlobalDimensions(int, int, int)
void setDimensions(int, int, int, int, int, int)
uint8_t calcFieldComponents(const VTKField &) const override
extension3D_t m_globalIndex
void setGeomData(VTKRectilinearField, std::vector< T > &)
std::string getExtension() const override
void writeMetaInformation() const override
extension3D_t m_localIndex
uint64_t calcFieldSize(const VTKField &) const override
void setGlobalIndex(const std::vector< extension3D_t > &)
uint64_t calcFieldEntries(const VTKField &) const override
void readMetaInformation() override
static VTKDataType whichType()
static uint8_t sizeOfType(VTKDataType type)
static VTKDataType registerType()
void setElementType(VTKElementType)
void setConnectivityField(const VTKField *connectivity)
void setCellCount(uint64_t)
VTK input output for Unstructured Meshes.
uint8_t calcFieldComponents(const VTKField &) const override
HomogeneousInfoStreamer m_homogeneousInfoStreamer
uint64_t readFaceStreamEntries()
uint64_t calcConnectivityEntries() const
std::string getExtension() const override
uint64_t m_nConnectivityEntries
uint64_t calcFieldSize(const VTKField &) const override
uint64_t m_nFaceStreamEntries
void setElementType(VTKElementType)
void writeMetaInformation() const override
uint64_t readConnectivityEntries()
void setDimensions(uint64_t, uint64_t, uint64_t nconn=0, uint64_t nfacestream=0)
VTKUnstructuredGrid(VTKElementType elementType=VTKElementType::UNDEFINED)
VTKElementType m_elementType
uint64_t calcFieldEntries(const VTKField &) const override
void readMetaInformation() override
void setGeomData(VTKUnstructuredField, std::vector< T > &)
Implementation of VTKBaseContainer in order to support natively std::vector in VTK.
void absorbData(std::fstream &, VTKFormat, uint64_t, uint8_t) override
VTKVectorContainer * clone() const override
VTKVectorContainer(std::vector< T > &)
void flushData(std::fstream &, VTKFormat) override
void resize(std::true_type, uint64_t, uint8_t)
A base class for VTK input output.
const VTKField * findGeomData(const std::string &name) const
virtual std::string getCollectionExtension() const
void setDirectory(const std::string &)
void setParallel(uint16_t, uint16_t)
std::size_t getDataCount() const
VTKField & addData(VTKField &&field)
std::vector< VTKField > m_geometry
void readDataHeader(std::fstream &)
void setNames(const std::string &, const std::string &)
int _findFieldIndex(const std::string &name, const std::vector< VTKField > &fields) const
void writeTimeSeries(double time) const
VTKField * _findData(const std::string &name)
VTKField * _findGeomData(const std::string &name)
const VTKField * findData(const std::string &name) const
std::vector< VTKField >::const_iterator getDataEnd() const
void disableData(const std::string &)
void setHeaderType(const std::string &)
void removeData(const std::string &)
std::string getName() const
const std::string & getHeaderType() const
bool readDataArray(std::fstream &, VTKField &) const
void setCounter(int c_=0)
void writeCollection() const
void enableData(const std::string &)
bool isASCIIActive() const
void setDataCodex(VTKFormat)
void setName(const std::string &)
void setGeomCodex(VTKFormat)
std::vector< VTKField >::const_iterator getDataBegin() const
void writePDataArray(std::fstream &, const VTKField &) const
VTKField * getGeomData(std::size_t id)
bool hasData(const std::string &) const
std::vector< VTKField >::const_iterator getGeomDataBegin() const
VTKField * getData(std::size_t id)
void setGeomData(VTKField &&field)
std::vector< VTKField >::const_iterator getGeomDataEnd() const
void calcAppendedOffsets()
void writeDataHeader(std::fstream &, bool parallel=false) const
bool isAppendedActive() const
std::size_t getGeomDataCount() const
void writeDataArray(std::fstream &, const VTKField &) const
VTKNativeStreamer m_nativeStreamer
std::vector< VTKField > m_data
FileHandler createCollectionHandler(const std::string &collectionName) const
std::string getDirectory() const
void write(VTKWriteMode writeMode, double time)
std::vector< std::string > getFieldNames(const std::vector< VTKField > &fields) const
void allocate(std::vector< T > &, int)
std::string convertDataArrayToString(const VTKField &)
std::string convertEnumToString(VTKLocation)
bool convertStringToEnum(const std::string &, VTKLocation &)
std::string convertPDataArrayToString(const VTKField &)
bool convertStringToDataArray(const std::string &, VTKField &)
uint8_t getElementNodeCount(VTKElementType)