VTK  9.0.2
VTXHelper.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: VTXHelper.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14  =========================================================================*/
15 
16 /*
17  * VTXHelper.h : collection of helper function needed by VTK::IOADIOS2 module
18  *
19  * Created on: May 3, 2019
20  * Author: William F Godoy godoywf@ornl.gov
21  */
22 
23 #ifndef VTK_IO_ADIOS2_VTX_COMMON_VTXHelper_h
24 #define VTK_IO_ADIOS2_VTX_COMMON_VTXHelper_h
25 
26 #include "VTXTypes.h"
27 
28 #include <cstddef> //std::size_t
29 #include <set>
30 #include <string>
31 #include <utility> // std::pair
32 #include <vector>
33 
34 #include <vtk_mpi.h>
35 
36 #include "vtkDataArray.h"
37 #include "vtkIdTypeArray.h"
38 #include "vtkSmartPointer.h"
39 
40 #include <vtk_pugixml.h>
41 
42 #include <adios2.h>
43 
44 namespace vtx
45 {
46 namespace helper
47 {
48 
50 MPI_Comm MPIGetComm();
51 
53 int MPIGetRank();
54 
56 int MPIGetSize();
57 
67 pugi::xml_document XMLDocument(
68  const std::string& input, const bool debugMode, const std::string& hint);
69 
81 pugi::xml_node XMLNode(const std::string nodeName, const pugi::xml_document& xmlDocument,
82  const bool debugMode, const std::string& hint, const bool isMandatory = true,
83  const bool isUnique = false);
84 
97 pugi::xml_node XMLNode(const std::string nodeName, const pugi::xml_node& upperNode,
98  const bool debugMode, const std::string& hint, const bool isMandatory = true,
99  const bool isUnique = false);
100 
107 
118 pugi::xml_attribute XMLAttribute(const std::string attributeName, const pugi::xml_node& node,
119  const bool debugMode, const std::string& hint, const bool isMandatory = true);
120 
126 std::string SetToCSV(const std::set<std::string>& input) noexcept;
127 
134 template <class T>
135 std::vector<T> StringToVector(const std::string& input) noexcept;
136 
142 std::size_t TotalElements(const std::vector<std::size_t>& dimensions) noexcept;
143 
153  const pugi::xml_node& dataSetNode, const std::set<std::string>& specialNames);
154 
159 template <class T>
161 
167 
173 adios2::Box<adios2::Dims> PartitionCart1D(const adios2::Dims& shape);
174 
180 template <class T, class U>
181 std::vector<T> MapKeysToVector(const std::map<T, U>& input) noexcept;
182 
188 template <class T>
189 void Print(const std::vector<T>& input, const std::string& name);
190 
197 size_t LinearizePoint(const adios2::Dims& shape, const adios2::Dims& point) noexcept;
198 
204 std::string GetFileName(const std::string& fileName) noexcept;
205 
211 std::string GetEngineType(const std::string& fileName) noexcept;
212 
219 bool EndsWith(const std::string& input, const std::string& ends) noexcept;
220 
221 } // end namespace helper
222 } // end namespace vtx
223 
224 #include "VTXHelper.inl"
225 
226 #endif /* VTK_IO_ADIOS2_VTX_COMMON_VTXHelper_h */
@ point
Definition: vtkX3D.h:242
@ name
Definition: vtkX3D.h:225
@ string
Definition: vtkX3D.h:496
types::DataSet XMLInitDataSet(const pugi::xml_node &dataSetNode, const std::set< std::string > &specialNames)
Initialize DataSet structure from parsing a pugi::xml_node, loops through DataArray nodes.
vtkSmartPointer< vtkDataArray > NewDataArray()
Return a derived class of vtkDataArray specialized for supported types.
bool EndsWith(const std::string &input, const std::string &ends) noexcept
Check if input ends with a certain (ends) string.
std::string GetEngineType(const std::string &fileName) noexcept
Set the appropriate engine type based on recognized user input.
std::string FileToString(const std::string &fileName)
Translate file contents to string.
vtkSmartPointer< vtkIdTypeArray > NewDataArrayIdType()
Special type for vtkIdTypeArray.
std::size_t TotalElements(const std::vector< std::size_t > &dimensions) noexcept
Return product of all dimensions components to get the total number of elements.
adios2::Box< adios2::Dims > PartitionCart1D(const adios2::Dims &shape)
Simple partition to load balance shape across viz processes.
std::vector< T > MapKeysToVector(const std::map< T, U > &input) noexcept
Map's keys to a vector.
size_t LinearizePoint(const adios2::Dims &shape, const adios2::Dims &point) noexcept
Linear index for a point within a box with shape dimensions from zero origin.
std::vector< T > StringToVector(const std::string &input) noexcept
Converts a single string "s1 s2 s3" list to a vector vector ={ "s1", "s2", "s3" };.
pugi::xml_node XMLNode(const std::string nodeName, const pugi::xml_document &xmlDocument, const bool debugMode, const std::string &hint, const bool isMandatory=true, const bool isUnique=false)
Get safely a pugi::xml_document from a pugmi::xml_document.
int MPIGetSize()
Get current MPI size from MPIGetComm.
MPI_Comm MPIGetComm()
Get current MPI global communicator from VTK.
std::string GetFileName(const std::string &fileName) noexcept
Set the appropriate file name based on recognized user input.
void Print(const std::vector< T > &input, const std::string &name)
Print a vector with an associated name.
std::string SetToCSV(const std::set< std::string > &input) noexcept
Convert a set of strings into a csv "string1,string2,string3" string.
pugi::xml_document XMLDocument(const std::string &input, const bool debugMode, const std::string &hint)
Get safely a pugi::xml_document from XML as a string.
pugi::xml_attribute XMLAttribute(const std::string attributeName, const pugi::xml_node &node, const bool debugMode, const std::string &hint, const bool isMandatory=true)
Get a node attribute identified by its key.
int MPIGetRank()
Get current MPI rank from MPIGetComm.
std::map< std::string, DataArray > DataSet
key: variable name, value: DataArray
Definition: VTXTypes.h:39