VTK  9.1.0
Functions
vtx::helper Namespace Reference

Functions

MPI_Comm MPIGetComm ()
 Get current MPI global communicator from VTK. More...
 
int MPIGetRank ()
 Get current MPI rank from MPIGetComm. More...
 
int MPIGetSize ()
 Get current MPI size from MPIGetComm. More...
 
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. More...
 
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. More...
 
pugi::xml_node XMLNode (const std::string nodeName, const pugi::xml_node &upperNode, const bool debugMode, const std::string &hint, const bool isMandatory=true, const bool isUnique=false)
 Overloaded version that gets a XML node from inside another node called upperNode. More...
 
std::string FileToString (const std::string &fileName)
 Translate file contents to string. More...
 
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. More...
 
std::string SetToCSV (const std::set< std::string > &input) noexcept
 Convert a set of strings into a csv "string1,string2,string3" string. More...
 
template<class T >
std::vector< T > StringToVector (const std::string &input) noexcept
 Converts a single string "s1 s2 s3" list to a vector vector ={ "s1", "s2", "s3" };. More...
 
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. More...
 
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. More...
 
template<class T >
vtkSmartPointer< vtkDataArrayNewDataArray ()
 Return a derived class of vtkDataArray specialized for supported types. More...
 
vtkSmartPointer< vtkIdTypeArrayNewDataArrayIdType ()
 Special type for vtkIdTypeArray. More...
 
adios2::Box< adios2::Dims > PartitionCart1D (const adios2::Dims &shape)
 Simple partition to load balance shape across viz processes. More...
 
template<class T , class U >
std::vector< T > MapKeysToVector (const std::map< T, U > &input) noexcept
 Map's keys to a vector. More...
 
template<class T >
void Print (const std::vector< T > &input, const std::string &name)
 Print a vector with an associated name. More...
 
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. More...
 
std::string GetFileName (const std::string &fileName) noexcept
 Set the appropriate file name based on recognized user input. More...
 
std::string GetEngineType (const std::string &fileName) noexcept
 Set the appropriate engine type based on recognized user input. More...
 
bool EndsWith (const std::string &input, const std::string &ends) noexcept
 Check if input ends with a certain (ends) string. More...
 

Function Documentation

◆ MPIGetComm()

MPI_Comm vtx::helper::MPIGetComm ( )

Get current MPI global communicator from VTK.

◆ MPIGetRank()

int vtx::helper::MPIGetRank ( )

Get current MPI rank from MPIGetComm.

◆ MPIGetSize()

int vtx::helper::MPIGetSize ( )

Get current MPI size from MPIGetComm.

◆ XMLDocument()

pugi::xml_document vtx::helper::XMLDocument ( const std::string &  input,
const bool  debugMode,
const std::string &  hint 
)

Get safely a pugi::xml_document from XML as a string.

Parameters
inputentire XML contents as a string or file, depending on bool isFile
debugModetrue: safe mode throws exceptions
hintadd extra information on exceptions
Returns
xml as pugi object
Exceptions
std::invalid_argument

◆ XMLNode() [1/2]

pugi::xml_node vtx::helper::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.

Parameters
nodeNameinput node to be found
xmlDocumentinput document
debugModetrue: safe mode throws exceptions
hintadd extra information on exceptions
isMandatorytrue: throws exception if node is not found
isUniquetrue: throws exception if node exist more than once
Returns
node if found, empty node if not mandatory
Exceptions
std::invalid_argument

◆ XMLNode() [2/2]

pugi::xml_node vtx::helper::XMLNode ( const std::string  nodeName,
const pugi::xml_node &  upperNode,
const bool  debugMode,
const std::string &  hint,
const bool  isMandatory = true,
const bool  isUnique = false 
)

Overloaded version that gets a XML node from inside another node called upperNode.

Parameters
nodeNameinput node to be found
upperNodeinput node to search inside for nodeName
debugModetrue: safe mode throws exceptions
hintadd extra information on exceptions
isMandatorytrue: throws exception if node is not found
isUniquetrue: throws exception if node exist more than once
Returns
node if found, empty node if not mandatory
Exceptions
std::invalid_argument

