Zoltan2
Static Public Member Functions
Zoltan2::IdentifierTraits< T > Struct Template Reference

The functions to be defined for users' global ID types. More...

#include <Zoltan2_IdentifierTraits.hpp>

List of all members.

Static Public Member Functions

static int hashCode (const T id)
 Compute an integer hash code for the user's global ID.
static bool hasUniqueKey ()
 Determine if the data type supports unique hash keys.
static double key (const T c)
 Return a double which is a unique key for the value.
static std::string name ()
 The name of the identifier data type.
static std::string stringify (T val)
 A string displaying the value.
static bool isGlobalOrdinal ()
 Determine whether the data type can be a Teuchos Ordinal.
static T difference (const T a, const T b)
 Compute b - a, if possible.
static bool is_valid_id_type ()
 Determine if the data type is one for which IdentifierTraits are defined.
static void minMax (const T *values, size_t numValues, T &min, T &max)
 Return the minimum and maximum of a list of values.
static void globalMinMax (const Comm< int > &comm, bool flag, T localMin, T localMax, T &globalMin, T &globalMax)
 Find global minimum and maximum.
static bool areConsecutive (const T *val, size_t n)
 Determine if the values are locally increasing consecutive.

Detailed Description

template<typename T>
struct Zoltan2::IdentifierTraits< T >

The functions to be defined for users' global ID types.

The template parameter is the user's global ID data type.

The data types permitted for global identifiers for Zoltan2 callers may include those that are not represented in Teuchos::OrdinalTraits. A common case is when a matrix nonzero is represented as an (i,j) pair.

In such a case, Zoltan2 will map them to a list of new IDs that are Teuchos Ordinals. All computation will be in the space of the new global numbers. When the Solution object is written, the internal global numbers are mapped back to the user's global IDs.

During this process of determining if the user's IDs can be used by Zoltan2, and mapping them to new global numbers if they can not, the Traits defined here are used to manipulate the user's IDs.

Traits are defined for the following types:

The long long and unsigned long long traits are only defined if Trilinos was configured with the TEUCHOS_ENABLE_LONG_LONG_INT option.

If the user's global ID type does not appear in the above list, it can be added by the user in his or her application code. See the example in tobeWritten.cpp.

Todo:
write an example where user's global ID is a C-struct containing i and j indices.
Todo:
fix this note regarding gid_t Developer note: By convention we use gid_t as the users global ID data type and gno_t as the data type used internally by Zoltan2.

Each data type which is not defined in Teuchos::DirectSerializationTraits must have a Zoltan2::AlltoAllv specialization in Zoltan2_AlltoAll.hpp.

Definition at line 240 of file Zoltan2_IdentifierTraits.hpp.


Member Function Documentation

template<typename T>
static int Zoltan2::IdentifierTraits< T >::hashCode ( const T  id) [inline, static]

Compute an integer hash code for the user's global ID.

Parameters:
idthe user's global id
Returns:
the integer code, which need not be unique for each id

Definition at line 247 of file Zoltan2_IdentifierTraits.hpp.

template<typename T>
static bool Zoltan2::IdentifierTraits< T >::hasUniqueKey ( ) [inline, static]

Determine if the data type supports unique hash keys.

Returns:
true if unique hash keys (of data type double) can be generated given a value, with no knowledge about the global space of values.

Definition at line 255 of file Zoltan2_IdentifierTraits.hpp.

template<typename T>
static double Zoltan2::IdentifierTraits< T >::key ( const T  c) [inline, static]

Return a double which is a unique key for the value.

Returns:
the integer code, which need not be unique for each id

if hasUniqueKey() is false, throw a logic_error.

Definition at line 265 of file Zoltan2_IdentifierTraits.hpp.

template<typename T>
static std::string Zoltan2::IdentifierTraits< T >::name ( ) [inline, static]

The name of the identifier data type.

Returns:
The name

Definition at line 271 of file Zoltan2_IdentifierTraits.hpp.

template<typename T>
static std::string Zoltan2::IdentifierTraits< T >::stringify ( val) [inline, static]

A string displaying the value.

Parameters:
valthe value to represent as a string
Returns:
The string

Definition at line 280 of file Zoltan2_IdentifierTraits.hpp.

template<typename T>
static bool Zoltan2::IdentifierTraits< T >::isGlobalOrdinal ( ) [inline, static]

Determine whether the data type can be a Teuchos Ordinal.

Returns:
true if it can be a Teuchos Ordinal

Data types are those with a definition in Teuchos::OrdinalTraits.

Definition at line 290 of file Zoltan2_IdentifierTraits.hpp.

template<typename T>
static T Zoltan2::IdentifierTraits< T >::difference ( const T  a,
const T  b 
) [inline, static]

Compute b - a, if possible.

Parameters:
aThe a of b-a
bThe b of b-a
Returns:
the value b-a

A std::logic_error is throw at runtime if the operation is not valid for T.

Definition at line 303 of file Zoltan2_IdentifierTraits.hpp.

template<typename T>
static bool Zoltan2::IdentifierTraits< T >::is_valid_id_type ( ) [inline, static]

Determine if the data type is one for which IdentifierTraits are defined.

Returns:
true if data type has definition

Definition at line 312 of file Zoltan2_IdentifierTraits.hpp.

template<typename T>
static void Zoltan2::IdentifierTraits< T >::minMax ( const T *  values,
size_t  numValues,
T &  min,
T &  max 
) [inline, static]

Return the minimum and maximum of a list of values.

Parameters:
valuesa pointer to numValues values
numValuesthe number of values to consider
minon return the minimum value in the list
maxon return the maximum value in the list

A std::logic_error is throw at runtime if T is a type that can not be ordered.

Definition at line 323 of file Zoltan2_IdentifierTraits.hpp.

template<typename T>
static void Zoltan2::IdentifierTraits< T >::globalMinMax ( const Comm< int > &  comm,
bool  flag,
localMin,
localMax,
T &  globalMin,
T &  globalMax 
) [inline, static]

Find global minimum and maximum.

Parameters:
commCommunicator for global operation
flagtrue if there are no values on this process (so localMin and localMax are ignored), false otherwise
localMinThe local minimum
localMaxThe local maximum
globalMinOn return, the global minimum
globalMaxOn return, the global maximum

A std::logic_error is throw at runtime if T is a type that can not be ordered.

Definition at line 340 of file Zoltan2_IdentifierTraits.hpp.

template<typename T>
static bool Zoltan2::IdentifierTraits< T >::areConsecutive ( const T *  val,
size_t  n 
) [inline, static]

Determine if the values are locally increasing consecutive.

Parameters:
vala pointer to n values
nthe number of values in the list
Returns:
true if the values are increasing consecutive, false if otherwise

A std::logic_error is throw at runtime if T is a type that can not be ordered.

Definition at line 355 of file Zoltan2_IdentifierTraits.hpp.


The documentation for this struct was generated from the following file: