mirror of
https://github.com/PhasicFlow/phasicFlow.git
synced 2025-06-22 16:28:30 +00:00
format clang-format
This commit is contained in:
@ -28,18 +28,15 @@ Licence:
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <Kokkos_Core.hpp>
|
#include <Kokkos_Core.hpp>
|
||||||
#include <Kokkos_DualView.hpp>
|
#include <Kokkos_DualView.hpp>
|
||||||
#include <Kokkos_UnorderedMap.hpp>
|
#include <Kokkos_UnorderedMap.hpp>
|
||||||
|
|
||||||
#include "builtinTypes.hpp"
|
#include "builtinTypes.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/// Host memory space
|
/// Host memory space
|
||||||
using HostSpace = Kokkos::HostSpace;
|
using HostSpace = Kokkos::HostSpace;
|
||||||
|
|
||||||
@ -63,34 +60,26 @@ using DefaultHostExecutionSpace = Kokkos::DefaultHostExecutionSpace;
|
|||||||
/// activated.
|
/// activated.
|
||||||
using DefaultExecutionSpace = Kokkos::DefaultExecutionSpace;
|
using DefaultExecutionSpace = Kokkos::DefaultExecutionSpace;
|
||||||
|
|
||||||
|
using deviceRPolicyStatic = Kokkos::RangePolicy<
|
||||||
using deviceRPolicyStatic =
|
|
||||||
Kokkos::RangePolicy<
|
|
||||||
Kokkos::DefaultExecutionSpace,
|
Kokkos::DefaultExecutionSpace,
|
||||||
Kokkos::Schedule<Kokkos::Static>,
|
Kokkos::Schedule<Kokkos::Static>,
|
||||||
Kokkos::IndexType<pFlow::uint32>>;
|
Kokkos::IndexType<pFlow::uint32>>;
|
||||||
|
|
||||||
|
using hostRPolicyStatic = Kokkos::RangePolicy<
|
||||||
using hostRPolicyStatic =
|
|
||||||
Kokkos::RangePolicy<
|
|
||||||
Kokkos::DefaultExecutionSpace,
|
Kokkos::DefaultExecutionSpace,
|
||||||
Kokkos::Schedule<Kokkos::Static>,
|
Kokkos::Schedule<Kokkos::Static>,
|
||||||
Kokkos::IndexType<pFlow::uint32>>;
|
Kokkos::IndexType<pFlow::uint32>>;
|
||||||
|
|
||||||
using deviceRPolicyDynamic =
|
using deviceRPolicyDynamic = Kokkos::RangePolicy<
|
||||||
Kokkos::RangePolicy<
|
|
||||||
Kokkos::DefaultExecutionSpace,
|
Kokkos::DefaultExecutionSpace,
|
||||||
Kokkos::Schedule<Kokkos::Dynamic>,
|
Kokkos::Schedule<Kokkos::Dynamic>,
|
||||||
Kokkos::IndexType<pFlow::uint32>>;
|
Kokkos::IndexType<pFlow::uint32>>;
|
||||||
|
|
||||||
|
using hostRPolicyDynamic = Kokkos::RangePolicy<
|
||||||
using hostRPolicyDynamic =
|
|
||||||
Kokkos::RangePolicy<
|
|
||||||
Kokkos::DefaultExecutionSpace,
|
Kokkos::DefaultExecutionSpace,
|
||||||
Kokkos::Schedule<Kokkos::Dynamic>,
|
Kokkos::Schedule<Kokkos::Dynamic>,
|
||||||
Kokkos::IndexType<pFlow::uint32>>;
|
Kokkos::IndexType<pFlow::uint32>>;
|
||||||
|
|
||||||
|
|
||||||
/// Pair of two variables
|
/// Pair of two variables
|
||||||
template<typename T1, typename T2>
|
template<typename T1, typename T2>
|
||||||
using Pair = Kokkos::pair<T1, T2>;
|
using Pair = Kokkos::pair<T1, T2>;
|
||||||
@ -139,8 +128,6 @@ template<typename T, typename Layout=void>
|
|||||||
template<typename T, typename Layout = void>
|
template<typename T, typename Layout = void>
|
||||||
using deviceViewType3D = Kokkos::View<T***, Layout, void>;
|
using deviceViewType3D = Kokkos::View<T***, Layout, void>;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
using hostViewTypeScalar = Kokkos::View<T, Kokkos::HostSpace>;
|
using hostViewTypeScalar = Kokkos::View<T, Kokkos::HostSpace>;
|
||||||
|
|
||||||
@ -158,18 +145,17 @@ template<typename T, typename Layout=void>
|
|||||||
|
|
||||||
/// 1D vector on device with atomic capabilities
|
/// 1D vector on device with atomic capabilities
|
||||||
template<typename T>
|
template<typename T>
|
||||||
using deviceAtomicViewType1D =
|
using deviceAtomicViewType1D = Kokkos::View<
|
||||||
Kokkos::View<
|
|
||||||
T*,
|
T*,
|
||||||
Kokkos::MemoryTraits<std::is_same<DefaultExecutionSpace,Serial>::value?0:Kokkos::Atomic>>;
|
Kokkos::MemoryTraits<
|
||||||
|
std::is_same_v<DefaultExecutionSpace, Serial> ? 0 : Kokkos::Atomic>>;
|
||||||
|
|
||||||
/// 3D array on device with atomic capabilities
|
/// 3D array on device with atomic capabilities
|
||||||
template<typename T>
|
template<typename T>
|
||||||
using deviceAtomicViewType3D =
|
using deviceAtomicViewType3D = Kokkos::View<
|
||||||
Kokkos::View<
|
|
||||||
T***,
|
T***,
|
||||||
Kokkos::MemoryTraits<std::is_same<DefaultExecutionSpace,Serial>::value?0:Kokkos::Atomic>>;
|
Kokkos::MemoryTraits<
|
||||||
|
std::is_same_v<DefaultExecutionSpace, Serial> ? 0 : Kokkos::Atomic>>;
|
||||||
|
|
||||||
} // pFlow
|
} // pFlow
|
||||||
|
|
||||||
|
@ -21,201 +21,198 @@ Licence:
|
|||||||
#ifndef __KokkosUtilities_hpp__
|
#ifndef __KokkosUtilities_hpp__
|
||||||
#define __KokkosUtilities_hpp__
|
#define __KokkosUtilities_hpp__
|
||||||
|
|
||||||
|
|
||||||
#include "KokkosTypes.hpp"
|
#include "KokkosTypes.hpp"
|
||||||
#include "pFlowMacros.hpp"
|
|
||||||
#include "types.hpp"
|
|
||||||
#include "span.hpp"
|
|
||||||
#include "dataIO.hpp"
|
#include "dataIO.hpp"
|
||||||
#include "iOstream.hpp"
|
#include "iOstream.hpp"
|
||||||
|
#include "pFlowMacros.hpp"
|
||||||
|
#include "span.hpp"
|
||||||
|
#include "types.hpp"
|
||||||
|
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
|
|
||||||
template<typename ExecutionSpace>
|
template<typename ExecutionSpace>
|
||||||
INLINE_FUNCTION_H
|
INLINE_FUNCTION_H bool constexpr isHostAccessible()
|
||||||
bool constexpr isHostAccessible()
|
|
||||||
{
|
{
|
||||||
return Kokkos::SpaceAccessibility<ExecutionSpace, HostSpace>::accessible;
|
return Kokkos::SpaceAccessibility<ExecutionSpace, HostSpace>::accessible;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename ExecutionSpace>
|
template<typename ExecutionSpace>
|
||||||
INLINE_FUNCTION_H
|
INLINE_FUNCTION_H bool constexpr isDeviceAccessible()
|
||||||
bool constexpr isDeviceAccessible()
|
|
||||||
{
|
{
|
||||||
return Kokkos::SpaceAccessibility<ExecutionSpace,DefaultExecutionSpace::memory_space>::accessible;
|
return Kokkos::SpaceAccessibility<
|
||||||
|
ExecutionSpace,
|
||||||
|
DefaultExecutionSpace::memory_space>::accessible;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Is MemoerySpace accessible from ExecutionSpace
|
/// Is MemoerySpace accessible from ExecutionSpace
|
||||||
template<typename ExecutionSpace, typename MemoerySpace>
|
template<typename ExecutionSpace, typename MemoerySpace>
|
||||||
INLINE_FUNCTION_H
|
INLINE_FUNCTION_H bool constexpr areAccessible()
|
||||||
bool constexpr areAccessible()
|
|
||||||
{
|
{
|
||||||
return Kokkos::SpaceAccessibility<ExecutionSpace, MemoerySpace>::accessible;
|
return Kokkos::SpaceAccessibility<ExecutionSpace, MemoerySpace>::accessible;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <
|
template<typename Type, typename... Properties>
|
||||||
typename Type,
|
INLINE_FUNCTION_H void
|
||||||
typename... Properties>
|
reallocInit(ViewType1D<Type, Properties...>& view, uint32 len)
|
||||||
INLINE_FUNCTION_H
|
|
||||||
void reallocInit( ViewType1D<Type,Properties...>& view, uint32 len)
|
|
||||||
{
|
{
|
||||||
Kokkos::realloc(Kokkos::WithoutInitializing, view, len);
|
Kokkos::realloc(Kokkos::WithoutInitializing, view, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <
|
template<typename Type, typename... Properties>
|
||||||
typename Type,
|
INLINE_FUNCTION_H void
|
||||||
typename... Properties>
|
reallocNoInit(ViewType1D<Type, Properties...>& view, uint32 len)
|
||||||
INLINE_FUNCTION_H
|
|
||||||
void reallocNoInit(ViewType1D<Type,Properties...>& view, uint32 len)
|
|
||||||
{
|
{
|
||||||
Kokkos::realloc(Kokkos::WithoutInitializing, view, len);
|
Kokkos::realloc(Kokkos::WithoutInitializing, view, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <
|
template<typename Type, typename... Properties>
|
||||||
typename Type,
|
INLINE_FUNCTION_H void
|
||||||
typename... Properties>
|
reallocFill(ViewType1D<Type, Properties...>& view, uint32 len, Type val)
|
||||||
INLINE_FUNCTION_H
|
|
||||||
void reallocFill( ViewType1D<Type,Properties...>& view, uint32 len, Type val)
|
|
||||||
{
|
{
|
||||||
reallocNoInit(view, len);
|
reallocNoInit(view, len);
|
||||||
Kokkos::deep_copy(view, val);
|
Kokkos::deep_copy(view, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <
|
template<typename Type, typename... Properties>
|
||||||
typename Type,
|
INLINE_FUNCTION_H void
|
||||||
typename... Properties>
|
reallocInit(ViewType2D<Type, Properties...>& view, uint32 len1, uint32 len2)
|
||||||
INLINE_FUNCTION_H
|
|
||||||
void reallocInit( ViewType2D<Type,Properties...>& view, uint32 len1, uint32 len2)
|
|
||||||
{
|
{
|
||||||
Kokkos::realloc(view, len1, len2);
|
Kokkos::realloc(view, len1, len2);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <
|
template<typename Type, typename... Properties>
|
||||||
typename Type,
|
INLINE_FUNCTION_H void
|
||||||
typename... Properties>
|
reallocNoInit(ViewType2D<Type, Properties...>& view, uint32 len1, uint32 len2)
|
||||||
INLINE_FUNCTION_H
|
|
||||||
void reallocNoInit(ViewType2D<Type,Properties...>& view, uint32 len1, uint32 len2)
|
|
||||||
{
|
{
|
||||||
Kokkos::realloc(Kokkos::WithoutInitializing, view, len1, len2);
|
Kokkos::realloc(Kokkos::WithoutInitializing, view, len1, len2);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <
|
template<typename Type, typename... Properties>
|
||||||
typename Type,
|
INLINE_FUNCTION_H void
|
||||||
typename... Properties>
|
reallocFill(
|
||||||
INLINE_FUNCTION_H
|
ViewType2D<Type, Properties...>& view,
|
||||||
void reallocFill( ViewType2D<Type,Properties...>& view, uint32 len1, uint32 len2, Type val)
|
uint32 len1,
|
||||||
|
uint32 len2,
|
||||||
|
Type val
|
||||||
|
)
|
||||||
{
|
{
|
||||||
reallocNoInit(view, len1, len2);
|
reallocNoInit(view, len1, len2);
|
||||||
Kokkos::deep_copy(view, val);
|
Kokkos::deep_copy(view, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <
|
template<typename Type, typename... Properties>
|
||||||
typename Type,
|
INLINE_FUNCTION_H void
|
||||||
typename... Properties>
|
reallocInit(
|
||||||
INLINE_FUNCTION_H
|
ViewType3D<Type, Properties...>& view,
|
||||||
void reallocInit( ViewType3D<Type,Properties...>& view, uint32 len1, uint32 len2, uint32 len3)
|
uint32 len1,
|
||||||
|
uint32 len2,
|
||||||
|
uint32 len3
|
||||||
|
)
|
||||||
{
|
{
|
||||||
Kokkos::realloc(view, len1, len2, len3);
|
Kokkos::realloc(view, len1, len2, len3);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <
|
template<typename Type, typename... Properties>
|
||||||
typename Type,
|
INLINE_FUNCTION_H void
|
||||||
typename... Properties>
|
reallocNoInit(
|
||||||
INLINE_FUNCTION_H
|
ViewType3D<Type, Properties...>& view,
|
||||||
void reallocNoInit(ViewType3D<Type,Properties...>& view, uint32 len1, uint32 len2, uint32 len3)
|
uint32 len1,
|
||||||
|
uint32 len2,
|
||||||
|
uint32 len3
|
||||||
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
Kokkos::realloc(Kokkos::WithoutInitializing, view, len1, len2, len3);
|
Kokkos::realloc(Kokkos::WithoutInitializing, view, len1, len2, len3);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <
|
template<typename Type, typename... Properties>
|
||||||
typename Type,
|
INLINE_FUNCTION_H void
|
||||||
typename... Properties>
|
reallocFill(
|
||||||
INLINE_FUNCTION_H
|
ViewType3D<Type, Properties...>& view,
|
||||||
void reallocFill( ViewType3D<Type,Properties...>& view, uint32 len1, uint32 len2, uint32 len3, Type val)
|
uint32 len1,
|
||||||
|
uint32 len2,
|
||||||
|
uint32 len3,
|
||||||
|
Type val
|
||||||
|
)
|
||||||
{
|
{
|
||||||
reallocNoInit(view, len1, len2, len3);
|
reallocNoInit(view, len1, len2, len3);
|
||||||
Kokkos::deep_copy(view, val);
|
Kokkos::deep_copy(view, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <
|
template<typename Type, typename... Properties>
|
||||||
typename Type,
|
INLINE_FUNCTION_H void
|
||||||
typename... Properties>
|
resizeInit(ViewType1D<Type, Properties...>& view, uint32 newLen)
|
||||||
INLINE_FUNCTION_H
|
|
||||||
void resizeInit(ViewType1D<Type,Properties...>& view, uint32 newLen)
|
|
||||||
{
|
{
|
||||||
Kokkos::resize(view, newLen);
|
Kokkos::resize(view, newLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <
|
template<typename Type, typename... Properties>
|
||||||
typename Type,
|
INLINE_FUNCTION_H void
|
||||||
typename... Properties>
|
resizeNoInit(ViewType1D<Type, Properties...>& view, uint32 newLen)
|
||||||
INLINE_FUNCTION_H
|
|
||||||
void resizeNoInit(ViewType1D<Type,Properties...>& view, uint32 newLen)
|
|
||||||
{
|
{
|
||||||
Kokkos::resize(Kokkos::WithoutInitializing, view, newLen);
|
Kokkos::resize(Kokkos::WithoutInitializing, view, newLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename ViewType>
|
template<typename ViewType>
|
||||||
INLINE_FUNCTION_H
|
INLINE_FUNCTION_H void
|
||||||
void swapViews(ViewType& v1, ViewType &v2)
|
swapViews(ViewType& v1, ViewType& v2)
|
||||||
{
|
{
|
||||||
static_assert(
|
static_assert(
|
||||||
std::is_move_assignable<ViewType>::value && std::is_move_constructible<ViewType>::value,
|
std::is_move_assignable_v<ViewType> &&
|
||||||
"swapViews arguments must be move assignable and move constructible");
|
std::is_move_constructible_v<ViewType>,
|
||||||
|
"swapViews arguments must be move assignable and move constructible"
|
||||||
|
);
|
||||||
|
|
||||||
ViewType tmp = std::move(v1);
|
ViewType tmp = std::move(v1);
|
||||||
v1 = std::move(v2);
|
v1 = std::move(v2);
|
||||||
v2 = std::move(tmp);
|
v2 = std::move(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename T1, typename T2>
|
template<typename T1, typename T2>
|
||||||
INLINE_FUNCTION_H
|
INLINE_FUNCTION_H iOstream&
|
||||||
iOstream& operator <<(iOstream& os, const Pair<T1,T2>& p)
|
operator<<(iOstream& os, const Pair<T1, T2>& p)
|
||||||
{
|
{
|
||||||
os << '(' << p.first << " " << p.second << ')';
|
os << '(' << p.first << " " << p.second << ')';
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
template<typename T, typename... properties>
|
||||||
INLINE_FUNCTION_H
|
INLINE_FUNCTION_H span<T>
|
||||||
span<T> makeSpan(ViewType1D<T, properties...> & v)
|
makeSpan(ViewType1D<T, properties...>& v)
|
||||||
{
|
{
|
||||||
return span<T>(v.data(), v.size());
|
return span<T>(v.data(), v.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
template<typename T, typename... properties>
|
||||||
INLINE_FUNCTION_H
|
INLINE_FUNCTION_H span<T>
|
||||||
span<T> makeSpan(ViewType1D<T, properties...> & v, uint32 size)
|
makeSpan(ViewType1D<T, properties...>& v, uint32 size)
|
||||||
{
|
{
|
||||||
return span<T>(v.data(), size);
|
return span<T>(v.data(), size);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
template<typename T, typename... properties>
|
||||||
INLINE_FUNCTION_H
|
INLINE_FUNCTION_H span<T>
|
||||||
span<T> makeSpan(const ViewType1D<T, properties...> & v)
|
makeSpan(const ViewType1D<T, properties...>& v)
|
||||||
{
|
{
|
||||||
return span<T>(const_cast<T*>(v.data()), v.size());
|
return span<T>(const_cast<T*>(v.data()), v.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
template<typename T, typename... properties>
|
||||||
INLINE_FUNCTION_H
|
INLINE_FUNCTION_H span<T>
|
||||||
span<T> makeSpan(const ViewType1D<T, properties...> & v, uint32 size)
|
makeSpan(const ViewType1D<T, properties...>& v, uint32 size)
|
||||||
{
|
{
|
||||||
return span<T>(const_cast<T*>(v.data()), size);
|
return span<T>(const_cast<T*>(v.data()), size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
template<typename T, typename... properties>
|
||||||
INLINE_FUNCTION_H
|
INLINE_FUNCTION_H iOstream&
|
||||||
iOstream& operator <<(iOstream& os, const ViewType1D<T, properties...> & v)
|
operator<<(iOstream& os, const ViewType1D<T, properties...>& v)
|
||||||
{
|
{
|
||||||
|
|
||||||
using ExSpace = typename ViewType1D<T, properties...>::execution_space;
|
using ExSpace = typename ViewType1D<T, properties...>::execution_space;
|
||||||
|
|
||||||
static_assert(isHostAccessible<ExSpace>(), "View memory is not accessible from Host");
|
static_assert(
|
||||||
|
isHostAccessible<ExSpace>(), "View memory is not accessible from Host"
|
||||||
|
);
|
||||||
|
|
||||||
span<T> spn(v.data(), v.size());
|
span<T> spn(v.data(), v.size());
|
||||||
os << spn;
|
os << spn;
|
||||||
@ -223,7 +220,6 @@ iOstream& operator <<(iOstream& os, const ViewType1D<T, properties...> & v)
|
|||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // pFlow
|
} // pFlow
|
||||||
|
|
||||||
#endif //__KokkosUtilities_hpp__
|
#endif //__KokkosUtilities_hpp__
|
||||||
|
@ -20,29 +20,22 @@ Licence:
|
|||||||
#ifndef __Range_hpp__
|
#ifndef __Range_hpp__
|
||||||
#define __Range_hpp__
|
#define __Range_hpp__
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <Kokkos_Core.hpp>
|
#include <Kokkos_Core.hpp>
|
||||||
|
|
||||||
#include "pFlowMacros.hpp"
|
|
||||||
#include "typeInfo.hpp"
|
|
||||||
#include "builtinTypes.hpp"
|
#include "builtinTypes.hpp"
|
||||||
#include "iOstream.hpp"
|
#include "iOstream.hpp"
|
||||||
|
#include "pFlowMacros.hpp"
|
||||||
|
#include "typeInfo.hpp"
|
||||||
|
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Range for elements in an vector [start,end)
|
* Range for elements in an vector [start,end)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct Range
|
struct Range : public Kokkos::pair<T, T>
|
||||||
:
|
|
||||||
public Kokkos::pair<T,T>
|
|
||||||
{
|
{
|
||||||
using Pair = Kokkos::pair<T, T>;
|
using Pair = Kokkos::pair<T, T>;
|
||||||
|
|
||||||
@ -51,29 +44,30 @@ public Kokkos::pair<T,T>
|
|||||||
//// - Constructors
|
//// - Constructors
|
||||||
|
|
||||||
/// Default
|
/// Default
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD Range()
|
||||||
Range(){}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// From end, set start to 0
|
/// From end, set start to 0
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
Range(const T& e)
|
Range(const T& e)
|
||||||
:
|
: Range(0, e)
|
||||||
Range(0,e)
|
{
|
||||||
{}
|
}
|
||||||
|
|
||||||
/// From componeents
|
/// From componeents
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
Range(const T& s, const T& e)
|
Range(const T& s, const T& e)
|
||||||
:
|
: Range::Pair(s, e)
|
||||||
Range::Pair(s,e)
|
{
|
||||||
{}
|
}
|
||||||
|
|
||||||
/// From pair
|
/// From pair
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
Range(const Range::Pair& src)
|
Range(const Range::Pair& src)
|
||||||
:
|
: Range::Pair(src)
|
||||||
Range::Pair(src)
|
{
|
||||||
{}
|
}
|
||||||
|
|
||||||
/// Copy
|
/// Copy
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
@ -134,12 +128,11 @@ public Kokkos::pair<T,T>
|
|||||||
{
|
{
|
||||||
return Pair(this->first, this->second);
|
return Pair(this->first, this->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_H
|
INLINE_FUNCTION_H iOstream&
|
||||||
iOstream& operator <<(iOstream& os, const Range<T>& rng)
|
operator<<(iOstream& os, const Range<T>& rng)
|
||||||
{
|
{
|
||||||
os << "[" << rng.start() << " " << rng.end() << ")";
|
os << "[" << rng.start() << " " << rng.end() << ")";
|
||||||
return os;
|
return os;
|
||||||
@ -153,7 +146,6 @@ using rangeU32 = Range<uint32>;
|
|||||||
|
|
||||||
using rangeU64 = Range<uint64>;
|
using rangeU64 = Range<uint64>;
|
||||||
|
|
||||||
|
|
||||||
} // pFlow
|
} // pFlow
|
||||||
|
|
||||||
#endif //__KokkosTypes_hpp__
|
#endif //__KokkosTypes_hpp__
|
||||||
|
@ -21,47 +21,38 @@ Licence:
|
|||||||
#ifndef __ViewAlgorithms_hpp__
|
#ifndef __ViewAlgorithms_hpp__
|
||||||
#define __ViewAlgorithms_hpp__
|
#define __ViewAlgorithms_hpp__
|
||||||
|
|
||||||
|
|
||||||
#include "numericConstants.hpp"
|
|
||||||
#include "Range.hpp"
|
|
||||||
#include "KokkosUtilities.hpp"
|
#include "KokkosUtilities.hpp"
|
||||||
|
#include "Range.hpp"
|
||||||
|
#include "numericConstants.hpp"
|
||||||
|
|
||||||
|
#include "cudaAlgorithms.hpp"
|
||||||
#include "kokkosAlgorithms.hpp"
|
#include "kokkosAlgorithms.hpp"
|
||||||
#include "stdAlgorithms.hpp"
|
#include "stdAlgorithms.hpp"
|
||||||
#include "cudaAlgorithms.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
template<typename T, typename... properties>
|
template<typename T, typename... properties>
|
||||||
INLINE_FUNCTION_H
|
INLINE_FUNCTION_H uint32
|
||||||
uint32 count(
|
count(
|
||||||
const ViewType1D<T, properties...>& view,
|
const ViewType1D<T, properties...>& view,
|
||||||
uint32 start,
|
uint32 start,
|
||||||
uint32 end,
|
uint32 end,
|
||||||
const T& val)
|
const T& val
|
||||||
|
)
|
||||||
{
|
{
|
||||||
|
using ExecutionSpace =
|
||||||
using ExecutionSpace = typename ViewType1D<T, properties...>::execution_space;
|
typename ViewType1D<T, properties...>::execution_space;
|
||||||
|
|
||||||
uint32 numElems = end - start;
|
uint32 numElems = end - start;
|
||||||
|
|
||||||
return pFlow::algorithms::KOKKOS::count<T, ExecutionSpace>
|
return pFlow::algorithms::KOKKOS::count<T, ExecutionSpace>(
|
||||||
(
|
view.data() + start, numElems, val
|
||||||
view.data()+start,
|
|
||||||
numElems,
|
|
||||||
val
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
template<typename T, typename... properties>
|
||||||
INLINE_FUNCTION_H
|
INLINE_FUNCTION_H void
|
||||||
void fill
|
fill(ViewType1D<T, properties...>& view, rangeU32 span, T val)
|
||||||
(
|
|
||||||
ViewType1D<T, properties...>& view,
|
|
||||||
rangeU32 span,
|
|
||||||
T val
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
using exe_space = typename ViewType1D<T, properties...>::execution_space;
|
using exe_space = typename ViewType1D<T, properties...>::execution_space;
|
||||||
auto subV = Kokkos::subview(view, span.getPair());
|
auto subV = Kokkos::subview(view, span.getPair());
|
||||||
@ -80,24 +71,18 @@ void fill
|
|||||||
{
|
{
|
||||||
static_assert("fill is not valid for non-trivially-copyable data type");
|
static_assert("fill is not valid for non-trivially-copyable data type");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
template<typename T, typename... properties>
|
||||||
void fill
|
void
|
||||||
(
|
fill(ViewType1D<T, properties...>& view, uint32 start, uint32 end, T val)
|
||||||
ViewType1D<T, properties...>& view,
|
|
||||||
uint32 start,
|
|
||||||
uint32 end,
|
|
||||||
T val
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
fill(view, rangeU32(start, end), val);
|
fill(view, rangeU32(start, end), val);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
template<typename T, typename... properties>
|
||||||
void fill
|
void
|
||||||
(
|
fill(
|
||||||
ViewType3D<T, properties...>& view,
|
ViewType3D<T, properties...>& view,
|
||||||
rangeU32 range1,
|
rangeU32 range1,
|
||||||
rangeU32 range2,
|
rangeU32 range2,
|
||||||
@ -111,59 +96,58 @@ void fill
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
template<typename T, typename... properties>
|
||||||
void fill
|
void
|
||||||
(
|
fill(ViewType3D<T, properties...>& view, const T& val)
|
||||||
ViewType3D<T, properties...>& view,
|
|
||||||
const T& val
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
static_assert(std::is_trivially_copyable_v<T>, "Not valid type for fill");
|
static_assert(std::is_trivially_copyable_v<T>, "Not valid type for fill");
|
||||||
Kokkos::deep_copy(view, val);
|
Kokkos::deep_copy(view, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<
|
template<typename Type, typename... properties>
|
||||||
typename Type,
|
void
|
||||||
typename... properties>
|
fillSequence(
|
||||||
void fillSequence(
|
|
||||||
ViewType1D<Type, properties...>& view,
|
ViewType1D<Type, properties...>& view,
|
||||||
uint32 start,
|
uint32 start,
|
||||||
uint32 end,
|
uint32 end,
|
||||||
const Type startVal
|
const Type startVal
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
static_assert(std::is_trivially_copyable_v<Type>, "Not valid type for fill");
|
static_assert(
|
||||||
using ExecutionSpace = typename ViewType1D<Type, properties...>::execution_space;
|
std::is_trivially_copyable_v<Type>, "Not valid type for fill"
|
||||||
|
);
|
||||||
|
using ExecutionSpace =
|
||||||
|
typename ViewType1D<Type, properties...>::execution_space;
|
||||||
uint32 numElems = end - start;
|
uint32 numElems = end - start;
|
||||||
|
|
||||||
pFlow::algorithms::KOKKOS::fillSequence<Type, ExecutionSpace>(
|
pFlow::algorithms::KOKKOS::fillSequence<Type, ExecutionSpace>(
|
||||||
view.data()+start,
|
view.data() + start, numElems, startVal
|
||||||
numElems,
|
);
|
||||||
startVal);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<
|
template<
|
||||||
typename Type,
|
typename Type,
|
||||||
typename... properties,
|
typename... properties,
|
||||||
typename indexType,
|
typename indexType,
|
||||||
typename... indexProperties>
|
typename... indexProperties>
|
||||||
bool fillSelected
|
bool
|
||||||
(
|
fillSelected(
|
||||||
ViewType1D<Type, properties...> view,
|
ViewType1D<Type, properties...> view,
|
||||||
ViewType1D<indexType, indexProperties...> indices,
|
ViewType1D<indexType, indexProperties...> indices,
|
||||||
uint32 numElems,
|
uint32 numElems,
|
||||||
Type val
|
Type val
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
static_assert(
|
||||||
static_assert(std::is_trivially_copyable_v<Type>, "Not valid type for fillSelected");
|
std::is_trivially_copyable_v<Type>, "Not valid type for fillSelected"
|
||||||
|
);
|
||||||
static_assert(
|
static_assert(
|
||||||
areAccessible<
|
areAccessible<
|
||||||
typename ViewType1D<Type, properties...>::execution_space,
|
typename ViewType1D<Type, properties...>::execution_space,
|
||||||
typename ViewType1D<indexType, indexProperties...>::memory_space>(),
|
typename ViewType1D<indexType, indexProperties...>::memory_space>(),
|
||||||
"In fillSelected, arguments view and indices must have similar spaces");
|
"In fillSelected, arguments view and indices must have similar spaces"
|
||||||
|
);
|
||||||
|
|
||||||
using ExSpace = typename ViewType1D<Type, properties...>::execution_space;
|
using ExSpace = typename ViewType1D<Type, properties...>::execution_space;
|
||||||
using policy = Kokkos::RangePolicy<ExSpace, Kokkos::IndexType<uint32>>;
|
using policy = Kokkos::RangePolicy<ExSpace, Kokkos::IndexType<uint32>>;
|
||||||
@ -173,7 +157,8 @@ bool fillSelected
|
|||||||
policy(0, numElems),
|
policy(0, numElems),
|
||||||
LAMBDA_HD(uint32 i){
|
LAMBDA_HD(uint32 i){
|
||||||
// view[indices[i]]= val;
|
// view[indices[i]]= val;
|
||||||
});
|
}
|
||||||
|
);
|
||||||
Kokkos::fence();
|
Kokkos::fence();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -184,66 +169,60 @@ template<
|
|||||||
typename... properties,
|
typename... properties,
|
||||||
typename indexType,
|
typename indexType,
|
||||||
typename... indexProperties>
|
typename... indexProperties>
|
||||||
bool fillSelected(
|
bool
|
||||||
|
fillSelected(
|
||||||
ViewType1D<Type, properties...> view,
|
ViewType1D<Type, properties...> view,
|
||||||
const ViewType1D<indexType, indexProperties...> indices,
|
const ViewType1D<indexType, indexProperties...> indices,
|
||||||
const ViewType1D<Type, properties...> vals,
|
const ViewType1D<Type, properties...> vals,
|
||||||
const uint32 numElems )
|
const uint32 numElems
|
||||||
|
)
|
||||||
{
|
{
|
||||||
static_assert(std::is_trivially_copyable_v<Type>, "Not valid type for fillSelected");
|
static_assert(
|
||||||
|
std::is_trivially_copyable_v<Type>, "Not valid type for fillSelected"
|
||||||
|
);
|
||||||
static_assert(
|
static_assert(
|
||||||
areAccessible<
|
areAccessible<
|
||||||
typename ViewType1D<Type, properties...>::execution_space,
|
typename ViewType1D<Type, properties...>::execution_space,
|
||||||
typename ViewType1D<indexType, indexProperties...>::memory_space>(),
|
typename ViewType1D<indexType, indexProperties...>::memory_space>(),
|
||||||
"In fillSelected arguments view and indices must have similar spaces");
|
"In fillSelected arguments view and indices must have similar spaces"
|
||||||
|
);
|
||||||
|
|
||||||
using ExecutionSpace = typename ViewType1D<Type, properties...>::execution_space;
|
using ExecutionSpace =
|
||||||
|
typename ViewType1D<Type, properties...>::execution_space;
|
||||||
|
|
||||||
pFlow::algorithms::KOKKOS::fillSelected<Type, indexType, ExecutionSpace>(
|
pFlow::algorithms::KOKKOS::fillSelected<Type, indexType, ExecutionSpace>(
|
||||||
view.data(),
|
view.data(), indices.data(), vals.data(), numElems
|
||||||
indices.data(),
|
|
||||||
vals.data(),
|
|
||||||
numElems
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
template<typename T, typename... properties>
|
||||||
INLINE_FUNCTION_H
|
INLINE_FUNCTION_H T
|
||||||
T min(
|
min(const ViewType1D<T, properties...>& view, uint32 start, uint32 end)
|
||||||
const ViewType1D<T, properties...>& view,
|
|
||||||
uint32 start,
|
|
||||||
uint32 end)
|
|
||||||
{
|
{
|
||||||
|
using ExecutionSpace =
|
||||||
using ExecutionSpace = typename ViewType1D<T, properties...>::execution_space;
|
typename ViewType1D<T, properties...>::execution_space;
|
||||||
|
|
||||||
uint32 numElems = end - start;
|
uint32 numElems = end - start;
|
||||||
|
|
||||||
return
|
return pFlow::algorithms::KOKKOS::min<T, ExecutionSpace>(
|
||||||
pFlow::algorithms::KOKKOS::min<T, ExecutionSpace>(
|
view.data() + start, numElems
|
||||||
view.data()+start,
|
);
|
||||||
numElems);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
template<typename T, typename... properties>
|
||||||
INLINE_FUNCTION_H
|
INLINE_FUNCTION_H T
|
||||||
T max(
|
max(const ViewType1D<T, properties...>& view, uint32 start, uint32 end)
|
||||||
const ViewType1D<T, properties...>& view,
|
|
||||||
uint32 start,
|
|
||||||
uint32 end)
|
|
||||||
{
|
{
|
||||||
|
using ExecutionSpace =
|
||||||
using ExecutionSpace = typename ViewType1D<T, properties...>::execution_space;
|
typename ViewType1D<T, properties...>::execution_space;
|
||||||
|
|
||||||
uint32 numElems = end - start;
|
uint32 numElems = end - start;
|
||||||
|
|
||||||
return
|
return pFlow::algorithms::KOKKOS::max<T, ExecutionSpace>(
|
||||||
pFlow::algorithms::KOKKOS::max<T, ExecutionSpace>(
|
view.data() + start, numElems
|
||||||
view.data()+start,
|
);
|
||||||
numElems);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<
|
template<
|
||||||
@ -251,8 +230,8 @@ template <
|
|||||||
typename... dProperties,
|
typename... dProperties,
|
||||||
typename sType,
|
typename sType,
|
||||||
typename... sProperties>
|
typename... sProperties>
|
||||||
INLINE_FUNCTION_H
|
INLINE_FUNCTION_H void
|
||||||
void copy(
|
copy(
|
||||||
const ViewType1D<dType, dProperties...>& dst,
|
const ViewType1D<dType, dProperties...>& dst,
|
||||||
const ViewType1D<sType, sProperties...>& src
|
const ViewType1D<sType, sProperties...>& src
|
||||||
)
|
)
|
||||||
@ -265,8 +244,8 @@ template <
|
|||||||
typename... dProperties,
|
typename... dProperties,
|
||||||
typename sType,
|
typename sType,
|
||||||
typename... sProperties>
|
typename... sProperties>
|
||||||
INLINE_FUNCTION_H
|
INLINE_FUNCTION_H void
|
||||||
void copy(
|
copy(
|
||||||
const ViewType1D<dType, dProperties...>& dst,
|
const ViewType1D<dType, dProperties...>& dst,
|
||||||
uint32 dStart,
|
uint32 dStart,
|
||||||
const ViewType1D<sType, sProperties...>& src,
|
const ViewType1D<sType, sProperties...>& src,
|
||||||
@ -274,7 +253,6 @@ void copy(
|
|||||||
uint32 sEnd
|
uint32 sEnd
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
range32 sSpan(sStart, sEnd);
|
range32 sSpan(sStart, sEnd);
|
||||||
range32 dSpan(dStart, dStart + (sEnd - sStart));
|
range32 dSpan(dStart, dStart + (sEnd - sStart));
|
||||||
|
|
||||||
@ -284,17 +262,10 @@ void copy(
|
|||||||
Kokkos::deep_copy(dstSub, srcSub);
|
Kokkos::deep_copy(dstSub, srcSub);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <
|
template<typename Type, typename... sProperties>
|
||||||
typename Type,
|
INLINE_FUNCTION_H void
|
||||||
typename... sProperties>
|
getNth(Type& dst, const ViewType1D<Type, sProperties...>& src, const uint32 n)
|
||||||
INLINE_FUNCTION_H
|
|
||||||
void getNth(
|
|
||||||
Type& dst,
|
|
||||||
const ViewType1D<Type, sProperties...>& src,
|
|
||||||
const uint32 n
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
auto subV = Kokkos::subview(src, Kokkos::make_pair(n, n + 1));
|
auto subV = Kokkos::subview(src, Kokkos::make_pair(n, n + 1));
|
||||||
hostViewType1D<Type> dstView("getNth", 1);
|
hostViewType1D<Type> dstView("getNth", 1);
|
||||||
// hostViewTypeScalar
|
// hostViewTypeScalar
|
||||||
@ -302,31 +273,24 @@ void getNth(
|
|||||||
dst = *dstView.data();
|
dst = *dstView.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
template<typename T, typename... properties>
|
||||||
INLINE_FUNCTION_H
|
INLINE_FUNCTION_H void
|
||||||
void sort(
|
sort(ViewType1D<T, properties...>& view, uint32 start, uint32 end)
|
||||||
ViewType1D<T, properties...>& view,
|
|
||||||
uint32 start,
|
|
||||||
uint32 end)
|
|
||||||
{
|
{
|
||||||
using ExecutionSpace = typename ViewType1D<T, properties...>::execution_space;
|
using ExecutionSpace =
|
||||||
|
typename ViewType1D<T, properties...>::execution_space;
|
||||||
|
|
||||||
uint32 numElems = end - start;
|
uint32 numElems = end - start;
|
||||||
|
|
||||||
if constexpr (isHostAccessible<ExecutionSpace>())
|
if constexpr (isHostAccessible<ExecutionSpace>())
|
||||||
{
|
{
|
||||||
pFlow::algorithms::STD::sort<T,true>(
|
pFlow::algorithms::STD::sort<T, true>(view.data() + start, numElems);
|
||||||
view.data()+start,
|
|
||||||
numElems);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __CUDACC__
|
#ifdef __CUDACC__
|
||||||
|
|
||||||
pFlow::algorithms::CUDA::sort<T>(
|
pFlow::algorithms::CUDA::sort<T>(view.data() + start, numElems);
|
||||||
view.data()+start,
|
|
||||||
numElems);
|
|
||||||
#else
|
#else
|
||||||
static_assert("sort on device is not defined!");
|
static_assert("sort on device is not defined!");
|
||||||
|
|
||||||
@ -336,33 +300,32 @@ void sort(
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename... properties, typename CompareFunc>
|
template<typename T, typename... properties, typename CompareFunc>
|
||||||
INLINE_FUNCTION_H
|
INLINE_FUNCTION_H void
|
||||||
void sort(
|
sort(
|
||||||
ViewType1D<T, properties...>& view,
|
ViewType1D<T, properties...>& view,
|
||||||
uint32 start,
|
uint32 start,
|
||||||
uint32 end,
|
uint32 end,
|
||||||
CompareFunc compare)
|
CompareFunc compare
|
||||||
|
)
|
||||||
{
|
{
|
||||||
|
using ExecutionSpace =
|
||||||
using ExecutionSpace = typename ViewType1D<T, properties...>::execution_space;
|
typename ViewType1D<T, properties...>::execution_space;
|
||||||
|
|
||||||
uint32 numElems = end - start;
|
uint32 numElems = end - start;
|
||||||
|
|
||||||
if constexpr (isHostAccessible<ExecutionSpace>())
|
if constexpr (isHostAccessible<ExecutionSpace>())
|
||||||
{
|
{
|
||||||
pFlow::algorithms::STD::sort<T, CompareFunc, true>(
|
pFlow::algorithms::STD::sort<T, CompareFunc, true>(
|
||||||
view.data()+start,
|
view.data() + start, numElems, compare
|
||||||
numElems,
|
);
|
||||||
compare);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __CUDACC__
|
#ifdef __CUDACC__
|
||||||
|
|
||||||
pFlow::algorithms::CUDA::sort<T, CompareFunc>(
|
pFlow::algorithms::CUDA::sort<T, CompareFunc>(
|
||||||
view.data()+start,
|
view.data() + start, numElems, compare
|
||||||
numElems,
|
);
|
||||||
compare);
|
|
||||||
#else
|
#else
|
||||||
static_assert("sort on device is not defined!");
|
static_assert("sort on device is not defined!");
|
||||||
|
|
||||||
@ -376,48 +339,49 @@ template<
|
|||||||
typename... properties,
|
typename... properties,
|
||||||
typename permType,
|
typename permType,
|
||||||
typename... permProperties>
|
typename... permProperties>
|
||||||
void permuteSort(
|
void
|
||||||
|
permuteSort(
|
||||||
const ViewType1D<Type, properties...>& view,
|
const ViewType1D<Type, properties...>& view,
|
||||||
uint32 start,
|
uint32 start,
|
||||||
uint32 end,
|
uint32 end,
|
||||||
ViewType1D<permType, permProperties...>& permuteView,
|
ViewType1D<permType, permProperties...>& permuteView,
|
||||||
uint32 permStart )
|
uint32 permStart
|
||||||
|
)
|
||||||
{
|
{
|
||||||
static_assert(
|
static_assert(
|
||||||
areAccessible<
|
areAccessible<
|
||||||
typename ViewType1D<Type, properties...>::execution_space,
|
typename ViewType1D<Type, properties...>::execution_space,
|
||||||
typename ViewType1D<permType, permProperties...>::memory_space>(),
|
typename ViewType1D<permType, permProperties...>::memory_space>(),
|
||||||
"In permuteSort, view and permuteView should have the same space");
|
"In permuteSort, view and permuteView should have the same space"
|
||||||
|
);
|
||||||
|
|
||||||
using ExecutionSpace = typename ViewType1D<Type, properties...>::execution_space;
|
using ExecutionSpace =
|
||||||
|
typename ViewType1D<Type, properties...>::execution_space;
|
||||||
|
|
||||||
uint32 numElems = end - start;
|
uint32 numElems = end - start;
|
||||||
|
|
||||||
pFlow::algorithms::STD::permuteSort<Type, permType, true>(
|
pFlow::algorithms::STD::permuteSort<Type, permType, true>(
|
||||||
view.data()+start,
|
view.data() + start, permuteView.data() + permStart, numElems
|
||||||
permuteView.data()+permStart,
|
);
|
||||||
numElems);
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
#ifdef __CUDACC__
|
#ifdef __CUDACC__
|
||||||
|
|
||||||
pFlow::algorithms::CUDA::permuteSort(
|
pFlow::algorithms::CUDA::permuteSort(
|
||||||
view.data()+start,
|
view.data() + start, permuteView.data() + permStart, numElems
|
||||||
permuteView.data()+permStart,
|
);
|
||||||
numElems);
|
|
||||||
#else
|
#else
|
||||||
static_assert("sort on device is not defined!");
|
static_assert("sort on device is not defined!");
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD int32
|
||||||
int32 binarySearch_(const T* array, int32 length, const T& val)
|
binarySearch_(const T* array, int32 length, const T& val)
|
||||||
{
|
{
|
||||||
if(length <= 0) return -1;
|
if (length <= 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
int low = 0;
|
int low = 0;
|
||||||
int high = length - 1;
|
int high = length - 1;
|
||||||
@ -444,42 +408,40 @@ int32 binarySearch_(const T* array, int32 length, const T& val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// On DEVICE and HOST calls
|
/// On DEVICE and HOST calls
|
||||||
template<
|
template<typename Type, typename... properties>
|
||||||
typename Type,
|
INLINE_FUNCTION_HD uint32
|
||||||
typename... properties>
|
binarySearch(
|
||||||
INLINE_FUNCTION_HD
|
|
||||||
uint32 binarySearch(
|
|
||||||
const ViewType1D<Type, properties...>& view,
|
const ViewType1D<Type, properties...>& view,
|
||||||
uint32 start,
|
uint32 start,
|
||||||
uint32 end,
|
uint32 end,
|
||||||
const Type& val)
|
const Type& val
|
||||||
|
)
|
||||||
{
|
{
|
||||||
|
if (end <= start)
|
||||||
|
return -1;
|
||||||
|
|
||||||
if(end<=start)return -1;
|
if (auto res = binarySearch_(view.data() + start, end - start, val);
|
||||||
|
res != -1)
|
||||||
if(auto res =
|
{
|
||||||
binarySearch_(view.data()+start,end-start,val); res!=-1) {
|
|
||||||
return res + start;
|
return res + start;
|
||||||
}
|
}
|
||||||
else{
|
else
|
||||||
|
{
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<
|
template<typename Type, typename... properties, typename... dProperties>
|
||||||
typename Type,
|
void
|
||||||
typename... properties,
|
exclusiveScan(
|
||||||
typename... dProperties>
|
|
||||||
void exclusiveScan(
|
|
||||||
const ViewType1D<Type, properties...>& view,
|
const ViewType1D<Type, properties...>& view,
|
||||||
uint32 start,
|
uint32 start,
|
||||||
uint32 end,
|
uint32 end,
|
||||||
ViewType1D<Type, dProperties...>& dView,
|
ViewType1D<Type, dProperties...>& dView,
|
||||||
uint32 dStart )
|
uint32 dStart
|
||||||
|
)
|
||||||
{
|
{
|
||||||
|
static_assert(
|
||||||
static_assert
|
|
||||||
(
|
|
||||||
areAccessible<
|
areAccessible<
|
||||||
typename ViewType1D<Type, properties...>::execution_space,
|
typename ViewType1D<Type, properties...>::execution_space,
|
||||||
typename ViewType1D<Type, dProperties...>::memory_space>(),
|
typename ViewType1D<Type, dProperties...>::memory_space>(),
|
||||||
@ -487,48 +449,43 @@ void exclusiveScan(
|
|||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
using ExecutionSpace = typename ViewType1D<Type, properties...>::execution_space;
|
using ExecutionSpace =
|
||||||
|
typename ViewType1D<Type, properties...>::execution_space;
|
||||||
|
|
||||||
uint32 numElems = end - start;
|
uint32 numElems = end - start;
|
||||||
|
|
||||||
pFlow::algorithms::KOKKOS::exclusiveScan<Type, ExecutionSpace>(
|
pFlow::algorithms::KOKKOS::exclusiveScan<Type, ExecutionSpace>(
|
||||||
view.data()+start,
|
view.data() + start, dView.data() + dStart, numElems
|
||||||
dView.data()+dStart,
|
);
|
||||||
numElems);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename Type, typename... properties, typename... dProperties>
|
||||||
template<
|
void
|
||||||
typename Type,
|
inclusiveScan(
|
||||||
typename... properties,
|
|
||||||
typename... dProperties>
|
|
||||||
void inclusiveScan(
|
|
||||||
const ViewType1D<Type, properties...>& view,
|
const ViewType1D<Type, properties...>& view,
|
||||||
uint32 start,
|
uint32 start,
|
||||||
uint32 end,
|
uint32 end,
|
||||||
ViewType1D<Type, dProperties...>& dView,
|
ViewType1D<Type, dProperties...>& dView,
|
||||||
uint32 dStart)
|
uint32 dStart
|
||||||
|
)
|
||||||
{
|
{
|
||||||
using ExecutionSpace = typename ViewType1D<Type, properties...>::execution_space;
|
using ExecutionSpace =
|
||||||
|
typename ViewType1D<Type, properties...>::execution_space;
|
||||||
|
|
||||||
static_assert
|
static_assert(
|
||||||
(
|
|
||||||
areAccessible<
|
areAccessible<
|
||||||
typename ViewType1D<Type, properties...>::execution_space,
|
typename ViewType1D<Type, properties...>::execution_space,
|
||||||
typename ViewType1D<Type, dProperties...>::memory_space>(),
|
typename ViewType1D<Type, dProperties...>::memory_space>(),
|
||||||
"In exclusiveScan, view and dView should have the same space"
|
"In exclusiveScan, view and dView should have the same space"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
uint32 numElems = end - start;
|
uint32 numElems = end - start;
|
||||||
|
|
||||||
pFlow::algorithms::KOKKOS::inclusiveScan<Type, ExecutionSpace>(
|
pFlow::algorithms::KOKKOS::inclusiveScan<Type, ExecutionSpace>(
|
||||||
view.data()+start,
|
view.data() + start, dView.data() + dStart, numElems
|
||||||
dView.data()+dStart,
|
);
|
||||||
numElems);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // pFlow
|
} // pFlow
|
||||||
|
|
||||||
|
#endif // __ViewAlgorithms_hpp__
|
||||||
#endif // Viewalgorithms
|
|
||||||
|
@ -19,32 +19,32 @@ Licence:
|
|||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
template<typename T, typename... properties>
|
||||||
void insertSetElementH
|
void
|
||||||
(
|
insertSetElementH(
|
||||||
ViewType1D<T, properties...>& view,
|
ViewType1D<T, properties...>& view,
|
||||||
hostViewType1D<label>& selected,
|
hostViewType1D<label>& selected,
|
||||||
T val
|
T val
|
||||||
);
|
);
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
template<typename T, typename... properties>
|
||||||
void insertSetElementH
|
void
|
||||||
(
|
insertSetElementH(
|
||||||
ViewType1D<T, properties...>& view,
|
ViewType1D<T, properties...>& view,
|
||||||
hostViewType1D<label>& selected,
|
hostViewType1D<label>& selected,
|
||||||
hostViewType1D<T>& vals
|
hostViewType1D<T>& vals
|
||||||
);
|
);
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
template<typename T, typename... properties>
|
||||||
void insertSetElementD
|
void
|
||||||
(
|
insertSetElementD(
|
||||||
ViewType1D<T, properties...>& view,
|
ViewType1D<T, properties...>& view,
|
||||||
deviceViewType1D<label>& selected,
|
deviceViewType1D<label>& selected,
|
||||||
T val
|
T val
|
||||||
);
|
);
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
template<typename T, typename... properties>
|
||||||
void insertSetElementD
|
void
|
||||||
(
|
insertSetElementD(
|
||||||
ViewType1D<T, properties...>& view,
|
ViewType1D<T, properties...>& view,
|
||||||
deviceViewType1D<label>& selected,
|
deviceViewType1D<label>& selected,
|
||||||
deviceViewType1D<T>& vals
|
deviceViewType1D<T>& vals
|
||||||
|
@ -21,9 +21,8 @@ Licence:
|
|||||||
#ifndef __baseAlgorithms_hpp__
|
#ifndef __baseAlgorithms_hpp__
|
||||||
#define __baseAlgorithms_hpp__
|
#define __baseAlgorithms_hpp__
|
||||||
|
|
||||||
|
|
||||||
#include "numericConstants.hpp"
|
|
||||||
#include "KokkosUtilities.hpp"
|
#include "KokkosUtilities.hpp"
|
||||||
|
#include "numericConstants.hpp"
|
||||||
|
|
||||||
inline const size_t sizeToSerial__ = 64;
|
inline const size_t sizeToSerial__ = 64;
|
||||||
|
|
||||||
@ -57,19 +56,18 @@ size_t count(
|
|||||||
return totalNum;
|
return totalNum;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
template<typename T, typename... properties>
|
||||||
INLINE_FUNCTION_H
|
INLINE_FUNCTION_H T
|
||||||
T min( const ViewType1D<T, properties...>& view, size_t start, size_t end )
|
min(const ViewType1D<T, properties...>& view, size_t start, size_t end)
|
||||||
{
|
{
|
||||||
|
|
||||||
T minValue = largestPositive<T>();
|
T minValue = largestPositive<T>();
|
||||||
|
|
||||||
auto RP = Kokkos::RangePolicy<
|
auto RP = Kokkos::RangePolicy<
|
||||||
Kokkos::IndexType<size_t>,
|
Kokkos::IndexType<size_t>,
|
||||||
typename ViewType1D<T, properties...>::execution_space>(start, end);
|
typename ViewType1D<T, properties...>::execution_space>(start, end);
|
||||||
|
|
||||||
Kokkos::parallel_reduce("baseAlgorithms-min",
|
Kokkos::parallel_reduce(
|
||||||
|
"baseAlgorithms-min",
|
||||||
RP,
|
RP,
|
||||||
LAMBDA_HD(label i, T & valueToUpdate) {
|
LAMBDA_HD(label i, T & valueToUpdate) {
|
||||||
valueToUpdate = min(view[i], valueToUpdate);
|
valueToUpdate = min(view[i], valueToUpdate);
|
||||||
@ -80,17 +78,17 @@ T min( const ViewType1D<T, properties...>& view, size_t start, size_t end )
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
template<typename T, typename... properties>
|
||||||
INLINE_FUNCTION_H
|
INLINE_FUNCTION_H T
|
||||||
T max( const ViewType1D<T, properties...>& view, size_t start, size_t end )
|
max(const ViewType1D<T, properties...>& view, size_t start, size_t end)
|
||||||
{
|
{
|
||||||
|
|
||||||
T maxValue = largestNegative<T>();
|
T maxValue = largestNegative<T>();
|
||||||
|
|
||||||
auto RP = Kokkos::RangePolicy<
|
auto RP = Kokkos::RangePolicy<
|
||||||
Kokkos::IndexType<size_t>,
|
Kokkos::IndexType<size_t>,
|
||||||
typename ViewType1D<T, properties...>::execution_space>(start, end);
|
typename ViewType1D<T, properties...>::execution_space>(start, end);
|
||||||
|
|
||||||
Kokkos::parallel_reduce("baseAlgorithms-max",
|
Kokkos::parallel_reduce(
|
||||||
|
"baseAlgorithms-max",
|
||||||
RP,
|
RP,
|
||||||
LAMBDA_HD(label i, T & valueToUpdate) {
|
LAMBDA_HD(label i, T & valueToUpdate) {
|
||||||
valueToUpdate = max(view[i], valueToUpdate);
|
valueToUpdate = max(view[i], valueToUpdate);
|
||||||
@ -101,8 +99,8 @@ T max( const ViewType1D<T, properties...>& view, size_t start, size_t end )
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
template<typename T, typename... properties>
|
||||||
INLINE_FUNCTION_H
|
INLINE_FUNCTION_H T
|
||||||
T min_serial(const ViewType1D<T, properties...>& view, size_t start, size_t end)
|
min_serial(const ViewType1D<T, properties...>& view, size_t start, size_t end)
|
||||||
{
|
{
|
||||||
T minValue = largestPositive<T>();
|
T minValue = largestPositive<T>();
|
||||||
for (label i = start; i < end; ++i)
|
for (label i = start; i < end; ++i)
|
||||||
@ -113,8 +111,8 @@ T min_serial(const ViewType1D<T, properties...>& view, size_t start, size_t end)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
template<typename T, typename... properties>
|
||||||
INLINE_FUNCTION_H
|
INLINE_FUNCTION_H T
|
||||||
T max_serial(const ViewType1D<T, properties...>& view, size_t start, size_t end)
|
max_serial(const ViewType1D<T, properties...>& view, size_t start, size_t end)
|
||||||
{
|
{
|
||||||
T maxValue = largestNegative<T>();
|
T maxValue = largestNegative<T>();
|
||||||
for (label i = start; i < end; ++i)
|
for (label i = start; i < end; ++i)
|
||||||
@ -124,49 +122,46 @@ T max_serial(const ViewType1D<T, properties...>& view, size_t start, size_t end)
|
|||||||
return maxValue;
|
return maxValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename UnaryFunction, typename T, typename... properties>
|
template<typename UnaryFunction, typename T, typename... properties>
|
||||||
void apply_to_each(const ViewType1D<T, properties...>& view, size_t start, size_t end, UnaryFunction func)
|
void
|
||||||
|
apply_to_each(
|
||||||
|
const ViewType1D<T, properties...>& view,
|
||||||
|
size_t start,
|
||||||
|
size_t end,
|
||||||
|
UnaryFunction func
|
||||||
|
)
|
||||||
{
|
{
|
||||||
auto RP = Kokkos::RangePolicy<
|
auto RP = Kokkos::RangePolicy<
|
||||||
Kokkos::IndexType<size_t>,
|
Kokkos::IndexType<size_t>,
|
||||||
typename ViewType1D<T, properties...>::execution_space>(start, end);
|
typename ViewType1D<T, properties...>::execution_space>(start, end);
|
||||||
|
|
||||||
Kokkos::parallel_for("baseAlgorithms-for_each",
|
Kokkos::parallel_for(
|
||||||
RP,
|
"baseAlgorithms-for_each", RP, LAMBDA_HD(label i) { view[i] = func(i); }
|
||||||
LAMBDA_HD(label i){
|
|
||||||
view[i] = func(i);
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
template<typename T, typename... properties>
|
||||||
void insertSetElementH
|
void
|
||||||
(
|
insertSetElementH(
|
||||||
ViewType1D<T, properties...>& view,
|
ViewType1D<T, properties...>& view,
|
||||||
hostViewType1D<label>& selected,
|
hostViewType1D<label>& selected,
|
||||||
T val
|
T val
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
for (auto i = 0; i < selected.size(); ++i)
|
for (auto i = 0; i < selected.size(); ++i)
|
||||||
{
|
{
|
||||||
view[selected[i]] = val;
|
view[selected[i]] = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
template<typename T, typename... properties>
|
||||||
void insertSetElementH
|
void
|
||||||
(
|
insertSetElementH(
|
||||||
ViewType1D<T, properties...>& view,
|
ViewType1D<T, properties...>& view,
|
||||||
hostViewType1D<label>& selected,
|
hostViewType1D<label>& selected,
|
||||||
hostViewType1D<T>& vals
|
hostViewType1D<T>& vals
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
for (auto i = 0; i < selected.size(); ++i)
|
for (auto i = 0; i < selected.size(); ++i)
|
||||||
{
|
{
|
||||||
view[selected[i]] = static_cast<const T&>(vals[i]);
|
view[selected[i]] = static_cast<const T&>(vals[i]);
|
||||||
@ -174,8 +169,8 @@ void insertSetElementH
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
template<typename T, typename... properties>
|
||||||
void insertSetElementD
|
void
|
||||||
(
|
insertSetElementD(
|
||||||
ViewType1D<T, properties...>& view,
|
ViewType1D<T, properties...>& view,
|
||||||
deviceViewType1D<label>& selected,
|
deviceViewType1D<label>& selected,
|
||||||
T val
|
T val
|
||||||
@ -183,19 +178,20 @@ void insertSetElementD
|
|||||||
{
|
{
|
||||||
auto RP = Kokkos::RangePolicy<
|
auto RP = Kokkos::RangePolicy<
|
||||||
Kokkos::IndexType<size_t>,
|
Kokkos::IndexType<size_t>,
|
||||||
typename ViewType1D<T, properties...>::execution_space >(0, selected.size());
|
typename ViewType1D<T, properties...>::execution_space>(
|
||||||
|
0, selected.size()
|
||||||
|
);
|
||||||
|
|
||||||
Kokkos::parallel_for(
|
Kokkos::parallel_for(
|
||||||
"baseAlgorithms-insertSetElementD",
|
"baseAlgorithms-insertSetElementD",
|
||||||
RP,
|
RP,
|
||||||
LAMBDA_D(size_t i) {
|
LAMBDA_D(size_t i) { view[selected[i]] = val; }
|
||||||
view[selected[i]] = val; } );
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
template<typename T, typename... properties>
|
||||||
void insertSetElementD
|
void
|
||||||
(
|
insertSetElementD(
|
||||||
ViewType1D<T, properties...>& view,
|
ViewType1D<T, properties...>& view,
|
||||||
deviceViewType1D<label>& selected,
|
deviceViewType1D<label>& selected,
|
||||||
deviceViewType1D<T>& vals
|
deviceViewType1D<T>& vals
|
||||||
@ -203,21 +199,20 @@ void insertSetElementD
|
|||||||
{
|
{
|
||||||
auto RP = Kokkos::RangePolicy<
|
auto RP = Kokkos::RangePolicy<
|
||||||
Kokkos::IndexType<size_t>,
|
Kokkos::IndexType<size_t>,
|
||||||
typename ViewType1D<T, properties...>::execution_space >(0, selected.size());
|
typename ViewType1D<T, properties...>::execution_space>(
|
||||||
|
0, selected.size()
|
||||||
|
);
|
||||||
|
|
||||||
Kokkos::parallel_for(
|
Kokkos::parallel_for(
|
||||||
"baseAlgorithms-insertSetElementD",
|
"baseAlgorithms-insertSetElementD",
|
||||||
RP,
|
RP,
|
||||||
LAMBDA_D(size_t i) {
|
LAMBDA_D(size_t i) { view[selected[i]] = vals[i]; }
|
||||||
view[selected[i]] = vals[i]; } );
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T, typename... properties>
|
template<typename T, typename... properties>
|
||||||
void fill
|
void
|
||||||
(
|
fill(
|
||||||
ViewType3D<T, properties...>& view,
|
ViewType3D<T, properties...>& view,
|
||||||
range range1,
|
range range1,
|
||||||
range range2,
|
range range2,
|
||||||
@ -231,5 +226,4 @@ void fill
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // __VectorSingleMath_hpp__
|
#endif // __VectorSingleMath_hpp__
|
||||||
|
@ -23,15 +23,13 @@ Licence:
|
|||||||
#include "streams.hpp"
|
#include "streams.hpp"
|
||||||
|
|
||||||
pFlow::Timer::Timer(const word& name, Timers* parrent)
|
pFlow::Timer::Timer(const word& name, Timers* parrent)
|
||||||
:
|
: name_(name),
|
||||||
name_(name),
|
|
||||||
parrent_(parrent)
|
parrent_(parrent)
|
||||||
{
|
{
|
||||||
if (parrent_)
|
if (parrent_)
|
||||||
parrent_->addToList(this);
|
parrent_->addToList(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pFlow::Timer::~Timer()
|
pFlow::Timer::~Timer()
|
||||||
{
|
{
|
||||||
if (parrent_)
|
if (parrent_)
|
||||||
@ -48,12 +46,10 @@ pFlow::int32 pFlow::Timer::level()const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool pFlow::Timer::write(iOstream& os, bool subTree) const
|
bool pFlow::Timer::write(iOstream& os, bool subTree) const
|
||||||
{
|
{
|
||||||
|
if (!timerActive() && !master())
|
||||||
if(!timerActive() && !master())return true;
|
return true;
|
||||||
|
|
||||||
|
|
||||||
int32 lvl = level();
|
int32 lvl = level();
|
||||||
for (int32 l = 1; l < lvl; l++)
|
for (int32 l = 1; l < lvl; l++)
|
||||||
@ -63,11 +59,9 @@ bool pFlow::Timer::write(iOstream& os, bool subTree)const
|
|||||||
|
|
||||||
if (lvl > 0)
|
if (lvl > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (master())
|
if (master())
|
||||||
os << "┣━━ ";
|
os << "┣━━ ";
|
||||||
else
|
else if (lvl == 1)
|
||||||
if(lvl==1)
|
|
||||||
os << "┃└─ ";
|
os << "┃└─ ";
|
||||||
else
|
else
|
||||||
os << " └─ ";
|
os << " └─ ";
|
||||||
@ -80,19 +74,16 @@ bool pFlow::Timer::write(iOstream& os, bool subTree)const
|
|||||||
else if (master())
|
else if (master())
|
||||||
os << yellowColor;
|
os << yellowColor;
|
||||||
|
|
||||||
|
|
||||||
os << name_;
|
os << name_;
|
||||||
|
|
||||||
auto tt = accTimersTotal();
|
auto tt = accTimersTotal();
|
||||||
if (abs(tt) > smallValue)
|
if (abs(tt) > smallValue)
|
||||||
{
|
{
|
||||||
os<<" execution time (s): total ("<<
|
os << " execution time (s): total (" << tt << ")";
|
||||||
tt<<")";
|
|
||||||
|
|
||||||
if (!master())
|
if (!master())
|
||||||
{
|
{
|
||||||
os<<", av. ("<<
|
os << ", av. (" << averageTime() << ").";
|
||||||
averageTime()<<").";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,24 +18,19 @@ Licence:
|
|||||||
|
|
||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __Timerr_hpp__
|
#ifndef __Timerr_hpp__
|
||||||
#define __Timerr_hpp__
|
#define __Timerr_hpp__
|
||||||
|
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
#include "types.hpp"
|
#include "types.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
|
|
||||||
// forward
|
// forward
|
||||||
class Timers;
|
class Timers;
|
||||||
|
|
||||||
|
|
||||||
class Timer
|
class Timer
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
@ -54,7 +49,8 @@ protected:
|
|||||||
/// last time duration
|
/// last time duration
|
||||||
real lastTime_ = 0.0;
|
real lastTime_ = 0.0;
|
||||||
|
|
||||||
/// @brief Accumulative duration for multiple steps between start() and end()
|
/// @brief Accumulative duration for multiple steps between start() and
|
||||||
|
/// end()
|
||||||
real stepAccTime_ = 0.0;
|
real stepAccTime_ = 0.0;
|
||||||
|
|
||||||
/// name for the timer
|
/// name for the timer
|
||||||
@ -70,14 +66,12 @@ public:
|
|||||||
Timer() = default;
|
Timer() = default;
|
||||||
|
|
||||||
explicit Timer(const word& name)
|
explicit Timer(const word& name)
|
||||||
:
|
: name_(name)
|
||||||
name_(name)
|
{
|
||||||
{}
|
}
|
||||||
|
|
||||||
|
|
||||||
Timer(const word& name, Timers* parrent);
|
Timer(const word& name, Timers* parrent);
|
||||||
|
|
||||||
|
|
||||||
const word& name() const
|
const word& name() const
|
||||||
{
|
{
|
||||||
return name_;
|
return name_;
|
||||||
@ -92,7 +86,6 @@ public:
|
|||||||
|
|
||||||
virtual int32 level() const;
|
virtual int32 level() const;
|
||||||
|
|
||||||
|
|
||||||
virtual bool master() const
|
virtual bool master() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -107,8 +100,11 @@ public:
|
|||||||
void pause()
|
void pause()
|
||||||
{
|
{
|
||||||
auto end = timer::now();
|
auto end = timer::now();
|
||||||
stepAccTime_ += std::chrono::duration_cast
|
stepAccTime_ +=
|
||||||
< std::chrono::duration<real> >(end - start_).count();
|
std::chrono::duration_cast<std::chrono::duration<real> >(
|
||||||
|
end - start_
|
||||||
|
)
|
||||||
|
.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
void resume()
|
void resume()
|
||||||
@ -125,33 +121,27 @@ public:
|
|||||||
accTime_ += lastTime_;
|
accTime_ += lastTime_;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline bool timerActive() const
|
||||||
bool timerActive()const
|
|
||||||
{
|
{
|
||||||
return numIteration_ != 0;
|
return numIteration_ != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline real lastTime() const
|
||||||
real lastTime()const
|
|
||||||
{
|
{
|
||||||
return lastTime_;
|
return lastTime_;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline real totalTime() const
|
||||||
real totalTime()const
|
|
||||||
{
|
{
|
||||||
return accTime_;
|
return accTime_;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline real averageTime() const
|
||||||
real averageTime()const
|
|
||||||
{
|
{
|
||||||
|
|
||||||
return accTime_ / max(numIteration_, 1);
|
return accTime_ / max(numIteration_, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual
|
virtual real accTimersTotal() const
|
||||||
real accTimersTotal()const
|
|
||||||
{
|
{
|
||||||
return totalTime();
|
return totalTime();
|
||||||
}
|
}
|
||||||
@ -166,7 +156,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline iOstream& operator<<(iOstream& os, const Timer& t)
|
inline iOstream& operator<<(iOstream& os, const Timer& t)
|
||||||
{
|
{
|
||||||
t.write(os, false);
|
t.write(os, false);
|
||||||
@ -178,7 +167,6 @@ inline iIstream& operator>>(iIstream& is, Timer& t)
|
|||||||
return is;
|
return is;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace pFlow
|
||||||
|
|
||||||
|
|
||||||
#endif //__Timer_hpp__
|
#endif //__Timer_hpp__
|
||||||
|
@ -17,7 +17,6 @@ Licence:
|
|||||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __createBoundaryFields_hpp__
|
#ifndef __createBoundaryFields_hpp__
|
||||||
#define __createBoundaryFields_hpp__
|
#define __createBoundaryFields_hpp__
|
||||||
|
|
||||||
@ -34,11 +33,8 @@ Licence:
|
|||||||
#define createBaseBoundary(DataType, MemorySpaceType) \
|
#define createBaseBoundary(DataType, MemorySpaceType) \
|
||||||
template class pFlow::boundaryField<DataType, MemorySpaceType>;
|
template class pFlow::boundaryField<DataType, MemorySpaceType>;
|
||||||
|
|
||||||
|
|
||||||
#define createBoundaryFields(DataType, MemorySpaceType) \
|
#define createBoundaryFields(DataType, MemorySpaceType) \
|
||||||
createBaseBoundary(DataType, MemorySpaceType); \
|
createBaseBoundary(DataType, MemorySpaceType); \
|
||||||
createDerivedBoundary(DataType, MemorySpaceType);
|
createDerivedBoundary(DataType, MemorySpaceType);
|
||||||
|
|
||||||
|
|
||||||
#endif //__createBoundaryFields_hpp__
|
#endif //__createBoundaryFields_hpp__
|
||||||
|
|
@ -21,86 +21,102 @@ Licence:
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
#include <Kokkos_Core.hpp>
|
#include <Kokkos_Core.hpp>
|
||||||
|
|
||||||
#include "error.hpp"
|
#include "error.hpp"
|
||||||
#include "processors.hpp"
|
#include "processors.hpp"
|
||||||
#include "streams.hpp"
|
#include "streams.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// static pFlow::Ostream& errorStream = pFlow::errReport;
|
// static pFlow::Ostream& errorStream = pFlow::errReport;
|
||||||
|
|
||||||
static pFlow::Ostream& errorStream = pFlow::pOutput;
|
static pFlow::Ostream& errorStream = pFlow::pOutput;
|
||||||
|
|
||||||
|
pFlow::iOstream&
|
||||||
pFlow::iOstream& fatalErrorMessage(const char* fileName, int linNumber )
|
fatalErrorMessage(const char* fileName, int linNumber)
|
||||||
{
|
{
|
||||||
|
errorStream << "\n>>> Fatal error in phasicFlow\n"
|
||||||
errorStream<<"\n>>> Fatal error in phasicFlow\n" <<
|
<< "Error occured in source file " << Red_Text(fileName)
|
||||||
"Error occured in source file "<< Red_Text(fileName) <<
|
<< " at line " << Red_Text(linNumber) << '\n';
|
||||||
" at line "<<Red_Text(linNumber)<<'\n';
|
|
||||||
return errorStream;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
pFlow::iOstream& fatalErrorInMessage(const char* fnName, const char* fileName, int linNumber )
|
|
||||||
{
|
|
||||||
|
|
||||||
errorStream<<"\n>>> Fatal error in phasicFlow\n" <<
|
|
||||||
" Error is issued in function " << Red_Text(fnName)<<
|
|
||||||
", located in file "<< Red_Text(fileName) <<
|
|
||||||
" at line "<< Red_Text(linNumber) << '\n';
|
|
||||||
return errorStream;
|
return errorStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
pFlow::iOstream& notImplementedErrorMessage(const char*fnName, const char* fileName, int lineNumber)
|
pFlow::iOstream&
|
||||||
|
fatalErrorInMessage(const char* fnName, const char* fileName, int linNumber)
|
||||||
{
|
{
|
||||||
|
errorStream << "\n>>> Fatal error in phasicFlow\n"
|
||||||
|
<< " Error is issued in function " << Red_Text(fnName)
|
||||||
|
<< ", located in file " << Red_Text(fileName) << " at line "
|
||||||
|
<< Red_Text(linNumber) << '\n';
|
||||||
|
return errorStream;
|
||||||
|
}
|
||||||
|
|
||||||
|
pFlow::iOstream&
|
||||||
|
notImplementedErrorMessage(
|
||||||
|
const char* fnName,
|
||||||
|
const char* fileName,
|
||||||
|
int lineNumber
|
||||||
|
)
|
||||||
|
{
|
||||||
errorStream << "\n>>> Fatal error in phasicFlow\n";
|
errorStream << "\n>>> Fatal error in phasicFlow\n";
|
||||||
errorStream<<" Function "<< Red_Text(fnName) << " has not been implemented yet!\n" <<
|
errorStream << " Function " << Red_Text(fnName)
|
||||||
" File "<< Yellow_Text(fileName) <<
|
<< " has not been implemented yet!\n"
|
||||||
" at line "<< Yellow_Text(lineNumber) <<'\n';
|
<< " File " << Yellow_Text(fileName) << " at line "
|
||||||
|
<< Yellow_Text(lineNumber) << '\n';
|
||||||
return errorStream;
|
return errorStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pFlow::iOstream&
|
||||||
pFlow::iOstream& ioErrorMessage(const char* fileName, int fileLineNumber, const char* fnName, const char* fName, int lNumber)
|
ioErrorMessage(
|
||||||
|
const char* fileName,
|
||||||
|
int fileLineNumber,
|
||||||
|
const char* fnName,
|
||||||
|
const char* fName,
|
||||||
|
int lNumber
|
||||||
|
)
|
||||||
{
|
{
|
||||||
|
errorStream << "\n>>> Fatal IO file error\n"
|
||||||
errorStream<<"\n>>> Fatal IO file error\n"<<
|
<< " IO error at number " << Red_Text(fileLineNumber)
|
||||||
" IO error at number "<<Red_Text(fileLineNumber)<<
|
<< " of file " << Red_Text(fileName) << '\n';
|
||||||
" of file " << Red_Text(fileName)<<'\n';
|
errorStream << " IO operation is peformed from function "
|
||||||
errorStream<<" IO operation is peformed from function "<<Red_Text(fnName) <<
|
<< Red_Text(fnName) << " in file " << Red_Text(fName)
|
||||||
" in file "<< Red_Text(fName)<< " at line "<< Red_Text(lNumber) <<'\n';
|
<< " at line " << Red_Text(lNumber) << '\n';
|
||||||
return errorStream;
|
return errorStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
pFlow::iOstream& ioErrorMessage(const pFlow::word& fileName, int fileLineNumber, const char* fnName, const char* fName, int lNumber)
|
pFlow::iOstream&
|
||||||
|
ioErrorMessage(
|
||||||
|
const pFlow::word& fileName,
|
||||||
|
int fileLineNumber,
|
||||||
|
const char* fnName,
|
||||||
|
const char* fName,
|
||||||
|
int lNumber
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return ioErrorMessage( fileName.c_str(), fileLineNumber, fnName, fName, lNumber);
|
return ioErrorMessage(
|
||||||
|
fileName.c_str(), fileLineNumber, fnName, fName, lNumber
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pFlow::iOstream&
|
||||||
pFlow::iOstream& warningMessage(const char* fnName, const char* fileName, int linNumber )
|
warningMessage(const char* fnName, const char* fileName, int linNumber)
|
||||||
{
|
{
|
||||||
|
errorStream << "\n>>> Warning in phasicFlow\n"
|
||||||
errorStream<<"\n>>> Warning in phasicFlow\n"<<
|
<< " Warning is issued in function " << Yellow_Text(fnName)
|
||||||
" Warning is issued in function " << Yellow_Text(fnName)<<
|
<< " in source file " << Yellow_Text(fileName) << " at line "
|
||||||
" in source file "<< Yellow_Text(fileName) <<
|
<< Yellow_Text(linNumber) << '\n';
|
||||||
" at line "<< Yellow_Text(linNumber) <<'\n';
|
|
||||||
return errorStream;
|
return errorStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
pFlow::iOstream& reportAndExit(int errorCode)
|
pFlow::iOstream&
|
||||||
|
reportAndExit(int errorCode)
|
||||||
{
|
{
|
||||||
errorStream << "\n>>> phasicFlow is exiting . . ." << pFlow::endl;
|
errorStream << "\n>>> phasicFlow is exiting . . ." << pFlow::endl;
|
||||||
fatalExitPhasicFlow(errorCode);
|
fatalExitPhasicFlow(errorCode);
|
||||||
return errorStream;
|
return errorStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fatalExitPhasicFlow(int errorCode)
|
int
|
||||||
|
fatalExitPhasicFlow(int errorCode)
|
||||||
{
|
{
|
||||||
// Kokkos should be finalized first
|
// Kokkos should be finalized first
|
||||||
Kokkos::finalize();
|
Kokkos::finalize();
|
||||||
|
@ -21,34 +21,53 @@ Licence:
|
|||||||
#ifndef __error_hpp__
|
#ifndef __error_hpp__
|
||||||
#define __error_hpp__
|
#define __error_hpp__
|
||||||
|
|
||||||
|
|
||||||
#include "builtinTypes.hpp"
|
#include "builtinTypes.hpp"
|
||||||
|
|
||||||
|
|
||||||
//- Forward decleartions
|
//- Forward decleartions
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
class iOstream;
|
class iOstream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//- Decleartions
|
//- Decleartions
|
||||||
|
|
||||||
/// Take actions to fatal exit phasicFlow
|
/// Take actions to fatal exit phasicFlow
|
||||||
int fatalExitPhasicFlow(int errorCode = EXIT_FAILURE);
|
int
|
||||||
|
fatalExitPhasicFlow(int errorCode = EXIT_FAILURE);
|
||||||
pFlow::iOstream& fatalErrorMessage(const char* fileName, int linNumber );
|
|
||||||
pFlow::iOstream& fatalErrorInMessage(const char* fnName, const char* fileName, int linNumber );
|
|
||||||
pFlow::iOstream& notImplementedErrorMessage(const char*fnName, const char* fileName, int lineNumber);
|
|
||||||
pFlow::iOstream& ioErrorMessage(const pFlow::word& fileName, int fileLineNumber, const char* fnName, const char* fName, int lNumber);
|
|
||||||
pFlow::iOstream& ioErrorMessage(const char* fileName, int fileLineNumber, const char* fnName, const char* fName, int lNumber);
|
|
||||||
pFlow::iOstream& warningMessage(const char* fnName, const char* fileName, int linNumber );
|
|
||||||
pFlow::iOstream& reportAndExit(int errorCode = EXIT_FAILURE);
|
|
||||||
|
|
||||||
|
pFlow::iOstream&
|
||||||
|
fatalErrorMessage(const char* fileName, int linNumber);
|
||||||
|
pFlow::iOstream&
|
||||||
|
fatalErrorInMessage(const char* fnName, const char* fileName, int linNumber);
|
||||||
|
pFlow::iOstream&
|
||||||
|
notImplementedErrorMessage(
|
||||||
|
const char* fnName,
|
||||||
|
const char* fileName,
|
||||||
|
int lineNumber
|
||||||
|
);
|
||||||
|
pFlow::iOstream&
|
||||||
|
ioErrorMessage(
|
||||||
|
const pFlow::word& fileName,
|
||||||
|
int fileLineNumber,
|
||||||
|
const char* fnName,
|
||||||
|
const char* fName,
|
||||||
|
int lNumber
|
||||||
|
);
|
||||||
|
pFlow::iOstream&
|
||||||
|
ioErrorMessage(
|
||||||
|
const char* fileName,
|
||||||
|
int fileLineNumber,
|
||||||
|
const char* fnName,
|
||||||
|
const char* fName,
|
||||||
|
int lNumber
|
||||||
|
);
|
||||||
|
pFlow::iOstream&
|
||||||
|
warningMessage(const char* fnName, const char* fileName, int linNumber);
|
||||||
|
pFlow::iOstream&
|
||||||
|
reportAndExit(int errorCode = EXIT_FAILURE);
|
||||||
|
|
||||||
/// Report a fatal error and exit the applicaiton
|
/// Report a fatal error and exit the applicaiton
|
||||||
#define fatalError \
|
#define fatalError fatalErrorMessage(__FILE__, __LINE__)
|
||||||
fatalErrorMessage(__FILE__, __LINE__)
|
|
||||||
|
|
||||||
/// Report a fatal error and supplied function name and exit the application
|
/// Report a fatal error and supplied function name and exit the application
|
||||||
#define fatalErrorIn(functionName) \
|
#define fatalErrorIn(functionName) \
|
||||||
@ -76,7 +95,6 @@ pFlow::iOstream& reportAndExit(int errorCode = EXIT_FAILURE);
|
|||||||
#define warningInFunction warningIn(FUNCTION_NAME)
|
#define warningInFunction warningIn(FUNCTION_NAME)
|
||||||
|
|
||||||
/// Fatal exit
|
/// Fatal exit
|
||||||
#define fatalExit \
|
#define fatalExit reportAndExit()
|
||||||
reportAndExit()
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -21,7 +21,6 @@ Licence:
|
|||||||
#ifndef __vocabs_hpp__
|
#ifndef __vocabs_hpp__
|
||||||
#define __vocabs_hpp__
|
#define __vocabs_hpp__
|
||||||
|
|
||||||
|
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -49,12 +48,9 @@ const inline char* propertyFile__ = "interaction";
|
|||||||
const inline char* interactionFile__ = "interaction";
|
const inline char* interactionFile__ = "interaction";
|
||||||
const inline char* postprocessFile__ = "postprocessDict";
|
const inline char* postprocessFile__ = "postprocessDict";
|
||||||
|
|
||||||
|
|
||||||
const inline char* uniform__ = "uniform";
|
const inline char* uniform__ = "uniform";
|
||||||
const inline char* nonUniform__ = "nonUniform";
|
const inline char* nonUniform__ = "nonUniform";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // __vocabs_hpp__
|
#endif // __vocabs_hpp__
|
||||||
|
@ -18,13 +18,12 @@ Licence:
|
|||||||
|
|
||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
#include "Time.hpp"
|
#include "Time.hpp"
|
||||||
#include "dictionary.hpp"
|
#include "dictionary.hpp"
|
||||||
#include "vocabs.hpp"
|
#include "vocabs.hpp"
|
||||||
|
|
||||||
|
bool
|
||||||
bool pFlow::Time::readDictionary(const dictionary& dict)
|
pFlow::Time::readDictionary(const dictionary& dict)
|
||||||
{
|
{
|
||||||
auto wF = toUpper(dict.getValOrSet<word>("writeFormat", "ASCII"));
|
auto wF = toUpper(dict.getValOrSet<word>("writeFormat", "ASCII"));
|
||||||
|
|
||||||
@ -34,30 +33,19 @@ bool pFlow::Time::readDictionary(const dictionary& dict)
|
|||||||
outFormatBinary_ = true;
|
outFormatBinary_ = true;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fatalErrorInFunction<<
|
fatalErrorInFunction << "Invalid writeFormat in file " << dict.name()
|
||||||
"Invalid writeFormat in file "<< dict.name()<<endl;
|
<< endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
pFlow::Time::Time
|
pFlow::Time::Time(repository* owner, const dictionary& setiingsDict)
|
||||||
(
|
: repository("Time", "", owner),
|
||||||
repository* owner,
|
|
||||||
const dictionary& setiingsDict
|
|
||||||
)
|
|
||||||
:
|
|
||||||
repository("Time", "", owner),
|
|
||||||
timeControl(setiingsDict),
|
timeControl(setiingsDict),
|
||||||
geometry_
|
geometry_(geometryRepository_, geometryFolder__, this)
|
||||||
(
|
|
||||||
geometryRepository_,
|
|
||||||
geometryFolder__,
|
|
||||||
this
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!readDictionary(setiingsDict))
|
if (!readDictionary(setiingsDict))
|
||||||
{
|
{
|
||||||
fatalExit;
|
fatalExit;
|
||||||
@ -70,21 +58,11 @@ pFlow::Time::Time(
|
|||||||
real startTime,
|
real startTime,
|
||||||
real endTime,
|
real endTime,
|
||||||
real saveInterval,
|
real saveInterval,
|
||||||
word startTimeName)
|
word startTimeName
|
||||||
:
|
|
||||||
repository("Time", "", owner),
|
|
||||||
timeControl(
|
|
||||||
setiingsDict,
|
|
||||||
startTime,
|
|
||||||
endTime,
|
|
||||||
saveInterval,
|
|
||||||
startTimeName),
|
|
||||||
geometry_
|
|
||||||
(
|
|
||||||
geometryRepository_,
|
|
||||||
geometryFolder__,
|
|
||||||
this
|
|
||||||
)
|
)
|
||||||
|
: repository("Time", "", owner),
|
||||||
|
timeControl(setiingsDict, startTime, endTime, saveInterval, startTimeName),
|
||||||
|
geometry_(geometryRepository_, geometryFolder__, this)
|
||||||
{
|
{
|
||||||
if (!readDictionary(setiingsDict))
|
if (!readDictionary(setiingsDict))
|
||||||
{
|
{
|
||||||
@ -92,24 +70,25 @@ pFlow::Time::Time(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pFlow::fileSystem pFlow::Time::localPath()const
|
pFlow::fileSystem
|
||||||
|
pFlow::Time::localPath() const
|
||||||
{
|
{
|
||||||
return fileSystem(timeName());
|
return fileSystem(timeName());
|
||||||
}
|
}
|
||||||
|
|
||||||
pFlow::fileSystem pFlow::Time::integrationFolder() const
|
pFlow::fileSystem
|
||||||
|
pFlow::Time::integrationFolder() const
|
||||||
{
|
{
|
||||||
return integrationFolder__;
|
return integrationFolder__;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::Time::write
|
bool
|
||||||
(
|
pFlow::Time::write(bool verbose) const
|
||||||
bool verbose
|
|
||||||
) const
|
|
||||||
{
|
{
|
||||||
if (outputToFile())
|
if (outputToFile())
|
||||||
{
|
{
|
||||||
REPORT(0)<<"\nWriting to file at time: "<< Cyan_Text(timeName())<<END_REPORT;
|
REPORT(0) << "\nWriting to file at time: " << Cyan_Text(timeName())
|
||||||
|
<< END_REPORT;
|
||||||
return repository::write(verbose);
|
return repository::write(verbose);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -18,18 +18,15 @@ Licence:
|
|||||||
|
|
||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __Time_hpp__
|
#ifndef __Time_hpp__
|
||||||
#define __Time_hpp__
|
#define __Time_hpp__
|
||||||
|
|
||||||
|
|
||||||
#include "types.hpp"
|
|
||||||
#include "error.hpp"
|
#include "error.hpp"
|
||||||
|
#include "types.hpp"
|
||||||
|
|
||||||
#include "timeControl.hpp"
|
|
||||||
#include "repository.hpp"
|
|
||||||
#include "fileSystem.hpp"
|
#include "fileSystem.hpp"
|
||||||
|
#include "repository.hpp"
|
||||||
|
#include "timeControl.hpp"
|
||||||
|
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
@ -37,12 +34,10 @@ namespace pFlow
|
|||||||
class dictionary;
|
class dictionary;
|
||||||
|
|
||||||
class Time
|
class Time
|
||||||
:
|
: public repository
|
||||||
public repository,
|
, public timeControl
|
||||||
public timeControl
|
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
protected:
|
|
||||||
|
|
||||||
bool outFormatBinary_ = false;
|
bool outFormatBinary_ = false;
|
||||||
|
|
||||||
@ -62,13 +57,12 @@ public:
|
|||||||
real startTime,
|
real startTime,
|
||||||
real endTime,
|
real endTime,
|
||||||
real saveInterval,
|
real saveInterval,
|
||||||
word startTimeName);
|
word startTimeName
|
||||||
|
);
|
||||||
|
|
||||||
//// - Methods
|
//// - Methods
|
||||||
fileSystem localPath() const override;
|
fileSystem localPath() const override;
|
||||||
|
|
||||||
|
|
||||||
// - geometry repository
|
// - geometry repository
|
||||||
const repository& geometry() const
|
const repository& geometry() const
|
||||||
{
|
{
|
||||||
@ -91,9 +85,8 @@ public:
|
|||||||
// override the base write to manage write operation
|
// override the base write to manage write operation
|
||||||
// based on the valid write time intervals
|
// based on the valid write time intervals
|
||||||
virtual bool write(bool verbose = false) const;
|
virtual bool write(bool verbose = false) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // pFlow
|
} // namespace pFlow
|
||||||
|
|
||||||
#endif // __Time_hpp__
|
#endif // __Time_hpp__
|
||||||
|
@ -75,3 +75,90 @@ bool pFlow::baseTimeControl::timeEvent(uint32 iter, real t, real dt) const
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
pFlow::baseTimeControl::isInRange(uint32 iter, real t, real dt) const
|
||||||
|
{
|
||||||
|
if(isTimeStep_)
|
||||||
|
{
|
||||||
|
return iRange_.isInRange(iter);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return rRange_.isInRange(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pFlow::real
|
||||||
|
pFlow::baseTimeControl::startTime() const
|
||||||
|
{
|
||||||
|
if(!isTimeStep_)
|
||||||
|
{
|
||||||
|
return rRange_.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
fatalErrorInFunction<<"timeControl is not simulationTime or runTime"<<endl;
|
||||||
|
fatalExit;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
pFlow::real
|
||||||
|
pFlow::baseTimeControl::endTime() const
|
||||||
|
{
|
||||||
|
if(!isTimeStep_)
|
||||||
|
{
|
||||||
|
return rRange_.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
fatalErrorInFunction<<"timeControl is not simulationTime or runTime"<<endl;
|
||||||
|
fatalExit;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
pFlow::real
|
||||||
|
pFlow::baseTimeControl::rInterval() const
|
||||||
|
{
|
||||||
|
if(!isTimeStep_)
|
||||||
|
{
|
||||||
|
return rRange_.stride();
|
||||||
|
}
|
||||||
|
fatalErrorInFunction<<"timeControl is not simulationTime or runTime"<<endl;
|
||||||
|
fatalExit;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
pFlow::int32
|
||||||
|
pFlow::baseTimeControl::startIter() const
|
||||||
|
{
|
||||||
|
if(isTimeStep_)
|
||||||
|
{
|
||||||
|
return iRange_.begin();
|
||||||
|
}
|
||||||
|
fatalErrorInFunction<<"timeControl is not timeStep"<<endl;
|
||||||
|
fatalExit;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
pFlow::int32
|
||||||
|
pFlow::baseTimeControl::endIter() const
|
||||||
|
{
|
||||||
|
if(isTimeStep_)
|
||||||
|
{
|
||||||
|
return iRange_.end();
|
||||||
|
}
|
||||||
|
fatalErrorInFunction<<"timeControl is not timeStep"<<endl;
|
||||||
|
fatalExit;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
pFlow::int32
|
||||||
|
pFlow::baseTimeControl::iInterval() const
|
||||||
|
{
|
||||||
|
if(isTimeStep_)
|
||||||
|
{
|
||||||
|
return iRange_.stride();
|
||||||
|
}
|
||||||
|
fatalErrorInFunction<<"timeControl is not timeStep"<<endl;
|
||||||
|
fatalExit;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@ -45,9 +45,28 @@ public:
|
|||||||
const word& intervalPrefix = "",
|
const word& intervalPrefix = "",
|
||||||
real defStartTime = 0.0);
|
real defStartTime = 0.0);
|
||||||
|
|
||||||
|
inline
|
||||||
|
bool isTimeStep()const
|
||||||
|
{
|
||||||
|
return isTimeStep_;
|
||||||
|
}
|
||||||
|
|
||||||
bool timeEvent(uint32 iter, real t, real dt)const;
|
bool timeEvent(uint32 iter, real t, real dt)const;
|
||||||
|
|
||||||
|
bool isInRange(uint32 iter, real t, real dt)const;
|
||||||
|
|
||||||
|
real startTime()const;
|
||||||
|
|
||||||
|
real endTime()const;
|
||||||
|
|
||||||
|
real rInterval()const;
|
||||||
|
|
||||||
|
int32 startIter()const;
|
||||||
|
|
||||||
|
int32 endIter()const;
|
||||||
|
|
||||||
|
int32 iInterval()const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,18 +18,14 @@ Licence:
|
|||||||
|
|
||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
#include "types.hpp"
|
|
||||||
#include "iOstream.hpp"
|
|
||||||
#include "error.hpp"
|
|
||||||
#include "systemControl.hpp"
|
#include "systemControl.hpp"
|
||||||
#include "vocabs.hpp"
|
|
||||||
#include "Lists.hpp"
|
#include "Lists.hpp"
|
||||||
|
#include "error.hpp"
|
||||||
|
#include "iOstream.hpp"
|
||||||
|
#include "types.hpp"
|
||||||
|
#include "vocabs.hpp"
|
||||||
|
|
||||||
bool pFlow::systemControl::readIncludeExclue
|
bool pFlow::systemControl::readIncludeExclue(const dictionary& dict)
|
||||||
(
|
|
||||||
const dictionary& dict
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (dict.containsDataEntry("includeObjects"))
|
if (dict.containsDataEntry("includeObjects"))
|
||||||
{
|
{
|
||||||
@ -51,12 +47,8 @@ bool pFlow::systemControl::readIncludeExclue
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
pFlow::word pFlow::systemControl::getRunName
|
pFlow::word pFlow::systemControl::getRunName(const fileSystem& path)
|
||||||
(
|
|
||||||
const fileSystem& path
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
// gets the canonical form of path
|
// gets the canonical form of path
|
||||||
word wPath = path.canonical().wordPath() + "/";
|
word wPath = path.canonical().wordPath() + "/";
|
||||||
|
|
||||||
@ -65,8 +57,7 @@ pFlow::word pFlow::systemControl::getRunName
|
|||||||
|
|
||||||
if (first == word::npos)
|
if (first == word::npos)
|
||||||
{
|
{
|
||||||
fatalErrorInFunction <<
|
fatalErrorInFunction << "path is empty \n";
|
||||||
"path is empty \n";
|
|
||||||
fatalExit;
|
fatalExit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,15 +70,10 @@ pFlow::word pFlow::systemControl::getRunName
|
|||||||
word rName = wPath.substr(last + 1);
|
word rName = wPath.substr(last + 1);
|
||||||
|
|
||||||
return rName;
|
return rName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pFlow::word pFlow::systemControl::getTopFolder
|
pFlow::word pFlow::systemControl::getTopFolder(const fileSystem& path)
|
||||||
(
|
|
||||||
const fileSystem& path
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
// gets the canonical form of path
|
// gets the canonical form of path
|
||||||
word wPath = path.canonical().wordPath();
|
word wPath = path.canonical().wordPath();
|
||||||
|
|
||||||
@ -96,8 +82,7 @@ pFlow::word pFlow::systemControl::getTopFolder
|
|||||||
|
|
||||||
if (first == word::npos)
|
if (first == word::npos)
|
||||||
{
|
{
|
||||||
fatalErrorInFunction <<
|
fatalErrorInFunction << "path is empty \n";
|
||||||
"path is empty \n";
|
|
||||||
fatalExit;
|
fatalExit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,77 +95,39 @@ pFlow::word pFlow::systemControl::getTopFolder
|
|||||||
word tFolder = wPath.substr(0, last);
|
word tFolder = wPath.substr(0, last);
|
||||||
|
|
||||||
return tFolder;
|
return tFolder;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pFlow::systemControl::systemControl(const fileSystem path)
|
||||||
pFlow::systemControl::systemControl
|
: repository(
|
||||||
(
|
|
||||||
const fileSystem path
|
|
||||||
)
|
|
||||||
:
|
|
||||||
repository
|
|
||||||
(
|
|
||||||
"systemControl",
|
"systemControl",
|
||||||
path, // local path
|
path, // local path
|
||||||
nullptr // no owner
|
nullptr // no owner
|
||||||
),
|
),
|
||||||
runName_
|
runName_(getRunName(path)),
|
||||||
(
|
topLevelFolder_(getTopFolder(path)),
|
||||||
getRunName(path)
|
settingsDict_(makeUnique<fileDictionary>(
|
||||||
),
|
objectFile(
|
||||||
topLevelFolder_
|
|
||||||
(
|
|
||||||
getTopFolder(path)
|
|
||||||
),
|
|
||||||
settingsDict_
|
|
||||||
(
|
|
||||||
makeUnique<fileDictionary>
|
|
||||||
(
|
|
||||||
objectFile
|
|
||||||
(
|
|
||||||
settingsFile__,
|
settingsFile__,
|
||||||
settingsFolder__,
|
settingsFolder__,
|
||||||
objectFile::READ_ALWAYS,
|
objectFile::READ_ALWAYS,
|
||||||
objectFile::WRITE_NEVER
|
objectFile::WRITE_NEVER
|
||||||
),
|
),
|
||||||
this
|
this
|
||||||
)
|
)),
|
||||||
|
Time_(this, settingsDict_()),
|
||||||
|
settings_(
|
||||||
|
makeUnique<repository>(settingsRepository__, settingsFolder__, this)
|
||||||
),
|
),
|
||||||
Time_
|
caseSetup_(
|
||||||
(
|
makeUnique<repository>(caseSetupRepository__, caseSetupFolder__, this)
|
||||||
this,
|
|
||||||
settingsDict_()
|
|
||||||
),
|
|
||||||
settings_
|
|
||||||
(
|
|
||||||
makeUnique<repository>
|
|
||||||
(
|
|
||||||
settingsRepository__,
|
|
||||||
settingsFolder__,
|
|
||||||
this
|
|
||||||
)
|
|
||||||
),
|
|
||||||
caseSetup_
|
|
||||||
(
|
|
||||||
makeUnique<repository>
|
|
||||||
(
|
|
||||||
caseSetupRepository__,
|
|
||||||
caseSetupFolder__,
|
|
||||||
this
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
|
|
||||||
libs_(settingsDict_()),
|
libs_(settingsDict_()),
|
||||||
outFilePrecision_
|
outFilePrecision_(
|
||||||
(
|
|
||||||
settingsDict_().getValOrSet("outFilePrecision", static_cast<uint64>(6))
|
settingsDict_().getValOrSet("outFilePrecision", static_cast<uint64>(6))
|
||||||
),
|
),
|
||||||
timers_(runName_),
|
timers_(runName_),
|
||||||
timersReport_
|
timersReport_(settingsDict_().getValOrSet("timersReport", Logical("Yes"))),
|
||||||
(
|
|
||||||
settingsDict_().getValOrSet("timersReport", Logical("Yes"))
|
|
||||||
),
|
|
||||||
writeToFileTimer_("Write to file", &timers_)
|
writeToFileTimer_("Write to file", &timers_)
|
||||||
{
|
{
|
||||||
readIncludeExclue(settingsDict_());
|
readIncludeExclue(settingsDict_());
|
||||||
@ -191,38 +138,25 @@ pFlow::systemControl::systemControl(
|
|||||||
const real endTime,
|
const real endTime,
|
||||||
const real saveInterval,
|
const real saveInterval,
|
||||||
const word startTimeName,
|
const word startTimeName,
|
||||||
const fileSystem path)
|
const fileSystem path
|
||||||
:
|
)
|
||||||
repository
|
: repository(
|
||||||
(
|
|
||||||
"systemControl",
|
"systemControl",
|
||||||
path, // local path
|
path, // local path
|
||||||
nullptr // no owner
|
nullptr // no owner
|
||||||
),
|
),
|
||||||
runName_
|
runName_(getRunName(path)),
|
||||||
(
|
topLevelFolder_(getTopFolder(path)),
|
||||||
getRunName(path)
|
settingsDict_(makeUnique<fileDictionary>(
|
||||||
),
|
objectFile(
|
||||||
topLevelFolder_
|
|
||||||
(
|
|
||||||
getTopFolder(path)
|
|
||||||
),
|
|
||||||
settingsDict_
|
|
||||||
(
|
|
||||||
makeUnique<fileDictionary>
|
|
||||||
(
|
|
||||||
objectFile
|
|
||||||
(
|
|
||||||
settingsFile__,
|
settingsFile__,
|
||||||
settingsFolder__,
|
settingsFolder__,
|
||||||
objectFile::READ_ALWAYS,
|
objectFile::READ_ALWAYS,
|
||||||
objectFile::WRITE_NEVER
|
objectFile::WRITE_NEVER
|
||||||
),
|
),
|
||||||
this
|
this
|
||||||
)
|
)),
|
||||||
),
|
Time_(
|
||||||
Time_
|
|
||||||
(
|
|
||||||
this,
|
this,
|
||||||
settingsDict_(),
|
settingsDict_(),
|
||||||
startTime,
|
startTime,
|
||||||
@ -230,40 +164,23 @@ pFlow::systemControl::systemControl(
|
|||||||
saveInterval,
|
saveInterval,
|
||||||
startTimeName
|
startTimeName
|
||||||
),
|
),
|
||||||
settings_
|
settings_(
|
||||||
(
|
makeUnique<repository>(settingsRepository__, settingsFolder__, this)
|
||||||
makeUnique<repository>
|
|
||||||
(
|
|
||||||
settingsRepository__,
|
|
||||||
settingsFolder__,
|
|
||||||
this
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
caseSetup_
|
caseSetup_(
|
||||||
(
|
makeUnique<repository>(caseSetupRepository__, caseSetupFolder__, this)
|
||||||
makeUnique<repository>
|
|
||||||
(
|
|
||||||
caseSetupRepository__,
|
|
||||||
caseSetupFolder__,
|
|
||||||
this
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
libs_(settingsDict_()),
|
libs_(settingsDict_()),
|
||||||
externalTimeControl_(true),
|
externalTimeControl_(true),
|
||||||
timers_(runName_),
|
timers_(runName_),
|
||||||
timersReport_
|
timersReport_(settingsDict_->getValOrSet("timersReport", Logical("Yes"))),
|
||||||
(
|
|
||||||
settingsDict_->getValOrSet("timersReport", Logical("Yes"))
|
|
||||||
),
|
|
||||||
writeToFileTimer_("Write to file", &timers_)
|
writeToFileTimer_("Write to file", &timers_)
|
||||||
{
|
{
|
||||||
readIncludeExclue(settingsDict_());
|
readIncludeExclue(settingsDict_());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool pFlow::systemControl::operator++(int)
|
bool pFlow::systemControl::operator++(int)
|
||||||
{
|
{
|
||||||
|
|
||||||
auto toContinue = time()++;
|
auto toContinue = time()++;
|
||||||
|
|
||||||
if (toContinue)
|
if (toContinue)
|
||||||
@ -280,12 +197,10 @@ bool pFlow::systemControl::operator ++(int)
|
|||||||
}
|
}
|
||||||
writeToFileTimer_.end();
|
writeToFileTimer_.end();
|
||||||
|
|
||||||
if( time().timersReportTime() &&
|
if (time().timersReportTime() && timersReport())
|
||||||
timersReport() )
|
|
||||||
{
|
{
|
||||||
timers_.write(output, true);
|
timers_.write(output, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (time().finalTime())
|
else if (time().finalTime())
|
||||||
{
|
{
|
||||||
@ -302,5 +217,3 @@ bool pFlow::systemControl::operator ++(int)
|
|||||||
|
|
||||||
return toContinue;
|
return toContinue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,23 +18,23 @@ Licence:
|
|||||||
|
|
||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __typeInfo_hpp__
|
#ifndef __typeInfo_hpp__
|
||||||
#define __typeInfo_hpp__
|
#define __typeInfo_hpp__
|
||||||
|
|
||||||
#include <typeinfo>
|
|
||||||
#include <cxxabi.h>
|
#include <cxxabi.h>
|
||||||
|
#include <typeinfo>
|
||||||
|
|
||||||
#include "bTypes.hpp"
|
#include "bTypes.hpp"
|
||||||
|
|
||||||
|
|
||||||
#define has_static_member(name) \
|
#define has_static_member(name) \
|
||||||
template <typename, typename> \
|
template <typename, typename> \
|
||||||
struct has_static_member_##name; \
|
struct has_static_member_##name; \
|
||||||
\
|
\
|
||||||
template <typename testType, typename Ret, typename... Args> \
|
template <typename testType, typename Ret, typename... Args> \
|
||||||
struct has_static_member_##name<testType, Ret(Args...)> { \
|
struct has_static_member_##name<testType, Ret(Args...)> \
|
||||||
template<typename U, U> struct Check; \
|
{ \
|
||||||
|
template <typename U, U> \
|
||||||
|
struct Check; \
|
||||||
\
|
\
|
||||||
template <typename U> \
|
template <typename U> \
|
||||||
static std::true_type Test(Check<Ret (*)(Args...), &U::name> *); \
|
static std::true_type Test(Check<Ret (*)(Args...), &U::name> *); \
|
||||||
@ -43,7 +43,6 @@ Licence:
|
|||||||
static const bool value = decltype(Test<testType>(0))::value; \
|
static const bool value = decltype(Test<testType>(0))::value; \
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@ -52,8 +51,7 @@ namespace pFlow
|
|||||||
{
|
{
|
||||||
has_static_member(TYPENAME);
|
has_static_member(TYPENAME);
|
||||||
|
|
||||||
static constexpr
|
static constexpr bool hasMember()
|
||||||
bool hasMember()
|
|
||||||
{
|
{
|
||||||
return has_static_member_TYPENAME<T, word(void)>::value;
|
return has_static_member_TYPENAME<T, word(void)>::value;
|
||||||
}
|
}
|
||||||
@ -71,38 +69,61 @@ namespace pFlow
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline word basicTypeName<word>(){ return "word"; }
|
inline word basicTypeName<word>()
|
||||||
|
{
|
||||||
|
return "word";
|
||||||
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline word basicTypeName<int64>(){ return "int64"; }
|
inline word basicTypeName<int64>()
|
||||||
|
{
|
||||||
|
return "int64";
|
||||||
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline word basicTypeName<int32>(){ return "int32"; }
|
inline word basicTypeName<int32>()
|
||||||
|
{
|
||||||
|
return "int32";
|
||||||
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline word basicTypeName<int8>(){ return "int8"; }
|
inline word basicTypeName<int8>()
|
||||||
|
{
|
||||||
|
return "int8";
|
||||||
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline word basicTypeName<uint64>(){ return "uint64"; }
|
inline word basicTypeName<uint64>()
|
||||||
|
{
|
||||||
|
return "uint64";
|
||||||
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline word basicTypeName<uint32>(){ return "uint32"; }
|
inline word basicTypeName<uint32>()
|
||||||
|
{
|
||||||
|
return "uint32";
|
||||||
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline word basicTypeName<uint8>(){ return "uint8"; }
|
inline word basicTypeName<uint8>()
|
||||||
|
{
|
||||||
|
return "uint8";
|
||||||
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline word basicTypeName<real>(){ return "real"; }
|
inline word basicTypeName<real>()
|
||||||
|
{
|
||||||
|
return "real";
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
word constexpr getTypeName()
|
word constexpr getTypeName()
|
||||||
{
|
{
|
||||||
|
|
||||||
if constexpr (checkStatic<T>::hasMember())
|
if constexpr (checkStatic<T>::hasMember())
|
||||||
{
|
{
|
||||||
return T::TYPENAME();
|
return T::TYPENAME();
|
||||||
}else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
return basicTypeName<T>();
|
return basicTypeName<T>();
|
||||||
}
|
}
|
||||||
@ -114,7 +135,8 @@ namespace pFlow
|
|||||||
if constexpr (checkStatic<T>::hasMember())
|
if constexpr (checkStatic<T>::hasMember())
|
||||||
{
|
{
|
||||||
return T::TYPENAME();
|
return T::TYPENAME();
|
||||||
}else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
return basicTypeName<T>();
|
return basicTypeName<T>();
|
||||||
}
|
}
|
||||||
@ -133,38 +155,59 @@ namespace pFlow
|
|||||||
{
|
{
|
||||||
return getTypeName<Type1>() == object.typeName();
|
return getTypeName<Type1>() == object.typeName();
|
||||||
}
|
}
|
||||||
}
|
} // namespace pFlow
|
||||||
|
|
||||||
|
|
||||||
#define TypeInfo(tName) \
|
#define TypeInfo(tName) \
|
||||||
inline static word TYPENAME() {return tName; } \
|
inline static word TYPENAME() \
|
||||||
virtual word typeName() const {return TYPENAME();}
|
{ \
|
||||||
|
return tName; \
|
||||||
|
} \
|
||||||
|
virtual word typeName() const \
|
||||||
|
{ \
|
||||||
|
return TYPENAME(); \
|
||||||
|
}
|
||||||
|
|
||||||
#define TypeInfoNV(tName) \
|
#define TypeInfoNV(tName) \
|
||||||
inline static word TYPENAME() {return tName; } \
|
inline static word TYPENAME() \
|
||||||
word typeName() const {return TYPENAME();}
|
{ \
|
||||||
|
return tName; \
|
||||||
|
} \
|
||||||
|
word typeName() const \
|
||||||
|
{ \
|
||||||
|
return TYPENAME(); \
|
||||||
|
}
|
||||||
|
|
||||||
#define TypeInfoTemplate11(tName, Type) \
|
#define TypeInfoTemplate11(tName, Type) \
|
||||||
inline static word TYPENAME() \
|
inline static word TYPENAME() \
|
||||||
{ \
|
{ \
|
||||||
return word(tName) + "<" + getTypeName<Type>() + ">"; \
|
return word(tName) + "<" + getTypeName<Type>() + ">"; \
|
||||||
} \
|
} \
|
||||||
virtual word typeName() const { return TYPENAME();}
|
virtual word typeName() const \
|
||||||
|
{ \
|
||||||
|
return TYPENAME(); \
|
||||||
|
}
|
||||||
|
|
||||||
#define TypeInfoTemplate12(tName, Type1, Type2) \
|
#define TypeInfoTemplate12(tName, Type1, Type2) \
|
||||||
inline static word TYPENAME() \
|
inline static word TYPENAME() \
|
||||||
{ \
|
{ \
|
||||||
return word(tName)+"<"+getTypeName<Type1>()+","+getTypeName<Type2>()+">"; \
|
return word(tName) + "<" + getTypeName<Type1>() + "," + \
|
||||||
|
getTypeName<Type2>() + ">"; \
|
||||||
} \
|
} \
|
||||||
virtual word typeName() const { return TYPENAME();}
|
virtual word typeName() const \
|
||||||
|
{ \
|
||||||
|
return TYPENAME(); \
|
||||||
|
}
|
||||||
|
|
||||||
#define TypeInfoTemplate13(tName, Type1, Type2, Type3) \
|
#define TypeInfoTemplate13(tName, Type1, Type2, Type3) \
|
||||||
inline static word TYPENAME() \
|
inline static word TYPENAME() \
|
||||||
{ \
|
{ \
|
||||||
return word(tName)+"<"+getTypeName<Type1>()+","+getTypeName<Type2>()+","+getTypeName<Type3>()+">";\
|
return word(tName) + "<" + getTypeName<Type1>() + "," + \
|
||||||
|
getTypeName<Type2>() + "," + getTypeName<Type3>() + ">"; \
|
||||||
} \
|
} \
|
||||||
virtual word typeName() const { return TYPENAME();}
|
virtual word typeName() const \
|
||||||
|
{ \
|
||||||
|
return TYPENAME(); \
|
||||||
|
}
|
||||||
|
|
||||||
// this is the non-virtual version
|
// this is the non-virtual version
|
||||||
#define TypeInfoTemplateNV11(tName, Type) \
|
#define TypeInfoTemplateNV11(tName, Type) \
|
||||||
@ -172,37 +215,53 @@ namespace pFlow
|
|||||||
{ \
|
{ \
|
||||||
return word(tName) + "<" + getTypeName<Type>() + ">"; \
|
return word(tName) + "<" + getTypeName<Type>() + ">"; \
|
||||||
} \
|
} \
|
||||||
inline word typeName() const { return TYPENAME();}
|
inline word typeName() const \
|
||||||
|
{ \
|
||||||
|
return TYPENAME(); \
|
||||||
|
}
|
||||||
|
|
||||||
#define TypeInfoTemplateNV111(tName, Type, tName2) \
|
#define TypeInfoTemplateNV111(tName, Type, tName2) \
|
||||||
inline static word TYPENAME() \
|
inline static word TYPENAME() \
|
||||||
{ \
|
{ \
|
||||||
return word(tName)+"<"+getTypeName<Type>()+","+word(tName2)+">"; \
|
return word(tName) + "<" + getTypeName<Type>() + "," + word(tName2) + \
|
||||||
|
">"; \
|
||||||
} \
|
} \
|
||||||
inline word typeName() const { return TYPENAME();}
|
inline word typeName() const \
|
||||||
|
{ \
|
||||||
|
return TYPENAME(); \
|
||||||
|
}
|
||||||
|
|
||||||
#define TypeInfoTemplate111(tName, Type, tName2) \
|
#define TypeInfoTemplate111(tName, Type, tName2) \
|
||||||
inline static word TYPENAME() \
|
inline static word TYPENAME() \
|
||||||
{ \
|
{ \
|
||||||
return word(tName)+"<"+getTypeName<Type>()+","+word(tName2)+">"; \
|
return word(tName) + "<" + getTypeName<Type>() + "," + word(tName2) + \
|
||||||
|
">"; \
|
||||||
} \
|
} \
|
||||||
virtual word typeName() const { return TYPENAME();}
|
virtual word typeName() const \
|
||||||
|
{ \
|
||||||
|
return TYPENAME(); \
|
||||||
|
}
|
||||||
|
|
||||||
#define TypeInfoTemplate211(tBase, tName1, Type, tName3) \
|
#define TypeInfoTemplate211(tBase, tName1, Type, tName3) \
|
||||||
inline static word TYPENAME() \
|
inline static word TYPENAME() \
|
||||||
{ \
|
{ \
|
||||||
return word(tBase)+"<"+word(tName1)+","+getTypeName<Type>()+","+word(tName3)+">"; \
|
return word(tBase) + "<" + word(tName1) + "," + getTypeName<Type>() + \
|
||||||
|
"," + word(tName3) + ">"; \
|
||||||
} \
|
} \
|
||||||
virtual word typeName() const { return TYPENAME();}
|
virtual word typeName() const \
|
||||||
|
{ \
|
||||||
|
return TYPENAME(); \
|
||||||
|
}
|
||||||
|
|
||||||
#define TypeInfoTemplate22(tBase, tName1, Type1, Type2) \
|
#define TypeInfoTemplate22(tBase, tName1, Type1, Type2) \
|
||||||
inline static word TYPENAME() \
|
inline static word TYPENAME() \
|
||||||
{ \
|
{ \
|
||||||
return word(tBase)+"<"+word(tName1)+","+getTypeName<Type1>()+","+getTypeName<Type2>()+">"; \
|
return word(tBase) + "<" + word(tName1) + "," + getTypeName<Type1>() + \
|
||||||
|
"," + getTypeName<Type2>() + ">"; \
|
||||||
} \
|
} \
|
||||||
virtual word typeName() const { return TYPENAME();}
|
virtual word typeName() const \
|
||||||
|
{ \
|
||||||
|
return TYPENAME(); \
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -23,36 +23,32 @@ Licence:
|
|||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
#include "types.hpp"
|
|
||||||
#include "error.hpp"
|
|
||||||
#include "Map.hpp"
|
#include "Map.hpp"
|
||||||
|
#include "error.hpp"
|
||||||
|
#include "types.hpp"
|
||||||
#include "uniquePtr.hpp"
|
#include "uniquePtr.hpp"
|
||||||
|
|
||||||
#define create_vCtor(baseClass, selectorName, argList, args) \
|
#define create_vCtor(baseClass, selectorName, argList, args) \
|
||||||
\
|
\
|
||||||
typedef std::function< uniquePtr<baseClass> argList > selectorName##FunctionType; \
|
typedef std::function<uniquePtr<baseClass> argList> \
|
||||||
typedef wordMap<selectorName##FunctionType> selectorName##vCtorSelectorType; \
|
selectorName##FunctionType; \
|
||||||
\
|
typedef wordMap<selectorName##FunctionType> \
|
||||||
inline static selectorName##vCtorSelectorType selectorName##vCtorSelector_; \
|
selectorName##vCtorSelectorType; \
|
||||||
\
|
\
|
||||||
|
inline static selectorName##vCtorSelectorType \
|
||||||
|
selectorName##vCtorSelector_; \
|
||||||
\
|
\
|
||||||
template<typename dType> \
|
template<typename dType> \
|
||||||
class create##selectorName##Callback \
|
class create##selectorName##Callback \
|
||||||
{ \
|
{ \
|
||||||
public: \
|
public: \
|
||||||
|
\
|
||||||
create##selectorName##Callback() \
|
create##selectorName##Callback() \
|
||||||
{ \
|
{ \
|
||||||
auto success = \
|
auto success = selectorName##vCtorSelector_.insertIf( \
|
||||||
selectorName##vCtorSelector_.insertIf \
|
|
||||||
( \
|
|
||||||
word(dType::TYPENAME()), \
|
word(dType::TYPENAME()), \
|
||||||
[&] argList -> uniquePtr<baseClass> \
|
[&] argList -> uniquePtr<baseClass> \
|
||||||
{ \
|
{ return uniquePtr<baseClass>(new dType args); } \
|
||||||
return uniquePtr<baseClass> \
|
|
||||||
( \
|
|
||||||
new dType args \
|
|
||||||
); \
|
|
||||||
} \
|
|
||||||
); \
|
); \
|
||||||
\
|
\
|
||||||
if (!success) \
|
if (!success) \
|
||||||
@ -62,21 +58,17 @@ public: \
|
|||||||
<< " in virtual constructor table of " << #baseClass \
|
<< " in virtual constructor table of " << #baseClass \
|
||||||
<< " with selector name " << #selectorName << endl; \
|
<< " with selector name " << #selectorName << endl; \
|
||||||
} \
|
} \
|
||||||
\
|
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
create##selectorName##Callback \
|
create##selectorName##Callback(const create##selectorName##Callback&) = \
|
||||||
(const create##selectorName##Callback&)= delete; \
|
delete; \
|
||||||
void operator= \
|
void operator=(const create##selectorName##Callback&) = delete; \
|
||||||
(const create##selectorName##Callback&)= delete; \
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define add_vCtor(baseClass, derivedClass, selectorName) \
|
#define add_vCtor(baseClass, derivedClass, selectorName) \
|
||||||
\
|
\
|
||||||
inline static typename baseClass::template create##selectorName##Callback<derivedClass> baseClass##derivedClass##selectorName##_;
|
inline static typename baseClass::template create##selectorName##Callback< \
|
||||||
|
derivedClass> \
|
||||||
|
baseClass##derivedClass##selectorName##_;
|
||||||
|
|
||||||
#endif // __virtualConstructor_hpp__
|
#endif // __virtualConstructor_hpp__
|
||||||
|
@ -23,23 +23,22 @@ Licence:
|
|||||||
#include "iIstream.hpp"
|
#include "iIstream.hpp"
|
||||||
#include "iOstream.hpp"
|
#include "iOstream.hpp"
|
||||||
|
|
||||||
|
|
||||||
pFlow::Logical::Logical(const word& l)
|
pFlow::Logical::Logical(const word& l)
|
||||||
{
|
{
|
||||||
if (!evaluteWord(l, s_, yesNoSet_))
|
if (!evaluteWord(l, s_, yesNoSet_))
|
||||||
{
|
{
|
||||||
fatalErrorInFunction<<
|
fatalErrorInFunction << " invalid input for Logical: " << l << endl;
|
||||||
" invalid input for Logical: "<< l << endl;
|
|
||||||
fatalExit;
|
fatalExit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pFlow::Logical::Logical(const char* ch)
|
pFlow::Logical::Logical(const char* ch)
|
||||||
:
|
: Logical(word(ch))
|
||||||
Logical(word(ch))
|
{
|
||||||
{}
|
}
|
||||||
|
|
||||||
bool pFlow::Logical::evaluteWord(const word& l, bool& b, int& yesNoSet )
|
bool
|
||||||
|
pFlow::Logical::evaluteWord(const word& l, bool& b, int& yesNoSet)
|
||||||
{
|
{
|
||||||
auto Ul = toUpper(l);
|
auto Ul = toUpper(l);
|
||||||
|
|
||||||
@ -62,7 +61,8 @@ bool pFlow::Logical::evaluteWord(const word& l, bool& b, int& yesNoSet )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::Logical::read(iIstream& is)
|
bool
|
||||||
|
pFlow::Logical::read(iIstream& is)
|
||||||
{
|
{
|
||||||
token t(is);
|
token t(is);
|
||||||
word w;
|
word w;
|
||||||
@ -85,8 +85,7 @@ bool pFlow::Logical::read(iIstream& is)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
ioErrorInFile(is.name(), is.lineNumber())
|
ioErrorInFile(is.name(), is.lineNumber())
|
||||||
<< "Wrong token type - expected Logical value, found "
|
<< "Wrong token type - expected Logical value, found " << t;
|
||||||
<< t;
|
|
||||||
is.setBad();
|
is.setBad();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -94,10 +93,8 @@ bool pFlow::Logical::read(iIstream& is)
|
|||||||
return evaluteWord(w, s_, yesNoSet_);
|
return evaluteWord(w, s_, yesNoSet_);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::Logical::write
|
bool
|
||||||
(
|
pFlow::Logical::write(iOstream& os) const
|
||||||
iOstream& os
|
|
||||||
)const
|
|
||||||
{
|
{
|
||||||
if (s_)
|
if (s_)
|
||||||
{
|
{
|
||||||
@ -110,7 +107,8 @@ bool pFlow::Logical::write
|
|||||||
return os.check(FUNCTION_NAME);
|
return os.check(FUNCTION_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
pFlow::iIstream& pFlow::operator>>( iIstream& is, Logical& L)
|
pFlow::iIstream&
|
||||||
|
pFlow::operator>>(iIstream& is, Logical& L)
|
||||||
{
|
{
|
||||||
if (!L.read(is))
|
if (!L.read(is))
|
||||||
{
|
{
|
||||||
@ -119,7 +117,8 @@ pFlow::iIstream& pFlow::operator>>( iIstream& is, Logical& L)
|
|||||||
return is;
|
return is;
|
||||||
}
|
}
|
||||||
|
|
||||||
pFlow::iOstream& pFlow::operator<< ( iOstream& os, const Logical& L)
|
pFlow::iOstream&
|
||||||
|
pFlow::operator<<(iOstream& os, const Logical& L)
|
||||||
{
|
{
|
||||||
if (!L.write(os))
|
if (!L.write(os))
|
||||||
{
|
{
|
||||||
|
@ -38,7 +38,7 @@ class iOstream;
|
|||||||
*/
|
*/
|
||||||
class Logical
|
class Logical
|
||||||
{
|
{
|
||||||
protected:
|
private:
|
||||||
|
|
||||||
/// bool value
|
/// bool value
|
||||||
bool s_ = false;
|
bool s_ = false;
|
||||||
@ -47,14 +47,17 @@ protected:
|
|||||||
int yesNoSet_ = 0;
|
int yesNoSet_ = 0;
|
||||||
|
|
||||||
/// Set of Yes or Nos
|
/// Set of Yes or Nos
|
||||||
inline static const word YesNo__[4][2] = {{"Yes", "No"},{"on","off"},{"true","false"}, {"Ok","No"}};
|
inline static const word YesNo__[4][2] = { { "Yes", "No" },
|
||||||
|
{ "on", "off" },
|
||||||
|
{ "true", "false" },
|
||||||
|
{ "Ok", "No" } };
|
||||||
|
|
||||||
/// Construct from bool and set number
|
/// Construct from bool and set number
|
||||||
inline explicit Logical(bool s, int yns)
|
inline explicit Logical(bool s, int yns)
|
||||||
:
|
: s_(s),
|
||||||
s_(s),
|
|
||||||
yesNoSet_(yns)
|
yesNoSet_(yns)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -64,13 +67,13 @@ public:
|
|||||||
//// Constructors
|
//// Constructors
|
||||||
|
|
||||||
/// Default constructor
|
/// Default constructor
|
||||||
inline Logical(){}
|
inline Logical() = default;
|
||||||
|
|
||||||
/// Construct from bool
|
/// Construct from bool
|
||||||
inline explicit Logical(bool s)
|
inline explicit Logical(bool s)
|
||||||
:
|
: s_(s)
|
||||||
s_(s)
|
{
|
||||||
{}
|
}
|
||||||
|
|
||||||
/// Construct from word
|
/// Construct from word
|
||||||
Logical(const word& l);
|
Logical(const word& l);
|
||||||
@ -127,13 +130,13 @@ public:
|
|||||||
//// Static members
|
//// Static members
|
||||||
|
|
||||||
bool static evaluteWord(const word& l, bool& b, int& yesNoSet);
|
bool static evaluteWord(const word& l, bool& b, int& yesNoSet);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
iIstream& operator>>( iIstream& is, Logical& L);
|
iIstream&
|
||||||
|
operator>>(iIstream& is, Logical& L);
|
||||||
|
|
||||||
iOstream& operator<<( iOstream& os, const Logical& L);
|
iOstream&
|
||||||
|
operator<<(iOstream& os, const Logical& L);
|
||||||
|
|
||||||
} // pFlow
|
} // pFlow
|
||||||
|
|
||||||
|
@ -19,59 +19,70 @@ Licence:
|
|||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <sstream>
|
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
#include "bTypesFunctions.hpp"
|
#include "bTypesFunctions.hpp"
|
||||||
|
|
||||||
|
pFlow::int32
|
||||||
pFlow::int32 pFlow::countChar(const word& s, const char c)
|
pFlow::countChar(const word& s, const char c)
|
||||||
{
|
{
|
||||||
return std::count(s.cbegin(), s.cend(), c);
|
return std::count(s.cbegin(), s.cend(), c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pFlow::int32
|
||||||
pFlow::int32 pFlow::countChar( const char* s, const char c)
|
pFlow::countChar(const char* s, const char c)
|
||||||
{
|
{
|
||||||
return
|
return (
|
||||||
(
|
s == nullptr ? 0
|
||||||
s == nullptr
|
|
||||||
? 0
|
|
||||||
: std::count(s, (s + std::char_traits<char>::length(s)), c)
|
: std::count(s, (s + std::char_traits<char>::length(s)), c)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pFlow::word pFlow::toUpper(const word & inStr)
|
pFlow::word
|
||||||
|
pFlow::toUpper(const word& inStr)
|
||||||
{
|
{
|
||||||
word oStr(inStr);
|
word oStr(inStr);
|
||||||
std::transform(inStr.begin(), inStr.end(), oStr.begin(), ::toupper);
|
std::transform(inStr.begin(), inStr.end(), oStr.begin(), ::toupper);
|
||||||
return oStr;
|
return oStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
pFlow::word pFlow::firstCapital(const word& inStr)
|
pFlow::word
|
||||||
|
pFlow::firstCapital(const word& inStr)
|
||||||
{
|
{
|
||||||
word oStr(inStr);
|
word oStr(inStr);
|
||||||
oStr[0] = std::toupper(oStr[0]);
|
oStr[0] = std::toupper(oStr[0]);
|
||||||
return oStr;
|
return oStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::isYes(const word & str)
|
bool
|
||||||
|
pFlow::isYes(const word& str)
|
||||||
{
|
{
|
||||||
word s = toUpper(str);
|
word s = toUpper(str);
|
||||||
|
|
||||||
if( s == "YES" || s=="Y" || s == "OK" || s == "TRUE" || s == "ON" || s=="T") return true;
|
if (s == "YES" ||
|
||||||
|
s == "Y" ||
|
||||||
|
s == "OK" ||
|
||||||
|
s == "TRUE" ||
|
||||||
|
s == "ON" ||
|
||||||
|
s == "T")
|
||||||
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::isNo(const word & str)
|
bool
|
||||||
|
pFlow::isNo(const word& str)
|
||||||
{
|
{
|
||||||
word s = toUpper(str);
|
word s = toUpper(str);
|
||||||
|
|
||||||
if( s == "NO" || s == "N" || "FALSE" || s == "OFF" || s == "F") return true;
|
if (s == "NO" || s == "N" || "FALSE" || s == "OFF" || s == "F")
|
||||||
|
return true;
|
||||||
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pFlow::word pFlow::real2Fixed(const real & v, int32 numPrecision)
|
pFlow::word
|
||||||
|
pFlow::real2Fixed(const real& v, int32 numPrecision)
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
|
||||||
@ -79,7 +90,8 @@ pFlow::word pFlow::real2Fixed(const real & v, int32 numPrecision)
|
|||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
pFlow::word pFlow::real2Word(const real & v, int32 numPrecision)
|
pFlow::word
|
||||||
|
pFlow::real2Word(const real& v, int32 numPrecision)
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
if (abs(v) < verySmallValue)
|
if (abs(v) < verySmallValue)
|
||||||
@ -94,7 +106,8 @@ pFlow::word pFlow::real2Word(const real & v, int32 numPrecision)
|
|||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
pFlow::word pFlow::int322Word(const int32 & v)
|
pFlow::word
|
||||||
|
pFlow::int322Word(const int32& v)
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
|
||||||
@ -102,13 +115,16 @@ pFlow::word pFlow::int322Word(const int32 & v)
|
|||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
pFlow::word pFlow::removeDecimalZeros(const word& str)
|
pFlow::word
|
||||||
|
pFlow::removeDecimalZeros(const word& str)
|
||||||
{
|
{
|
||||||
auto dec = str.find('.');
|
auto dec = str.find('.');
|
||||||
if(dec == word::npos) return str;
|
if (dec == word::npos)
|
||||||
|
return str;
|
||||||
|
|
||||||
auto len = str.size();
|
auto len = str.size();
|
||||||
if(len == word::npos) return str;
|
if (len == word::npos)
|
||||||
|
return str;
|
||||||
|
|
||||||
auto firstZero = word::npos;
|
auto firstZero = word::npos;
|
||||||
for (auto n = len - 1; n > dec; n--)
|
for (auto n = len - 1; n > dec; n--)
|
||||||
@ -123,44 +139,50 @@ pFlow::word pFlow::removeDecimalZeros(const word& str)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(firstZero == dec+1) firstZero = dec;
|
if (firstZero == dec + 1)
|
||||||
|
firstZero = dec;
|
||||||
|
|
||||||
return str.substr(0, firstZero);
|
return str.substr(0, firstZero);
|
||||||
}
|
}
|
||||||
|
|
||||||
pFlow::word pFlow::real2FixedStripZeros(const real & v, int32 numPrecision)
|
pFlow::word
|
||||||
|
pFlow::real2FixedStripZeros(const real& v, int32 numPrecision)
|
||||||
{
|
{
|
||||||
word strVal = real2Fixed(v, numPrecision);
|
word strVal = real2Fixed(v, numPrecision);
|
||||||
return removeDecimalZeros(strVal);
|
return removeDecimalZeros(strVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pFlow::word
|
||||||
pFlow::word pFlow::angleBracketsNames(const word& w1, const word& w2)
|
pFlow::angleBracketsNames(const word& w1, const word& w2)
|
||||||
{
|
{
|
||||||
return w1 + "<" + w2 + ">";
|
return w1 + "<" + w2 + ">";
|
||||||
}
|
}
|
||||||
|
|
||||||
pFlow::word pFlow::angleBracketsNames2
|
pFlow::word
|
||||||
(
|
pFlow::angleBracketsNames2(const word& base, const word& w1, const word& w2)
|
||||||
const word& base,
|
|
||||||
const word& w1,
|
|
||||||
const word& w2
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return base + "<" + w1 + "," + w2 + ">";
|
return base + "<" + w1 + "," + w2 + ">";
|
||||||
}
|
}
|
||||||
|
|
||||||
pFlow::word pFlow::angleBracketsNames3(const word& base, const word& w1, const word& w2, const word& w3)
|
pFlow::word
|
||||||
|
pFlow::angleBracketsNames3(
|
||||||
|
const word& base,
|
||||||
|
const word& w1,
|
||||||
|
const word& w2,
|
||||||
|
const word& w3
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return base + "<" + w1 + "," + w2 + "," + w3 + ">";
|
return base + "<" + w1 + "," + w2 + "," + w3 + ">";
|
||||||
}
|
}
|
||||||
|
|
||||||
pFlow::word pFlow::groupNames(const word& bw, const word& tw, char sep)
|
pFlow::word
|
||||||
|
pFlow::groupNames(const word& bw, const word& tw, char sep)
|
||||||
{
|
{
|
||||||
return bw + sep + tw;
|
return bw + sep + tw;
|
||||||
}
|
}
|
||||||
|
|
||||||
pFlow::word pFlow::baseName(const word& w, char sep)
|
pFlow::word
|
||||||
|
pFlow::baseName(const word& w, char sep)
|
||||||
{
|
{
|
||||||
if (auto pos = w.find_last_of(sep); pos != word::npos)
|
if (auto pos = w.find_last_of(sep); pos != word::npos)
|
||||||
{
|
{
|
||||||
@ -172,7 +194,8 @@ pFlow::word pFlow::baseName(const word& w, char sep)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pFlow::word pFlow::tailName(const word& w, char sep)
|
pFlow::word
|
||||||
|
pFlow::tailName(const word& w, char sep)
|
||||||
{
|
{
|
||||||
if (auto pos = w.find_last_of(sep); pos != word::npos)
|
if (auto pos = w.find_last_of(sep); pos != word::npos)
|
||||||
{
|
{
|
||||||
@ -184,12 +207,11 @@ pFlow::word pFlow::tailName(const word& w, char sep)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::validWord(char c)
|
bool
|
||||||
|
pFlow::validWord(char c)
|
||||||
{
|
{
|
||||||
return
|
return (
|
||||||
(
|
!isspace(c) && c != '"' // string quote
|
||||||
!isspace(c)
|
|
||||||
&& c != '"' // string quote
|
|
||||||
&& c != '\'' // string quote
|
&& c != '\'' // string quote
|
||||||
//&& c != '/' // path separator
|
//&& c != '/' // path separator
|
||||||
&& c != ';' // end statement
|
&& c != ';' // end statement
|
||||||
@ -198,40 +220,45 @@ bool pFlow::validWord(char c)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::validWordWithQuote(char c)
|
bool
|
||||||
|
pFlow::validWordWithQuote(char c)
|
||||||
{
|
{
|
||||||
return
|
return (
|
||||||
(
|
!isspace(c) && c != ';' // end statement
|
||||||
!isspace(c)
|
|
||||||
&& c != ';' // end statement
|
|
||||||
&& c != '{' // beg subdict
|
&& c != '{' // beg subdict
|
||||||
&& c != '}' // end subdict
|
&& c != '}' // end subdict
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::validWord(const word& w)
|
bool
|
||||||
|
pFlow::validWord(const word& w)
|
||||||
{
|
{
|
||||||
for (auto wi : w)
|
for (auto wi : w)
|
||||||
{
|
{
|
||||||
char c = wi;
|
char c = wi;
|
||||||
if ( !validWord(c) ) return false;
|
if (!validWord(c))
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::validWordWithQuote(const word& w)
|
bool
|
||||||
|
pFlow::validWordWithQuote(const word& w)
|
||||||
{
|
{
|
||||||
for (auto wi : w)
|
for (auto wi : w)
|
||||||
{
|
{
|
||||||
char c = wi;
|
char c = wi;
|
||||||
if ( !validWordWithQuote(c) ) return false;
|
if (!validWordWithQuote(c))
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::readUint32( const word& w, uint32 & val)
|
bool
|
||||||
|
pFlow::readUint32(const word& w, uint32& val)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
try{
|
|
||||||
val = std::stoul(w);
|
val = std::stoul(w);
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
@ -241,15 +268,18 @@ bool pFlow::readUint32( const word& w, uint32 & val)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::readUint32( const char* buf, uint32 & val)
|
bool
|
||||||
|
pFlow::readUint32(const char* buf, uint32& val)
|
||||||
{
|
{
|
||||||
word w(buf);
|
word w(buf);
|
||||||
return readUint32(w, val);
|
return readUint32(w, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::readInt64( const word& w, int64 & val)
|
bool
|
||||||
|
pFlow::readInt64(const word& w, int64& val)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
try{
|
|
||||||
val = std::stoll(w);
|
val = std::stoll(w);
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
@ -259,15 +289,18 @@ bool pFlow::readInt64( const word& w, int64 & val)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::readInt64( const char* buf, int64 & val)
|
bool
|
||||||
|
pFlow::readInt64(const char* buf, int64& val)
|
||||||
{
|
{
|
||||||
word w(buf);
|
word w(buf);
|
||||||
return readInt64(w, val);
|
return readInt64(w, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::readInt32( const word& w, int32 & val)
|
bool
|
||||||
|
pFlow::readInt32(const word& w, int32& val)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
try{
|
|
||||||
val = std::stoi(w);
|
val = std::stoi(w);
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
@ -277,15 +310,18 @@ bool pFlow::readInt32( const word& w, int32 & val)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::readInt32( const char* buf, int32 & val)
|
bool
|
||||||
|
pFlow::readInt32(const char* buf, int32& val)
|
||||||
{
|
{
|
||||||
word w(buf);
|
word w(buf);
|
||||||
return readInt32(w, val);
|
return readInt32(w, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::readInt8( const word& w, int8 & val)
|
bool
|
||||||
|
pFlow::readInt8(const word& w, int8& val)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
try{
|
|
||||||
val = std::stoi(w);
|
val = std::stoi(w);
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
@ -295,30 +331,34 @@ bool pFlow::readInt8( const word& w, int8 & val)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::readInt8( const char* buf, int8 & val)
|
bool
|
||||||
|
pFlow::readInt8(const char* buf, int8& val)
|
||||||
{
|
{
|
||||||
word w(buf);
|
word w(buf);
|
||||||
return readInt8(w, val);
|
return readInt8(w, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #include <iostream>
|
// #include <iostream>
|
||||||
bool pFlow::readReal( const word& w, real & val)
|
bool
|
||||||
|
pFlow::readReal(const word& w, real& val)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
try{
|
|
||||||
val = std::stod(w);
|
val = std::stod(w);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (std::out_of_range& e)
|
catch (std::out_of_range& e)
|
||||||
{
|
{
|
||||||
val = static_cast<real>(std::stold(w));
|
val = static_cast<real>(std::stold(w));
|
||||||
}
|
}
|
||||||
catch (...){
|
catch (...)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::readReal( const char* buf, real & val )
|
bool
|
||||||
|
pFlow::readReal(const char* buf, real& val)
|
||||||
{
|
{
|
||||||
char* c;
|
char* c;
|
||||||
|
|
||||||
@ -337,8 +377,8 @@ bool pFlow::readReal( const char* buf, real & val )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
bool pFlow::readBoolian_Str( const word& w, bool & val)
|
pFlow::readBoolian_Str(const word& w, bool& val)
|
||||||
{
|
{
|
||||||
if (bool t = isYes(w); t)
|
if (bool t = isYes(w); t)
|
||||||
{
|
{
|
||||||
@ -353,7 +393,8 @@ bool pFlow::readBoolian_Str( const word& w, bool & val)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pFlow::readBoolian_Str( const char* buf, bool & val)
|
bool
|
||||||
|
pFlow::readBoolian_Str(const char* buf, bool& val)
|
||||||
{
|
{
|
||||||
word w(buf);
|
word w(buf);
|
||||||
return readBoolian_Str(w, val);
|
return readBoolian_Str(w, val);
|
||||||
|
@ -25,12 +25,10 @@ Licence:
|
|||||||
#ifndef __bTypesFunctions_hpp__
|
#ifndef __bTypesFunctions_hpp__
|
||||||
#define __bTypesFunctions_hpp__
|
#define __bTypesFunctions_hpp__
|
||||||
|
|
||||||
#include "pFlowMacros.hpp"
|
|
||||||
#include "numericConstants.hpp"
|
|
||||||
#include "builtinTypes.hpp"
|
#include "builtinTypes.hpp"
|
||||||
#include "math.hpp"
|
#include "math.hpp"
|
||||||
|
#include "numericConstants.hpp"
|
||||||
|
#include "pFlowMacros.hpp"
|
||||||
|
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
@ -54,196 +52,236 @@ inline const word nullWord;
|
|||||||
inline const word whiteSpace(" \t\n\v\f\r");
|
inline const word whiteSpace(" \t\n\v\f\r");
|
||||||
|
|
||||||
/// Count numer of chars c in a word
|
/// Count numer of chars c in a word
|
||||||
int32 countChar (const word& s, const char c);
|
int32
|
||||||
|
countChar(const word& s, const char c);
|
||||||
|
|
||||||
/// Count numer of chars c in a char string
|
/// Count numer of chars c in a char string
|
||||||
int32 countChar(const char* s, const char c);
|
int32
|
||||||
|
countChar(const char* s, const char c);
|
||||||
|
|
||||||
/// convert a word to all caps
|
/// convert a word to all caps
|
||||||
word toUpper(const word & inStr);
|
word
|
||||||
|
toUpper(const word& inStr);
|
||||||
|
|
||||||
word firstCapital(const word& inStr);
|
word
|
||||||
|
firstCapital(const word& inStr);
|
||||||
|
|
||||||
/// Check if str equals "Yes", "Y", "True", "Ok", "ON", or "T"
|
/// Check if str equals "Yes", "Y", "True", "Ok", "ON", or "T"
|
||||||
bool isYes(const word & str);
|
bool
|
||||||
|
isYes(const word& str);
|
||||||
|
|
||||||
/// Check if str equals "No", "N", "False", or "Off"
|
/// Check if str equals "No", "N", "False", or "Off"
|
||||||
bool isNo(const word & str);
|
bool
|
||||||
|
isNo(const word& str);
|
||||||
|
|
||||||
/// Convert floating point variable to string with fixed number of precisions
|
/// Convert floating point variable to string with fixed number of precisions
|
||||||
word real2Fixed(const real & v, int32 numPrecision = 6);
|
word
|
||||||
|
real2Fixed(const real& v, int32 numPrecision = 6);
|
||||||
|
|
||||||
/// Convert floating point variable to string with general format
|
/// Convert floating point variable to string with general format
|
||||||
word real2Word(const real & v, int32 numPrecision = 6);
|
word
|
||||||
|
real2Word(const real& v, int32 numPrecision = 6);
|
||||||
|
|
||||||
/// Convert int32 to word
|
/// Convert int32 to word
|
||||||
word int322Word(const int32 & v);
|
word
|
||||||
|
int322Word(const int32& v);
|
||||||
|
|
||||||
/// Remove zeros from decimal part of a string number
|
/// Remove zeros from decimal part of a string number
|
||||||
word removeDecimalZeros(const word& str);
|
word
|
||||||
|
removeDecimalZeros(const word& str);
|
||||||
|
|
||||||
/// Convert to fixed point variable and remove zeros
|
/// Convert to fixed point variable and remove zeros
|
||||||
word real2FixedStripZeros(const real & v, int32 numPrecision = 6);
|
word
|
||||||
|
real2FixedStripZeros(const real& v, int32 numPrecision = 6);
|
||||||
|
|
||||||
/// Output <w1,w2>
|
/// Output <w1,w2>
|
||||||
word angleBracketsNames(const word& w1, const word& w2);
|
word
|
||||||
|
angleBracketsNames(const word& w1, const word& w2);
|
||||||
|
|
||||||
/// Output base<w1,w2>
|
/// Output base<w1,w2>
|
||||||
word angleBracketsNames2(const word& base, const word& w1, const word& w2);
|
word
|
||||||
|
angleBracketsNames2(const word& base, const word& w1, const word& w2);
|
||||||
|
|
||||||
/// Output base<w1,sw2,w3>
|
/// Output base<w1,sw2,w3>
|
||||||
word angleBracketsNames3(const word& base, const word& w1, const word& w2, const word& w3);
|
word
|
||||||
|
angleBracketsNames3(
|
||||||
|
const word& base,
|
||||||
|
const word& w1,
|
||||||
|
const word& w2,
|
||||||
|
const word& w3
|
||||||
|
);
|
||||||
|
|
||||||
/// Group words and output bw.tw
|
/// Group words and output bw.tw
|
||||||
word groupNames(const word& bw, const word& tw, char sep = '.');
|
word
|
||||||
|
groupNames(const word& bw, const word& tw, char sep = '.');
|
||||||
|
|
||||||
/// Find the base in a group separated by "." and return it.
|
/// Find the base in a group separated by "." and return it.
|
||||||
word baseName(const word& w, char sep = '.');
|
word
|
||||||
|
baseName(const word& w, char sep = '.');
|
||||||
|
|
||||||
/// Find tail name in a group separated by "." and return it.
|
/// Find tail name in a group separated by "." and return it.
|
||||||
word tailName(const word& w, char sep = '.');
|
word
|
||||||
|
tailName(const word& w, char sep = '.');
|
||||||
|
|
||||||
/// Is the character valid for a word name?
|
/// Is the character valid for a word name?
|
||||||
bool validWord(char c);
|
bool
|
||||||
|
validWord(char c);
|
||||||
|
|
||||||
/// Is c a valid character including quote?
|
/// Is c a valid character including quote?
|
||||||
bool validWordWithQuote(char c);
|
bool
|
||||||
|
validWordWithQuote(char c);
|
||||||
|
|
||||||
/// Is a valid word?
|
/// Is a valid word?
|
||||||
bool validWord(const word& w);
|
bool
|
||||||
|
validWord(const word& w);
|
||||||
|
|
||||||
/// Is a valid word with qoute?
|
/// Is a valid word with qoute?
|
||||||
bool validWordWithQuote(const word& c);
|
bool
|
||||||
|
validWordWithQuote(const word& c);
|
||||||
|
|
||||||
/// Convert word to uint32
|
/// Convert word to uint32
|
||||||
bool readUint32( const word& w, uint32 & val);
|
bool
|
||||||
|
readUint32(const word& w, uint32& val);
|
||||||
|
|
||||||
/// Convert char string to uint32
|
/// Convert char string to uint32
|
||||||
bool readUint32( const char* buf, uint32 & val);
|
bool
|
||||||
|
readUint32(const char* buf, uint32& val);
|
||||||
|
|
||||||
/// Convert word to int64
|
/// Convert word to int64
|
||||||
bool readInt64( const word& w, int64 & val);
|
bool
|
||||||
|
readInt64(const word& w, int64& val);
|
||||||
|
|
||||||
/// Convert char string to int64
|
/// Convert char string to int64
|
||||||
bool readInt64( const char* buf, int64 & val);
|
bool
|
||||||
|
readInt64(const char* buf, int64& val);
|
||||||
|
|
||||||
/// Convert word to int32
|
/// Convert word to int32
|
||||||
bool readInt32( const word& w, int32 & val);
|
bool
|
||||||
|
readInt32(const word& w, int32& val);
|
||||||
|
|
||||||
/// Convert char string to int32
|
/// Convert char string to int32
|
||||||
bool readInt32( const char* buf, int32 & val);
|
bool
|
||||||
|
readInt32(const char* buf, int32& val);
|
||||||
|
|
||||||
/// Convert word to int8
|
/// Convert word to int8
|
||||||
bool readInt8( const word& w, int8 & val);
|
bool
|
||||||
|
readInt8(const word& w, int8& val);
|
||||||
|
|
||||||
/// Convert char string to int8
|
/// Convert char string to int8
|
||||||
bool readInt8( const char* buf, int8 & val);
|
bool
|
||||||
|
readInt8(const char* buf, int8& val);
|
||||||
|
|
||||||
/// Convert word to real
|
/// Convert word to real
|
||||||
bool readReal( const word& w, real & val);
|
bool
|
||||||
|
readReal(const word& w, real& val);
|
||||||
|
|
||||||
/// Convert char string to real
|
/// Convert char string to real
|
||||||
bool readReal( const char* buf, real & val );
|
bool
|
||||||
|
readReal(const char* buf, real& val);
|
||||||
|
|
||||||
/// Convert word to bool
|
/// Convert word to bool
|
||||||
bool readBoolian_Str( const word& w, bool & val);
|
bool
|
||||||
|
readBoolian_Str(const word& w, bool& val);
|
||||||
|
|
||||||
/// Convert char string to bool
|
/// Convert char string to bool
|
||||||
bool readBoolian_Str( const char* buf, bool & val);
|
bool
|
||||||
|
readBoolian_Str(const char* buf, bool& val);
|
||||||
|
|
||||||
|
inline bool
|
||||||
inline
|
readValue(const word& w, real& val)
|
||||||
bool readValue(const word& w, real& val)
|
|
||||||
{
|
{
|
||||||
return readReal(w, val);
|
return readReal(w, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline bool
|
||||||
bool readValue(const word& w, uint32& val)
|
readValue(const word& w, uint32& val)
|
||||||
{
|
{
|
||||||
return readUint32(w, val);
|
return readUint32(w, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline bool
|
||||||
bool readValue(const word& w, int64& val)
|
readValue(const word& w, int64& val)
|
||||||
{
|
{
|
||||||
return readInt64(w, val);
|
return readInt64(w, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline bool
|
||||||
bool readValue(const word& w, int32& val)
|
readValue(const word& w, int32& val)
|
||||||
{
|
{
|
||||||
return readInt32(w, val);
|
return readInt32(w, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool
|
||||||
inline
|
readValue(const word& w, int8& val)
|
||||||
bool readValue(const word& w, int8& val)
|
|
||||||
{
|
{
|
||||||
return readInt8(w, val);
|
return readInt8(w, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline bool
|
||||||
bool readValue(const word& w, bool& val)
|
readValue(const word& w, bool& val)
|
||||||
{
|
{
|
||||||
return readBoolian_Str(w, val);
|
return readBoolian_Str(w, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
bool equal(const real& s1, const real& s2, real tol = smallValue)
|
bool
|
||||||
|
equal(const real& s1, const real& s2, real tol = smallValue)
|
||||||
{
|
{
|
||||||
return abs(s1 - s2) <= tol;
|
return abs(s1 - s2) <= tol;
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
bool equal(const int64& s1, const int64& s2)
|
bool
|
||||||
|
equal(const int64& s1, const int64& s2)
|
||||||
{
|
{
|
||||||
return s1 == s2;
|
return s1 == s2;
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
bool equal(const int32& s1, const int32& s2)
|
bool
|
||||||
|
equal(const int32& s1, const int32& s2)
|
||||||
{
|
{
|
||||||
return s1 == s2;
|
return s1 == s2;
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
bool equal(const int8& s1, const int8& s2)
|
bool
|
||||||
|
equal(const int8& s1, const int8& s2)
|
||||||
{
|
{
|
||||||
return s1 == s2;
|
return s1 == s2;
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
bool equal(const uint32& s1, const uint32& s2)
|
bool
|
||||||
|
equal(const uint32& s1, const uint32& s2)
|
||||||
{
|
{
|
||||||
return s1 == s2;
|
return s1 == s2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Are two words equal (host only)?
|
/// Are two words equal (host only)?
|
||||||
INLINE_FUNCTION
|
INLINE_FUNCTION
|
||||||
bool equal(const word& s1, const word& s2)
|
bool
|
||||||
|
equal(const word& s1, const word& s2)
|
||||||
{
|
{
|
||||||
return s1 == s2;
|
return s1 == s2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert degree to radians
|
/// Convert degree to radians
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
real degree2Radian(const real &theta)
|
real
|
||||||
|
degree2Radian(const real& theta)
|
||||||
{
|
{
|
||||||
return theta / 180.0 * Pi;
|
return theta / 180.0 * Pi;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert radians to degree
|
/// Convert radians to degree
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
real radian2Degree(const real &phi)
|
real
|
||||||
|
radian2Degree(const real& phi)
|
||||||
{
|
{
|
||||||
return phi / Pi * 180.0;
|
return phi / Pi * 180.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // end of pFlow
|
} // end of pFlow
|
||||||
|
|
||||||
|
|
||||||
#endif //__bTypesFunctions_hpp__
|
#endif //__bTypesFunctions_hpp__
|
||||||
|
@ -38,7 +38,6 @@ inline const char* floatingPointType__ = "float";
|
|||||||
inline const bool usingDouble__ = false;
|
inline const bool usingDouble__ = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// scalars
|
// scalars
|
||||||
#if useDouble
|
#if useDouble
|
||||||
using real = double;
|
using real = double;
|
||||||
@ -66,8 +65,8 @@ using word = std::string;
|
|||||||
|
|
||||||
inline const int numBytesForReal__ = sizeof(real);
|
inline const int numBytesForReal__ = sizeof(real);
|
||||||
|
|
||||||
inline
|
inline word
|
||||||
word floatingPointDescription()
|
floatingPointDescription()
|
||||||
{
|
{
|
||||||
return word("In this build, ") + word(floatingPointType__) +
|
return word("In this build, ") + word(floatingPointType__) +
|
||||||
word(" is used for floating point operations.");
|
word(" is used for floating point operations.");
|
||||||
@ -75,5 +74,4 @@ word floatingPointDescription()
|
|||||||
|
|
||||||
} // end of pFlow
|
} // end of pFlow
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -21,17 +21,14 @@ Licence:
|
|||||||
#ifndef __math_hpp__
|
#ifndef __math_hpp__
|
||||||
#define __math_hpp__
|
#define __math_hpp__
|
||||||
|
|
||||||
|
|
||||||
#ifdef __CUDACC__
|
#ifdef __CUDACC__
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
#else
|
#else
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "pFlowMacros.hpp"
|
|
||||||
#include "builtinTypes.hpp"
|
#include "builtinTypes.hpp"
|
||||||
|
#include "pFlowMacros.hpp"
|
||||||
|
|
||||||
|
|
||||||
//* * * * * * * * * * * List of functinos * * * * * * * * //
|
//* * * * * * * * * * * List of functinos * * * * * * * * //
|
||||||
// abs, mod, exp, log, log10, pow, sqrt, cbrt
|
// abs, mod, exp, log, log10, pow, sqrt, cbrt
|
||||||
@ -43,9 +40,9 @@ Licence:
|
|||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
real abs(real x)
|
real
|
||||||
|
abs(real x)
|
||||||
{
|
{
|
||||||
#ifdef __CUDACC__
|
#ifdef __CUDACC__
|
||||||
return ::fabs(x);
|
return ::fabs(x);
|
||||||
@ -56,21 +53,23 @@ real abs(real x)
|
|||||||
|
|
||||||
#ifndef __CUDACC__
|
#ifndef __CUDACC__
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
int64 abs(int64 x)
|
int64
|
||||||
|
abs(int64 x)
|
||||||
{
|
{
|
||||||
return std::abs(x);
|
return std::abs(x);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __CUDACC__
|
#ifndef __CUDACC__
|
||||||
INLINE_FUNCTION_HD int32 abs(int32 x)
|
INLINE_FUNCTION_HD int32
|
||||||
|
abs(int32 x)
|
||||||
{
|
{
|
||||||
return std::abs(x);
|
return std::abs(x);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
INLINE_FUNCTION_HD real
|
||||||
INLINE_FUNCTION_HD real mod(real x, real y)
|
mod(real x, real y)
|
||||||
{
|
{
|
||||||
#ifdef __CUDACC__
|
#ifdef __CUDACC__
|
||||||
return ::fmod(x, y);
|
return ::fmod(x, y);
|
||||||
@ -79,28 +78,33 @@ INLINE_FUNCTION_HD real mod(real x, real y)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_FUNCTION_HD int64 mod(int64 x, int64 y)
|
INLINE_FUNCTION_HD int64
|
||||||
|
mod(int64 x, int64 y)
|
||||||
{
|
{
|
||||||
return x % y;
|
return x % y;
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_FUNCTION_HD int32 mod(int32 x, int32 y)
|
INLINE_FUNCTION_HD int32
|
||||||
|
mod(int32 x, int32 y)
|
||||||
{
|
{
|
||||||
return x % y;
|
return x % y;
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_FUNCTION_HD int64 mod(uint64 x, uint64 y)
|
INLINE_FUNCTION_HD int64
|
||||||
|
mod(uint64 x, uint64 y)
|
||||||
{
|
{
|
||||||
return x % y;
|
return x % y;
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_FUNCTION_HD auto mod(uint32 x, uint32 y)
|
INLINE_FUNCTION_HD auto
|
||||||
|
mod(uint32 x, uint32 y)
|
||||||
{
|
{
|
||||||
return x % y;
|
return x % y;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __CUDACC__
|
#ifndef __CUDACC__
|
||||||
INLINE_FUNCTION_HD real remainder(real x, real y)
|
INLINE_FUNCTION_HD real
|
||||||
|
remainder(real x, real y)
|
||||||
{
|
{
|
||||||
return std::remainder(x, y);
|
return std::remainder(x, y);
|
||||||
}
|
}
|
||||||
@ -108,7 +112,8 @@ INLINE_FUNCTION_HD real remainder(real x, real y)
|
|||||||
|
|
||||||
#ifndef __CUDACC__
|
#ifndef __CUDACC__
|
||||||
INLINE_FUNCTION_H
|
INLINE_FUNCTION_H
|
||||||
real exp(real x)
|
real
|
||||||
|
exp(real x)
|
||||||
{
|
{
|
||||||
return std::exp(x);
|
return std::exp(x);
|
||||||
}
|
}
|
||||||
@ -116,7 +121,8 @@ real exp(real x)
|
|||||||
|
|
||||||
#ifndef __CUDACC__
|
#ifndef __CUDACC__
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
real log(real x)
|
real
|
||||||
|
log(real x)
|
||||||
{
|
{
|
||||||
return std::log(x);
|
return std::log(x);
|
||||||
}
|
}
|
||||||
@ -124,7 +130,8 @@ real log(real x)
|
|||||||
|
|
||||||
#ifndef __CUDACC__
|
#ifndef __CUDACC__
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
real log10(real x)
|
real
|
||||||
|
log10(real x)
|
||||||
{
|
{
|
||||||
return std::log10(x);
|
return std::log10(x);
|
||||||
}
|
}
|
||||||
@ -132,7 +139,8 @@ real log10(real x)
|
|||||||
|
|
||||||
#ifndef __CUDACC__
|
#ifndef __CUDACC__
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
real pow(real x, real y)
|
real
|
||||||
|
pow(real x, real y)
|
||||||
{
|
{
|
||||||
return std::pow(x, y);
|
return std::pow(x, y);
|
||||||
}
|
}
|
||||||
@ -140,7 +148,8 @@ real pow(real x, real y)
|
|||||||
|
|
||||||
#ifndef __CUDACC__
|
#ifndef __CUDACC__
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
real sqrt(real x)
|
real
|
||||||
|
sqrt(real x)
|
||||||
{
|
{
|
||||||
return std::sqrt(x);
|
return std::sqrt(x);
|
||||||
}
|
}
|
||||||
@ -148,7 +157,8 @@ real sqrt(real x)
|
|||||||
|
|
||||||
#ifndef __CUDACC__
|
#ifndef __CUDACC__
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
real cbrt (real x)
|
real
|
||||||
|
cbrt(real x)
|
||||||
{
|
{
|
||||||
return std::cbrt(x);
|
return std::cbrt(x);
|
||||||
}
|
}
|
||||||
@ -156,7 +166,8 @@ real cbrt (real x)
|
|||||||
|
|
||||||
#ifndef __CUDACC__
|
#ifndef __CUDACC__
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
real sin(real x)
|
real
|
||||||
|
sin(real x)
|
||||||
{
|
{
|
||||||
return std::sin(x);
|
return std::sin(x);
|
||||||
}
|
}
|
||||||
@ -164,7 +175,8 @@ real sin(real x)
|
|||||||
|
|
||||||
#ifndef __CUDACC__
|
#ifndef __CUDACC__
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
real cos(real x)
|
real
|
||||||
|
cos(real x)
|
||||||
{
|
{
|
||||||
return std::cos(x);
|
return std::cos(x);
|
||||||
}
|
}
|
||||||
@ -172,7 +184,8 @@ real cos(real x)
|
|||||||
|
|
||||||
#ifndef __CUDACC__
|
#ifndef __CUDACC__
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
real tan(real x)
|
real
|
||||||
|
tan(real x)
|
||||||
{
|
{
|
||||||
return std::tan(x);
|
return std::tan(x);
|
||||||
}
|
}
|
||||||
@ -180,7 +193,8 @@ real tan(real x)
|
|||||||
|
|
||||||
#ifndef __CUDACC__
|
#ifndef __CUDACC__
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
real asin(real x)
|
real
|
||||||
|
asin(real x)
|
||||||
{
|
{
|
||||||
return std::asin(x);
|
return std::asin(x);
|
||||||
}
|
}
|
||||||
@ -188,7 +202,8 @@ real asin(real x)
|
|||||||
|
|
||||||
#ifndef __CUDACC__
|
#ifndef __CUDACC__
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
real acos(real x)
|
real
|
||||||
|
acos(real x)
|
||||||
{
|
{
|
||||||
return std::acos(x);
|
return std::acos(x);
|
||||||
}
|
}
|
||||||
@ -196,7 +211,8 @@ real acos(real x)
|
|||||||
|
|
||||||
#ifndef __CUDACC__
|
#ifndef __CUDACC__
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
real atan(real x)
|
real
|
||||||
|
atan(real x)
|
||||||
{
|
{
|
||||||
return std::atan(x);
|
return std::atan(x);
|
||||||
}
|
}
|
||||||
@ -212,7 +228,8 @@ atan2(real y, real x)
|
|||||||
|
|
||||||
#ifndef __CUDACC__
|
#ifndef __CUDACC__
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
real sinh(real x)
|
real
|
||||||
|
sinh(real x)
|
||||||
{
|
{
|
||||||
return std::sinh(x);
|
return std::sinh(x);
|
||||||
}
|
}
|
||||||
@ -220,13 +237,15 @@ real sinh(real x)
|
|||||||
|
|
||||||
#ifndef __CUDACC__
|
#ifndef __CUDACC__
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
real cosh(real x)
|
real
|
||||||
|
cosh(real x)
|
||||||
{
|
{
|
||||||
return std::cosh(x);
|
return std::cosh(x);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
INLINE_FUNCTION_HD real tanh(real x)
|
INLINE_FUNCTION_HD real
|
||||||
|
tanh(real x)
|
||||||
{
|
{
|
||||||
#ifdef __CUDACC__
|
#ifdef __CUDACC__
|
||||||
return ::tanh(x);
|
return ::tanh(x);
|
||||||
@ -235,7 +254,8 @@ INLINE_FUNCTION_HD real tanh(real x)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_FUNCTION_HD real asinh(real x)
|
INLINE_FUNCTION_HD real
|
||||||
|
asinh(real x)
|
||||||
{
|
{
|
||||||
#ifdef __CUDACC__
|
#ifdef __CUDACC__
|
||||||
return ::asinh(x);
|
return ::asinh(x);
|
||||||
@ -244,7 +264,8 @@ INLINE_FUNCTION_HD real asinh(real x)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE_FUNCTION_HD real acosh(real x)
|
INLINE_FUNCTION_HD real
|
||||||
|
acosh(real x)
|
||||||
{
|
{
|
||||||
#ifdef __CUDACC__
|
#ifdef __CUDACC__
|
||||||
return ::acosh(x);
|
return ::acosh(x);
|
||||||
@ -255,14 +276,15 @@ INLINE_FUNCTION_HD real acosh(real x)
|
|||||||
|
|
||||||
#ifndef __CUDACC__
|
#ifndef __CUDACC__
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
real atanh(real x)
|
real
|
||||||
|
atanh(real x)
|
||||||
{
|
{
|
||||||
return std::atanh(x);
|
return std::atanh(x);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
INLINE_FUNCTION_HD real
|
||||||
INLINE_FUNCTION_HD real min(real x, real y)
|
min(real x, real y)
|
||||||
{
|
{
|
||||||
#ifdef __CUDACC__
|
#ifdef __CUDACC__
|
||||||
return ::fmin(x, y);
|
return ::fmin(x, y);
|
||||||
@ -273,7 +295,8 @@ INLINE_FUNCTION_HD real min(real x, real y)
|
|||||||
|
|
||||||
#ifndef __CUDACC__
|
#ifndef __CUDACC__
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
int64 min(int32 x, int32 y)
|
int64
|
||||||
|
min(int32 x, int32 y)
|
||||||
{
|
{
|
||||||
return std::min(x, y);
|
return std::min(x, y);
|
||||||
}
|
}
|
||||||
@ -281,7 +304,8 @@ int64 min(int32 x, int32 y)
|
|||||||
|
|
||||||
#ifndef __CUDACC__
|
#ifndef __CUDACC__
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
int64 min(int64 x, int64 y)
|
int64
|
||||||
|
min(int64 x, int64 y)
|
||||||
{
|
{
|
||||||
return std::min(x, y);
|
return std::min(x, y);
|
||||||
}
|
}
|
||||||
@ -289,21 +313,23 @@ int64 min(int64 x, int64 y)
|
|||||||
|
|
||||||
#ifndef __CUDACC__
|
#ifndef __CUDACC__
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
uint64 min(uint64 x, uint64 y)
|
uint64
|
||||||
|
min(uint64 x, uint64 y)
|
||||||
{
|
{
|
||||||
return std::min(x, y);
|
return std::min(x, y);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __CUDACC__
|
#ifndef __CUDACC__
|
||||||
INLINE_FUNCTION_HD uint32 min(uint32 x, uint32 y)
|
INLINE_FUNCTION_HD uint32
|
||||||
|
min(uint32 x, uint32 y)
|
||||||
{
|
{
|
||||||
return std::min(x, y);
|
return std::min(x, y);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
INLINE_FUNCTION_HD real
|
||||||
INLINE_FUNCTION_HD real max(real x, real y)
|
max(real x, real y)
|
||||||
{
|
{
|
||||||
#ifdef __CUDACC__
|
#ifdef __CUDACC__
|
||||||
return ::fmax(x, y);
|
return ::fmax(x, y);
|
||||||
@ -312,38 +338,38 @@ INLINE_FUNCTION_HD real max(real x, real y)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef __CUDACC__
|
#ifndef __CUDACC__
|
||||||
INLINE_FUNCTION_HD int64 max(int64 x, int64 y)
|
INLINE_FUNCTION_HD int64
|
||||||
|
max(int64 x, int64 y)
|
||||||
{
|
{
|
||||||
return std::max(x, y);
|
return std::max(x, y);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __CUDACC__
|
#ifndef __CUDACC__
|
||||||
INLINE_FUNCTION_HD int32 max(int32 x, int32 y)
|
INLINE_FUNCTION_HD int32
|
||||||
|
max(int32 x, int32 y)
|
||||||
{
|
{
|
||||||
return std::max(x, y);
|
return std::max(x, y);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __CUDACC__
|
#ifndef __CUDACC__
|
||||||
INLINE_FUNCTION_HD uint64 max(uint64 x, uint64 y)
|
INLINE_FUNCTION_HD uint64
|
||||||
|
max(uint64 x, uint64 y)
|
||||||
{
|
{
|
||||||
return std::max(x, y);
|
return std::max(x, y);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __CUDACC__
|
#ifndef __CUDACC__
|
||||||
INLINE_FUNCTION_HD uint32 max(uint32 x, uint32 y)
|
INLINE_FUNCTION_HD uint32
|
||||||
|
max(uint32 x, uint32 y)
|
||||||
{
|
{
|
||||||
return std::max(x, y);
|
return std::max(x, y);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
} // pFlow
|
} // pFlow
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // __math_hpp__
|
#endif // __math_hpp__
|
||||||
|
@ -21,10 +21,8 @@ Licence:
|
|||||||
#ifndef __numericConstants_hpp__
|
#ifndef __numericConstants_hpp__
|
||||||
#define __numericConstants_hpp__
|
#define __numericConstants_hpp__
|
||||||
|
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include "builtinTypes.hpp"
|
#include "builtinTypes.hpp"
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
@ -37,20 +35,23 @@ namespace pFlow
|
|||||||
|
|
||||||
// - largest negative value
|
// - largest negative value
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr inline T largestNegative()
|
constexpr T
|
||||||
|
largestNegative()
|
||||||
{
|
{
|
||||||
return std::numeric_limits<T>::lowest();
|
return std::numeric_limits<T>::lowest();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr inline T epsilonValue()
|
constexpr T
|
||||||
|
epsilonValue()
|
||||||
{
|
{
|
||||||
return std::numeric_limits<T>::min();
|
return std::numeric_limits<T>::min();
|
||||||
}
|
}
|
||||||
|
|
||||||
// largest positive value
|
// largest positive value
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr inline T largestPositive()
|
constexpr T
|
||||||
|
largestPositive()
|
||||||
{
|
{
|
||||||
return std::numeric_limits<T>::max();
|
return std::numeric_limits<T>::max();
|
||||||
}
|
}
|
||||||
@ -65,8 +66,6 @@ namespace pFlow
|
|||||||
const inline real largestPosREAL = largestPositive<real>();
|
const inline real largestPosREAL = largestPositive<real>();
|
||||||
const inline real epsilonREAL = epsilonValue<real>();
|
const inline real epsilonREAL = epsilonValue<real>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // end of pFlow
|
} // end of pFlow
|
||||||
|
|
||||||
#endif //__numericConstants_hpp__
|
#endif //__numericConstants_hpp__
|
||||||
|
@ -21,25 +21,24 @@ Licence:
|
|||||||
#ifndef __quadruple_hpp__
|
#ifndef __quadruple_hpp__
|
||||||
#define __quadruple_hpp__
|
#define __quadruple_hpp__
|
||||||
|
|
||||||
|
|
||||||
#include "uniquePtr.hpp"
|
|
||||||
#include "triple.hpp"
|
|
||||||
#include "iOstream.hpp"
|
|
||||||
#include "iIstream.hpp"
|
|
||||||
#include "token.hpp"
|
|
||||||
#include "error.hpp"
|
#include "error.hpp"
|
||||||
|
#include "iIstream.hpp"
|
||||||
|
#include "iOstream.hpp"
|
||||||
|
#include "token.hpp"
|
||||||
|
#include "triple.hpp"
|
||||||
|
#include "uniquePtr.hpp"
|
||||||
|
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
template<typename T> class quadruple;
|
class quadruple;
|
||||||
class iIstream;
|
class iIstream;
|
||||||
|
|
||||||
#include "quadrupleFwd.hpp"
|
#include "quadrupleFwd.hpp"
|
||||||
|
|
||||||
// you can see it as a sequence of four elements (w,x,y,z) or an (scalar and vector)
|
// you can see it as a sequence of four elements (w,x,y,z) or an (scalar and
|
||||||
|
// vector)
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class quadruple
|
class quadruple
|
||||||
{
|
{
|
||||||
@ -47,40 +46,41 @@ public:
|
|||||||
|
|
||||||
T s_;
|
T s_;
|
||||||
triple<T> v_;
|
triple<T> v_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//// constructors
|
//// constructors
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
quadruple()
|
quadruple()
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//// Constructors
|
//// Constructors
|
||||||
|
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
quadruple(const T& w, const T& x, const T& y, const T& z)
|
quadruple(const T& w, const T& x, const T& y, const T& z)
|
||||||
:
|
: s_(w),
|
||||||
s_(w),
|
|
||||||
v_(x, y, z)
|
v_(x, y, z)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
quadruple(const T& s, const triple<T> v)
|
quadruple(const T& s, const triple<T> v)
|
||||||
:
|
: s_(s),
|
||||||
s_(s),
|
|
||||||
v_(v)
|
v_(v)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
quadruple(const T& val)
|
quadruple(const T& val)
|
||||||
:
|
: s_(val),
|
||||||
s_(val),
|
|
||||||
v_(val)
|
v_(val)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
// type conversion trough assignment
|
// type conversion trough assignment
|
||||||
template<typename T2>
|
template<typename T2>
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD quadruple<T>& operator=(const quadruple<T2>& rhs)
|
||||||
quadruple<T> & operator = (const quadruple<T2> & rhs)
|
|
||||||
{
|
{
|
||||||
this->v_ = rhs.v_;
|
this->v_ = rhs.v_;
|
||||||
this->s_ = static_cast<T>(rhs.s_);
|
this->s_ = static_cast<T>(rhs.s_);
|
||||||
@ -89,11 +89,11 @@ public:
|
|||||||
|
|
||||||
// type casting through copy constructor
|
// type casting through copy constructor
|
||||||
template<typename T2>
|
template<typename T2>
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD quadruple(const quadruple<T2>& src)
|
||||||
quadruple(const quadruple<T2> &src):
|
: s_(static_cast<T>(src.s_)),
|
||||||
s_(static_cast<T>(src.s_)),
|
|
||||||
v_(src.v_)
|
v_(src.v_)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
// copy construct
|
// copy construct
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
@ -126,74 +126,120 @@ public:
|
|||||||
|
|
||||||
// Access
|
// Access
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
T & w(){ return s_; }
|
T& w()
|
||||||
|
{
|
||||||
|
return s_;
|
||||||
|
}
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
const T & w()const { return s_; }
|
const T& w() const
|
||||||
|
{
|
||||||
|
return s_;
|
||||||
|
}
|
||||||
|
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
T & x(){ return v_.x(); }
|
T& x()
|
||||||
|
{
|
||||||
|
return v_.x();
|
||||||
|
}
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
const T & x()const { return v_.x(); }
|
const T& x() const
|
||||||
|
{
|
||||||
|
return v_.x();
|
||||||
|
}
|
||||||
|
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
T & y(){ return v_.y(); }
|
T& y()
|
||||||
|
{
|
||||||
|
return v_.y();
|
||||||
|
}
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
const T & y()const { return v_.y(); }
|
const T& y() const
|
||||||
|
{
|
||||||
|
return v_.y();
|
||||||
|
}
|
||||||
|
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
T & z(){ return v_.z(); }
|
T& z()
|
||||||
|
{
|
||||||
|
return v_.z();
|
||||||
|
}
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
const T & z()const { return v_.z(); }
|
const T& z() const
|
||||||
|
{
|
||||||
|
return v_.z();
|
||||||
|
}
|
||||||
|
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
T & s(){ return s_; }
|
T& s()
|
||||||
|
{
|
||||||
|
return s_;
|
||||||
|
}
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
const T & s()const { return s_; }
|
const T& s() const
|
||||||
|
{
|
||||||
|
return s_;
|
||||||
|
}
|
||||||
|
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
triple<T> v() {return v_;}
|
triple<T> v()
|
||||||
|
{
|
||||||
|
return v_;
|
||||||
|
}
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
const triple<T> v() const {return v_;}
|
const triple<T> v() const
|
||||||
|
{
|
||||||
|
return v_;
|
||||||
|
}
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
friend FUNCTION_HD T dot <T> (const quadruple<T> & oprnd1, const quadruple<T> & oprnd2);
|
friend FUNCTION_HD T
|
||||||
|
dot<T>(const quadruple<T>& oprnd1, const quadruple<T>& oprnd2);
|
||||||
|
|
||||||
INLINE_FUNCTION_HD T length() const;
|
INLINE_FUNCTION_HD T length() const;
|
||||||
|
|
||||||
INLINE_FUNCTION_HD void normalize();
|
INLINE_FUNCTION_HD void normalize();
|
||||||
|
|
||||||
|
|
||||||
//// operators
|
//// operators
|
||||||
|
|
||||||
// + operator
|
// + operator
|
||||||
friend FUNCTION_HD quadruple<T> operator+ <T> (const quadruple<T> & oprnd1, const quadruple<T> & oprnd2);
|
friend FUNCTION_HD quadruple<T> operator+
|
||||||
|
<T>(const quadruple<T>& oprnd1, const quadruple<T>& oprnd2);
|
||||||
|
|
||||||
friend FUNCTION_HD quadruple<T> operator+ <T> (const quadruple<T> & oprnd1, const T & oprnd2);
|
friend FUNCTION_HD quadruple<T> operator+
|
||||||
|
<T>(const quadruple<T>& oprnd1, const T& oprnd2);
|
||||||
|
|
||||||
friend FUNCTION_HD quadruple<T> operator+ <T> (const T & oprnd1, const quadruple<T> & oprnd2);
|
friend FUNCTION_HD quadruple<T> operator+
|
||||||
|
<T>(const T& oprnd1, const quadruple<T>& oprnd2);
|
||||||
|
|
||||||
// - operator
|
// - operator
|
||||||
friend FUNCTION_HD quadruple<T> operator - <T> (const quadruple<T> & oprnd1, const quadruple<T> & oprnd2);
|
friend FUNCTION_HD quadruple<T> operator-
|
||||||
|
<T>(const quadruple<T>& oprnd1, const quadruple<T>& oprnd2);
|
||||||
|
|
||||||
friend FUNCTION_HD quadruple<T> operator - <T> (const quadruple<T> & oprnd1, const T & oprnd2);
|
friend FUNCTION_HD quadruple<T> operator-
|
||||||
|
<T>(const quadruple<T>& oprnd1, const T& oprnd2);
|
||||||
|
|
||||||
friend FUNCTION_HD quadruple<T> operator - <T> (const T & oprnd1, const quadruple<T> & oprnd2);
|
friend FUNCTION_HD quadruple<T> operator-
|
||||||
|
<T>(const T& oprnd1, const quadruple<T>& oprnd2);
|
||||||
|
|
||||||
// * operators
|
// * operators
|
||||||
friend FUNCTION_HD quadruple<T> operator * <T> (const quadruple<T> & oprnd1, const quadruple<T> & oprnd2);
|
friend FUNCTION_HD quadruple<T> operator*
|
||||||
|
<T>(const quadruple<T>& oprnd1, const quadruple<T>& oprnd2);
|
||||||
|
|
||||||
friend FUNCTION_HD quadruple<T> operator * <T> (const quadruple<T> & oprnd1, const T & oprnd2);
|
friend FUNCTION_HD quadruple<T> operator*
|
||||||
|
<T>(const quadruple<T>& oprnd1, const T& oprnd2);
|
||||||
|
|
||||||
friend FUNCTION_HD quadruple<T> operator * <T> (const T & oprnd1, const quadruple<T> & oprnd2);
|
friend FUNCTION_HD quadruple<T> operator*
|
||||||
|
<T>(const T& oprnd1, const quadruple<T>& oprnd2);
|
||||||
|
|
||||||
// / operators
|
// / operators
|
||||||
friend FUNCTION_HD quadruple<T> operator / <T> (const quadruple<T> & oprnd1, const quadruple<T> & oprnd2);
|
friend FUNCTION_HD quadruple<T> operator/
|
||||||
|
<T>(const quadruple<T>& oprnd1, const quadruple<T>& oprnd2);
|
||||||
|
|
||||||
friend FUNCTION_HD quadruple<T> operator / <T> (const quadruple<T> & oprnd1, const T & oprnd2);
|
friend FUNCTION_HD quadruple<T> operator/
|
||||||
|
<T>(const quadruple<T>& oprnd1, const T& oprnd2);
|
||||||
friend FUNCTION_HD quadruple<T> operator / <T> (const T & oprnd1, const quadruple<T> & oprnd2);
|
|
||||||
|
|
||||||
|
friend FUNCTION_HD quadruple<T> operator/
|
||||||
|
<T>(const T& oprnd1, const quadruple<T>& oprnd2);
|
||||||
|
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
void operator+=(const quadruple& oprnd2);
|
void operator+=(const quadruple& oprnd2);
|
||||||
@ -207,7 +253,6 @@ public:
|
|||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
void operator/=(const quadruple& oprnd2);
|
void operator/=(const quadruple& oprnd2);
|
||||||
|
|
||||||
|
|
||||||
// unary negate operator
|
// unary negate operator
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
quadruple operator-() const;
|
quadruple operator-() const;
|
||||||
@ -216,24 +261,22 @@ public:
|
|||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
quadruple operator+() const;
|
quadruple operator+() const;
|
||||||
|
|
||||||
|
friend FUNCTION_HD bool operator==
|
||||||
friend FUNCTION_HD bool operator == <T> (const quadruple<T> &opr1, const quadruple<T> &opr2);
|
<T>(const quadruple<T>& opr1, const quadruple<T>& opr2);
|
||||||
|
|
||||||
// << operator
|
// << operator
|
||||||
friend FUNCTION_H iOstream& operator<< <T> (iOstream& str, const quadruple<T> & ov);
|
friend FUNCTION_H iOstream&
|
||||||
|
operator<< <T>(iOstream& str, const quadruple<T>& ov);
|
||||||
|
|
||||||
// >> operator
|
// >> operator
|
||||||
friend FUNCTION_H iIstream& operator>> <T>(iIstream& str, quadruple<T>& iv);
|
friend FUNCTION_H iIstream& operator>> <T>(iIstream& str, quadruple<T>& iv);
|
||||||
|
|
||||||
// same as >> operator, but faster, good for mass read
|
// same as >> operator, but faster, good for mass read
|
||||||
friend FUNCTION_H void readIstream<T>(iIstream& str, quadruple<T>& iv);
|
friend FUNCTION_H void readIstream<T>(iIstream& str, quadruple<T>& iv);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // pFlow
|
} // pFlow
|
||||||
|
|
||||||
|
|
||||||
#include "quadrupleI.hpp"
|
#include "quadrupleI.hpp"
|
||||||
// #include "quadrupleMath.hpp"
|
// #include "quadrupleMath.hpp"
|
||||||
|
|
||||||
|
@ -19,123 +19,69 @@ Licence:
|
|||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD T dot
|
INLINE_FUNCTION_HD T
|
||||||
(
|
dot(const quadruple<T>& oprnd1, const quadruple<T>& oprnd2);
|
||||||
const quadruple<T> & oprnd1,
|
|
||||||
const quadruple<T> & oprnd2
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD quadruple<T> operator +
|
INLINE_FUNCTION_HD quadruple<T>
|
||||||
(
|
operator+(const quadruple<T>& oprnd1, const quadruple<T>& oprnd2);
|
||||||
const quadruple<T> & oprnd1,
|
|
||||||
const quadruple<T> & oprnd2
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD quadruple<T> operator+
|
INLINE_FUNCTION_HD quadruple<T>
|
||||||
(
|
operator+(const quadruple<T>& oprnd1, const T& oprnd2);
|
||||||
const quadruple<T> & oprnd1,
|
|
||||||
const T & oprnd2
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD quadruple<T> operator+
|
INLINE_FUNCTION_HD quadruple<T>
|
||||||
(
|
operator+(const T& oprnd2, const quadruple<T>& oprnd1);
|
||||||
const T & oprnd2,
|
|
||||||
const quadruple<T> & oprnd1
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD quadruple<T> operator-
|
INLINE_FUNCTION_HD quadruple<T>
|
||||||
(
|
operator-(const quadruple<T>& oprnd1, const quadruple<T>& oprnd2);
|
||||||
const quadruple<T> & oprnd1,
|
|
||||||
const quadruple<T> & oprnd2
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD quadruple<T> operator-
|
INLINE_FUNCTION_HD quadruple<T>
|
||||||
(
|
operator-(const quadruple<T>& oprnd1, const T& oprnd2);
|
||||||
const quadruple<T> & oprnd1,
|
|
||||||
const T & oprnd2
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD quadruple<T> operator-
|
INLINE_FUNCTION_HD quadruple<T>
|
||||||
(
|
operator-(const T& oprnd1, const quadruple<T>& oprnd2);
|
||||||
const T & oprnd1,
|
|
||||||
const quadruple<T> & oprnd2
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD quadruple<T> operator*
|
INLINE_FUNCTION_HD quadruple<T>
|
||||||
(
|
operator*(const quadruple<T>& oprnd1, const quadruple<T>& oprnd2);
|
||||||
const quadruple<T> & oprnd1,
|
|
||||||
const quadruple<T> & oprnd2
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD quadruple<T> operator*
|
INLINE_FUNCTION_HD quadruple<T>
|
||||||
(
|
operator*(const quadruple<T>& oprnd1, const T& oprnd2);
|
||||||
const quadruple<T> & oprnd1,
|
|
||||||
const T & oprnd2
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD quadruple<T> operator*
|
INLINE_FUNCTION_HD quadruple<T>
|
||||||
(
|
operator*(const T& oprnd1, const quadruple<T>& oprnd2);
|
||||||
const T & oprnd1,
|
|
||||||
const quadruple<T> & oprnd2
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD quadruple<T> operator/
|
INLINE_FUNCTION_HD quadruple<T>
|
||||||
(
|
operator/(const quadruple<T>& oprnd1, const quadruple<T>& oprnd2);
|
||||||
const quadruple<T> & oprnd1,
|
|
||||||
const quadruple<T> & oprnd2
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD quadruple<T> operator/
|
INLINE_FUNCTION_HD quadruple<T>
|
||||||
(
|
operator/(const quadruple<T>& oprnd1, const T& oprnd2);
|
||||||
const quadruple<T> & oprnd1,
|
|
||||||
const T & oprnd2
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD quadruple<T> operator/
|
INLINE_FUNCTION_HD quadruple<T>
|
||||||
(
|
operator/(const T& oprnd1, const quadruple<T>& oprnd2);
|
||||||
const T & oprnd1,
|
|
||||||
const quadruple<T> & oprnd2
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD bool operator ==
|
INLINE_FUNCTION_HD bool
|
||||||
(
|
operator==(const quadruple<T>& opr1, const quadruple<T>& opr2);
|
||||||
const quadruple<T> &opr1,
|
|
||||||
const quadruple<T> &opr2
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_H iOstream& operator<<
|
INLINE_FUNCTION_H iOstream&
|
||||||
(
|
operator<<(iOstream& str, const quadruple<T>& ov);
|
||||||
iOstream& str,
|
|
||||||
const quadruple<T> & ov
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_H iIstream& operator>>
|
INLINE_FUNCTION_H iIstream&
|
||||||
(
|
operator>>(iIstream& str, quadruple<T>& iv);
|
||||||
iIstream& str,
|
|
||||||
quadruple<T> & iv
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_H void readIstream
|
INLINE_FUNCTION_H void
|
||||||
(
|
readIstream(iIstream& str, quadruple<T>& iv);
|
||||||
iIstream& str,
|
|
||||||
quadruple<T> & iv
|
|
||||||
);
|
|
@ -19,28 +19,22 @@ Licence:
|
|||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD T pFlow::dot
|
INLINE_FUNCTION_HD T
|
||||||
(
|
pFlow::dot(const quadruple<T>& oprnd1, const quadruple<T>& oprnd2)
|
||||||
const quadruple<T> & oprnd1,
|
|
||||||
const quadruple<T> & oprnd2
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return oprnd1.s_ * oprnd2.s_ +
|
return oprnd1.s_ * oprnd2.s_ + dot(oprnd1.v(), oprnd2.v());
|
||||||
dot(oprnd1.v(), oprnd2.v()) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD T pFlow::quadruple<T>::length
|
INLINE_FUNCTION_HD T
|
||||||
(
|
pFlow::quadruple<T>::length() const
|
||||||
)const
|
|
||||||
{
|
{
|
||||||
return sqrt(dot(*this, *this));
|
return sqrt(dot(*this, *this));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD void pFlow::quadruple<T>::normalize
|
INLINE_FUNCTION_HD void
|
||||||
(
|
pFlow::quadruple<T>::normalize()
|
||||||
)
|
|
||||||
{
|
{
|
||||||
T l = length();
|
T l = length();
|
||||||
if (static_cast<real>(l) > smallValue)
|
if (static_cast<real>(l) > smallValue)
|
||||||
@ -50,249 +44,148 @@ INLINE_FUNCTION_HD void pFlow::quadruple<T>::normalize
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD pFlow::quadruple<T> pFlow::operator+
|
INLINE_FUNCTION_HD pFlow::quadruple<T>
|
||||||
(
|
pFlow::operator+(const quadruple<T>& oprnd1, const quadruple<T>& oprnd2)
|
||||||
const quadruple<T> & oprnd1,
|
|
||||||
const quadruple<T> & oprnd2
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return quadruple<T>(
|
return quadruple<T>(oprnd1.s_ + oprnd2.s_, oprnd1.v_ + oprnd2.v_);
|
||||||
oprnd1.s_ + oprnd2.s_,
|
|
||||||
oprnd1.v_ + oprnd2.v_
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
INLINE_FUNCTION_HD pFlow::quadruple<T> pFlow::operator+
|
|
||||||
(
|
|
||||||
const quadruple<T> & oprnd1,
|
|
||||||
const T & oprnd2
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return quadruple<T>(
|
|
||||||
oprnd1.s_ + oprnd2,
|
|
||||||
oprnd1.v_ + oprnd2
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD pFlow::quadruple<T> pFlow::operator+
|
INLINE_FUNCTION_HD pFlow::quadruple<T>
|
||||||
(
|
pFlow::operator+(const quadruple<T>& oprnd1, const T& oprnd2)
|
||||||
const T & oprnd1,
|
|
||||||
const quadruple<T> & oprnd2
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return quadruple<T>(
|
return quadruple<T>(oprnd1.s_ + oprnd2, oprnd1.v_ + oprnd2);
|
||||||
oprnd1 + oprnd2.s_,
|
|
||||||
oprnd1 + oprnd2.v_
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
INLINE_FUNCTION_HD pFlow::quadruple<T> pFlow::operator-
|
|
||||||
(
|
|
||||||
const quadruple<T> & oprnd1,
|
|
||||||
const quadruple<T> & oprnd2
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return quadruple<T>(
|
|
||||||
oprnd1.s_ - oprnd2.s_,
|
|
||||||
oprnd1.v_ - oprnd2.v_
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
INLINE_FUNCTION_HD pFlow::quadruple<T> pFlow::operator-
|
|
||||||
(
|
|
||||||
const quadruple<T> & oprnd1,
|
|
||||||
const T & oprnd2
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return quadruple<T>(
|
|
||||||
oprnd1.s_ - oprnd2,
|
|
||||||
oprnd1.v_ - oprnd2
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD pFlow::quadruple<T> pFlow::operator-
|
INLINE_FUNCTION_HD pFlow::quadruple<T>
|
||||||
(
|
pFlow::operator+(const T& oprnd1, const quadruple<T>& oprnd2)
|
||||||
const T & oprnd1,
|
|
||||||
const quadruple<T> & oprnd2
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return quadruple<T>(
|
return quadruple<T>(oprnd1 + oprnd2.s_, oprnd1 + oprnd2.v_);
|
||||||
oprnd1 - oprnd2.s_,
|
|
||||||
oprnd1 - oprnd2.v_
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
INLINE_FUNCTION_HD pFlow::quadruple<T> pFlow::operator*
|
|
||||||
(
|
|
||||||
const quadruple<T> & oprnd1,
|
|
||||||
const quadruple<T> & oprnd2
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return quadruple<T>(
|
|
||||||
oprnd1.s_ * oprnd2.s_,
|
|
||||||
oprnd1.v_ * oprnd2.v_
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
INLINE_FUNCTION_HD pFlow::quadruple<T> pFlow::operator*
|
|
||||||
(
|
|
||||||
const quadruple<T> & oprnd1,
|
|
||||||
const T & oprnd2
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return quadruple<T>(
|
|
||||||
oprnd1.s_ * oprnd2,
|
|
||||||
oprnd1.v_ * oprnd2
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD pFlow::quadruple<T> pFlow::operator*
|
INLINE_FUNCTION_HD pFlow::quadruple<T>
|
||||||
(
|
pFlow::operator-(const quadruple<T>& oprnd1, const quadruple<T>& oprnd2)
|
||||||
const T & oprnd1,
|
|
||||||
const quadruple<T> & oprnd2
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return quadruple<T>(
|
return quadruple<T>(oprnd1.s_ - oprnd2.s_, oprnd1.v_ - oprnd2.v_);
|
||||||
oprnd1 * oprnd2.s_,
|
|
||||||
oprnd1 * oprnd2.v_
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
INLINE_FUNCTION_HD pFlow::quadruple<T> pFlow::operator/
|
|
||||||
(
|
|
||||||
const quadruple<T> & oprnd1,
|
|
||||||
const quadruple<T> & oprnd2
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return quadruple<T>(
|
|
||||||
oprnd1.s_ / oprnd2.s_,
|
|
||||||
oprnd1.v_ / oprnd2.v_
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
INLINE_FUNCTION_HD pFlow::quadruple<T> pFlow::operator/
|
|
||||||
(
|
|
||||||
const quadruple<T> & oprnd1,
|
|
||||||
const T & oprnd2
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return quadruple<T>(
|
|
||||||
oprnd1.s_ / oprnd2,
|
|
||||||
oprnd1.v_ / oprnd2
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD pFlow::quadruple<T> pFlow::operator/
|
INLINE_FUNCTION_HD pFlow::quadruple<T>
|
||||||
(
|
pFlow::operator-(const quadruple<T>& oprnd1, const T& oprnd2)
|
||||||
const T & oprnd1,
|
|
||||||
const quadruple<T> & oprnd2
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return quadruple<T>(
|
return quadruple<T>(oprnd1.s_ - oprnd2, oprnd1.v_ - oprnd2);
|
||||||
oprnd1 / oprnd2.s_,
|
|
||||||
oprnd1 / oprnd2.v_
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD void pFlow::quadruple<T>::operator+=
|
INLINE_FUNCTION_HD pFlow::quadruple<T>
|
||||||
(
|
pFlow::operator-(const T& oprnd1, const quadruple<T>& oprnd2)
|
||||||
const quadruple<T> & oprnd2
|
{
|
||||||
)
|
return quadruple<T>(oprnd1 - oprnd2.s_, oprnd1 - oprnd2.v_);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
INLINE_FUNCTION_HD pFlow::quadruple<T>
|
||||||
|
pFlow::operator*(const quadruple<T>& oprnd1, const quadruple<T>& oprnd2)
|
||||||
|
{
|
||||||
|
return quadruple<T>(oprnd1.s_ * oprnd2.s_, oprnd1.v_ * oprnd2.v_);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
INLINE_FUNCTION_HD pFlow::quadruple<T>
|
||||||
|
pFlow::operator*(const quadruple<T>& oprnd1, const T& oprnd2)
|
||||||
|
{
|
||||||
|
return quadruple<T>(oprnd1.s_ * oprnd2, oprnd1.v_ * oprnd2);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
INLINE_FUNCTION_HD pFlow::quadruple<T>
|
||||||
|
pFlow::operator*(const T& oprnd1, const quadruple<T>& oprnd2)
|
||||||
|
{
|
||||||
|
return quadruple<T>(oprnd1 * oprnd2.s_, oprnd1 * oprnd2.v_);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
INLINE_FUNCTION_HD pFlow::quadruple<T>
|
||||||
|
pFlow::operator/(const quadruple<T>& oprnd1, const quadruple<T>& oprnd2)
|
||||||
|
{
|
||||||
|
return quadruple<T>(oprnd1.s_ / oprnd2.s_, oprnd1.v_ / oprnd2.v_);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
INLINE_FUNCTION_HD pFlow::quadruple<T>
|
||||||
|
pFlow::operator/(const quadruple<T>& oprnd1, const T& oprnd2)
|
||||||
|
{
|
||||||
|
return quadruple<T>(oprnd1.s_ / oprnd2, oprnd1.v_ / oprnd2);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
INLINE_FUNCTION_HD pFlow::quadruple<T>
|
||||||
|
pFlow::operator/(const T& oprnd1, const quadruple<T>& oprnd2)
|
||||||
|
{
|
||||||
|
return quadruple<T>(oprnd1 / oprnd2.s_, oprnd1 / oprnd2.v_);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
INLINE_FUNCTION_HD void
|
||||||
|
pFlow::quadruple<T>::operator+=(const quadruple<T>& oprnd2)
|
||||||
{
|
{
|
||||||
this->s_ += oprnd2.s_;
|
this->s_ += oprnd2.s_;
|
||||||
this->v_ += oprnd2.v_;
|
this->v_ += oprnd2.v_;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD void pFlow::quadruple<T>::operator-=
|
INLINE_FUNCTION_HD void
|
||||||
(
|
pFlow::quadruple<T>::operator-=(const quadruple<T>& oprnd2)
|
||||||
const quadruple<T> & oprnd2
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
this->s_ -= oprnd2.s_;
|
this->s_ -= oprnd2.s_;
|
||||||
this->v_ -= oprnd2.v_;
|
this->v_ -= oprnd2.v_;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD void pFlow::quadruple<T>::operator*=
|
INLINE_FUNCTION_HD void
|
||||||
(
|
pFlow::quadruple<T>::operator*=(const quadruple<T>& oprnd2)
|
||||||
const quadruple<T> & oprnd2
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
this->s_ *= oprnd2.s_;
|
this->s_ *= oprnd2.s_;
|
||||||
this->v_ *= oprnd2.v_;
|
this->v_ *= oprnd2.v_;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD void pFlow::quadruple<T>::operator/=
|
INLINE_FUNCTION_HD void
|
||||||
(
|
pFlow::quadruple<T>::operator/=(const quadruple<T>& oprnd2)
|
||||||
const quadruple<T> & oprnd2
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
this->s_ /= oprnd2.s_;
|
this->s_ /= oprnd2.s_;
|
||||||
this->v_ /= oprnd2.v_;
|
this->v_ /= oprnd2.v_;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD pFlow::quadruple<T> pFlow::quadruple<T>::operator-
|
INLINE_FUNCTION_HD pFlow::quadruple<T>
|
||||||
(
|
pFlow::quadruple<T>::operator-() const
|
||||||
) const
|
|
||||||
{
|
{
|
||||||
return quadruple<T>(-this->s_, -this->v_);
|
return quadruple<T>(-this->s_, -this->v_);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD pFlow::quadruple<T> pFlow::quadruple<T>::operator+
|
INLINE_FUNCTION_HD pFlow::quadruple<T>
|
||||||
(
|
pFlow::quadruple<T>::operator+() const
|
||||||
) const
|
|
||||||
{
|
{
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD bool pFlow::operator ==
|
INLINE_FUNCTION_HD bool
|
||||||
(
|
pFlow::operator==(const quadruple<T>& opr1, const quadruple<T>& opr2)
|
||||||
const quadruple<T> &opr1,
|
{
|
||||||
const quadruple<T> &opr2
|
|
||||||
){
|
|
||||||
return equal(opr1.s_, opr2.s_) && equal(opr1.v_, opr2.v_);
|
return equal(opr1.s_, opr2.s_) && equal(opr1.v_, opr2.v_);
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_H pFlow::iOstream& pFlow::operator <<
|
INLINE_FUNCTION_H pFlow::iOstream&
|
||||||
(
|
pFlow::operator<<(iOstream& str, const quadruple<T>& ov)
|
||||||
iOstream & str,
|
|
||||||
const quadruple<T> & ov
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
str << token::BEGIN_LIST << ov.w() << token::SPACE << ov.x() << token::SPACE
|
||||||
str << token::BEGIN_LIST << ov.w()
|
<< ov.y() << token::SPACE << ov.z() << token::END_LIST;
|
||||||
<< token::SPACE << ov.x()
|
|
||||||
<< token::SPACE << ov.y()
|
|
||||||
<< token::SPACE << ov.z()
|
|
||||||
<< token::END_LIST;
|
|
||||||
|
|
||||||
str.check(FUNCTION_NAME);
|
str.check(FUNCTION_NAME);
|
||||||
|
|
||||||
@ -300,13 +193,9 @@ INLINE_FUNCTION_H pFlow::iOstream& pFlow::operator <<
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_H pFlow::iIstream& pFlow::operator >>
|
INLINE_FUNCTION_H pFlow::iIstream&
|
||||||
(
|
pFlow::operator>>(iIstream& str, quadruple<T>& iv)
|
||||||
iIstream & str,
|
|
||||||
quadruple<T> & iv
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
str.readBegin("quadruple<T>");
|
str.readBegin("quadruple<T>");
|
||||||
|
|
||||||
str >> iv.w();
|
str >> iv.w();
|
||||||
@ -322,13 +211,9 @@ INLINE_FUNCTION_H pFlow::iIstream& pFlow::operator >>
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_H void pFlow::readIstream
|
INLINE_FUNCTION_H void
|
||||||
(
|
pFlow::readIstream(iIstream& str, quadruple<T>& iv)
|
||||||
iIstream & str,
|
|
||||||
quadruple<T> & iv
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
str.readBegin("quadruple<T>");
|
str.readBegin("quadruple<T>");
|
||||||
T val;
|
T val;
|
||||||
|
|
||||||
@ -347,5 +232,4 @@ INLINE_FUNCTION_H void pFlow::readIstream
|
|||||||
str.readEnd("quadruple<T>");
|
str.readEnd("quadruple<T>");
|
||||||
|
|
||||||
str.check(FUNCTION_NAME);
|
str.check(FUNCTION_NAME);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,9 +27,13 @@ inline pFlow::quadruple<T> pFlow::fnName(const quadruple<T>& q) \
|
|||||||
|
|
||||||
#define Q4Func2(fnName) \
|
#define Q4Func2(fnName) \
|
||||||
template<typename T> \
|
template<typename T> \
|
||||||
inline pFlow::quadruple<T> pFlow::fnName(const quadruple<T>& arg1, const quadruple<T>& arg2) \
|
inline pFlow::quadruple<T> pFlow::fnName( \
|
||||||
|
const quadruple<T>& arg1, const quadruple<T>& arg2 \
|
||||||
|
) \
|
||||||
{ \
|
{ \
|
||||||
return quadruple<T>(fnName(arg1.s_, arg2.s_), fnName(arg1.v_,arg2.v_)); \
|
return quadruple<T>( \
|
||||||
|
fnName(arg1.s_, arg2.s_), fnName(arg1.v_, arg2.v_) \
|
||||||
|
); \
|
||||||
}
|
}
|
||||||
|
|
||||||
//* * * * * * * * * * * List of functinos * * * * * * * * //
|
//* * * * * * * * * * * List of functinos * * * * * * * * //
|
||||||
@ -39,7 +43,6 @@ inline pFlow::quadruple<T> pFlow::fnName(const quadruple<T>& arg1, const quadrup
|
|||||||
// min, max
|
// min, max
|
||||||
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
Q4Func(abs);
|
Q4Func(abs);
|
||||||
Q4Func2(mod);
|
Q4Func2(mod);
|
||||||
Q4Func(exp);
|
Q4Func(exp);
|
||||||
@ -64,28 +67,28 @@ Q4Func(atanh);
|
|||||||
Q4Func2(min);
|
Q4Func2(min);
|
||||||
Q4Func2(max);
|
Q4Func2(max);
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline pFlow::quadruple<T> pFlow::pow(const quadruple<T>& q4, T e)
|
inline pFlow::quadruple<T>
|
||||||
|
pFlow::pow(const quadruple<T>& q4, T e)
|
||||||
{
|
{
|
||||||
return quadruple<T>(pow(q4.s_, e), pow(q4.v_, e));
|
return quadruple<T>(pow(q4.s_, e), pow(q4.v_, e));
|
||||||
}
|
}
|
||||||
|
|
||||||
// return the min of 3 elements x, y, z
|
// return the min of 3 elements x, y, z
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline T pFlow::min(const quadruple<T>& q4)
|
inline T
|
||||||
|
pFlow::min(const quadruple<T>& q4)
|
||||||
{
|
{
|
||||||
return min(min(q4.v_), q4.s_);
|
return min(min(q4.v_), q4.s_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// return the max of 3 elements x, y, z
|
// return the max of 3 elements x, y, z
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline T pFlow::max(const quadruple<T>& q4)
|
inline T
|
||||||
|
pFlow::max(const quadruple<T>& q4)
|
||||||
{
|
{
|
||||||
return max(max(q4.v_), q4.s_);
|
return max(max(q4.v_), q4.s_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#undef Q4Func
|
#undef Q4Func
|
||||||
#undef Q4Func2
|
#undef Q4Func2
|
@ -27,14 +27,12 @@ Licence:
|
|||||||
#include "iIstream.hpp"
|
#include "iIstream.hpp"
|
||||||
#include "error.hpp"
|
#include "error.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
|
|
||||||
/// - Forward
|
/// - Forward
|
||||||
template<typename T> class triple;
|
template<typename T>
|
||||||
|
class triple;
|
||||||
|
|
||||||
#include "tripleFwd.hpp"
|
#include "tripleFwd.hpp"
|
||||||
|
|
||||||
@ -55,26 +53,28 @@ struct triple
|
|||||||
|
|
||||||
/// Initilize to zero
|
/// Initilize to zero
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
triple():
|
triple()
|
||||||
x_(0),
|
: x_(),
|
||||||
y_(0),
|
y_(),
|
||||||
z_(0)
|
z_()
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// Construct from x, y, z
|
/// Construct from x, y, z
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
triple(const T &x, const T &y, const T &z):
|
triple(const T& x, const T& y, const T& z)
|
||||||
x_(x),
|
: x_(x),
|
||||||
y_(y),
|
y_(y),
|
||||||
z_(z)
|
z_(z)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// Construct from v
|
/// Construct from v
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
triple(const T &v):
|
triple(const T& v)
|
||||||
triple(v, v, v)
|
: triple(v, v, v)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// Type conversion trough assignment
|
/// Type conversion trough assignment
|
||||||
template<typename T2>
|
template<typename T2>
|
||||||
@ -89,18 +89,16 @@ struct triple
|
|||||||
/// Type casting through copy constructor
|
/// Type casting through copy constructor
|
||||||
template<typename T2>
|
template<typename T2>
|
||||||
INLINE_FUNCTION_HD triple(const triple<T2>& src)
|
INLINE_FUNCTION_HD triple(const triple<T2>& src)
|
||||||
:
|
: x_(static_cast<T>(src.x_)),
|
||||||
x_(static_cast<T>(src.x_)),
|
|
||||||
y_(static_cast<T>(src.y_)),
|
y_(static_cast<T>(src.y_)),
|
||||||
z_(static_cast<T>(src.z_))
|
z_(static_cast<T>(src.z_))
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// Copy construct
|
/// Copy construct
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
triple(const triple<T>& src) = default;
|
triple(const triple<T>& src) = default;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Move construct
|
/// Move construct
|
||||||
INLINE_FUNCTION_HD
|
INLINE_FUNCTION_HD
|
||||||
triple(triple<T>&& src) = default;
|
triple(triple<T>&& src) = default;
|
||||||
@ -129,48 +127,86 @@ struct triple
|
|||||||
////// member methods
|
////// member methods
|
||||||
|
|
||||||
/// access component
|
/// access component
|
||||||
INLINE_FUNCTION_HD T & x(){ return x_; }
|
INLINE_FUNCTION_HD T& x()
|
||||||
|
{
|
||||||
|
return x_;
|
||||||
|
}
|
||||||
|
|
||||||
/// access component
|
/// access component
|
||||||
INLINE_FUNCTION_HD const T & x()const { return x_; }
|
INLINE_FUNCTION_HD const T& x() const
|
||||||
|
{
|
||||||
|
return x_;
|
||||||
|
}
|
||||||
|
|
||||||
/// access component
|
/// access component
|
||||||
INLINE_FUNCTION_HD T & y(){ return y_; }
|
INLINE_FUNCTION_HD T& y()
|
||||||
|
{
|
||||||
|
return y_;
|
||||||
|
}
|
||||||
|
|
||||||
/// access component
|
/// access component
|
||||||
INLINE_FUNCTION_HD const T & y()const { return y_; }
|
INLINE_FUNCTION_HD const T& y() const
|
||||||
|
{
|
||||||
|
return y_;
|
||||||
|
}
|
||||||
|
|
||||||
/// access component
|
/// access component
|
||||||
INLINE_FUNCTION_HD T & z(){ return z_; }
|
INLINE_FUNCTION_HD T& z()
|
||||||
|
{
|
||||||
|
return z_;
|
||||||
|
}
|
||||||
|
|
||||||
/// access component
|
/// access component
|
||||||
INLINE_FUNCTION_HD const T & z()const { return z_; }
|
INLINE_FUNCTION_HD const T& z() const
|
||||||
|
{
|
||||||
|
return z_;
|
||||||
|
}
|
||||||
|
|
||||||
/// access component
|
/// access component
|
||||||
INLINE_FUNCTION_HD T & comp1(){ return x_; }
|
INLINE_FUNCTION_HD T& comp1()
|
||||||
|
{
|
||||||
|
return x_;
|
||||||
|
}
|
||||||
|
|
||||||
/// access component
|
/// access component
|
||||||
INLINE_FUNCTION_HD const T & comp1()const { return x_; }
|
INLINE_FUNCTION_HD const T& comp1() const
|
||||||
|
{
|
||||||
|
return x_;
|
||||||
|
}
|
||||||
|
|
||||||
/// access component
|
/// access component
|
||||||
INLINE_FUNCTION_HD T & comp2(){ return y_; }
|
INLINE_FUNCTION_HD T& comp2()
|
||||||
|
{
|
||||||
|
return y_;
|
||||||
|
}
|
||||||
|
|
||||||
/// access component
|
/// access component
|
||||||
INLINE_FUNCTION_HD const T & comp2()const { return y_; }
|
INLINE_FUNCTION_HD const T& comp2() const
|
||||||
|
{
|
||||||
|
return y_;
|
||||||
|
}
|
||||||
|
|
||||||
/// access component
|
/// access component
|
||||||
INLINE_FUNCTION_HD T & comp3(){ return z_; }
|
INLINE_FUNCTION_HD T& comp3()
|
||||||
|
{
|
||||||
|
return z_;
|
||||||
|
}
|
||||||
|
|
||||||
/// access component
|
/// access component
|
||||||
INLINE_FUNCTION_HD const T & comp3()const { return z_; }
|
INLINE_FUNCTION_HD const T& comp3() const
|
||||||
|
{
|
||||||
|
return z_;
|
||||||
|
}
|
||||||
|
|
||||||
//// methods
|
//// methods
|
||||||
|
|
||||||
/// Dot product of two vectors
|
/// Dot product of two vectors
|
||||||
friend FUNCTION_HD T dot <T> (const triple<T> & oprnd1, const triple<T> & oprnd2);
|
friend FUNCTION_HD T
|
||||||
|
dot<T>(const triple<T>& oprnd1, const triple<T>& oprnd2);
|
||||||
|
|
||||||
/// Cross product of two vectors
|
/// Cross product of two vectors
|
||||||
friend FUNCTION_HD triple<T> cross <T>(const triple<T> & v1, const triple<T> & v2);
|
friend FUNCTION_HD triple<T>
|
||||||
|
cross<T>(const triple<T>& v1, const triple<T>& v2);
|
||||||
|
|
||||||
/// Length of the vector
|
/// Length of the vector
|
||||||
INLINE_FUNCTION_HD T length() const;
|
INLINE_FUNCTION_HD T length() const;
|
||||||
@ -181,33 +217,44 @@ struct triple
|
|||||||
//// operators
|
//// operators
|
||||||
|
|
||||||
/// + operator
|
/// + operator
|
||||||
friend FUNCTION_HD triple<T> operator+ <T> (const triple<T> & oprnd1, const triple<T> & oprnd2);
|
friend FUNCTION_HD triple<T> operator+
|
||||||
|
<T>(const triple<T>& oprnd1, const triple<T>& oprnd2);
|
||||||
|
|
||||||
friend FUNCTION_HD triple<T> operator+ <T> (const triple<T> & oprnd1, const T & oprnd2);
|
friend FUNCTION_HD triple<T> operator+
|
||||||
|
<T>(const triple<T>& oprnd1, const T& oprnd2);
|
||||||
|
|
||||||
friend FUNCTION_HD triple<T> operator+ <T> (const T & oprnd1, const triple<T> & oprnd2);
|
friend FUNCTION_HD triple<T> operator+
|
||||||
|
<T>(const T& oprnd1, const triple<T>& oprnd2);
|
||||||
|
|
||||||
/// - operator
|
/// - operator
|
||||||
friend FUNCTION_HD triple<T> operator - <T> (const triple<T> & oprnd1, const triple<T> & oprnd2);
|
friend FUNCTION_HD triple<T> operator-
|
||||||
|
<T>(const triple<T>& oprnd1, const triple<T>& oprnd2);
|
||||||
|
|
||||||
friend FUNCTION_HD triple<T> operator - <T> (const triple<T> & oprnd1, const T & oprnd2);
|
friend FUNCTION_HD triple<T> operator-
|
||||||
|
<T>(const triple<T>& oprnd1, const T& oprnd2);
|
||||||
|
|
||||||
friend FUNCTION_HD triple<T> operator - <T> (const T & oprnd1, const triple<T> & oprnd2);
|
friend FUNCTION_HD triple<T> operator-
|
||||||
|
<T>(const T& oprnd1, const triple<T>& oprnd2);
|
||||||
|
|
||||||
/// * operators
|
/// * operators
|
||||||
friend FUNCTION_HD triple<T> operator * <T> (const triple<T> & oprnd1, const triple<T> & oprnd2);
|
friend FUNCTION_HD triple<T> operator*
|
||||||
|
<T>(const triple<T>& oprnd1, const triple<T>& oprnd2);
|
||||||
|
|
||||||
friend FUNCTION_HD triple<T> operator * <T> (const triple<T> & oprnd1, const T & oprnd2);
|
friend FUNCTION_HD triple<T> operator*
|
||||||
|
<T>(const triple<T>& oprnd1, const T& oprnd2);
|
||||||
|
|
||||||
friend FUNCTION_HD triple<T> operator * <T> (const T & oprnd1, const triple<T> & oprnd2);
|
friend FUNCTION_HD triple<T> operator*
|
||||||
|
<T>(const T& oprnd1, const triple<T>& oprnd2);
|
||||||
|
|
||||||
/// / operators
|
/// / operators
|
||||||
friend FUNCTION_HD triple<T> operator / <T> (const triple<T> & oprnd1, const triple<T> & oprnd2);
|
friend FUNCTION_HD triple<T> operator/
|
||||||
|
<T>(const triple<T>& oprnd1, const triple<T>& oprnd2);
|
||||||
|
|
||||||
friend FUNCTION_HD triple<T> operator / <T> (const triple<T> & oprnd1, const T & oprnd2);
|
friend FUNCTION_HD triple<T> operator/
|
||||||
|
<T>(const triple<T>& oprnd1, const T& oprnd2);
|
||||||
friend FUNCTION_HD triple<T> operator / <T> (const T & oprnd1, const triple<T> & oprnd2);
|
|
||||||
|
|
||||||
|
friend FUNCTION_HD triple<T> operator/
|
||||||
|
<T>(const T& oprnd1, const triple<T>& oprnd2);
|
||||||
|
|
||||||
INLINE_FUNCTION_HD void operator+=(const triple& oprnd2);
|
INLINE_FUNCTION_HD void operator+=(const triple& oprnd2);
|
||||||
|
|
||||||
@ -217,23 +264,26 @@ struct triple
|
|||||||
|
|
||||||
INLINE_FUNCTION_HD void operator/=(const triple& oprnd2);
|
INLINE_FUNCTION_HD void operator/=(const triple& oprnd2);
|
||||||
|
|
||||||
|
|
||||||
/// unary negate operator
|
/// unary negate operator
|
||||||
INLINE_FUNCTION_HD triple operator-() const;
|
INLINE_FUNCTION_HD triple operator-() const;
|
||||||
|
|
||||||
/// unary plus operator
|
/// unary plus operator
|
||||||
INLINE_FUNCTION_HD triple operator+() const;
|
INLINE_FUNCTION_HD triple operator+() const;
|
||||||
|
|
||||||
|
friend FUNCTION_HD bool operator==
|
||||||
|
<T>(const triple<T>& opr1, const triple<T>& opr2);
|
||||||
|
|
||||||
friend FUNCTION_HD bool operator == <T> (const triple<T> &opr1, const triple<T> &opr2);
|
friend FUNCTION_HD bool
|
||||||
|
operator< <T>(const triple<T>& opr1, const triple<T>& opr2);
|
||||||
|
|
||||||
friend FUNCTION_HD bool operator < <T> (const triple<T> &opr1, const triple<T> &opr2);
|
friend FUNCTION_HD bool operator>
|
||||||
|
<T>(const triple<T>& opr1, const triple<T>& opr2);
|
||||||
|
|
||||||
friend FUNCTION_HD bool operator > <T> (const triple<T> &opr1, const triple<T> &opr2);
|
friend FUNCTION_HD bool operator>=
|
||||||
|
<T>(const triple<T>& opr1, const triple<T>& opr2);
|
||||||
|
|
||||||
friend FUNCTION_HD bool operator >= <T> (const triple<T> &opr1, const triple<T> &opr2);
|
friend FUNCTION_HD bool operator<=
|
||||||
|
<T>(const triple<T>& opr1, const triple<T>& opr2);
|
||||||
friend FUNCTION_HD bool operator <= <T> (const triple<T> &opr1, const triple<T> &opr2);
|
|
||||||
|
|
||||||
//// IO operators
|
//// IO operators
|
||||||
|
|
||||||
@ -245,27 +295,22 @@ struct triple
|
|||||||
|
|
||||||
/// same as >> operator, but faster, good for mass read
|
/// same as >> operator, but faster, good for mass read
|
||||||
friend void readIstream<T>(iIstream& str, triple<T>& iv);
|
friend void readIstream<T>(iIstream& str, triple<T>& iv);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool INLINE_FUNCTION_HD equal( const triple<T>& opr1, const triple<T>& opr2);
|
bool INLINE_FUNCTION_HD
|
||||||
|
equal(const triple<T>& opr1, const triple<T>& opr2);
|
||||||
|
|
||||||
|
bool INLINE_FUNCTION_HD
|
||||||
bool
|
|
||||||
INLINE_FUNCTION_HD
|
|
||||||
equal(const triple<real>& opr1, const triple<real>& opr2, real tol)
|
equal(const triple<real>& opr1, const triple<real>& opr2, real tol)
|
||||||
{
|
{
|
||||||
return equal( opr1.x(), opr2.x(), tol ) &&
|
return equal(opr1.x(), opr2.x(), tol) && equal(opr1.y(), opr2.y(), tol) &&
|
||||||
equal( opr1.y(), opr2.y(), tol ) &&
|
|
||||||
equal(opr1.z(), opr2.z(), tol);
|
equal(opr1.z(), opr2.z(), tol);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} /// end of pFlow
|
} /// end of pFlow
|
||||||
|
|
||||||
#include "tripleI.hpp"
|
#include "tripleI.hpp"
|
||||||
#include "tripleMath.hpp"
|
#include "tripleMath.hpp"
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -19,171 +19,97 @@ Licence:
|
|||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD T dot
|
INLINE_FUNCTION_HD T
|
||||||
(
|
dot(const triple<T>& oprnd1, const triple<T>& oprnd2);
|
||||||
const triple<T> & oprnd1,
|
|
||||||
const triple<T> & oprnd2
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD triple<T> cross
|
INLINE_FUNCTION_HD triple<T>
|
||||||
(
|
cross(const triple<T>& v1, const triple<T>& v2);
|
||||||
const triple<T> & v1,
|
|
||||||
const triple<T> & v2
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD T length
|
INLINE_FUNCTION_HD T
|
||||||
(
|
length(const triple<T>& v1);
|
||||||
const triple<T> & v1
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD triple<T> normalize
|
INLINE_FUNCTION_HD triple<T>
|
||||||
(
|
normalize(const triple<T>& v1);
|
||||||
const triple<T>& v1
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD triple<T> operator +
|
INLINE_FUNCTION_HD triple<T>
|
||||||
(
|
operator+(const triple<T>& oprnd1, const triple<T>& oprnd2);
|
||||||
const triple<T> & oprnd1,
|
|
||||||
const triple<T> & oprnd2
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD triple<T> operator+
|
INLINE_FUNCTION_HD triple<T>
|
||||||
(
|
operator+(const triple<T>& oprnd1, const T& oprnd2);
|
||||||
const triple<T> & oprnd1,
|
|
||||||
const T & oprnd2
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD triple<T> operator+
|
INLINE_FUNCTION_HD triple<T>
|
||||||
(
|
operator+(const T& oprnd2, const triple<T>& oprnd1);
|
||||||
const T & oprnd2,
|
|
||||||
const triple<T> & oprnd1
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD triple<T> operator-
|
INLINE_FUNCTION_HD triple<T>
|
||||||
(
|
operator-(const triple<T>& oprnd1, const triple<T>& oprnd2);
|
||||||
const triple<T> & oprnd1,
|
|
||||||
const triple<T> & oprnd2
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD triple<T> operator-
|
INLINE_FUNCTION_HD triple<T>
|
||||||
(
|
operator-(const triple<T>& oprnd1, const T& oprnd2);
|
||||||
const triple<T> & oprnd1,
|
|
||||||
const T & oprnd2
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD triple<T> operator-
|
INLINE_FUNCTION_HD triple<T>
|
||||||
(
|
operator-(const T& oprnd1, const triple<T>& oprnd2);
|
||||||
const T & oprnd1,
|
|
||||||
const triple<T> & oprnd2
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD triple<T> operator*
|
INLINE_FUNCTION_HD triple<T>
|
||||||
(
|
operator*(const triple<T>& oprnd1, const triple<T>& oprnd2);
|
||||||
const triple<T> & oprnd1,
|
|
||||||
const triple<T> & oprnd2
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD triple<T> operator*
|
INLINE_FUNCTION_HD triple<T>
|
||||||
(
|
operator*(const triple<T>& oprnd1, const T& oprnd2);
|
||||||
const triple<T> & oprnd1,
|
|
||||||
const T & oprnd2
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD triple<T> operator*
|
INLINE_FUNCTION_HD triple<T>
|
||||||
(
|
operator*(const T& oprnd1, const triple<T>& oprnd2);
|
||||||
const T & oprnd1,
|
|
||||||
const triple<T> & oprnd2
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD triple<T> operator/
|
INLINE_FUNCTION_HD triple<T>
|
||||||
(
|
operator/(const triple<T>& oprnd1, const triple<T>& oprnd2);
|
||||||
const triple<T> & oprnd1,
|
|
||||||
const triple<T> & oprnd2
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD triple<T> operator/
|
INLINE_FUNCTION_HD triple<T>
|
||||||
(
|
operator/(const triple<T>& oprnd1, const T& oprnd2);
|
||||||
const triple<T> & oprnd1,
|
|
||||||
const T & oprnd2
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD triple<T> operator/
|
INLINE_FUNCTION_HD triple<T>
|
||||||
(
|
operator/(const T& oprnd1, const triple<T>& oprnd2);
|
||||||
const T & oprnd1,
|
|
||||||
const triple<T> & oprnd2
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD bool operator ==
|
INLINE_FUNCTION_HD bool
|
||||||
(
|
operator==(const triple<T>& opr1, const triple<T>& opr2);
|
||||||
const triple<T> &opr1,
|
|
||||||
const triple<T> &opr2
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD bool operator >
|
INLINE_FUNCTION_HD bool
|
||||||
(
|
operator>(const triple<T>& opr1, const triple<T>& opr2);
|
||||||
const triple<T> &opr1,
|
|
||||||
const triple<T> &opr2
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD bool operator <
|
INLINE_FUNCTION_HD bool
|
||||||
(
|
operator<(const triple<T>& opr1, const triple<T>& opr2);
|
||||||
const triple<T> &opr1,
|
|
||||||
const triple<T> &opr2
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD bool operator <=
|
INLINE_FUNCTION_HD bool
|
||||||
(
|
operator<=(const triple<T>& opr1, const triple<T>& opr2);
|
||||||
const triple<T> &opr1,
|
|
||||||
const triple<T> &opr2
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD bool operator >=
|
INLINE_FUNCTION_HD bool
|
||||||
(
|
operator>=(const triple<T>& opr1, const triple<T>& opr2);
|
||||||
const triple<T> &opr1,
|
|
||||||
const triple<T> &opr2
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION iOstream& operator<<
|
INLINE_FUNCTION iOstream&
|
||||||
(
|
operator<<(iOstream& str, const triple<T>& ov);
|
||||||
iOstream& str,
|
|
||||||
const triple<T> & ov
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION iIstream& operator>>
|
INLINE_FUNCTION iIstream&
|
||||||
(
|
operator>>(iIstream& str, triple<T>& iv);
|
||||||
iIstream& str,
|
|
||||||
triple<T> & iv
|
|
||||||
);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION void readIstream
|
INLINE_FUNCTION void
|
||||||
(
|
readIstream(iIstream& str, triple<T>& iv);
|
||||||
iIstream& str,
|
|
||||||
triple<T> & iv
|
|
||||||
);
|
|
@ -19,23 +19,16 @@ Licence:
|
|||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD T pFlow::dot
|
INLINE_FUNCTION_HD T
|
||||||
(
|
pFlow::dot(const triple<T>& oprnd1, const triple<T>& oprnd2)
|
||||||
const triple<T> & oprnd1,
|
|
||||||
const triple<T> & oprnd2
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return oprnd1.x_ * oprnd2.x_ +
|
return oprnd1.x_ * oprnd2.x_ + oprnd1.y_ * oprnd2.y_ +
|
||||||
oprnd1.y_ * oprnd2.y_ +
|
|
||||||
oprnd1.z_ * oprnd2.z_;
|
oprnd1.z_ * oprnd2.z_;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD pFlow::triple<T> pFlow::cross
|
INLINE_FUNCTION_HD pFlow::triple<T>
|
||||||
(
|
pFlow::cross(const triple<T>& v1, const triple<T>& v2)
|
||||||
const triple<T> & v1,
|
|
||||||
const triple<T> & v2
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return triple<T>(
|
return triple<T>(
|
||||||
v1.y_ * v2.z_ - v1.z_ * v2.y_,
|
v1.y_ * v2.z_ - v1.z_ * v2.y_,
|
||||||
@ -45,216 +38,144 @@ INLINE_FUNCTION_HD pFlow::triple<T> pFlow::cross
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD T pFlow::length
|
INLINE_FUNCTION_HD T
|
||||||
(
|
pFlow::length(const triple<T>& v1)
|
||||||
const triple<T> & v1
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return v1.length();
|
return v1.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD pFlow::triple<T> pFlow::normalize(const triple<T>& v1)
|
INLINE_FUNCTION_HD pFlow::triple<T>
|
||||||
|
pFlow::normalize(const triple<T>& v1)
|
||||||
{
|
{
|
||||||
return v1 / max(length(v1), verySmallValue);
|
return v1 / max(length(v1), verySmallValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD T pFlow::triple<T>::length
|
INLINE_FUNCTION_HD T
|
||||||
(
|
pFlow::triple<T>::length() const
|
||||||
)const
|
|
||||||
{
|
{
|
||||||
return sqrt(dot(*this, *this));
|
return sqrt(dot(*this, *this));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD void pFlow::triple<T>::normalize
|
INLINE_FUNCTION_HD void
|
||||||
(
|
pFlow::triple<T>::normalize()
|
||||||
)
|
|
||||||
{
|
{
|
||||||
*this = *this / max(length(), verySmallValue);
|
*this = *this / max(length(), verySmallValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD pFlow::triple<T> pFlow::operator+
|
INLINE_FUNCTION_HD pFlow::triple<T>
|
||||||
(
|
pFlow::operator+(const triple<T>& oprnd1, const triple<T>& oprnd2)
|
||||||
const triple<T> & oprnd1,
|
|
||||||
const triple<T> & oprnd2
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return triple<T>(
|
return triple<T>(
|
||||||
oprnd1.x_ + oprnd2.x_,
|
oprnd1.x_ + oprnd2.x_, oprnd1.y_ + oprnd2.y_, oprnd1.z_ + oprnd2.z_
|
||||||
oprnd1.y_ + oprnd2.y_,
|
|
||||||
oprnd1.z_ + oprnd2.z_
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
INLINE_FUNCTION_HD pFlow::triple<T> pFlow::operator+
|
|
||||||
(
|
|
||||||
const triple<T> & oprnd1,
|
|
||||||
const T & oprnd2
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return triple<T>(
|
|
||||||
oprnd1.x_ + oprnd2,
|
|
||||||
oprnd1.y_ + oprnd2,
|
|
||||||
oprnd1.z_ + oprnd2
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD pFlow::triple<T> pFlow::operator+
|
INLINE_FUNCTION_HD pFlow::triple<T>
|
||||||
(
|
pFlow::operator+(const triple<T>& oprnd1, const T& oprnd2)
|
||||||
const T & oprnd1,
|
|
||||||
const triple<T> & oprnd2
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return triple<T>(
|
return triple<T>(
|
||||||
oprnd1 + oprnd2.x_,
|
oprnd1.x_ + oprnd2, oprnd1.y_ + oprnd2, oprnd1.z_ + oprnd2
|
||||||
oprnd1 + oprnd2.y_,
|
|
||||||
oprnd1 + oprnd2.z_
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
INLINE_FUNCTION_HD pFlow::triple<T> pFlow::operator-
|
|
||||||
(
|
|
||||||
const triple<T> & oprnd1,
|
|
||||||
const triple<T> & oprnd2
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return triple<T>(
|
|
||||||
oprnd1.x_ - oprnd2.x_,
|
|
||||||
oprnd1.y_ - oprnd2.y_,
|
|
||||||
oprnd1.z_ - oprnd2.z_
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
INLINE_FUNCTION_HD pFlow::triple<T> pFlow::operator-
|
|
||||||
(
|
|
||||||
const triple<T> & oprnd1,
|
|
||||||
const T & oprnd2
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return triple<T>(
|
|
||||||
oprnd1.x_ - oprnd2,
|
|
||||||
oprnd1.y_ - oprnd2,
|
|
||||||
oprnd1.z_ - oprnd2
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD pFlow::triple<T> pFlow::operator-
|
INLINE_FUNCTION_HD pFlow::triple<T>
|
||||||
(
|
pFlow::operator+(const T& oprnd1, const triple<T>& oprnd2)
|
||||||
const T & oprnd1,
|
|
||||||
const triple<T> & oprnd2
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return triple<T>(
|
return triple<T>(
|
||||||
oprnd1 - oprnd2.x_,
|
oprnd1 + oprnd2.x_, oprnd1 + oprnd2.y_, oprnd1 + oprnd2.z_
|
||||||
oprnd1 - oprnd2.y_,
|
|
||||||
oprnd1 - oprnd2.z_
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
INLINE_FUNCTION_HD pFlow::triple<T> pFlow::operator*
|
|
||||||
(
|
|
||||||
const triple<T> & oprnd1,
|
|
||||||
const triple<T> & oprnd2
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return triple<T>(
|
|
||||||
oprnd1.x_ * oprnd2.x_,
|
|
||||||
oprnd1.y_ * oprnd2.y_,
|
|
||||||
oprnd1.z_ * oprnd2.z_
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
INLINE_FUNCTION_HD pFlow::triple<T> pFlow::operator*
|
|
||||||
(
|
|
||||||
const triple<T> & oprnd1,
|
|
||||||
const T & oprnd2
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return triple<T>(
|
|
||||||
oprnd1.x_ * oprnd2,
|
|
||||||
oprnd1.y_ * oprnd2,
|
|
||||||
oprnd1.z_ * oprnd2
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD pFlow::triple<T> pFlow::operator*
|
INLINE_FUNCTION_HD pFlow::triple<T>
|
||||||
(
|
pFlow::operator-(const triple<T>& oprnd1, const triple<T>& oprnd2)
|
||||||
const T & oprnd1,
|
|
||||||
const triple<T> & oprnd2
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return triple<T>(
|
return triple<T>(
|
||||||
oprnd1 * oprnd2.x_,
|
oprnd1.x_ - oprnd2.x_, oprnd1.y_ - oprnd2.y_, oprnd1.z_ - oprnd2.z_
|
||||||
oprnd1 * oprnd2.y_,
|
|
||||||
oprnd1 * oprnd2.z_
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
INLINE_FUNCTION_HD pFlow::triple<T> pFlow::operator/
|
|
||||||
(
|
|
||||||
const triple<T> & oprnd1,
|
|
||||||
const triple<T> & oprnd2
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return triple<T>(
|
|
||||||
oprnd1.x_ / oprnd2.x_,
|
|
||||||
oprnd1.y_ / oprnd2.y_,
|
|
||||||
oprnd1.z_ / oprnd2.z_
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
INLINE_FUNCTION_HD pFlow::triple<T> pFlow::operator/
|
|
||||||
(
|
|
||||||
const triple<T> & oprnd1,
|
|
||||||
const T & oprnd2
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return triple<T>(
|
|
||||||
oprnd1.x_ / oprnd2,
|
|
||||||
oprnd1.y_ / oprnd2,
|
|
||||||
oprnd1.z_ / oprnd2
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD pFlow::triple<T> pFlow::operator/
|
INLINE_FUNCTION_HD pFlow::triple<T>
|
||||||
(
|
pFlow::operator-(const triple<T>& oprnd1, const T& oprnd2)
|
||||||
const T & oprnd1,
|
|
||||||
const triple<T> & oprnd2
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return triple<T>(
|
return triple<T>(
|
||||||
oprnd1 / oprnd2.x_,
|
oprnd1.x_ - oprnd2, oprnd1.y_ - oprnd2, oprnd1.z_ - oprnd2
|
||||||
oprnd1 / oprnd2.y_,
|
|
||||||
oprnd1 / oprnd2.z_
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD void pFlow::triple<T>::operator+=
|
INLINE_FUNCTION_HD pFlow::triple<T>
|
||||||
(
|
pFlow::operator-(const T& oprnd1, const triple<T>& oprnd2)
|
||||||
const triple<T> & oprnd2
|
{
|
||||||
)
|
return triple<T>(
|
||||||
|
oprnd1 - oprnd2.x_, oprnd1 - oprnd2.y_, oprnd1 - oprnd2.z_
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
INLINE_FUNCTION_HD pFlow::triple<T>
|
||||||
|
pFlow::operator*(const triple<T>& oprnd1, const triple<T>& oprnd2)
|
||||||
|
{
|
||||||
|
return triple<T>(
|
||||||
|
oprnd1.x_ * oprnd2.x_, oprnd1.y_ * oprnd2.y_, oprnd1.z_ * oprnd2.z_
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
INLINE_FUNCTION_HD pFlow::triple<T>
|
||||||
|
pFlow::operator*(const triple<T>& oprnd1, const T& oprnd2)
|
||||||
|
{
|
||||||
|
return triple<T>(
|
||||||
|
oprnd1.x_ * oprnd2, oprnd1.y_ * oprnd2, oprnd1.z_ * oprnd2
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
INLINE_FUNCTION_HD pFlow::triple<T>
|
||||||
|
pFlow::operator*(const T& oprnd1, const triple<T>& oprnd2)
|
||||||
|
{
|
||||||
|
return triple<T>(
|
||||||
|
oprnd1 * oprnd2.x_, oprnd1 * oprnd2.y_, oprnd1 * oprnd2.z_
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
INLINE_FUNCTION_HD pFlow::triple<T>
|
||||||
|
pFlow::operator/(const triple<T>& oprnd1, const triple<T>& oprnd2)
|
||||||
|
{
|
||||||
|
return triple<T>(
|
||||||
|
oprnd1.x_ / oprnd2.x_, oprnd1.y_ / oprnd2.y_, oprnd1.z_ / oprnd2.z_
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
INLINE_FUNCTION_HD pFlow::triple<T>
|
||||||
|
pFlow::operator/(const triple<T>& oprnd1, const T& oprnd2)
|
||||||
|
{
|
||||||
|
return triple<T>(
|
||||||
|
oprnd1.x_ / oprnd2, oprnd1.y_ / oprnd2, oprnd1.z_ / oprnd2
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
INLINE_FUNCTION_HD pFlow::triple<T>
|
||||||
|
pFlow::operator/(const T& oprnd1, const triple<T>& oprnd2)
|
||||||
|
{
|
||||||
|
return triple<T>(
|
||||||
|
oprnd1 / oprnd2.x_, oprnd1 / oprnd2.y_, oprnd1 / oprnd2.z_
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
INLINE_FUNCTION_HD void
|
||||||
|
pFlow::triple<T>::operator+=(const triple<T>& oprnd2)
|
||||||
{
|
{
|
||||||
this->x_ = this->x_ + oprnd2.x_;
|
this->x_ = this->x_ + oprnd2.x_;
|
||||||
this->y_ = this->y_ + oprnd2.y_;
|
this->y_ = this->y_ + oprnd2.y_;
|
||||||
@ -262,10 +183,8 @@ INLINE_FUNCTION_HD void pFlow::triple<T>::operator+=
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD void pFlow::triple<T>::operator-=
|
INLINE_FUNCTION_HD void
|
||||||
(
|
pFlow::triple<T>::operator-=(const triple<T>& oprnd2)
|
||||||
const triple<T> & oprnd2
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
this->x_ = this->x_ - oprnd2.x_;
|
this->x_ = this->x_ - oprnd2.x_;
|
||||||
this->y_ = this->y_ - oprnd2.y_;
|
this->y_ = this->y_ - oprnd2.y_;
|
||||||
@ -273,10 +192,8 @@ INLINE_FUNCTION_HD void pFlow::triple<T>::operator-=
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD void pFlow::triple<T>::operator*=
|
INLINE_FUNCTION_HD void
|
||||||
(
|
pFlow::triple<T>::operator*=(const triple<T>& oprnd2)
|
||||||
const triple<T> & oprnd2
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
this->x_ = this->x_ * oprnd2.x_;
|
this->x_ = this->x_ * oprnd2.x_;
|
||||||
this->y_ = this->y_ * oprnd2.y_;
|
this->y_ = this->y_ * oprnd2.y_;
|
||||||
@ -284,10 +201,8 @@ INLINE_FUNCTION_HD void pFlow::triple<T>::operator*=
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD void pFlow::triple<T>::operator/=
|
INLINE_FUNCTION_HD void
|
||||||
(
|
pFlow::triple<T>::operator/=(const triple<T>& oprnd2)
|
||||||
const triple<T> & oprnd2
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
this->x_ = this->x_ / oprnd2.x_;
|
this->x_ = this->x_ / oprnd2.x_;
|
||||||
this->y_ = this->y_ / oprnd2.y_;
|
this->y_ = this->y_ / oprnd2.y_;
|
||||||
@ -295,37 +210,29 @@ INLINE_FUNCTION_HD void pFlow::triple<T>::operator/=
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD pFlow::triple<T> pFlow::triple<T>::operator-
|
INLINE_FUNCTION_HD pFlow::triple<T>
|
||||||
(
|
pFlow::triple<T>::operator-() const
|
||||||
) const
|
|
||||||
{
|
{
|
||||||
return triple<T>(-this->x_, -this->y_, -this->z_);
|
return triple<T>(-this->x_, -this->y_, -this->z_);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD pFlow::triple<T> pFlow::triple<T>::operator+
|
INLINE_FUNCTION_HD pFlow::triple<T>
|
||||||
(
|
pFlow::triple<T>::operator+() const
|
||||||
) const
|
|
||||||
{
|
{
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD bool pFlow::operator ==
|
INLINE_FUNCTION_HD bool
|
||||||
(
|
pFlow::operator==(const triple<T>& opr1, const triple<T>& opr2)
|
||||||
const triple<T> &opr1,
|
{
|
||||||
const triple<T> &opr2
|
|
||||||
){
|
|
||||||
return equal(opr1, opr2);
|
return equal(opr1, opr2);
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD bool pFlow::operator <
|
INLINE_FUNCTION_HD bool
|
||||||
(
|
pFlow::operator<(const triple<T>& opr1, const triple<T>& opr2)
|
||||||
const triple<T> &opr1,
|
|
||||||
const triple<T> &opr2
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (opr1.x_ < opr2.x_ && opr1.y_ < opr2.y_ && opr1.z_ < opr2.z_)
|
if (opr1.x_ < opr2.x_ && opr1.y_ < opr2.y_ && opr1.z_ < opr2.z_)
|
||||||
{
|
{
|
||||||
@ -338,11 +245,8 @@ INLINE_FUNCTION_HD bool pFlow::operator <
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD bool pFlow::operator >
|
INLINE_FUNCTION_HD bool
|
||||||
(
|
pFlow::operator>(const triple<T>& opr1, const triple<T>& opr2)
|
||||||
const triple<T> &opr1,
|
|
||||||
const triple<T> &opr2
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (opr1.x_ > opr2.x_ && opr1.y_ > opr2.y_ && opr1.z_ > opr2.z_)
|
if (opr1.x_ > opr2.x_ && opr1.y_ > opr2.y_ && opr1.z_ > opr2.z_)
|
||||||
{
|
{
|
||||||
@ -355,11 +259,8 @@ INLINE_FUNCTION_HD bool pFlow::operator >
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD bool pFlow::operator <=
|
INLINE_FUNCTION_HD bool
|
||||||
(
|
pFlow::operator<=(const triple<T>& opr1, const triple<T>& opr2)
|
||||||
const triple<T> &opr1,
|
|
||||||
const triple<T> &opr2
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (opr1.x_ <= opr2.x_ && opr1.y_ <= opr2.y_ && opr1.z_ <= opr2.z_)
|
if (opr1.x_ <= opr2.x_ && opr1.y_ <= opr2.y_ && opr1.z_ <= opr2.z_)
|
||||||
{
|
{
|
||||||
@ -371,13 +272,9 @@ INLINE_FUNCTION_HD bool pFlow::operator <=
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD bool pFlow::operator >=
|
INLINE_FUNCTION_HD bool
|
||||||
(
|
pFlow::operator>=(const triple<T>& opr1, const triple<T>& opr2)
|
||||||
const triple<T> &opr1,
|
|
||||||
const triple<T> &opr2
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (opr1.x_ >= opr2.x_ && opr1.y_ >= opr2.y_ && opr1.z_ >= opr2.z_)
|
if (opr1.x_ >= opr2.x_ && opr1.y_ >= opr2.y_ && opr1.z_ >= opr2.z_)
|
||||||
{
|
{
|
||||||
@ -389,19 +286,12 @@ INLINE_FUNCTION_HD bool pFlow::operator >=
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION pFlow::iOstream& pFlow::operator <<
|
INLINE_FUNCTION pFlow::iOstream&
|
||||||
(
|
pFlow::operator<<(iOstream& str, const triple<T>& ov)
|
||||||
iOstream & str,
|
|
||||||
const triple<T> & ov
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
str << token::BEGIN_LIST << ov.x_ << token::SPACE << ov.y_ << token::SPACE
|
||||||
str << token::BEGIN_LIST << ov.x_
|
<< ov.z_ << token::END_LIST;
|
||||||
<< token::SPACE << ov.y_
|
|
||||||
<< token::SPACE << ov.z_
|
|
||||||
<< token::END_LIST;
|
|
||||||
|
|
||||||
str.check(FUNCTION_NAME);
|
str.check(FUNCTION_NAME);
|
||||||
|
|
||||||
@ -409,20 +299,15 @@ INLINE_FUNCTION pFlow::iOstream& pFlow::operator <<
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION pFlow::iIstream& pFlow::operator >>
|
INLINE_FUNCTION pFlow::iIstream&
|
||||||
(
|
pFlow::operator>>(iIstream& str, triple<T>& iv)
|
||||||
iIstream & str,
|
|
||||||
triple<T> & iv
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
str.readBegin("triple<T>");
|
str.readBegin("triple<T>");
|
||||||
|
|
||||||
str >> iv.x_;
|
str >> iv.x_;
|
||||||
str >> iv.y_;
|
str >> iv.y_;
|
||||||
str >> iv.z_;
|
str >> iv.z_;
|
||||||
|
|
||||||
|
|
||||||
str.readEnd("triple<T>");
|
str.readEnd("triple<T>");
|
||||||
|
|
||||||
str.check(FUNCTION_NAME);
|
str.check(FUNCTION_NAME);
|
||||||
@ -431,13 +316,9 @@ INLINE_FUNCTION pFlow::iIstream& pFlow::operator >>
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION void pFlow::readIstream
|
INLINE_FUNCTION void
|
||||||
(
|
pFlow::readIstream(iIstream& str, triple<T>& iv)
|
||||||
iIstream & str,
|
|
||||||
triple<T> & iv
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
str.readBegin("triple<T>");
|
str.readBegin("triple<T>");
|
||||||
T val;
|
T val;
|
||||||
|
|
||||||
@ -453,15 +334,12 @@ INLINE_FUNCTION void pFlow::readIstream
|
|||||||
str.readEnd("triple<T>");
|
str.readEnd("triple<T>");
|
||||||
|
|
||||||
str.check(FUNCTION_NAME);
|
str.check(FUNCTION_NAME);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool INLINE_FUNCTION_HD pFlow::equal
|
bool INLINE_FUNCTION_HD
|
||||||
(
|
pFlow::equal(const triple<T>& opr1, const triple<T>& opr2)
|
||||||
const triple<T>& opr1,
|
|
||||||
const triple<T>& opr2
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return equal( opr1.x(), opr2.x() ) && equal( opr1.y(), opr2.y() ) && equal( opr1.z(), opr2.z() );
|
return equal(opr1.x(), opr2.x()) && equal(opr1.y(), opr2.y()) &&
|
||||||
|
equal(opr1.z(), opr2.z());
|
||||||
}
|
}
|
@ -31,9 +31,15 @@ INLINE_FUNCTION_HD triple<T> fnName(const triple<T>& v) \
|
|||||||
|
|
||||||
#define T3Func2(fnName) \
|
#define T3Func2(fnName) \
|
||||||
template<typename T> \
|
template<typename T> \
|
||||||
INLINE_FUNCTION_HD triple<T> fnName(const triple<T>& arg1, const triple<T>& arg2) \
|
INLINE_FUNCTION_HD triple<T> fnName( \
|
||||||
|
const triple<T>& arg1, const triple<T>& arg2 \
|
||||||
|
) \
|
||||||
{ \
|
{ \
|
||||||
return triple<T>(fnName(arg1.x_, arg2.x_), fnName(arg1.y_,arg2.y_), fnName(arg1.z_, arg2.z_)); \
|
return triple<T>( \
|
||||||
|
fnName(arg1.x_, arg2.x_), \
|
||||||
|
fnName(arg1.y_, arg2.y_), \
|
||||||
|
fnName(arg1.z_, arg2.z_) \
|
||||||
|
); \
|
||||||
}
|
}
|
||||||
|
|
||||||
//* * * * * * * * * * * List of functinos * * * * * * * * //
|
//* * * * * * * * * * * List of functinos * * * * * * * * //
|
||||||
@ -43,7 +49,6 @@ INLINE_FUNCTION_HD triple<T> fnName(const triple<T>& arg1, const triple<T>& arg2
|
|||||||
// min, max
|
// min, max
|
||||||
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
T3Func(abs);
|
T3Func(abs);
|
||||||
T3Func2(mod);
|
T3Func2(mod);
|
||||||
T3Func(exp);
|
T3Func(exp);
|
||||||
@ -72,27 +77,28 @@ T3Func2(max);
|
|||||||
|
|
||||||
// elements of t3 raised by e
|
// elements of t3 raised by e
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD triple<T> pow(const triple<T>& t3, T e)
|
INLINE_FUNCTION_HD triple<T>
|
||||||
|
pow(const triple<T>& t3, T e)
|
||||||
{
|
{
|
||||||
return triple<T>(pow(t3.x_, e), pow(t3.y_, e), pow(t3.z_, e));
|
return triple<T>(pow(t3.x_, e), pow(t3.y_, e), pow(t3.z_, e));
|
||||||
}
|
}
|
||||||
|
|
||||||
// return the min of 3 elements x, y, z
|
// return the min of 3 elements x, y, z
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD T min(const triple<T>& t3)
|
INLINE_FUNCTION_HD T
|
||||||
|
min(const triple<T>& t3)
|
||||||
{
|
{
|
||||||
return min(min(t3.x_, t3.y_), t3.z_);
|
return min(min(t3.x_, t3.y_), t3.z_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// return the max of 3 elements x, y, z
|
// return the max of 3 elements x, y, z
|
||||||
template<typename T>
|
template<typename T>
|
||||||
INLINE_FUNCTION_HD T max(const triple<T>& t3)
|
INLINE_FUNCTION_HD T
|
||||||
|
max(const triple<T>& t3)
|
||||||
{
|
{
|
||||||
return max(max(t3.x_, t3.y_), t3.z_);
|
return max(max(t3.x_, t3.y_), t3.z_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#undef T3Func
|
#undef T3Func
|
||||||
#undef T3Func2
|
#undef T3Func2
|
||||||
|
|
||||||
|
@ -31,5 +31,4 @@ namespace pFlow
|
|||||||
|
|
||||||
const realx4 zero4(zero);
|
const realx4 zero4(zero);
|
||||||
|
|
||||||
|
|
||||||
} // pFlow
|
} // pFlow
|
@ -21,7 +21,6 @@ Licence:
|
|||||||
#ifndef __types_hpp__
|
#ifndef __types_hpp__
|
||||||
#define __types_hpp__
|
#define __types_hpp__
|
||||||
|
|
||||||
|
|
||||||
#include "bTypes.hpp"
|
#include "bTypes.hpp"
|
||||||
|
|
||||||
#include "bTypesFunctions.hpp"
|
#include "bTypesFunctions.hpp"
|
||||||
@ -32,7 +31,6 @@ Licence:
|
|||||||
|
|
||||||
#include "typeInfo.hpp"
|
#include "typeInfo.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace pFlow
|
namespace pFlow
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -52,48 +50,93 @@ using realx4 = quadruple<real>;
|
|||||||
|
|
||||||
using realx4x3 = quadruple<realx3>;
|
using realx4x3 = quadruple<realx3>;
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline word
|
||||||
|
basicTypeName<int8x3>()
|
||||||
|
{
|
||||||
|
return "int8x3";
|
||||||
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline word basicTypeName<int8x3>(){ return "int8x3"; }
|
inline word
|
||||||
|
basicTypeName<int32x3>()
|
||||||
|
{
|
||||||
|
return "int32x3";
|
||||||
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline word basicTypeName<int32x3>(){ return "int32x3"; }
|
inline word
|
||||||
|
basicTypeName<int64x3>()
|
||||||
|
{
|
||||||
|
return "int64x3";
|
||||||
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline word basicTypeName<int64x3>(){ return "int64x3"; }
|
inline word
|
||||||
|
basicTypeName<uint8x3>()
|
||||||
|
{
|
||||||
|
return "uint8x3";
|
||||||
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline word basicTypeName<uint8x3>(){ return "uint8x3"; }
|
inline word
|
||||||
|
basicTypeName<uint32x3>()
|
||||||
|
{
|
||||||
|
return "uint32x3";
|
||||||
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline word basicTypeName<uint32x3>(){ return "uint32x3"; }
|
inline word
|
||||||
|
basicTypeName<uint64x3>()
|
||||||
|
{
|
||||||
|
return "unit64x3";
|
||||||
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline word basicTypeName<uint64x3>(){ return "unit64x3"; }
|
inline word
|
||||||
|
basicTypeName<realx3>()
|
||||||
|
{
|
||||||
|
return "realx3";
|
||||||
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline word basicTypeName<realx3>(){ return "realx3"; }
|
inline word
|
||||||
|
basicTypeName<int32x3x3>()
|
||||||
|
{
|
||||||
|
return "int32x3x3";
|
||||||
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline word basicTypeName<int32x3x3>(){ return "int32x3x3"; }
|
inline word
|
||||||
|
basicTypeName<uint32x3x3>()
|
||||||
|
{
|
||||||
|
return "uint32x3x3";
|
||||||
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline word basicTypeName<uint32x3x3>(){ return "uint32x3x3"; }
|
inline word
|
||||||
|
basicTypeName<realx3x3>()
|
||||||
|
{
|
||||||
|
return "realx3x3";
|
||||||
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline word basicTypeName<realx3x3>(){ return "realx3x3"; }
|
inline word
|
||||||
|
basicTypeName<realx4>()
|
||||||
|
{
|
||||||
|
return "realx4";
|
||||||
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
inline word basicTypeName<realx4>(){ return "realx4"; }
|
inline word
|
||||||
|
basicTypeName<realx4x3>()
|
||||||
template<>
|
{
|
||||||
inline word basicTypeName<realx4x3>(){ return "realx4x3"; }
|
return "realx4x3";
|
||||||
|
}
|
||||||
|
|
||||||
extern const realx3 zero3;
|
extern const realx3 zero3;
|
||||||
extern const realx3 one3;
|
extern const realx3 one3;
|
||||||
|
|
||||||
|
|
||||||
extern const realx3x3 zero33;
|
extern const realx3x3 zero33;
|
||||||
extern const realx3x3 one33;
|
extern const realx3x3 one33;
|
||||||
|
|
||||||
@ -101,5 +144,4 @@ extern const realx4 zero4;
|
|||||||
|
|
||||||
} // pFlow
|
} // pFlow
|
||||||
|
|
||||||
|
|
||||||
#endif //__types_hpp__
|
#endif //__types_hpp__
|
Reference in New Issue
Block a user