Skip to content
Snippets Groups Projects
  • William F Godoy's avatar
    77a5923b
    Tested refactored implementation · 77a5923b
    William F Godoy authored
    1 Now IO (replaced Method) and is the factory for Variables and Engines
    2 Reduced core components to user-public objects only
    3 Moved and reorganized all helper functions to helper directory
    4 Engines are now lightweight (except for ADIOS1Reader WIP) using MACRO
    5 HF5Common and ADIOS1Common (except for Readers WIP) are now part of the toolkit so they can be reused by Engines
    6 TransportMan is a new layer for transport management (file is default)
    7 DataMan will be implemented under toolkit/transportman/dataman
    8 Template separation (tcc and inl) applied all over the code
    9 Improved Doxygen documentation
    
    Runtime Issues:
    DataMan library compilation (cacheman)
    ADIOS1 Warning
    TestADIOSInterfaceWrite catches exceptions
    77a5923b
    History
    Tested refactored implementation
    William F Godoy authored
    1 Now IO (replaced Method) and is the factory for Variables and Engines
    2 Reduced core components to user-public objects only
    3 Moved and reorganized all helper functions to helper directory
    4 Engines are now lightweight (except for ADIOS1Reader WIP) using MACRO
    5 HF5Common and ADIOS1Common (except for Readers WIP) are now part of the toolkit so they can be reused by Engines
    6 TransportMan is a new layer for transport management (file is default)
    7 DataMan will be implemented under toolkit/transportman/dataman
    8 Template separation (tcc and inl) applied all over the code
    9 Improved Doxygen documentation
    
    Runtime Issues:
    DataMan library compilation (cacheman)
    ADIOS1 Warning
    TestADIOSInterfaceWrite catches exceptions
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
adiosMath.h 2.76 KiB
/*
 * Distributed under the OSI-approved Apache License, Version 2.0.  See
 * accompanying file Copyright.txt for details.
 *
 * adiosMath.h math functions used in the ADIOS framework
 *
 *  Created on: May 17, 2017
 *      Author: William F Godoy godoywf@ornl.gov
 */

#ifndef ADIOS2_HELPER_ADIOSMATH_H_
#define ADIOS2_HELPER_ADIOSMATH_H_

/// \cond EXCLUDE_FROM_DOXYGEN
#include <vector>
/// \endcond

#include "adios2/ADIOSTypes.h"

namespace adios
{
/**
 * Loops through a vector containing dimensions and returns the product of all
 * elements
 * @param dimensions input containing size on each dimension {Nx, Ny, Nz}
 * @return product of all dimensions Nx * Ny * Nz
 */
size_t GetTotalSize(const Dims &dimensions) noexcept;

/**
 * Gets the min and max from a values array of primitive types (not including
 * complex)
 * @param values input array
 * @param size of values array
 * @param min of values
 * @param max of values
 */
template <class T>
void GetMinMax(const T *values, const size_t size, T &min, T &max) noexcept;

/**
 * Version for complex types of GetMinMax, gets the "doughnut" range between min
 * and max modulus. Needed a different function as thread can't resolve the
 * overload of a GetMinMax with complex types
 * @param values array of complex numbers
 * @param size of the values array
 * @param min modulus from values
 * @param max modulus from values
 */
template <class T>
void GetMinMaxComplex(const std::complex<T> *values, const size_t size, T &min,
                      T &max) noexcept;

/**
 * Threaded version of GetMinMax.
 * Gets the min and max from a values array of primitive types (not including
 * complex) using threads
 * @param values input array of complex
 * @param size of values array
 * @param min of values
 * @param max of values
 * @param threads used for parallel computation
 */
template <class T>
void GetMinMaxThreads(const T *values, const size_t size, T &min, T &max,
                      const unsigned int threads = 1) noexcept;

/**
 * Overloaded version of GetMinMaxThreads for complex types
 * @param values input array of complex
 * @param size of values array
 * @param min of values
 * @param max of values
 * @param threads used for parallel computation
 */
template <class T>
void GetMinMaxThreads(const std::complex<T> *values, const size_t size, T &min,
                      T &max, const unsigned int threads = 1) noexcept;

/**
 * Check if index is within (inclusive) limits
 * lowerLimit <= index <= upperLimit
 * @param index input to be checked
 * @param upperLimit
 * @param lowerLimit
 * @return true index is within limits
 */
bool CheckIndexRange(const int index, const int upperLimit,
                     const int lowerLimit = 0) noexcept;

} // end namespace adios

#include "adiosMath.inl"

#endif /* ADIOS2_HELPER_ADIOSMATH_H_ */