26 #ifndef TOOLS_VTKDATA_H
27 #define TOOLS_VTKDATA_H
36 #include <type_traits>
67 virtual void emit(std::ostream& out,
const T& t)
const = 0;
88 typename std::enable_if<std::is_floating_point<V>::value, std::string>::type
95 typename std::enable_if<std::is_integral<V>::value && std::is_unsigned<V>::value, std::string>::type
102 typename std::enable_if<std::is_integral<V>::value && std::is_signed<V>::value, std::string>::type
109 typename std::enable_if<std::is_array<V>::value, std::string>::type
112 return toVTKDataType< typename std::remove_extent<V>::type >();
123 logger.assert_debug(std::isfinite(in),
"Detected nans!");
124 return (fabs(in)<1e-33)?0.0:in;
128 template<
typename T,
typename V>
129 typename std::enable_if<std::is_array<V>::value || std::is_pointer<V>::value,
void>::type
130 emitProxy(std::ostream& out,
const T& t, std::size_t nComponents, V T::*member)
132 for (std::size_t
i = 0;
i < nComponents;
i++)
134 out <<
round((t.*member)[
i]) <<
" ";
138 template<
typename T,
typename V>
139 typename std::enable_if<!(std::is_array<V>::value || std::is_pointer<V>::value),
void>::type
140 emitProxy(std::ostream& out,
const T& t, std::size_t nComponents, V T::*member)
142 out <<
round(t.*member) <<
" ";
148 template<
typename T,
typename V>
160 return toVTKDataType<V>();
163 void emit(std::ostream& out,
const T& t)
const override
186 std::vector< Detail::VTKPointDescriptorEntry<T>* >
entries_;
199 template<
typename DATATYPE>
212 template<
typename DATATYPE>
225 template<
typename DATATYPE>
238 template<
typename VT>
257 "<?xml version=\"1.0\"?>\n"
258 "<VTKFile type=\"Collection\" version=\"0.1\" byte_order=\"LittleEndian\">\n"
296 "<DataSet group=\"\" part=\"0\" timestep=\"" <<
recordID_ <<
"\" file=\"" << filename <<
"\" />\n";
336 "<?xml version=\"1.0\"?>\n"
337 "<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n"
338 " <UnstructuredGrid>\n"
339 " <Piece NumberOfPoints=\"" << container.size() <<
"\" NumberOfCells=\"0\">\n"
341 " <DataArray type=\"Int32\" name=\"connectivity\" format=\"ascii\">\n"
344 " <DataArray type=\"Float32\" name=\"offset\" format=\"ascii\">\n"
347 " <DataArray type=\"UInt8\" name=\"types\" format=\"ascii\">\n"
355 "format=\"ascii\">\n";
356 for (
const T& mem : container)
369 "Name=\"" << descr->
getName() <<
"\" "
371 "format=\"ascii\">\n";
372 for (
const T& mem : container)
382 " </UnstructuredGrid>\n"
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
Definition: Tools/VTKData.h:150
const std::size_t nComponents_
Definition: Tools/VTKData.h:152
std::size_t getNumberOfComponents() const override
Returns the number of components in this type.
Definition: Tools/VTKData.h:168
void emit(std::ostream &out, const T &t) const override
writes this VTKData to the given output stream for a single T
Definition: Tools/VTKData.h:163
std::string getTypeName() const override
Gives the VTKDataType for VTK.
Definition: Tools/VTKData.h:158
VTKPointDescriptorEntryImpl(std::string name, V T::*member, std::size_t nComponents)
Definition: Tools/VTKData.h:154
const V T::* member_
Definition: Tools/VTKData.h:151
Definition: Tools/VTKData.h:46
std::string name_
Definition: Tools/VTKData.h:47
virtual ~VTKPointDescriptorEntry()
Definition: Tools/VTKData.h:58
std::string getName() const
Returns the name associated with this field.
Definition: Tools/VTKData.h:76
virtual void emit(std::ostream &out, const T &t) const =0
writes this VTKData to the given output stream for a single T
virtual std::size_t getNumberOfComponents() const =0
Returns the number of components in this type.
VTKPointDescriptorEntry(std::string fieldName)
initialises this data member with given name.
Definition: Tools/VTKData.h:53
virtual std::string getTypeName() const =0
Gives the VTKDataType for VTK.
Definition: Tools/VTKData.h:248
VTKCollection(std::string fileName)
Definition: Tools/VTKData.h:272
std::ofstream outFile_
Definition: Tools/VTKData.h:249
bool hasHeader_
Definition: Tools/VTKData.h:250
~VTKCollection()
Definition: Tools/VTKData.h:277
void writeFooter()
Definition: Tools/VTKData.h:263
std::size_t recordID_
Definition: Tools/VTKData.h:252
bool hasFooter_
Definition: Tools/VTKData.h:251
void append(std::string filename)
Definition: Tools/VTKData.h:290
void writeHeader()
Definition: Tools/VTKData.h:254
Definition: Tools/VTKData.h:185
std::enable_if<!std::is_array< DATATYPE >::value, VTKPointDescriptor & >::type addProperty(std::string name, DATATYPE T::*m, bool isPrimary=false)
Definition: Tools/VTKData.h:214
Detail::VTKPointDescriptorEntry< T > * positionEntry_
Definition: Tools/VTKData.h:187
VTKPointDescriptor()
Definition: Tools/VTKData.h:189
~VTKPointDescriptor()
Definition: Tools/VTKData.h:193
std::vector< Detail::VTKPointDescriptorEntry< T > * > entries_
Definition: Tools/VTKData.h:186
VTKPointDescriptor & addProperty(std::string name, DATATYPE T::*m, std::size_t nComponents, bool isPrimary=false)
Definition: Tools/VTKData.h:226
std::enable_if< std::is_array< DATATYPE >::value, VTKPointDescriptor & >::type addProperty(std::string name, DATATYPE T::*m, bool isPrimary=false)
Definition: Tools/VTKData.h:201
Definition: Tools/VTKData.h:308
const VTKPointDescriptor< T > * descriptor_
Definition: Tools/VTKData.h:309
VTKUnstructuredGrid(std::string filename, const VTKPointDescriptor< T > *descr)
Definition: Tools/VTKData.h:316
std::ofstream outFile_
Definition: Tools/VTKData.h:310
void write(const C &container)
Definition: Tools/VTKData.h:333
Definition: MpiContainer.h:91
V round(V in)
Definition: Tools/VTKData.h:116
std::enable_if< std::is_floating_point< V >::value, std::string >::type toVTKDataType()
Definition: Tools/VTKData.h:89
std::enable_if< std::is_array< V >::value||std::is_pointer< V >::value, void >::type emitProxy(std::ostream &out, const T &t, std::size_t nComponents, V T::*member)
This function actually writes the correct datatype to ostream.
Definition: Tools/VTKData.h:130
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51
std::string name
Definition: MercuryProb.h:48