◆ FileToString()

std::string vtx::helper::FileToString ( const std::string &  fileName)

Translate file contents to string.

Parameters
fileNameinput
Returns
file contents as a single string

◆ XMLAttribute()

pugi::xml_attribute vtx::helper::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.

Parameters
attributeNameinput xml attribute to be found
nodeinput node to search inside for attributeName
debugModetrue: safe mode throws exceptions
hintadd extra information on exceptions
isMandatorytrue: throws exception if node is not found
Returns
attribute if found, empty node if not mandatory
Exceptions
std::invalid_argument

◆ SetToCSV()

std::string vtx::helper::SetToCSV ( const std::set< std::string > &  input)
noexcept

Convert a set of strings into a csv "string1,string2,string3" string.

Parameters
inputset of ordered strings
Returns
csv string

◆ StringToVector()

template<class T >
std::vector< T > vtx::helper::StringToVector ( const std::string &  input)
noexcept

Converts a single string "s1 s2 s3" list to a vector vector ={ "s1", "s2", "s3" };.

Parameters
input
Returns

◆ TotalElements()

std::size_t vtx::helper::TotalElements ( const std::vector< std::size_t > &  dimensions)
noexcept

Return product of all dimensions components to get the total number of elements.

Parameters
dimensionsinput
Returns
total number of elements

◆ XMLInitDataSet()

types::DataSet vtx::helper::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.

Parameters
dataSetNodeinput
specialNamesinput check for vector components even if NumberOfComponents wasn't declared
Returns
initialiazed DataSet

◆ NewDataArray()

template<class T >
vtkSmartPointer< vtkDataArray > vtx::helper::NewDataArray ( )

Return a derived class of vtkDataArray specialized for supported types.

Returns
specialized vtkDataArray

◆ NewDataArrayIdType()

vtkSmartPointer< vtkIdTypeArray > vtx::helper::NewDataArrayIdType ( )

Special type for vtkIdTypeArray.

Returns
smart pointer of type vtkIdTypeArray

◆ PartitionCart1D()

adios2::Box< adios2::Dims > vtx::helper::PartitionCart1D ( const adios2::Dims &  shape)

Simple partition to load balance shape across viz processes.

Parameters
shapeinput
Returns
selection first=start second=count

◆ MapKeysToVector()

template<class T , class U >
std::vector< T > vtx::helper::MapKeysToVector ( const std::map< T, U > &  input)
noexcept

Map's keys to a vector.

Parameters
inputmap
Returns
vector with keys only

◆ Print()

template<class T >
void vtx::helper::Print ( const std::vector< T > &  input,
const std::string &  name 
)

Print a vector with an associated name.

For debugging purposes.

Parameters
inputvector data
nameinput name

◆ LinearizePoint()

size_t vtx::helper::LinearizePoint ( const adios2::Dims &  shape,
const adios2::Dims &  point 
)
noexcept

Linear index for a point within a box with shape dimensions from zero origin.

Parameters
shapeinput shape box
pointinput point
Returns
linearized point inside shape

◆ GetFileName()

std::string vtx::helper::GetFileName ( const std::string &  fileName)
noexcept

Set the appropriate file name based on recognized user input.

Parameters
fileNameinput from user selected file
Returns
file name to be used by adios2 engine

◆ GetEngineType()

std::string vtx::helper::GetEngineType ( const std::string &  fileName)
noexcept

Set the appropriate engine type based on recognized user input.

Parameters
fileNameinput from user selected file
Returns
engine type to be used by adios2 engine

◆ EndsWith()

bool vtx::helper::EndsWith ( const std::string &  input,
const std::string &  ends 
)
noexcept

Check if input ends with a certain (ends) string.

Parameters
inputstring input
endsending string to check in input
Returns
true: input ends with "ends", false: it doesn't end with ends