format clang-format

This commit is contained in:
Hamidreza Norouzi
2024-04-08 12:33:08 -07:00
parent a9290e911b
commit ff8968e595
36 changed files with 3353 additions and 3505 deletions

View File

@ -2,17 +2,17 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: Licence:
This file is part of phasicFlow code. It is a free software for simulating This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions. the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@ -22,155 +22,141 @@ Licence:
/** /**
* \file KokkosType.hpp * \file KokkosType.hpp
* *
* \brief name aliases and typedesf for Kokkos entities that are * \brief name aliases and typedesf for Kokkos entities that are
* frequently used in PhasicFlow. * frequently used in PhasicFlow.
* *
*/ */
#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
using HostSpace = Kokkos::HostSpace;
/// Host memory space /// Serial execution space
using HostSpace = Kokkos::HostSpace; using Serial = Kokkos::Serial;
/// Serial execution space
using Serial = Kokkos::Serial;
#ifdef _OPENMP #ifdef _OPENMP
/// OpenMp execution space /// OpenMp execution space
using OpenMP = Kokkos::OpenMP; using OpenMP = Kokkos::OpenMP;
#endif #endif
#ifdef __CUDACC__ #ifdef __CUDACC__
/// Cuda execution space /// Cuda execution space
using Cuda = Kokkos::Cuda; using Cuda = Kokkos::Cuda;
#endif #endif
/// Default Host execution space, on top of all host execution spaces /// Default Host execution space, on top of all host execution spaces
using DefaultHostExecutionSpace = Kokkos::DefaultHostExecutionSpace; using DefaultHostExecutionSpace = Kokkos::DefaultHostExecutionSpace;
/// Default execution space, it can be device exe. space, if a device space is /// Default execution space, it can be device exe. space, if a device space is
/// activated. /// activated.
using DefaultExecutionSpace = Kokkos::DefaultExecutionSpace; using DefaultExecutionSpace = Kokkos::DefaultExecutionSpace;
using deviceRPolicyStatic = Kokkos::RangePolicy<
Kokkos::DefaultExecutionSpace,
Kokkos::Schedule<Kokkos::Static>,
Kokkos::IndexType<pFlow::uint32>>;
using deviceRPolicyStatic = using hostRPolicyStatic = Kokkos::RangePolicy<
Kokkos::RangePolicy< Kokkos::DefaultExecutionSpace,
Kokkos::DefaultExecutionSpace, Kokkos::Schedule<Kokkos::Static>,
Kokkos::Schedule<Kokkos::Static>, Kokkos::IndexType<pFlow::uint32>>;
Kokkos::IndexType<pFlow::uint32> >;
using deviceRPolicyDynamic = Kokkos::RangePolicy<
Kokkos::DefaultExecutionSpace,
Kokkos::Schedule<Kokkos::Dynamic>,
Kokkos::IndexType<pFlow::uint32>>;
using hostRPolicyStatic = using hostRPolicyDynamic = Kokkos::RangePolicy<
Kokkos::RangePolicy< Kokkos::DefaultExecutionSpace,
Kokkos::DefaultExecutionSpace, Kokkos::Schedule<Kokkos::Dynamic>,
Kokkos::Schedule<Kokkos::Static>, Kokkos::IndexType<pFlow::uint32>>;
Kokkos::IndexType<pFlow::uint32> >;
using deviceRPolicyDynamic =
Kokkos::RangePolicy<
Kokkos::DefaultExecutionSpace,
Kokkos::Schedule<Kokkos::Dynamic>,
Kokkos::IndexType<pFlow::uint32> >;
using hostRPolicyDynamic =
Kokkos::RangePolicy<
Kokkos::DefaultExecutionSpace,
Kokkos::Schedule<Kokkos::Dynamic>,
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>;
/// View for a scalar /// View for a scalar
template<typename T, typename... properties> template<typename T, typename... properties>
using ViewTypeScalar = Kokkos::View<T,properties...>; using ViewTypeScalar = Kokkos::View<T, properties...>;
/// 1D veiw as a vector /// 1D veiw as a vector
template<typename T, typename... properties> template<typename T, typename... properties>
using ViewType1D = Kokkos::View<T*,properties...>; using ViewType1D = Kokkos::View<T*, properties...>;
/// 2D view as an array /// 2D view as an array
template<typename T, typename... properties> template<typename T, typename... properties>
using ViewType2D = Kokkos::View<T**,properties...>; using ViewType2D = Kokkos::View<T**, properties...>;
/// 3D view as an array /// 3D view as an array
template<typename T, typename... properties> template<typename T, typename... properties>
using ViewType3D = Kokkos::View<T***,properties...>; using ViewType3D = Kokkos::View<T***, properties...>;
/// 1D dual view as a vector /// 1D dual view as a vector
template<typename T, typename... properties> template<typename T, typename... properties>
using DualViewType1D = Kokkos::DualView<T*,properties...>; using DualViewType1D = Kokkos::DualView<T*, properties...>;
/// unordered map /// unordered map
template<typename Key, typename Value, typename... properties> template<typename Key, typename Value, typename... properties>
using unorderedMap = Kokkos::UnorderedMap<Key, Value, properties...>; using unorderedMap = Kokkos::UnorderedMap<Key, Value, properties...>;
/// unordered set /// unordered set
template<typename Key, typename... properties> template<typename Key, typename... properties>
using unorderedSet = Kokkos::UnorderedMap<Key, void, properties...>; using unorderedSet = Kokkos::UnorderedMap<Key, void, properties...>;
/// Scalar on device /// Scalar on device
template<typename T> template<typename T>
using deviceViewTypeScalar = Kokkos::View<T>; using deviceViewTypeScalar = Kokkos::View<T>;
/// 1D array (vector) with default device (memory space and execution space) /// 1D array (vector) with default device (memory space and execution space)
template<typename T> template<typename T>
using deviceViewType1D = Kokkos::View<T*>; using deviceViewType1D = Kokkos::View<T*>;
/// 2D view on device as an array on device
template<typename T, typename Layout=void>
using deviceViewType2D = Kokkos::View<T**,Layout, void>;
/// 3D view on device as an array on device
template<typename T, typename Layout=void>
using deviceViewType3D = Kokkos::View<T***,Layout, void>;
/// 2D view on device as an array on device
template<typename T, typename Layout = void>
using deviceViewType2D = Kokkos::View<T**, Layout, void>;
/// 3D view on device as an array on device
template<typename T, typename 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>;
/// 1D array (vector with host memeory space) /// 1D array (vector with host memeory space)
template<typename T> template<typename T>
using hostViewType1D = Kokkos::View<T*, Kokkos::HostSpace>; using hostViewType1D = Kokkos::View<T*, Kokkos::HostSpace>;
/// 2D array on host /// 2D array on host
template<typename T, typename Layout=void> template<typename T, typename Layout = void>
using hostViewType2D = Kokkos::View<T**,Layout, Kokkos::HostSpace>; using hostViewType2D = Kokkos::View<T**, Layout, Kokkos::HostSpace>;
/// 3D array on host /// 3D array on host
template<typename T, typename Layout=void> template<typename T, typename Layout = void>
using hostViewType3D = Kokkos::View<T***,Layout, Kokkos::HostSpace>; using hostViewType3D = Kokkos::View<T***, Layout, Kokkos::HostSpace>;
/// 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<
Kokkos::MemoryTraits<std::is_same<DefaultExecutionSpace,Serial>::value?0:Kokkos::Atomic>>; 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<
Kokkos::MemoryTraits<std::is_same<DefaultExecutionSpace,Serial>::value?0:Kokkos::Atomic>>; std::is_same_v<DefaultExecutionSpace, Serial> ? 0 : Kokkos::Atomic>>;
} // pFlow } // pFlow
#endif //__KokkosTypes_hpp__ #endif //__KokkosTypes_hpp__

View File

@ -2,17 +2,17 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: Licence:
This file is part of phasicFlow code. It is a free software for simulating This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions. the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@ -21,209 +21,205 @@ 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);
}
template <
typename Type,
typename... Properties>
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> reallocNoInit(ViewType1D<Type, Properties...>& view, uint32 len)
INLINE_FUNCTION_H {
void reallocFill( ViewType1D<Type,Properties...>& view, uint32 len, Type val) Kokkos::realloc(Kokkos::WithoutInitializing, view, len);
}
template<typename Type, typename... Properties>
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;
return os; return os;
} }
} // pFlow } // pFlow
#endif //__KokkosUtilities_hpp__ #endif //__KokkosUtilities_hpp__

View File

@ -2,17 +2,17 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: Licence:
This file is part of phasicFlow code. It is a free software for simulating This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions. the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@ -20,140 +20,132 @@ 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>;
TypeInfoTemplateNV11("Range", T) TypeInfoTemplateNV11("Range", 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
INLINE_FUNCTION_HD
Range(const T& s, const T& e)
:
Range::Pair(s,e)
{}
/// From pair /// From componeents
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
Range(const Range::Pair &src ) Range(const T& s, const T& e)
: : Range::Pair(s, e)
Range::Pair(src) {
{} }
/// Copy /// From pair
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
Range(const Range&) = default; Range(const Range::Pair& src)
: Range::Pair(src)
{
}
/// Move /// Copy
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
Range(Range&&) = default; Range(const Range&) = default;
/// Copy assignment /// Move
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
Range& operator=(const Range&) = default; Range(Range&&) = default;
/// Move assignment /// Copy assignment
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
Range& operator=(Range&&) = default; Range& operator=(const Range&) = default;
/// Destructor /// Move assignment
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
~Range()=default; Range& operator=(Range&&) = default;
/// Destructor
INLINE_FUNCTION_HD
~Range() = default;
//// - Methods //// - Methods
/// Start /// Start
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
T& start() T& start()
{ {
return this->first; return this->first;
} }
/// End /// End
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
T& end() T& end()
{ {
return this->second; return this->second;
} }
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
const T& start()const const T& start() const
{ {
return this->first; return this->first;
} }
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
const T& end()const const T& end() const
{ {
return this->second; return this->second;
} }
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
T numElements() T numElements()
{ {
return end()-start(); return end() - start();
} }
INLINE_FUNCTION_HD
auto getPair()const
{
return Pair(this->first, this->second);
}
INLINE_FUNCTION_HD
auto getPair() const
{
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;
} }
using range32 = Range<int32>; using range32 = Range<int32>;
using range64 = Range<int64>; using range64 = Range<int64>;
using rangeU32 = Range<uint32>; using rangeU32 = Range<uint32>;
using rangeU64 = Range<uint64>;
using rangeU64 = Range<uint64>;
} // pFlow } // pFlow
#endif //__KokkosTypes_hpp__ #endif //__KokkosTypes_hpp__

View File

@ -2,17 +2,17 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: Licence:
This file is part of phasicFlow code. It is a free software for simulating This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions. the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@ -21,57 +21,48 @@ 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>
INLINE_FUNCTION_H
uint32 count(
const ViewType1D<T, properties...>& view,
uint32 start,
uint32 end,
const T& val)
{ {
using ExecutionSpace = typename ViewType1D<T, properties...>::execution_space;
uint32 numElems = end-start;
return pFlow::algorithms::KOKKOS::count<T, ExecutionSpace>
(
view.data()+start,
numElems,
val
);
}
template<typename T, typename... properties> template<typename T, typename... properties>
INLINE_FUNCTION_H INLINE_FUNCTION_H uint32
void fill count(
( const ViewType1D<T, properties...>& view,
ViewType1D<T, properties...>& view, uint32 start,
rangeU32 span, uint32 end,
T val const T& val
) )
{
using ExecutionSpace =
typename ViewType1D<T, properties...>::execution_space;
uint32 numElems = end - start;
return pFlow::algorithms::KOKKOS::count<T, ExecutionSpace>(
view.data() + start, numElems, val
);
}
template<typename T, typename... properties>
INLINE_FUNCTION_H void
fill(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());
if constexpr ( std::is_trivially_copyable_v<T>) if constexpr (std::is_trivially_copyable_v<T>)
{ {
Kokkos::deep_copy(subV, val); Kokkos::deep_copy(subV, val);
} }
else if constexpr( isHostAccessible<exe_space>()) else if constexpr (isHostAccessible<exe_space>())
{ {
for(auto i=span.start(); i<span.end(); i++ ) for (auto i = span.start(); i < span.end(); i++)
{ {
view[i] = val; view[i] = val;
} }
@ -80,29 +71,23 @@ 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,
rangeU32 range3, rangeU32 range3,
const T& val 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");
@ -111,222 +96,201 @@ 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");
using ExecutionSpace = typename ViewType1D<Type, properties...>::execution_space;
uint32 numElems = end-start;
pFlow::algorithms::KOKKOS::fillSequence<Type, ExecutionSpace>(
view.data()+start,
numElems,
startVal);
return ;
}
template<
typename Type,
typename... properties,
typename indexType,
typename... indexProperties>
bool fillSelected
(
ViewType1D<Type, properties...> view,
ViewType1D<indexType, indexProperties...> indices,
uint32 numElems,
Type val
) )
{ {
static_assert(std::is_trivially_copyable_v<Type>, "Not valid type for fillSelected");
static_assert( static_assert(
areAccessible< std::is_trivially_copyable_v<Type>, "Not valid type for fill"
typename ViewType1D<Type, properties...>::execution_space, );
typename ViewType1D<indexType, indexProperties...>::memory_space>(), using ExecutionSpace =
"In fillSelected, arguments view and indices must have similar spaces"); typename ViewType1D<Type, properties...>::execution_space;
uint32 numElems = end - start;
pFlow::algorithms::KOKKOS::fillSequence<Type, ExecutionSpace>(
view.data() + start, numElems, startVal
);
return;
}
template<
typename Type,
typename... properties,
typename indexType,
typename... indexProperties>
bool
fillSelected(
ViewType1D<Type, properties...> view,
ViewType1D<indexType, indexProperties...> indices,
uint32 numElems,
Type val
)
{
static_assert(
std::is_trivially_copyable_v<Type>, "Not valid type for fillSelected"
);
static_assert(
areAccessible<
typename ViewType1D<Type, properties...>::execution_space,
typename ViewType1D<indexType, indexProperties...>::memory_space>(),
"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>>;
Kokkos::parallel_for( Kokkos::parallel_for(
"ViewAlgorithms::fillSelected", "ViewAlgorithms::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;
} }
template< template<
typename Type, typename Type,
typename... properties, typename... properties,
typename indexType, typename indexType,
typename... indexProperties> typename... indexProperties>
bool fillSelected( bool
ViewType1D<Type, properties...> view, fillSelected(
const ViewType1D<indexType, indexProperties...> indices, ViewType1D<Type, properties...> view,
const ViewType1D<Type, properties...> vals, const ViewType1D<indexType, indexProperties...> indices,
const uint32 numElems ) const ViewType1D<Type, properties...> vals,
const uint32 numElems
)
{ {
static_assert(std::is_trivially_copyable_v<Type>, "Not valid type for fillSelected");
static_assert( static_assert(
areAccessible< std::is_trivially_copyable_v<Type>, "Not valid type for fillSelected"
typename ViewType1D<Type, properties...>::execution_space, );
typename ViewType1D<indexType, indexProperties...>::memory_space>(), static_assert(
"In fillSelected arguments view and indices must have similar spaces"); areAccessible<
typename ViewType1D<Type, properties...>::execution_space,
typename ViewType1D<indexType, indexProperties...>::memory_space>(),
"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 =
typename ViewType1D<T, properties...>::execution_space;
using ExecutionSpace = typename ViewType1D<T, properties...>::execution_space; uint32 numElems = end - start;
uint32 numElems = end-start; return pFlow::algorithms::KOKKOS::min<T, ExecutionSpace>(
view.data() + start, numElems
return );
pFlow::algorithms::KOKKOS::min<T, ExecutionSpace>(
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 =
typename ViewType1D<T, properties...>::execution_space;
using ExecutionSpace = 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 <
typename dType,
typename... dProperties,
typename sType,
typename... sProperties>
INLINE_FUNCTION_H
void copy(
const ViewType1D<dType, dProperties...>& dst,
const ViewType1D<sType, sProperties...>& src
)
{
Kokkos::deep_copy(dst,src);
} }
template < template<
typename dType, typename dType,
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, const ViewType1D<sType, sProperties...>& src
const ViewType1D<sType, sProperties...>& src, )
uint32 sStart,
uint32 sEnd
)
{ {
Kokkos::deep_copy(dst, src);
range32 sSpan(sStart,sEnd);
range32 dSpan(dStart,dStart+(sEnd-sStart));
auto srcSub = Kokkos::subview(src, sSpan);
auto dstSub = Kokkos::subview(dst, dSpan);
Kokkos::deep_copy(dstSub,srcSub);
} }
template < template<
typename Type, typename dType,
typename... sProperties> typename... dProperties,
INLINE_FUNCTION_H typename sType,
void getNth( typename... sProperties>
Type& dst, INLINE_FUNCTION_H void
const ViewType1D<Type, sProperties...>& src, copy(
const uint32 n const ViewType1D<dType, dProperties...>& dst,
) uint32 dStart,
const ViewType1D<sType, sProperties...>& src,
uint32 sStart,
uint32 sEnd
)
{ {
range32 sSpan(sStart, sEnd);
auto subV = Kokkos::subview(src, Kokkos::make_pair(n,n+1)); range32 dSpan(dStart, dStart + (sEnd - sStart));
hostViewType1D<Type> dstView("getNth",1);
//hostViewTypeScalar auto srcSub = Kokkos::subview(src, sSpan);
Kokkos::deep_copy(dstView,subV); auto dstSub = Kokkos::subview(dst, dSpan);
Kokkos::deep_copy(dstSub, srcSub);
}
template<typename Type, typename... sProperties>
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));
hostViewType1D<Type> dstView("getNth", 1);
// hostViewTypeScalar
Kokkos::deep_copy(dstView, subV);
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;
if constexpr( isHostAccessible<ExecutionSpace>()) uint32 numElems = end - start;
{
pFlow::algorithms::STD::sort<T,true>( if constexpr (isHostAccessible<ExecutionSpace>())
view.data()+start, {
numElems); pFlow::algorithms::STD::sort<T, true>(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 =
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,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!");
@ -372,163 +335,157 @@ void sort(
} }
template< template<
typename Type, typename Type,
typename... properties, typename... properties,
typename permType, typename permType,
typename... permProperties> typename... permProperties>
void permuteSort( void
const ViewType1D<Type, properties...>& view, permuteSort(
uint32 start, const ViewType1D<Type, properties...>& view,
uint32 end, uint32 start,
ViewType1D<permType, permProperties...>& permuteView, uint32 end,
uint32 permStart ) ViewType1D<permType, permProperties...>& permuteView,
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>(
view.data()+start, pFlow::algorithms::STD::permuteSort<Type, permType, true>(
permuteView.data()+permStart, view.data() + start, permuteView.data() + permStart, numElems
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 high = length - 1;
while (low <= high) int low = 0;
{ int high = length - 1;
int mid = low + (high - low)/2;
if ( array[mid] > val)
{
high = mid - 1;
}
else if ( array[mid] < val)
{
low = mid + 1;
}
else
{
return mid;
}
}
return -1; // val not found in array[0, length) while (low <= high)
{
int mid = low + (high - low) / 2;
if (array[mid] > val)
{
high = mid - 1;
}
else if (array[mid] < val)
{
low = mid + 1;
}
else
{
return mid;
}
}
return -1; // val not found in array[0, length)
} }
/// 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 const ViewType1D<Type, properties...>& view,
uint32 binarySearch( uint32 start,
const ViewType1D<Type, properties...>& view, uint32 end,
uint32 start, const Type& val
uint32 end, )
const Type& val)
{ {
if (end <= start)
if(end<=start)return -1; return -1;
if(auto res = if (auto res = binarySearch_(view.data() + start, end - start, val);
binarySearch_(view.data()+start,end-start,val); res!=-1) { 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> const ViewType1D<Type, properties...>& view,
void exclusiveScan( uint32 start,
const ViewType1D<Type, properties...>& view, uint32 end,
uint32 start, ViewType1D<Type, dProperties...>& dView,
uint32 end, uint32 dStart
ViewType1D<Type, dProperties...>& dView, )
uint32 dStart )
{ {
static_assert(
static_assert areAccessible<
( typename ViewType1D<Type, properties...>::execution_space,
areAccessible< typename ViewType1D<Type, dProperties...>::memory_space>(),
typename ViewType1D<Type, properties...>::execution_space, "In exclusiveScan, view and dView should have the same space"
typename ViewType1D<Type, dProperties...>::memory_space>(),
"In exclusiveScan, view and dView 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::KOKKOS::exclusiveScan<Type,ExecutionSpace>(
view.data()+start, pFlow::algorithms::KOKKOS::exclusiveScan<Type, ExecutionSpace>(
dView.data()+dStart, view.data() + start, dView.data() + dStart, numElems
numElems); );
} }
template<typename Type, typename... properties, typename... dProperties>
template< void
typename Type, inclusiveScan(
typename... properties, const ViewType1D<Type, properties...>& view,
typename... dProperties> uint32 start,
void inclusiveScan( uint32 end,
const ViewType1D<Type, properties...>& view, ViewType1D<Type, dProperties...>& dView,
uint32 start, uint32 dStart
uint32 end, )
ViewType1D<Type, dProperties...>& dView,
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>(
view.data() + start, dView.data() + dStart, numElems
pFlow::algorithms::KOKKOS::inclusiveScan<Type,ExecutionSpace>( );
view.data()+start,
dView.data()+dStart,
numElems);
} }
} // pFlow } // pFlow
#endif // __ViewAlgorithms_hpp__
#endif // Viewalgorithms

View File

@ -2,50 +2,50 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: Licence:
This file is part of phasicFlow code. It is a free software for simulating This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions. the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/ -----------------------------------------------------------------------------*/
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
); );

View File

@ -2,17 +2,17 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: Licence:
This file is part of phasicFlow code. It is a free software for simulating This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions. the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@ -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;
@ -31,81 +30,80 @@ namespace pFlow
{ {
// counts the number of elements that matches val // counts the number of elements that matches val
// the execution space is selected based on the View::execution_spcae // the execution space is selected based on the View::execution_spcae
/*template<typename T, typename... properties> /*template<typename T, typename... properties>
INLINE_FUNCTION_H INLINE_FUNCTION_H
size_t count( size_t count(
const ViewType1D<T, properties...>& view, const ViewType1D<T, properties...>& view,
size_t start, size_t start,
size_t end, size_t end,
const T& val const T& val
) )
{ {
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);
size_t totalNum=0; size_t totalNum=0;
Kokkos::parallel_reduce( Kokkos::parallel_reduce(
"baseAlgorithms-count", "baseAlgorithms-count",
RP, RP,
LAMBDA_HD(label i, size_t & valueToUpdate){ LAMBDA_HD(label i, size_t & valueToUpdate){
if( equal(view[i], val) ) valueToUpdate += 1; if( equal(view[i], val) ) valueToUpdate += 1;
}, totalNum ); }, totalNum );
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(
RP, "baseAlgorithms-min",
LAMBDA_HD(label i, T& valueToUpdate){ RP,
valueToUpdate = min(view[i],valueToUpdate); LAMBDA_HD(label i, T & valueToUpdate) {
}, valueToUpdate = min(view[i], valueToUpdate);
Kokkos :: Min < T >( minValue ) },
); Kokkos ::Min<T>(minValue)
);
return minValue; return minValue;
} }
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(
RP, "baseAlgorithms-max",
LAMBDA_HD(label i, T& valueToUpdate){ RP,
valueToUpdate = max(view[i],valueToUpdate); LAMBDA_HD(label i, T & valueToUpdate) {
}, valueToUpdate = max(view[i], valueToUpdate);
Kokkos::Max<T>( maxValue ) },
); Kokkos::Max<T>(maxValue)
);
return maxValue; return maxValue;
} }
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)
{ {
minValue = min(minValue, view[i]); minValue = min(minValue, view[i]);
} }
@ -113,116 +111,113 @@ 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)
{ {
maxValue = max(maxValue, view[i]); maxValue = max(maxValue, view[i]);
} }
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(
auto RP = Kokkos::RangePolicy< const ViewType1D<T, properties...>& view,
Kokkos::IndexType<size_t>, size_t start,
typename ViewType1D<T, properties...>::execution_space >(start, end); size_t end,
UnaryFunction func
Kokkos::parallel_for("baseAlgorithms-for_each",
RP,
LAMBDA_HD(label i){
view[i] = func(i);
}
);
}
template<typename T, typename... properties>
void insertSetElementH
(
ViewType1D<T, properties...>& view,
hostViewType1D<label>& selected,
T val
) )
{ {
auto RP = Kokkos::RangePolicy<
for(auto i=0; i<selected.size();++i) Kokkos::IndexType<size_t>,
typename ViewType1D<T, properties...>::execution_space>(start, end);
Kokkos::parallel_for(
"baseAlgorithms-for_each", RP, LAMBDA_HD(label i) { view[i] = func(i); }
);
}
template<typename T, typename... properties>
void
insertSetElementH(
ViewType1D<T, properties...>& view,
hostViewType1D<label>& selected,
T val
)
{
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]);
} }
} }
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
) )
{ {
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
) )
{ {
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,
range range3, range range3,
T val T val
) )
{ {
auto subV = Kokkos::subview(view, range1, range2, range3); auto subV = Kokkos::subview(view, range1, range2, range3);
@ -231,5 +226,4 @@ void fill
} }
#endif // __VectorSingleMath_hpp__ #endif // __VectorSingleMath_hpp__

View File

@ -2,17 +2,17 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: Licence:
This file is part of phasicFlow code. It is a free software for simulating This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions. the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@ -23,81 +23,72 @@ 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_)
{ {
parrent_->removeFromList(this); parrent_->removeFromList(this);
} }
} }
pFlow::int32 pFlow::Timer::level()const pFlow::int32 pFlow::Timer::level() const
{ {
if(parrent_) if (parrent_)
return parrent_->level()+1; return parrent_->level() + 1;
else else
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++)
{ {
os<<""; os << "";
} }
if(lvl>0) if (lvl > 0)
{ {
if (master())
if(master()) os << "┣━━ ";
os<<"┣━━ "; else if (lvl == 1)
os << "┃└─ ";
else else
if(lvl==1) os << " └─ ";
os<<"┃└─ ";
else
os<<" └─ ";
} }
else else
; //os<<"⊿ "; ; // os<<"⊿ ";
if(lvl==0)
os<<greenColor<<boldChar;
else if(master())
os<<yellowColor;
if (lvl == 0)
os << greenColor << boldChar;
else if (master())
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()<<").";
} }
} }
os<<defaultColor; os << defaultColor;
os<<'\n'; os << '\n';
return true; return true;
} }

View File

@ -2,40 +2,35 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: Licence:
This file is part of phasicFlow code. It is a free software for simulating This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions. the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/ -----------------------------------------------------------------------------*/
#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:
@ -43,25 +38,26 @@ protected:
using timer = std::chrono::high_resolution_clock; using timer = std::chrono::high_resolution_clock;
/// start time /// start time
timer::time_point start_; timer::time_point start_;
/// number of times start() and end() are called /// number of times start() and end() are called
int32 numIteration_ = 0; int32 numIteration_ = 0;
/// sum of time duratios (in seconds) between all start() and end() calls /// sum of time duratios (in seconds) between all start() and end() calls
real accTime_ = 0.0; real accTime_ = 0.0;
/// 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
real stepAccTime_ = 0.0; /// end()
real stepAccTime_ = 0.0;
/// name for the timer /// name for the timer
word name_ = "noNameTimer"; word name_ = "noNameTimer";
/// @brief parrent of timer /// @brief parrent of timer
Timers* parrent_ = nullptr; Timers* parrent_ = nullptr;
public: public:
@ -70,45 +66,45 @@ 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_;
} }
virtual ~Timer(); virtual ~Timer();
virtual void removeParrent() virtual void removeParrent()
{ {
parrent_ = nullptr; parrent_ = nullptr;
} }
virtual int32 level()const; virtual int32 level() const;
virtual bool master()const virtual bool master() const
{ {
return false; return false;
} }
void start() void start()
{ {
start_ = timer::now(); start_ = timer::now();
stepAccTime_ = 0; stepAccTime_ = 0;
} }
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()
@ -119,46 +115,40 @@ public:
void end() void end()
{ {
pause(); pause();
lastTime_ = stepAccTime_; lastTime_ = stepAccTime_;
numIteration_++; numIteration_++;
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();
} }
//// - IO operations //// - IO operations
virtual bool write(iOstream& os, bool subTree)const; virtual bool write(iOstream& os, bool subTree) const;
virtual bool read(iIstream& is) virtual bool read(iIstream& is)
{ {
@ -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__

View File

@ -2,22 +2,21 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: Licence:
This file is part of phasicFlow code. It is a free software for simulating This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions. the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
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__
@ -26,19 +25,16 @@ Licence:
#include "periodicBoundaryField/periodicBoundaryField.hpp" #include "periodicBoundaryField/periodicBoundaryField.hpp"
#include "reflectiveBoundaryField/reflectiveBoundaryField.hpp" #include "reflectiveBoundaryField/reflectiveBoundaryField.hpp"
#define createDerivedBoundary(DataType, MemorySpaceType) \ #define createDerivedBoundary(DataType, MemorySpaceType) \
template class pFlow::exitBoundaryField<DataType, MemorySpaceType>; \ template class pFlow::exitBoundaryField<DataType, MemorySpaceType>; \
template class pFlow::periodicBoundaryField<DataType, MemorySpaceType>; \ template class pFlow::periodicBoundaryField<DataType, MemorySpaceType>; \
template class pFlow::reflectiveBoundaryField<DataType, MemorySpaceType>; template class pFlow::reflectiveBoundaryField<DataType, MemorySpaceType>;
#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__

View File

@ -2,17 +2,17 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: Licence:
This file is part of phasicFlow code. It is a free software for simulating This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions. the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@ -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::pOutput;
//static pFlow::Ostream& errorStream = pFlow::errReport; pFlow::iOstream&
fatalErrorMessage(const char* fileName, int linNumber)
static pFlow::Ostream& errorStream = pFlow::pOutput; {
errorStream << "\n>>> Fatal error in phasicFlow\n"
<< "Error occured in source file " << Red_Text(fileName)
pFlow::iOstream& fatalErrorMessage(const char* fileName, int linNumber ) << " at line " << Red_Text(linNumber) << '\n';
{
errorStream<<"\n>>> Fatal error in phasicFlow\n" <<
"Error occured in source file "<< Red_Text(fileName) <<
" 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"
errorStream<<"\n>>> Fatal error in phasicFlow\n"; << " Error is issued in function " << Red_Text(fnName)
errorStream<<" Function "<< Red_Text(fnName) << " has not been implemented yet!\n" << << ", located in file " << Red_Text(fileName) << " at line "
" File "<< Yellow_Text(fileName) << << Red_Text(linNumber) << '\n';
" 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) notImplementedErrorMessage(
const char* fnName,
const char* fileName,
int lineNumber
)
{ {
errorStream << "\n>>> Fatal error in phasicFlow\n";
errorStream<<"\n>>> Fatal IO file error\n"<< errorStream << " Function " << Red_Text(fnName)
" IO error at number "<<Red_Text(fileLineNumber)<< << " has not been implemented yet!\n"
" of file " << Red_Text(fileName)<<'\n'; << " File " << Yellow_Text(fileName) << " at line "
errorStream<<" IO operation is peformed from function "<<Red_Text(fnName) << << Yellow_Text(lineNumber) << '\n';
" in file "<< Red_Text(fName)<< " 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 char* fileName,
int fileLineNumber,
const char* fnName,
const char* fName,
int lNumber
)
{ {
return ioErrorMessage( fileName.c_str(), fileLineNumber, fnName, fName, lNumber); errorStream << "\n>>> Fatal IO file error\n"
} << " IO error at number " << Red_Text(fileLineNumber)
<< " of file " << Red_Text(fileName) << '\n';
errorStream << " IO operation is peformed from function "
pFlow::iOstream& warningMessage(const char* fnName, const char* fileName, int linNumber ) << Red_Text(fnName) << " in file " << Red_Text(fName)
{ << " at line " << Red_Text(lNumber) << '\n';
errorStream<<"\n>>> Warning in phasicFlow\n"<<
" Warning is issued in function " << Yellow_Text(fnName)<<
" in source file "<< Yellow_Text(fileName) <<
" at line "<< Yellow_Text(linNumber) <<'\n';
return errorStream; return errorStream;
} }
pFlow::iOstream& reportAndExit(int errorCode) pFlow::iOstream&
ioErrorMessage(
const pFlow::word& fileName,
int fileLineNumber,
const char* fnName,
const char* fName,
int lNumber
)
{ {
errorStream<<"\n>>> phasicFlow is exiting . . ." << pFlow::endl; return ioErrorMessage(
fileName.c_str(), fileLineNumber, fnName, fName, lNumber
);
}
pFlow::iOstream&
warningMessage(const char* fnName, const char* fileName, int linNumber)
{
errorStream << "\n>>> Warning in phasicFlow\n"
<< " Warning is issued in function " << Yellow_Text(fnName)
<< " in source file " << Yellow_Text(fileName) << " at line "
<< Yellow_Text(linNumber) << '\n';
return errorStream;
}
pFlow::iOstream&
reportAndExit(int errorCode)
{
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();

View File

@ -2,17 +2,17 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: Licence:
This file is part of phasicFlow code. It is a free software for simulating This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions. the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@ -21,62 +21,80 @@ 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&
pFlow::iOstream& fatalErrorInMessage(const char* fnName, const char* fileName, int linNumber ); fatalErrorMessage(const char* fileName, int linNumber);
pFlow::iOstream& notImplementedErrorMessage(const char*fnName, const char* fileName, int lineNumber); pFlow::iOstream&
pFlow::iOstream& ioErrorMessage(const pFlow::word& fileName, int fileLineNumber, const char* fnName, const char* fName, int lNumber); fatalErrorInMessage(const char* fnName, const char* fileName, int linNumber);
pFlow::iOstream& ioErrorMessage(const char* fileName, int fileLineNumber, const char* fnName, const char* fName, int lNumber); pFlow::iOstream&
pFlow::iOstream& warningMessage(const char* fnName, const char* fileName, int linNumber ); notImplementedErrorMessage(
pFlow::iOstream& reportAndExit(int errorCode = EXIT_FAILURE); 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
#define fatalError fatalErrorMessage(__FILE__, __LINE__)
/// Report a fatal error and exit the applicaiton /// Report a fatal error and supplied function name and exit the application
#define fatalError \ #define fatalErrorIn(functionName) \
fatalErrorMessage(__FILE__, __LINE__) fatalErrorInMessage((functionName), __FILE__, __LINE__)
/// Report a fatal error and supplied function name and exit the application /// Report a fatal error and function name and exit the application
#define fatalErrorIn( functionName ) \
fatalErrorInMessage((functionName), __FILE__, __LINE__ )
/// Report a fatal error and function name and exit the application
#define fatalErrorInFunction fatalErrorIn(FUNCTION_NAME) #define fatalErrorInFunction fatalErrorIn(FUNCTION_NAME)
/// Report that a function is yet not implemented with supplied function name. /// Report that a function is yet not implemented with supplied function name.
#define Not_Implemented(functionName) \ #define Not_Implemented(functionName) \
notImplementedErrorMessage ((functionName), __FILE__, __LINE__ ) notImplementedErrorMessage((functionName), __FILE__, __LINE__)
/// Report that a function is yet not implemented. /// Report that a function is yet not implemented.
#define notImplementedFunction Not_Implemented(FUNCTION_NAME) #define notImplementedFunction Not_Implemented(FUNCTION_NAME)
/// Report an error in file operation with supplied fileName and lineNumber. /// Report an error in file operation with supplied fileName and lineNumber.
#define ioErrorInFile( fileName, lineNumber) \ #define ioErrorInFile(fileName, lineNumber) \
ioErrorMessage( fileName, lineNumber, FUNCTION_NAME, __FILE__, __LINE__ ) ioErrorMessage(fileName, lineNumber, FUNCTION_NAME, __FILE__, __LINE__)
/// Report a warning with supplied function name /// Report a warning with supplied function name
#define warningIn( functionName ) \ #define warningIn(functionName) \
warningMessage((functionName), __FILE__, __LINE__ ) warningMessage((functionName), __FILE__, __LINE__)
/// Report a warning /// Report a warning
#define warningInFunction warningIn(FUNCTION_NAME) #define warningInFunction warningIn(FUNCTION_NAME)
/// Fatal exit /// Fatal exit
#define fatalExit \ #define fatalExit reportAndExit()
reportAndExit()
#endif #endif

View File

@ -2,17 +2,17 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: Licence:
This file is part of phasicFlow code. It is a free software for simulating This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions. the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@ -21,40 +21,36 @@ Licence:
#ifndef __vocabs_hpp__ #ifndef __vocabs_hpp__
#define __vocabs_hpp__ #define __vocabs_hpp__
namespace pFlow namespace pFlow
{ {
// folders / repositories // folders / repositories
const inline char* settingsFolder__ = "settings"; const inline char* settingsFolder__ = "settings";
const inline char* settingsRepository__ = "settings"; const inline char* settingsRepository__ = "settings";
const inline char* caseSetupFolder__ = "caseSetup"; const inline char* caseSetupFolder__ = "caseSetup";
const inline char* caseSetupRepository__ = "caseSetup"; const inline char* caseSetupRepository__ = "caseSetup";
const inline char* geometryFolder__ = "geometry"; const inline char* geometryFolder__ = "geometry";
const inline char* geometryRepository_ = "geometry"; const inline char* geometryRepository_ = "geometry";
const inline char* integrationRepository__ = "integration"; const inline char* integrationRepository__ = "integration";
const inline char* integrationFolder__ = "integration"; const inline char* integrationFolder__ = "integration";
// file names // file names
const inline char* settingsFile__ = "settingsDict"; const inline char* settingsFile__ = "settingsDict";
const inline char* domainFile__ = "domainDict"; const inline char* domainFile__ = "domainDict";
const inline char* insertionFile__ = "particleInsertion"; const inline char* insertionFile__ = "particleInsertion";
const inline char* shapeFile__ = "shapes"; const inline char* shapeFile__ = "shapes";
const inline char* pointStructureFile__ = "pStructure"; const inline char* pointStructureFile__ = "pStructure";
const inline char* triSurfaceFile__ = "triSurface"; const inline char* triSurfaceFile__ = "triSurface";
const inline char* createParticles__ = "createParticles"; const inline char* createParticles__ = "createParticles";
const inline char* motionModelFile__ = "motionModel"; const inline char* motionModelFile__ = "motionModel";
const inline char* contactSearchFile__ = "contactSearch"; const inline char* contactSearchFile__ = "contactSearch";
const inline char* propertyFile__ = "interaction"; 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__

View File

@ -2,114 +2,93 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: Licence:
This file is part of phasicFlow code. It is a free software for simulating This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions. the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/ -----------------------------------------------------------------------------*/
#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"));
if(wF == "ASCII") if (wF == "ASCII")
outFormatBinary_ = false; outFormatBinary_ = false;
else if(wF == "BINARY") else if (wF == "BINARY")
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, timeControl(setiingsDict),
const dictionary& setiingsDict geometry_(geometryRepository_, geometryFolder__, this)
{
if (!readDictionary(setiingsDict))
{
fatalExit;
}
}
pFlow::Time::Time(
repository* owner,
dictionary& setiingsDict,
real startTime,
real endTime,
real saveInterval,
word startTimeName
) )
: : repository("Time", "", owner),
repository("Time", "", owner), timeControl(setiingsDict, startTime, endTime, saveInterval, startTimeName),
timeControl(setiingsDict), geometry_(geometryRepository_, geometryFolder__, this)
geometry_
(
geometryRepository_,
geometryFolder__,
this
)
{ {
if (!readDictionary(setiingsDict))
if(!readDictionary(setiingsDict))
{ {
fatalExit; fatalExit;
} }
} }
pFlow::Time::Time( pFlow::fileSystem
repository* owner, pFlow::Time::localPath() const
dictionary& setiingsDict,
real startTime,
real endTime,
real saveInterval,
word startTimeName)
:
repository("Time", "", owner),
timeControl(
setiingsDict,
startTime,
endTime,
saveInterval,
startTimeName),
geometry_
(
geometryRepository_,
geometryFolder__,
this
)
{ {
if(!readDictionary(setiingsDict)) return fileSystem(timeName());
{
fatalExit;
}
} }
pFlow::fileSystem pFlow::Time::localPath()const pFlow::fileSystem
{ pFlow::Time::integrationFolder() const
return fileSystem(timeName());
}
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;

View File

@ -2,34 +2,31 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: Licence:
This file is part of phasicFlow code. It is a free software for simulating This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions. the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/ -----------------------------------------------------------------------------*/
#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,63 +34,59 @@ 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; // - geometry folder/repository
repository geometry_;
// - geometry folder/repository bool readDictionary(const dictionary& dict);
repository geometry_;
bool readDictionary(const dictionary& dict);
public: public:
// Constructor with owner and settings dict // Constructor with owner and settings dict
Time( repository* owner, const dictionary& setiingsDict); Time(repository* owner, const dictionary& setiingsDict);
Time(
repository* owner,
dictionary& setiingsDict,
real startTime,
real endTime,
real saveInterval,
word startTimeName);
Time(
repository* owner,
dictionary& setiingsDict,
real startTime,
real endTime,
real saveInterval,
word startTimeName
);
//// - Methods //// - Methods
fileSystem localPath()const override; fileSystem localPath() const override;
// - geometry repository
const repository& geometry()const
{
return geometry_;
}
repository& geometry() // - geometry repository
{ const repository& geometry() const
return geometry_; {
} return geometry_;
}
fileSystem integrationFolder()const; repository& geometry()
{
/// Write to the file with binary format? return geometry_;
bool outFileBinary()const override }
{
return outFormatBinary_;
}
// override the base write to manage write operation fileSystem integrationFolder() const;
// based on the valid write time intervals
virtual bool write(bool verbose = false) const; /// Write to the file with binary format?
bool outFileBinary() const override
{
return outFormatBinary_;
}
// override the base write to manage write operation
// based on the valid write time intervals
virtual bool write(bool verbose = false) const;
}; };
} // pFlow } // namespace pFlow
#endif // __Time_hpp__ #endif // __Time_hpp__

View File

@ -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;
}

View File

@ -44,10 +44,29 @@ public:
const dictionary& dict, const dictionary& dict,
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;
}; };
} }

View File

@ -2,48 +2,44 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: Licence:
This file is part of phasicFlow code. It is a free software for simulating This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions. the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/ -----------------------------------------------------------------------------*/
#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"))
{ {
wordList incld = dict.getVal<wordList>("includeObjects"); wordList incld = dict.getVal<wordList>("includeObjects");
for(auto& nm:incld) for (auto& nm : incld)
{ {
includeList_.insert(nm); includeList_.insert(nm);
} }
} }
if(dict.containsDataEntry("excludeObjects")) if (dict.containsDataEntry("excludeObjects"))
{ {
wordList excld = dict.getVal<wordList>("excludeObjects"); wordList excld = dict.getVal<wordList>("excludeObjects");
for(auto& nm:excld) for (auto& nm : excld)
{ {
excludeList_.insert(nm); excludeList_.insert(nm);
} }
@ -51,228 +47,149 @@ 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() + "/";
auto first = wPath.find_first_of('/'); auto first = wPath.find_first_of('/');
auto last = wPath.find_last_of('/'); auto last = wPath.find_last_of('/');
if (first == word::npos)
{
fatalErrorInFunction << "path is empty \n";
fatalExit;
}
if (last == wPath.size() - 1)
{
wPath = wPath.substr(0, last);
last = wPath.find_last_of('/');
}
word rName = wPath.substr(last + 1);
if( first == word::npos)
{
fatalErrorInFunction <<
"path is empty \n";
fatalExit;
}
if( last == wPath.size()-1)
{
wPath = wPath.substr(0,last);
last = wPath.find_last_of('/');
}
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();
auto first = wPath.find_first_of('/'); auto first = wPath.find_first_of('/');
auto last = wPath.find_last_of('/'); auto last = wPath.find_last_of('/');
if( first == word::npos) if (first == word::npos)
{ {
fatalErrorInFunction << fatalErrorInFunction << "path is empty \n";
"path is empty \n"; fatalExit;
fatalExit; }
}
if( last == wPath.size()-1) if (last == wPath.size() - 1)
{ {
wPath = wPath.substr(0,last); wPath = wPath.substr(0, last);
last = wPath.find_last_of('/'); last = wPath.find_last_of('/');
} }
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(
( "systemControl",
const fileSystem path path, // local path
) nullptr // no owner
:
repository
(
"systemControl",
path, // local path
nullptr // no owner
),
runName_
(
getRunName(path)
),
topLevelFolder_
(
getTopFolder(path)
),
settingsDict_
(
makeUnique<fileDictionary>
(
objectFile
(
settingsFile__,
settingsFolder__,
objectFile::READ_ALWAYS,
objectFile::WRITE_NEVER
),
this
)
), ),
Time_ runName_(getRunName(path)),
( topLevelFolder_(getTopFolder(path)),
this, settingsDict_(makeUnique<fileDictionary>(
settingsDict_() objectFile(
), settingsFile__,
settings_
(
makeUnique<repository>
(
settingsRepository__,
settingsFolder__, settingsFolder__,
this objectFile::READ_ALWAYS,
) objectFile::WRITE_NEVER
),
this
)),
Time_(this, settingsDict_()),
settings_(
makeUnique<repository>(settingsRepository__, settingsFolder__, this)
), ),
caseSetup_ caseSetup_(
( makeUnique<repository>(caseSetupRepository__, caseSetupFolder__, this)
makeUnique<repository> ),
(
caseSetupRepository__, libs_(settingsDict_()),
caseSetupFolder__, outFilePrecision_(
this settingsDict_().getValOrSet("outFilePrecision", static_cast<uint64>(6))
) ),
), timers_(runName_),
timersReport_(settingsDict_().getValOrSet("timersReport", Logical("Yes"))),
libs_(settingsDict_()), writeToFileTimer_("Write to file", &timers_)
outFilePrecision_
(
settingsDict_().getValOrSet("outFilePrecision", static_cast<uint64>(6))
),
timers_(runName_),
timersReport_
(
settingsDict_().getValOrSet("timersReport", Logical("Yes"))
),
writeToFileTimer_("Write to file", &timers_)
{ {
readIncludeExclue(settingsDict_()); readIncludeExclue(settingsDict_());
} }
pFlow::systemControl::systemControl( pFlow::systemControl::systemControl(
const real startTime, const real startTime,
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_
(
getRunName(path)
),
topLevelFolder_
(
getTopFolder(path)
),
settingsDict_
(
makeUnique<fileDictionary>
(
objectFile
(
settingsFile__,
settingsFolder__,
objectFile::READ_ALWAYS,
objectFile::WRITE_NEVER
),
this
)
), ),
Time_ runName_(getRunName(path)),
( topLevelFolder_(getTopFolder(path)),
this, settingsDict_(makeUnique<fileDictionary>(
settingsDict_(), objectFile(
startTime, settingsFile__,
endTime,
saveInterval,
startTimeName
),
settings_
(
makeUnique<repository>
(
settingsRepository__,
settingsFolder__, settingsFolder__,
this objectFile::READ_ALWAYS,
) objectFile::WRITE_NEVER
),
this
)),
Time_(
this,
settingsDict_(),
startTime,
endTime,
saveInterval,
startTimeName
), ),
caseSetup_ settings_(
( makeUnique<repository>(settingsRepository__, settingsFolder__, this)
makeUnique<repository> ),
( caseSetup_(
caseSetupRepository__, makeUnique<repository>(caseSetupRepository__, caseSetupFolder__, this)
caseSetupFolder__, ),
this libs_(settingsDict_()),
) externalTimeControl_(true),
), timers_(runName_),
libs_(settingsDict_()), timersReport_(settingsDict_->getValOrSet("timersReport", Logical("Yes"))),
externalTimeControl_(true), writeToFileTimer_("Write to file", &timers_)
timers_(runName_),
timersReport_
(
settingsDict_->getValOrSet("timersReport", Logical("Yes"))
),
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)
{ {
writeToFileTimer_.start(); writeToFileTimer_.start();
//if(time().currentIter() != 0 ) // if(time().currentIter() != 0 )
{ {
//- save the results to file //- save the results to file
if( !time().write() ) if (!time().write())
{ {
fatalErrorInFunction; fatalErrorInFunction;
return false; return false;
@ -280,17 +197,15 @@ 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())
{ {
writeToFileTimer_.start(); writeToFileTimer_.start();
if( !time().write() ) if (!time().write())
{ {
fatalErrorInFunction; fatalErrorInFunction;
return false; return false;
@ -299,8 +214,6 @@ bool pFlow::systemControl::operator ++(int)
timers_.write(output, true); timers_.write(output, true);
} }
return toContinue; return toContinue;
} }

View File

@ -2,207 +2,266 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: Licence:
This file is part of phasicFlow code. It is a free software for simulating This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions. the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/ -----------------------------------------------------------------------------*/
#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> \ \
static std::true_type Test(Check<Ret(*)(Args...), &U::name>*); \ template <typename U> \
template<typename U> \ static std::true_type Test(Check<Ret (*)(Args...), &U::name> *); \
static std::false_type Test(...); \ template <typename U> \
static const bool value = decltype(Test<testType>(0))::value; \ static std::false_type Test(...); \
}; static const bool value = decltype(Test<testType>(0))::value; \
};
namespace pFlow namespace pFlow
{ {
// //
template<typename T> template <typename T>
struct checkStatic struct checkStatic
{ {
has_static_member(TYPENAME); has_static_member(TYPENAME);
static constexpr
bool hasMember()
{
return has_static_member_TYPENAME<T,word(void)>::value;
}
};
template <typename T> static constexpr bool hasMember()
inline word basicTypeName()
{ {
int status; return has_static_member_TYPENAME<T, word(void)>::value;
auto& ti = typeid(T);
char* realname = abi::__cxa_demangle(ti.name(), nullptr, nullptr, &status);
word name(realname);
free(realname);
return name;
} }
};
template<> template <typename T>
inline word basicTypeName<word>(){ return "word"; } inline word basicTypeName()
{
int status;
auto &ti = typeid(T);
char *realname = abi::__cxa_demangle(ti.name(), nullptr, nullptr, &status);
word name(realname);
free(realname);
return name;
}
template<> template <>
inline word basicTypeName<int64>(){ return "int64"; } inline word basicTypeName<word>()
{
return "word";
}
template<> template <>
inline word basicTypeName<int32>(){ return "int32"; } inline word basicTypeName<int64>()
{
return "int64";
}
template<> template <>
inline word basicTypeName<int8>(){ return "int8"; } inline word basicTypeName<int32>()
{
return "int32";
}
template<> template <>
inline word basicTypeName<uint64>(){ return "uint64"; } inline word basicTypeName<int8>()
{
return "int8";
}
template<> template <>
inline word basicTypeName<uint32>(){ return "uint32"; } inline word basicTypeName<uint64>()
{
return "uint64";
}
template<> template <>
inline word basicTypeName<uint8>(){ return "uint8"; } inline word basicTypeName<uint32>()
{
return "uint32";
}
template<> template <>
inline word basicTypeName<real>(){ return "real"; } inline word basicTypeName<uint8>()
{
return "uint8";
}
template <>
template<typename T> inline word basicTypeName<real>()
word constexpr getTypeName() {
return "real";
}
template <typename T>
word constexpr getTypeName()
{
if constexpr (checkStatic<T>::hasMember())
{ {
return T::TYPENAME();
if constexpr ( checkStatic<T>::hasMember() )
{
return T::TYPENAME();
}else
{
return basicTypeName<T>();
}
} }
else
template<typename T>
word constexpr getTypeName(const T&)
{ {
if constexpr ( checkStatic<T>::hasMember() ) return basicTypeName<T>();
{
return T::TYPENAME();
}else
{
return basicTypeName<T>();
}
}
// compare the overriden typeName of object with concrete TYPENAME
// of Type1
template <typename Type1, typename Type2>
bool checkType(Type2* object)
{
return getTypeName<Type1>() == object->typeName();
}
template <typename Type1, typename Type2>
bool checkType(Type2& object)
{
return getTypeName<Type1>() == object.typeName();
} }
} }
template <typename T>
word constexpr getTypeName(const T &)
{
if constexpr (checkStatic<T>::hasMember())
{
return T::TYPENAME();
}
else
{
return basicTypeName<T>();
}
}
#define TypeInfo(tName) \ // compare the overriden typeName of object with concrete TYPENAME
inline static word TYPENAME() {return tName; } \ // of Type1
virtual word typeName() const {return TYPENAME();} template <typename Type1, typename Type2>
bool checkType(Type2 *object)
{
return getTypeName<Type1>() == object->typeName();
}
#define TypeInfoNV(tName) \ template <typename Type1, typename Type2>
inline static word TYPENAME() {return tName; } \ bool checkType(Type2 &object)
word typeName() const {return TYPENAME();} {
return getTypeName<Type1>() == object.typeName();
}
} // namespace pFlow
#define TypeInfo(tName) \
inline static word TYPENAME() \
{ \
return tName; \
} \
virtual word typeName() const \
{ \
return TYPENAME(); \
}
#define TypeInfoTemplate11(tName, Type) \ #define TypeInfoNV(tName) \
inline static word TYPENAME() \ inline static word TYPENAME() \
{ \ { \
return word(tName)+"<"+getTypeName<Type>()+">"; \ return tName; \
} \ } \
virtual word typeName() const { return TYPENAME();} word typeName() const \
{ \
return TYPENAME(); \
}
#define TypeInfoTemplate12(tName, Type1, Type2) \ #define TypeInfoTemplate11(tName, Type) \
inline static word TYPENAME() \ inline static word TYPENAME() \
{ \ { \
return word(tName)+"<"+getTypeName<Type1>()+","+getTypeName<Type2>()+">"; \ return word(tName) + "<" + getTypeName<Type>() + ">"; \
} \ } \
virtual word typeName() const { return TYPENAME();} virtual word typeName() const \
{ \
return TYPENAME(); \
}
#define TypeInfoTemplate13(tName, Type1, Type2, Type3) \ #define TypeInfoTemplate12(tName, Type1, Type2) \
inline static word TYPENAME() \ inline static word TYPENAME() \
{ \ { \
return word(tName)+"<"+getTypeName<Type1>()+","+getTypeName<Type2>()+","+getTypeName<Type3>()+">";\ 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) \
inline static word TYPENAME() \
{ \
return word(tName) + "<" + getTypeName<Type1>() + "," + \
getTypeName<Type2>() + "," + getTypeName<Type3>() + ">"; \
} \
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) \
inline static word TYPENAME() \ inline static word TYPENAME() \
{ \ { \
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) \
inline static word TYPENAME() \
{ \
return word(tName) + "<" + getTypeName<Type>() + "," + word(tName2) + \
">"; \
} \
inline word typeName() const \
{ \
return TYPENAME(); \
}
#define TypeInfoTemplateNV111(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) + \
} \ ">"; \
inline word typeName() const { return TYPENAME();} } \
virtual word typeName() const \
{ \
return TYPENAME(); \
}
#define TypeInfoTemplate111(tName, Type, tName2) \ #define TypeInfoTemplate211(tBase, tName1, Type, tName3) \
inline static word TYPENAME() \ inline static word TYPENAME() \
{ \ { \
return word(tName)+"<"+getTypeName<Type>()+","+word(tName2)+">"; \ return word(tBase) + "<" + word(tName1) + "," + getTypeName<Type>() + \
} \ "," + word(tName3) + ">"; \
virtual word typeName() const { return TYPENAME();} } \
virtual word typeName() const \
{ \
#define TypeInfoTemplate211(tBase,tName1, Type, tName3) \ return TYPENAME(); \
inline static word TYPENAME() \ }
{ \
return word(tBase)+"<"+word(tName1)+","+getTypeName<Type>()+","+word(tName3)+">"; \
} \
virtual word typeName() const { return TYPENAME();}
#define TypeInfoTemplate22(tBase,tName1, Type1, Type2) \
inline static word TYPENAME() \
{ \
return word(tBase)+"<"+word(tName1)+","+getTypeName<Type1>()+","+getTypeName<Type2>()+">"; \
} \
virtual word typeName() const { return TYPENAME();}
#define TypeInfoTemplate22(tBase, tName1, Type1, Type2) \
inline static word TYPENAME() \
{ \
return word(tBase) + "<" + word(tName1) + "," + getTypeName<Type1>() + \
"," + getTypeName<Type2>() + ">"; \
} \
virtual word typeName() const \
{ \
return TYPENAME(); \
}
#endif #endif

View File

@ -2,17 +2,17 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: Licence:
This file is part of phasicFlow code. It is a free software for simulating This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions. the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@ -23,60 +23,52 @@ 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 \
template<typename dType> \ selectorName##vCtorSelector_; \
class create##selectorName##Callback \ \
{ \ template<typename dType> \
public: \ class create##selectorName##Callback \
create##selectorName##Callback () \ { \
{ \ public: \
auto success = \ \
selectorName##vCtorSelector_.insertIf \ create##selectorName##Callback() \
( \ { \
word(dType::TYPENAME()), \ auto success = selectorName##vCtorSelector_.insertIf( \
[&] argList -> uniquePtr<baseClass> \ word(dType::TYPENAME()), \
{ \ [&] argList -> uniquePtr<baseClass> \
return uniquePtr<baseClass> \ { return uniquePtr<baseClass>(new dType args); } \
( \ ); \
new dType args \ \
); \ if (!success) \
} \ { \
); \ fatalErrorInFunction \
\ << "Duplicate entry " << dType::TYPENAME() \
if( !success ) \ << " in virtual constructor table of " << #baseClass \
{ \ << " with selector name " << #selectorName << endl; \
fatalErrorInFunction \ } \
<< "Duplicate entry "<< dType::TYPENAME() \ } \
<< " in virtual constructor table of "<< #baseClass \ \
<< " with selector name " << #selectorName <<endl; \ create##selectorName##Callback(const create##selectorName##Callback&) = \
} \ delete; \
\ void operator=(const create##selectorName##Callback&) = delete; \
} \ };
\
create##selectorName##Callback \
(const create##selectorName##Callback&)= delete; \
void operator= \
(const create##selectorName##Callback&)= delete; \
};
#define add_vCtor(baseClass, derivedClass, selectorName) \
\
inline static typename baseClass::template create##selectorName##Callback<derivedClass> baseClass##derivedClass##selectorName##_;
#define add_vCtor(baseClass, derivedClass, selectorName) \
\
inline static typename baseClass::template create##selectorName##Callback< \
derivedClass> \
baseClass##derivedClass##selectorName##_;
#endif // __virtualConstructor_hpp__ #endif // __virtualConstructor_hpp__

View File

@ -2,17 +2,17 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: Licence:
This file is part of phasicFlow code. It is a free software for simulating This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions. the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@ -23,37 +23,36 @@ 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);
for(int i=0; i<4; ++i) for (int i = 0; i < 4; ++i)
{ {
if(toUpper(YesNo__[i][0]) == Ul) if (toUpper(YesNo__[i][0]) == Ul)
{ {
b = true; b = true;
yesNoSet = i; yesNoSet = i;
return true; return true;
} }
else if( toUpper(YesNo__[i][1]) == Ul ) else if (toUpper(YesNo__[i][1]) == Ul)
{ {
b = false; b = false;
yesNoSet = i; yesNoSet = i;
return true; return true;
} }
@ -62,66 +61,66 @@ 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;
if (!t.good()) if (!t.good())
{
ioErrorInFile(is.name(), is.lineNumber())
<< "Bad token - could not get Logical value";
is.setBad();
return false;
}
if (t.isString())
{
w = t.stringToken();
}
else if(t.isWord() )
{
w = t.wordToken();
}
else
{
ioErrorInFile(is.name(), is.lineNumber())
<< "Wrong token type - expected Logical value, found "
<< t;
is.setBad();
return false;
}
return evaluteWord(w, s_, yesNoSet_);
}
bool pFlow::Logical::write
(
iOstream& os
)const
{
if(s_)
{ {
os<< YesNo__[yesNoSet_][0]; ioErrorInFile(is.name(), is.lineNumber())
<< "Bad token - could not get Logical value";
is.setBad();
return false;
}
if (t.isString())
{
w = t.stringToken();
}
else if (t.isWord())
{
w = t.wordToken();
} }
else else
{ {
os<< YesNo__[yesNoSet_][1]; ioErrorInFile(is.name(), is.lineNumber())
<< "Wrong token type - expected Logical value, found " << t;
is.setBad();
return false;
} }
return os.check(FUNCTION_NAME);
}
pFlow::iIstream& pFlow::operator>>( iIstream& is, Logical& L) return evaluteWord(w, s_, yesNoSet_);
{
if(!L.read(is))
{
fatalExit;
}
return is;
} }
pFlow::iOstream& pFlow::operator<< ( iOstream& os, const Logical& L) bool
pFlow::Logical::write(iOstream& os) const
{ {
if(!L.write(os)) if (s_)
{
os << YesNo__[yesNoSet_][0];
}
else
{
os << YesNo__[yesNoSet_][1];
}
return os.check(FUNCTION_NAME);
}
pFlow::iIstream&
pFlow::operator>>(iIstream& is, Logical& L)
{
if (!L.read(is))
{
fatalExit;
}
return is;
}
pFlow::iOstream&
pFlow::operator<<(iOstream& os, const Logical& L)
{
if (!L.write(os))
{ {
fatalExit; fatalExit;
} }

View File

@ -2,17 +2,17 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: Licence:
This file is part of phasicFlow code. It is a free software for simulating This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions. the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@ -28,112 +28,115 @@ Licence:
namespace pFlow namespace pFlow
{ {
//- Forward //- Forward
class iIstream; class iIstream;
class iOstream; class iOstream;
/** /**
* Holds a bool value and converts strings to bool * Holds a bool value and converts strings to bool
* *
*/ */
class Logical class Logical
{ {
protected: private:
/// bool value /// bool value
bool s_ = false; bool s_ = false;
/// Set numbe of of Yes or No /// Set numbe of of Yes or No
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:
/// Type info /// Type info
TypeInfoNV("Logical"); TypeInfoNV("Logical");
//// Constructors
/// Default constructor //// Constructors
inline Logical(){}
/// Construct from bool
inline explicit Logical(bool s)
:
s_(s)
{}
/// Construct from word /// Default constructor
Logical(const word& l); inline Logical() = default;
/// Construct from char string
Logical(const char* ch);
/// Copy /// Construct from bool
Logical(const Logical&) = default; inline explicit Logical(bool s)
: s_(s)
{
}
/// Move /// Construct from word
Logical(Logical&&) = default; Logical(const word& l);
/// Copy assignment /// Construct from char string
Logical& operator=(const Logical&) = default; Logical(const char* ch);
/// Move assignment /// Copy
Logical& operator=(Logical&&) = default; Logical(const Logical&) = default;
/// Assignment with bool /// Move
inline Logical& operator=(const bool& b) Logical(Logical&&) = default;
{
s_ = b;
yesNoSet_ = 0;
return *this;
}
//// Methods
/// () operator, return bool value
inline bool operator()() const
{
return s_;
}
/// Return bool value
inline explicit operator bool() const
{
return s_;
}
/// Not operator /// Copy assignment
inline Logical operator!()const Logical& operator=(const Logical&) = default;
{
return Logical(!s_, yesNoSet_); /// Move assignment
} Logical& operator=(Logical&&) = default;
/// Assignment with bool
inline Logical& operator=(const bool& b)
{
s_ = b;
yesNoSet_ = 0;
return *this;
}
//// Methods
/// () operator, return bool value
inline bool operator()() const
{
return s_;
}
/// Return bool value
inline explicit operator bool() const
{
return s_;
}
/// Not operator
inline Logical operator!() const
{
return Logical(!s_, yesNoSet_);
}
//// IO operations //// IO operations
bool read(iIstream& is);
bool write(iOstream& os)const; bool read(iIstream& is);
//// Static members bool write(iOstream& os) const;
bool static evaluteWord(const word& l, bool& b, int& yesNoSet ); //// Static members
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

View File

@ -2,359 +2,400 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: Licence:
This file is part of phasicFlow code. It is a free software for simulating This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions. the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/ -----------------------------------------------------------------------------*/
#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 : std::count(s, (s + std::char_traits<char>::length(s)), c)
? 0 );
: 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" ||
return false; s == "Y" ||
s == "OK" ||
s == "TRUE" ||
s == "ON" ||
s == "T")
return true;
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 false; return true;
else
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;
ss << std::fixed << std::setprecision(numPrecision) << v; ss << std::fixed << std::setprecision(numPrecision) << v;
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)
{ {
ss <<"0"; ss << "0";
} }
else else
{ {
ss << std::setprecision(numPrecision) << v; ss << std::setprecision(numPrecision) << v;
} }
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;
ss << v; ss << 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();
if(len == word::npos) return str;
auto firstZero = word::npos;
for(auto n=len-1; n>dec;n--)
{
if( str[n] == '0' )
{
firstZero = n;
}
else
{
break;
}
}
if(firstZero == dec+1) firstZero = dec; auto len = str.size();
if (len == word::npos)
return str.substr(0,firstZero); return str;
auto firstZero = word::npos;
for (auto n = len - 1; n > dec; n--)
{
if (str[n] == '0')
{
firstZero = n;
}
else
{
break;
}
}
if (firstZero == dec + 1)
firstZero = dec;
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, return base + "<" + w1 + "," + w2 + ">";
const word& w2 }
pFlow::word
pFlow::angleBracketsNames3(
const word& base,
const word& w1,
const word& w2,
const word& w3
) )
{ {
return base+"<"+w1+","+w2+">"; return base + "<" + w1 + "," + w2 + "," + w3 + ">";
} }
pFlow::word pFlow::angleBracketsNames3(const word& base, const word& w1, const word& w2, const word& w3) pFlow::word
pFlow::groupNames(const word& bw, const word& tw, char sep)
{ {
return base+"<"+w1+","+w2+","+w3+">"; return bw + sep + tw;
} }
pFlow::word pFlow::groupNames(const word& bw, const word& tw, char sep) pFlow::word
pFlow::baseName(const word& w, char sep)
{ {
return bw + sep + tw; if (auto pos = w.find_last_of(sep); pos != word::npos)
{
return w.substr(0, pos);
}
else
{
return w;
}
} }
pFlow::word pFlow::baseName(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)
{ {
return w.substr(0,pos); return w.substr(pos + 1);
} }
else else
{ {
return w; return nullWord;
} }
} }
pFlow::word pFlow::tailName(const word& w, char sep) bool
pFlow::validWord(char c)
{ {
if( auto pos = w.find_last_of(sep); pos != word::npos) return (
{ !isspace(c) && c != '"' // string quote
return w.substr(pos+1); && c != '\'' // string quote
} //&& c != '/' // path separator
else && c != ';' // end statement
{ && c != '{' // beg subdict
return nullWord; && c != '}' // end subdict
} );
} }
bool pFlow::validWord(char c) bool
pFlow::validWordWithQuote(char c)
{ {
return return (
( !isspace(c) && c != ';' // end statement
!isspace(c) && c != '{' // beg subdict
&& c != '"' // string quote && c != '}' // end subdict
&& c != '\'' // string quote );
//&& c != '/' // path separator
&& c != ';' // end statement
&& c != '{' // beg subdict
&& c != '}' // end subdict
);
} }
bool pFlow::validWordWithQuote(char c) bool
pFlow::validWord(const word& w)
{ {
return for (auto wi : w)
( {
!isspace(c) char c = wi;
&& c != ';' // end statement if (!validWord(c))
&& c != '{' // beg subdict return false;
&& c != '}' // end subdict }
); return true;
} }
bool pFlow::validWord(const word& w) bool
pFlow::validWordWithQuote(const word& w)
{ {
for(auto wi:w) for (auto wi : w)
{ {
char c = wi; char c = wi;
if ( !validWord(c) ) return false; if (!validWordWithQuote(c))
} return false;
return true; }
return true;
} }
bool pFlow::validWordWithQuote(const word& w) bool
pFlow::readUint32(const word& w, uint32& val)
{ {
for(auto wi:w) try
{ {
char c = wi; val = std::stoul(w);
if ( !validWordWithQuote(c) ) return false; }
} catch (...)
return true; {
return false;
}
return true;
} }
bool pFlow::readUint32( const word& w, uint32 & val) bool
pFlow::readUint32(const char* buf, uint32& val)
{ {
try{ word w(buf);
val = std::stoul(w); return readUint32(w, val);
}
catch (...)
{
return false;
}
return true;
} }
bool pFlow::readUint32( const char* buf, uint32 & val) bool
pFlow::readInt64(const word& w, int64& val)
{ {
word w(buf); try
return readUint32(w, val); {
val = std::stoll(w);
}
catch (...)
{
return false;
}
return true;
} }
bool pFlow::readInt64( const word& w, int64 & val) bool
pFlow::readInt64(const char* buf, int64& val)
{ {
try{ word w(buf);
val = std::stoll(w); return readInt64(w, val);
}
catch (...)
{
return false;
}
return true;
} }
bool pFlow::readInt64( const char* buf, int64 & val) bool
pFlow::readInt32(const word& w, int32& val)
{ {
word w(buf); try
return readInt64(w, val); {
val = std::stoi(w);
}
catch (...)
{
return false;
}
return true;
} }
bool pFlow::readInt32( const word& w, int32 & val) bool
pFlow::readInt32(const char* buf, int32& val)
{ {
try{ word w(buf);
val = std::stoi(w); return readInt32(w, val);
}
catch (...)
{
return false;
}
return true;
} }
bool pFlow::readInt32( const char* buf, int32 & val) bool
pFlow::readInt8(const word& w, int8& val)
{ {
word w(buf); try
return readInt32(w, val); {
val = std::stoi(w);
}
catch (...)
{
return false;
}
return true;
} }
bool pFlow::readInt8( const word& w, int8 & val) bool
pFlow::readInt8(const char* buf, int8& val)
{ {
try{ word w(buf);
val = std::stoi(w); return readInt8(w, val);
}
catch (...)
{
return false;
}
return true;
} }
bool pFlow::readInt8( const char* buf, int8 & val) // #include <iostream>
bool
pFlow::readReal(const word& w, real& val)
{ {
word w(buf); try
return readInt8(w, val); {
val = std::stod(w);
}
catch (std::out_of_range& e)
{
val = static_cast<real>(std::stold(w));
}
catch (...)
{
return false;
}
return true;
} }
//#include <iostream> bool
bool pFlow::readReal( const word& w, real & val) pFlow::readReal(const char* buf, real& val)
{ {
try{ char* c;
val = std::stod(w);
val = std::strtod(buf, &c);
} if (val == HUGE_VAL)
catch (std:: out_of_range& e) {
{ val = static_cast<real>(std::strtold(buf, &c));
val = static_cast<real>( std::stold(w) ); if (val == HUGE_VAL || c == buf)
} return false;
catch (...){ }
return false; else if (c == buf)
} {
return true; return false;
}
return true;
} }
bool pFlow::readReal( const char* buf, real & val ) bool
pFlow::readBoolian_Str(const word& w, bool& val)
{ {
char* c; if (bool t = isYes(w); t)
{
val = std::strtod(buf, &c); val = true;
if(val == HUGE_VAL) return true;
{ }
val = static_cast<real>( std::strtold(buf, &c) ); if (bool f = isNo(w); f)
if(val == HUGE_VAL || c==buf) {
return false; val = false;
} return true;
else if(c == buf) }
{ return false;
return false;
}
return true;
} }
bool
bool pFlow::readBoolian_Str( const word& w, bool & val) pFlow::readBoolian_Str(const char* buf, bool& val)
{ {
if( bool t = isYes(w); t ) word w(buf);
{ return readBoolian_Str(w, val);
val = true;
return true;
}
if( bool f = isNo(w); f )
{
val = false;
return true;
}
return false;
}
bool pFlow::readBoolian_Str( const char* buf, bool & val)
{
word w(buf);
return readBoolian_Str(w, val);
} }

View File

@ -2,248 +2,286 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: Licence:
This file is part of phasicFlow code. It is a free software for simulating This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions. the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/ -----------------------------------------------------------------------------*/
/*! \file bTypeFunctions.hpp /*! \file bTypeFunctions.hpp
\brief Helper functions for built-in types. \brief Helper functions for built-in types.
*/ */
#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
{ {
/// Zero real variable /// Zero real variable
inline const real zero = 0.0; inline const real zero = 0.0;
/// one real variable /// one real variable
inline const real one = 1.0; inline const real one = 1.0;
/// zero int32 variable /// zero int32 variable
inline const int32 zero32 = 0; inline const int32 zero32 = 0;
/// one int32 variable /// one int32 variable
inline const int32 one32 = 1; inline const int32 one32 = 1;
/// null/empty word /// null/empty word
inline const word nullWord; inline const word nullWord;
/// white space /// white space
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>
word angleBracketsNames(const word& w1, const word& w2); /// Output <w1,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
bool equal(const real& s1, const real& s2, real tol = smallValue) 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;
}
INLINE_FUNCTION_HD
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 int32& s1, const int32& s2)
{ {
return s1 == s2; return s1 == s2;
} }
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
bool equal(const uint32& s1, const uint32& s2) bool
equal(const int8& s1, const int8& s2)
{ {
return s1 == s2; return s1 == s2;
}
INLINE_FUNCTION_HD
bool
equal(const uint32& s1, const uint32& 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__

View File

@ -2,17 +2,17 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: Licence:
This file is part of phasicFlow code. It is a free software for simulating This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions. the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@ -28,52 +28,50 @@ Licence:
namespace pFlow namespace pFlow
{ {
#ifdef pFlow_Build_Double #ifdef pFlow_Build_Double
#define useDouble 1 #define useDouble 1
inline const char* floatingPointType__ = "double"; inline const char* floatingPointType__ = "double";
inline const bool usingDouble__ = true; inline const bool usingDouble__ = true;
#else #else
#define useDouble 0 #define useDouble 0
inline const char* floatingPointType__ = "float"; 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;
#else #else
using real = float; using real = float;
#endif #endif
using int8 = signed char; using int8 = signed char;
using int32 = int; using int32 = int;
using int64 = long long int; using int64 = long long int;
using uint8 = unsigned char ; using uint8 = unsigned char;
using uint32 = unsigned int; using uint32 = unsigned int;
using uint64 = unsigned long long int; using uint64 = unsigned long long int;
using id_t = uint32; using id_t = uint32;
using size_t = std::size_t; using size_t = std::size_t;
using word = std::string; 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.");
} }
} // end of pFlow } // end of pFlow
#endif #endif

View File

@ -2,17 +2,17 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: Licence:
This file is part of phasicFlow code. It is a free software for simulating This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions. the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@ -21,31 +21,28 @@ 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
// sin, cos, tan, asin, acos, atan, atan2 // sin, cos, tan, asin, acos, atan, atan2
// sinh, cosh, tanh, asinh, acosh, atanh // sinh, cosh, tanh, asinh, acosh, atanh
// min, max // min, max
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * // //* * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace pFlow namespace pFlow
{ {
INLINE_FUNCTION_HD
INLINE_FUNCTION_HD real
real abs(real x) abs(real x)
{ {
#ifdef __CUDACC__ #ifdef __CUDACC__
return ::fabs(x); return ::fabs(x);
@ -55,22 +52,24 @@ 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);
}
#endif
#ifndef __CUDACC__
INLINE_FUNCTION_HD int32 abs(int32 x)
{ {
return std::abs(x); return std::abs(x);
} }
#endif #endif
#ifndef __CUDACC__
INLINE_FUNCTION_HD int32
abs(int32 x)
{
return std::abs(x);
}
#endif
INLINE_FUNCTION_HD real mod(real x, real y) INLINE_FUNCTION_HD real
mod(real x, real y)
{ {
#ifdef __CUDACC__ #ifdef __CUDACC__
return ::fmod(x, y); return ::fmod(x, y);
@ -79,131 +78,148 @@ 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);
} }
#endif #endif
#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);
} }
#endif #endif
#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);
} }
#endif #endif
#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);
} }
#endif #endif
#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);
} }
#endif #endif
#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);
} }
#endif #endif
#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);
} }
#endif #endif
#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);
} }
#endif #endif
#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);
} }
#endif #endif
#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);
} }
#endif #endif
#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);
} }
#endif #endif
#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);
} }
#endif #endif
#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);
} }
#endif #endif
#ifndef __CUDACC__ #ifndef __CUDACC__
INLINE_FUNCTION_HD real INLINE_FUNCTION_HD real
atan2(real y, real x) atan2(real y, real x)
{ {
return std::atan2(y, x); return std::atan2(y, x);
@ -211,22 +227,25 @@ atan2(real y, real x)
#endif #endif
#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);
} }
#endif #endif
#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);
@ -254,96 +275,101 @@ 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);
#else #else
return std::fmin(x,y); return std::fmin(x, y);
#endif #endif
} }
#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);
} }
#endif #endif
#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);
} }
#endif #endif
#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);
#else #else
return std::fmax(x,y); return std::fmax(x, 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__

View File

@ -2,17 +2,17 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: Licence:
This file is part of phasicFlow code. It is a free software for simulating This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions. the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@ -21,51 +21,50 @@ 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
{ {
const inline real Pi = real(3.1415926535897932384626433832); const inline real Pi = real(3.1415926535897932384626433832);
const inline real smallValue = 1.0e-15; const inline real smallValue = 1.0e-15;
const inline real verySmallValue = 1.0e-30; const inline real verySmallValue = 1.0e-30;
const inline real largeValue = 1.0e15; const inline real largeValue = 1.0e15;
const inline real veryLargeValue = 1.0e30; const inline real veryLargeValue = 1.0e30;
// - 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();
}
const inline int32 largestNegInt32 = largestNegative<int32>(); const inline int32 largestNegInt32 = largestNegative<int32>();
const inline int32 largestPosInt32 = largestPositive<int32>(); const inline int32 largestPosInt32 = largestPositive<int32>();
const inline int64 largestNegInt64 = largestNegative<int64>(); const inline int64 largestNegInt64 = largestNegative<int64>();
const inline int64 largestPosInt64 = largestPositive<int64>(); const inline int64 largestPosInt64 = largestPositive<int64>();
const inline real largestNegREAL = largestNegative<real>(); const inline real largestNegREAL = largestNegative<real>();
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

View File

@ -2,17 +2,17 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: Licence:
This file is part of phasicFlow code. It is a free software for simulating This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions. the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@ -21,79 +21,79 @@ 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
{ {
public: 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_);
return *this; return *this;
} }
// 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
@ -111,130 +111,173 @@ public:
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
quadruple<T>& operator=(quadruple<T>&& src) = default; quadruple<T>& operator=(quadruple<T>&& src) = default;
// clone // clone
INLINE_FUNCTION_H INLINE_FUNCTION_H
uniquePtr<quadruple<T>> clone()const uniquePtr<quadruple<T>> clone() const
{ {
return makeUnique<quadruple<T>>(*this); return makeUnique<quadruple<T>>(*this);
} }
INLINE_FUNCTION_H INLINE_FUNCTION_H
quadruple<T>* clonePtr()const quadruple<T>* clonePtr() const
{ {
return new quadruple<T>(*this); return new quadruple<T>(*this);
} }
// 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
{
INLINE_FUNCTION_HD return v_.x();
T & y(){ return v_.y(); } }
INLINE_FUNCTION_HD
const T & y()const { return v_.y(); }
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
T & z(){ return v_.z(); } T& y()
{
return v_.y();
}
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
const T & z()const { return v_.z(); } const T& y() const
{
INLINE_FUNCTION_HD return v_.y();
T & s(){ return s_; } }
INLINE_FUNCTION_HD
const T & s()const { return s_; } INLINE_FUNCTION_HD
T& z()
INLINE_FUNCTION_HD {
triple<T> v() {return v_;} return v_.z();
INLINE_FUNCTION_HD }
const triple<T> v() const {return v_;} INLINE_FUNCTION_HD
const T& z() const
{
return v_.z();
}
INLINE_FUNCTION_HD
T& s()
{
return s_;
}
INLINE_FUNCTION_HD
const T& s() const
{
return s_;
}
INLINE_FUNCTION_HD
triple<T> v()
{
return v_;
}
INLINE_FUNCTION_HD
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 void normalize(); INLINE_FUNCTION_HD T length() const;
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 T& oprnd1, const quadruple<T>& oprnd2);
// - 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 T& oprnd2);
friend FUNCTION_HD quadruple<T> operator-
<T>(const 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 T & oprnd1, const quadruple<T> & oprnd2);
// - 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 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*
friend FUNCTION_HD quadruple<T> operator * <T> (const T & oprnd1, const quadruple<T> & oprnd2); <T>(const quadruple<T>& oprnd1, const 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 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 T& oprnd1, const quadruple<T>& oprnd2);
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
void operator+= (const quadruple & oprnd2); void operator+=(const quadruple& oprnd2);
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
void operator-= (const quadruple & oprnd2); void operator-=(const quadruple& oprnd2);
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
void operator*= (const quadruple & oprnd2); void operator*=(const quadruple& oprnd2);
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
void operator/= (const quadruple & oprnd2); void operator/=(const quadruple& oprnd2);
// unary negate operator
INLINE_FUNCTION_HD
quadruple operator- ()const;
// unary plus operator
INLINE_FUNCTION_HD
quadruple operator+ ()const;
friend FUNCTION_HD bool operator == <T> (const quadruple<T> &opr1, const quadruple<T> &opr2); // unary negate operator
INLINE_FUNCTION_HD
// << operator quadruple operator-() const;
friend FUNCTION_H iOstream& operator<< <T> (iOstream& str, const quadruple<T> & ov);
// unary plus operator
// >> operator INLINE_FUNCTION_HD
friend FUNCTION_H iIstream& operator >> <T> (iIstream & str, quadruple<T> & iv); quadruple operator+() const;
friend FUNCTION_HD bool operator==
<T>(const quadruple<T>& opr1, const quadruple<T>& opr2);
// << operator
friend FUNCTION_H iOstream&
operator<< <T>(iOstream& str, const quadruple<T>& ov);
// >> operator
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"
#endif #endif

View File

@ -2,140 +2,86 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: Licence:
This file is part of phasicFlow code. It is a free software for simulating This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions. the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/ -----------------------------------------------------------------------------*/
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>
INLINE_FUNCTION_HD quadruple<T> operator +
(
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 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 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 T& oprnd2, const quadruple<T>& oprnd1);
const quadruple<T> & oprnd1,
const quadruple<T> & oprnd2
);
template<typename T>
INLINE_FUNCTION_HD quadruple<T> operator-
(
const quadruple<T> & oprnd1,
const T & oprnd2
);
template<typename T>
INLINE_FUNCTION_HD quadruple<T> operator-
(
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>
INLINE_FUNCTION_HD quadruple<T> operator*
(
const quadruple<T> & oprnd1,
const T & oprnd2
);
template<typename T>
INLINE_FUNCTION_HD quadruple<T> operator*
(
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 T& oprnd2);
const quadruple<T> & oprnd1,
const quadruple<T> & oprnd2
);
template<typename T>
INLINE_FUNCTION_HD quadruple<T> operator/
(
const quadruple<T> & oprnd1,
const T & oprnd2
);
template<typename T>
INLINE_FUNCTION_HD quadruple<T> operator/
(
const T & oprnd1,
const quadruple<T> & oprnd2
);
template<typename T> template<typename T>
INLINE_FUNCTION_HD bool operator == INLINE_FUNCTION_HD quadruple<T>
( operator-(const T& oprnd1, const quadruple<T>& oprnd2);
const quadruple<T> &opr1,
const quadruple<T> &opr2
);
template<typename T>
INLINE_FUNCTION_H iOstream& operator<<
(
iOstream& str,
const quadruple<T> & ov
);
template<typename T>
INLINE_FUNCTION_H iIstream& operator>>
(
iIstream& str,
quadruple<T> & iv
);
template<typename T> template<typename T>
INLINE_FUNCTION_H void readIstream INLINE_FUNCTION_HD quadruple<T>
( operator*(const quadruple<T>& oprnd1, const quadruple<T>& oprnd2);
iIstream& str,
quadruple<T> & iv template<typename T>
); INLINE_FUNCTION_HD quadruple<T>
operator*(const quadruple<T>& oprnd1, const T& oprnd2);
template<typename T>
INLINE_FUNCTION_HD quadruple<T>
operator*(const T& oprnd1, const quadruple<T>& oprnd2);
template<typename T>
INLINE_FUNCTION_HD quadruple<T>
operator/(const quadruple<T>& oprnd1, const quadruple<T>& oprnd2);
template<typename T>
INLINE_FUNCTION_HD quadruple<T>
operator/(const quadruple<T>& oprnd1, const T& oprnd2);
template<typename T>
INLINE_FUNCTION_HD quadruple<T>
operator/(const T& oprnd1, const quadruple<T>& oprnd2);
template<typename T>
INLINE_FUNCTION_HD bool
operator==(const quadruple<T>& opr1, const quadruple<T>& opr2);
template<typename T>
INLINE_FUNCTION_H iOstream&
operator<<(iOstream& str, const quadruple<T>& ov);
template<typename T>
INLINE_FUNCTION_H iIstream&
operator>>(iIstream& str, quadruple<T>& iv);
template<typename T>
INLINE_FUNCTION_H void
readIstream(iIstream& str, quadruple<T>& iv);

View File

@ -2,297 +2,190 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: Licence:
This file is part of phasicFlow code. It is a free software for simulating This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions. the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/ -----------------------------------------------------------------------------*/
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)
{ {
*this /= l; *this /= l;
} }
} }
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 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> template<typename T>
INLINE_FUNCTION_HD void pFlow::quadruple<T>::operator+= INLINE_FUNCTION_HD pFlow::quadruple<T>
( pFlow::operator+(const quadruple<T>& oprnd1, const quadruple<T>& oprnd2)
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 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,52 +193,43 @@ 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();
str >> iv.x(); str >> iv.x();
str >> iv.y(); str >> iv.y();
str >> iv.z(); str >> iv.z();
str.readEnd("quadruple<T>"); str.readEnd("quadruple<T>");
str.check(FUNCTION_NAME); str.check(FUNCTION_NAME);
return str; return str;
} }
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;
readIstream(str, val); readIstream(str, val);
iv.w() = val; iv.w() = val;
readIstream(str, val); readIstream(str, val);
iv.x() = val; iv.x() = val;
readIstream(str, val);
iv.y() = val;
readIstream(str, val); readIstream(str, val);
iv.z() = val; iv.y() = val;
str.readEnd("quadruple<T>");
str.check(FUNCTION_NAME); readIstream(str, val);
iv.z() = val;
str.readEnd("quadruple<T>");
str.check(FUNCTION_NAME);
} }

View File

@ -2,44 +2,47 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: Licence:
This file is part of phasicFlow code. It is a free software for simulating This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions. the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/ -----------------------------------------------------------------------------*/
#define Q4Func(fnName) \ #define Q4Func(fnName) \
template<typename T> \ template<typename T> \
inline pFlow::quadruple<T> pFlow::fnName(const quadruple<T>& q) \ inline pFlow::quadruple<T> pFlow::fnName(const quadruple<T>& q) \
{ \ { \
return quadruple<T>(fnName(q.s_), fnName(q.v_)); \ return quadruple<T>(fnName(q.s_), fnName(q.v_)); \
} }
#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 * * * * * * * * //
// abs, mod, exp, log, log10, pow, sqrt, cbrt // abs, mod, exp, log, log10, pow, sqrt, cbrt
// sin, cos, tan, asin, acos, atan, atan2 // sin, cos, tan, asin, acos, atan, atan2
// sinh, cosh, tanh, asinh, acosh, atanh // sinh, cosh, tanh, asinh, acosh, atanh
// 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

View File

@ -2,17 +2,17 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: Licence:
This file is part of phasicFlow code. It is a free software for simulating This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions. the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@ -27,23 +27,21 @@ 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"
/** /**
* A set of 3 variables that can be used for vector variables. * A set of 3 variables that can be used for vector variables.
* The template parameter should be numeric type only. * The template parameter should be numeric type only.
* *
*/ */
template <typename T> template<typename T>
struct triple struct triple
{ {
/// data members /// data members
@ -53,219 +51,266 @@ struct triple
//// Constructors //// Constructors
/// 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>
INLINE_FUNCTION_HD triple<T> & operator = (const triple<T2> & rhs) INLINE_FUNCTION_HD triple<T>& operator=(const triple<T2>& rhs)
{ {
this->x_ = static_cast<T>(rhs.x_); this->x_ = static_cast<T>(rhs.x_);
this->y_ = static_cast<T>(rhs.y_); this->y_ = static_cast<T>(rhs.y_);
this->z_ = static_cast<T>(rhs.z_); this->z_ = static_cast<T>(rhs.z_);
return *this; return *this;
} }
/// 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
INLINE_FUNCTION_HD
triple(const triple<T>& src) = default;
/// Copy construct
INLINE_FUNCTION_HD
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;
/// copy assignment /// copy assignment
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
triple<T>& operator=(const triple<T>& src) = default; triple<T>& operator=(const triple<T>& src) = default;
/// move assignment /// move assignment
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
triple<T>& operator=(triple<T>&& src) = default; triple<T>& operator=(triple<T>&& src) = default;
/// clone /// clone
INLINE_FUNCTION INLINE_FUNCTION
uniquePtr<triple<T>> clone() const uniquePtr<triple<T>> clone() const
{ {
return makeUnique<triple<T>>(*this); return makeUnique<triple<T>>(*this);
} }
INLINE_FUNCTION INLINE_FUNCTION
triple<T>* clonePtr()const triple<T>* clonePtr() const
{ {
return new triple<T>(*this); return new triple<T>(*this);
} }
////// 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
{
/// access component return x_;
INLINE_FUNCTION_HD T & y(){ return y_; } }
/// access component
INLINE_FUNCTION_HD const T & y()const { return y_; }
/// access component /// access component
INLINE_FUNCTION_HD T & z(){ return z_; } INLINE_FUNCTION_HD T& y()
{
/// access component return y_;
INLINE_FUNCTION_HD const T & z()const { return z_; } }
/// access component /// access component
INLINE_FUNCTION_HD T & comp1(){ return x_; } INLINE_FUNCTION_HD const T& y() const
{
return y_;
}
/// access component /// access component
INLINE_FUNCTION_HD const T & comp1()const { return x_; } INLINE_FUNCTION_HD T& z()
{
/// access component return z_;
INLINE_FUNCTION_HD T & comp2(){ return y_; } }
/// access component
INLINE_FUNCTION_HD const T & comp2()const { return y_; }
/// access component /// access component
INLINE_FUNCTION_HD T & comp3(){ return z_; } INLINE_FUNCTION_HD const T& z() const
{
/// access component return z_;
INLINE_FUNCTION_HD const T & comp3()const { return z_; } }
/// access component
INLINE_FUNCTION_HD T& comp1()
{
return x_;
}
/// access component
INLINE_FUNCTION_HD const T& comp1() const
{
return x_;
}
/// access component
INLINE_FUNCTION_HD T& comp2()
{
return y_;
}
/// access component
INLINE_FUNCTION_HD const T& comp2() const
{
return y_;
}
/// access component
INLINE_FUNCTION_HD T& comp3()
{
return z_;
}
/// access component
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
friend FUNCTION_HD triple<T> cross <T>(const triple<T> & v1, const triple<T> & v2);
/// Length of the vector
INLINE_FUNCTION_HD T length() const;
/// Normalize the vector /// Cross product of two vectors
INLINE_FUNCTION_HD void normalize(); friend FUNCTION_HD triple<T>
cross<T>(const triple<T>& v1, const triple<T>& v2);
//// operators /// Length of the vector
INLINE_FUNCTION_HD T length() const;
/// + 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 T & oprnd2); /// Normalize the vector
INLINE_FUNCTION_HD void normalize();
friend FUNCTION_HD triple<T> operator+ <T> (const T & oprnd1, const triple<T> & oprnd2);
/// - 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 T & oprnd2);
friend FUNCTION_HD triple<T> operator - <T> (const T & oprnd1, const triple<T> & oprnd2);
/// * 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 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 T & oprnd2);
friend FUNCTION_HD triple<T> operator / <T> (const T & oprnd1, const triple<T> & oprnd2);
/// + operator
friend FUNCTION_HD triple<T> operator+
<T>(const triple<T>& oprnd1, const triple<T>& oprnd2);
INLINE_FUNCTION_HD void operator+= (const triple & oprnd2); friend FUNCTION_HD triple<T> operator+
<T>(const triple<T>& oprnd1, const T& oprnd2);
INLINE_FUNCTION_HD void operator-= (const triple & oprnd2); friend FUNCTION_HD triple<T> operator+
<T>(const T& oprnd1, const triple<T>& oprnd2);
INLINE_FUNCTION_HD void operator*= (const triple & oprnd2); /// - operator
friend FUNCTION_HD triple<T> operator-
<T>(const triple<T>& oprnd1, const triple<T>& oprnd2);
INLINE_FUNCTION_HD void operator/= (const triple & oprnd2); friend FUNCTION_HD triple<T> operator-
<T>(const triple<T>& oprnd1, const T& oprnd2);
/// unary negate operator
INLINE_FUNCTION_HD triple operator- ()const;
/// unary plus operator
INLINE_FUNCTION_HD triple operator+ ()const;
friend FUNCTION_HD bool operator == <T> (const triple<T> &opr1, const triple<T> &opr2); friend FUNCTION_HD triple<T> operator-
<T>(const T& oprnd1, const triple<T>& oprnd2);
friend FUNCTION_HD bool operator < <T> (const triple<T> &opr1, const triple<T> &opr2); /// * operators
friend FUNCTION_HD triple<T> operator*
<T>(const triple<T>& oprnd1, const triple<T>& oprnd2);
friend FUNCTION_HD bool operator > <T> (const triple<T> &opr1, const triple<T> &opr2); friend FUNCTION_HD triple<T> operator*
<T>(const triple<T>& oprnd1, const T& oprnd2);
friend FUNCTION_HD bool operator >= <T> (const triple<T> &opr1, const triple<T> &opr2); friend FUNCTION_HD triple<T> operator*
<T>(const T& oprnd1, const triple<T>& oprnd2);
/// / 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 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);
INLINE_FUNCTION_HD void operator*=(const triple& oprnd2);
INLINE_FUNCTION_HD void operator/=(const triple& oprnd2);
/// unary negate operator
INLINE_FUNCTION_HD triple operator-() const;
/// unary plus operator
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);
//// IO operators //// IO operators
/// << operator /// << operator
friend iOstream& operator<< <T> (iOstream& str, const triple<T> & ov); friend iOstream& operator<< <T>(iOstream& str, const triple<T>& ov);
/// >> operator
friend iIstream& operator >> <T> (iIstream & str, triple<T> & iv);
/// same as >> operator, but faster, good for mass read /// >> operator
friend void readIstream <T>( iIstream& str, triple<T> &iv); friend iIstream& operator>> <T>(iIstream& str, triple<T>& iv);
/// same as >> operator, but faster, good for mass read
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

View File

@ -2,188 +2,114 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: Licence:
This file is part of phasicFlow code. It is a free software for simulating This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions. the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/ -----------------------------------------------------------------------------*/
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>
INLINE_FUNCTION_HD triple<T> operator +
(
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 triple<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 triple<T>& oprnd1, const T& oprnd2);
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 T& oprnd2, const triple<T>& oprnd1);
const triple<T> & oprnd1,
const triple<T> & oprnd2
);
template<typename T>
INLINE_FUNCTION_HD triple<T> operator-
(
const triple<T> & oprnd1,
const T & oprnd2
);
template<typename T>
INLINE_FUNCTION_HD triple<T> operator-
(
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>
INLINE_FUNCTION_HD triple<T> operator*
(
const triple<T> & oprnd1,
const T & oprnd2
);
template<typename T>
INLINE_FUNCTION_HD triple<T> operator*
(
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 T& oprnd2);
const triple<T> & oprnd1,
const triple<T> & oprnd2
);
template<typename T>
INLINE_FUNCTION_HD triple<T> operator/
(
const triple<T> & oprnd1,
const T & oprnd2
);
template<typename T>
INLINE_FUNCTION_HD triple<T> operator/
(
const T & oprnd1,
const triple<T> & oprnd2
);
template<typename T> template<typename T>
INLINE_FUNCTION_HD bool operator == INLINE_FUNCTION_HD triple<T>
( operator-(const T& oprnd1, const triple<T>& oprnd2);
const triple<T> &opr1,
const triple<T> &opr2
);
template<typename T> template<typename T>
INLINE_FUNCTION_HD bool operator > INLINE_FUNCTION_HD triple<T>
( operator*(const triple<T>& oprnd1, const triple<T>& oprnd2);
const triple<T> &opr1,
const triple<T> &opr2
);
template<typename T> template<typename T>
INLINE_FUNCTION_HD bool operator < INLINE_FUNCTION_HD triple<T>
( operator*(const triple<T>& oprnd1, const T& oprnd2);
const triple<T> &opr1,
const triple<T> &opr2
);
template<typename T> template<typename T>
INLINE_FUNCTION_HD bool operator <= INLINE_FUNCTION_HD triple<T>
( operator*(const T& oprnd1, const triple<T>& oprnd2);
const triple<T> &opr1,
const triple<T> &opr2
);
template<typename T> template<typename T>
INLINE_FUNCTION_HD bool operator >= INLINE_FUNCTION_HD triple<T>
( operator/(const triple<T>& oprnd1, const triple<T>& oprnd2);
const triple<T> &opr1,
const triple<T> &opr2
);
template<typename T>
INLINE_FUNCTION iOstream& operator<<
(
iOstream& str,
const triple<T> & ov
);
template<typename T>
INLINE_FUNCTION iIstream& operator>>
(
iIstream& str,
triple<T> & iv
);
template<typename T> template<typename T>
INLINE_FUNCTION void readIstream INLINE_FUNCTION_HD triple<T>
( operator/(const triple<T>& oprnd1, const T& oprnd2);
iIstream& str,
triple<T> & iv template<typename T>
); INLINE_FUNCTION_HD triple<T>
operator/(const T& oprnd1, const triple<T>& oprnd2);
template<typename T>
INLINE_FUNCTION_HD bool
operator==(const triple<T>& opr1, const triple<T>& opr2);
template<typename T>
INLINE_FUNCTION_HD bool
operator>(const triple<T>& opr1, const triple<T>& opr2);
template<typename T>
INLINE_FUNCTION_HD bool
operator<(const triple<T>& opr1, const triple<T>& opr2);
template<typename T>
INLINE_FUNCTION_HD bool
operator<=(const triple<T>& opr1, const triple<T>& opr2);
template<typename T>
INLINE_FUNCTION_HD bool
operator>=(const triple<T>& opr1, const triple<T>& opr2);
template<typename T>
INLINE_FUNCTION iOstream&
operator<<(iOstream& str, const triple<T>& ov);
template<typename T>
INLINE_FUNCTION iIstream&
operator>>(iIstream& str, triple<T>& iv);
template<typename T>
INLINE_FUNCTION void
readIstream(iIstream& str, triple<T>& iv);

View File

@ -2,332 +2,239 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: Licence:
This file is part of phasicFlow code. It is a free software for simulating This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions. the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/ -----------------------------------------------------------------------------*/
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_,
v1.z_*v2.x_ - v1.x_*v2.z_, v1.z_ * v2.x_ - v1.x_ * v2.z_,
v1.x_*v2.y_ - v1.y_*v2.x_ v1.x_ * v2.y_ - v1.y_ * v2.x_
); );
} }
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>
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 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> template<typename T>
INLINE_FUNCTION_HD void pFlow::triple<T>::operator+= INLINE_FUNCTION_HD pFlow::triple<T>
( pFlow::operator+(const triple<T>& oprnd1, const triple<T>& oprnd2)
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 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_;
this->z_ = this->z_ + oprnd2.z_; this->z_ = this->z_ + oprnd2.z_;
} }
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_;
this->z_ = this->z_ - oprnd2.z_; this->z_ = this->z_ - oprnd2.z_;
} }
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_;
this->z_ = this->z_ * oprnd2.z_; this->z_ = this->z_ * oprnd2.z_;
} }
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_;
this->z_ = this->z_ / oprnd2.z_; this->z_ = this->z_ / oprnd2.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 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_)
{ {
return true; return true;
} }
@ -338,13 +245,10 @@ 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_)
{ {
return true; return true;
} }
@ -355,13 +259,10 @@ 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_)
{ {
return true; return true;
} }
@ -371,15 +272,11 @@ 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_)
{ {
return true; return true;
} }
@ -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,59 +299,47 @@ 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);
return str; return str;
} }
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;
readIstream(str, val); readIstream(str, val);
iv.x_ = val; iv.x_ = val;
readIstream(str, val);
iv.y_ = val;
readIstream(str, val); readIstream(str, val);
iv.z_ = val; iv.y_ = val;
str.readEnd("triple<T>");
str.check(FUNCTION_NAME); readIstream(str, val);
iv.z_ = val;
str.readEnd("triple<T>");
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());
} }

View File

@ -2,17 +2,17 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: Licence:
This file is part of phasicFlow code. It is a free software for simulating This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions. the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@ -22,28 +22,33 @@ namespace pFlow
{ {
#define T3Func(fnName) \ #define T3Func(fnName) \
template<typename T> \ template<typename T> \
INLINE_FUNCTION_HD triple<T> fnName(const triple<T>& v) \ INLINE_FUNCTION_HD triple<T> fnName(const triple<T>& v) \
{ \ { \
return triple<T>(fnName(v.x_), fnName(v.y_), fnName(v.z_)); \ return triple<T>(fnName(v.x_), fnName(v.y_), fnName(v.z_)); \
} }
#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 * * * * * * * * //
// abs, mod, exp, log, log10, pow, sqrt, cbrt // abs, mod, exp, log, log10, pow, sqrt, cbrt
// sin, cos, tan, asin, acos, atan, atan2 // sin, cos, tan, asin, acos, atan, atan2
// sinh, cosh, tanh, asinh, acosh, atanh // sinh, cosh, tanh, asinh, acosh, atanh
// min, max // min, max
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * // //* * * * * * * * * * * * * * * * * * * * * * * * * * * * //
T3Func(abs); T3Func(abs);
T3Func2(mod); T3Func2(mod);
T3Func(exp); T3Func(exp);
@ -68,31 +73,32 @@ T3Func(atanh);
T3Func2(min); T3Func2(min);
T3Func2(max); T3Func2(max);
//// special forms of functions //// special forms of functions
// 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

View File

@ -2,17 +2,17 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: Licence:
This file is part of phasicFlow code. It is a free software for simulating This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions. the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@ -22,14 +22,13 @@ Licence:
namespace pFlow namespace pFlow
{ {
const realx3 zero3(0.0); const realx3 zero3(0.0);
const realx3 one3(1.0); const realx3 one3(1.0);
const realx3x3 zero33(zero3); const realx3x3 zero33(zero3);
const realx3x3 one33(one3); const realx3x3 one33(one3);
const realx4 zero4(zero); const realx4 zero4(zero);
} // pFlow } // pFlow

View File

@ -2,17 +2,17 @@
O C enter of O C enter of
O O E ngineering and O O E ngineering and
O O M ultiscale modeling of O O M ultiscale modeling of
OOOOOOO F luid flow OOOOOOO F luid flow
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Copyright (C): www.cemf.ir Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Licence: Licence:
This file is part of phasicFlow code. It is a free software for simulating This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions. the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@ -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,74 +31,117 @@ Licence:
#include "typeInfo.hpp" #include "typeInfo.hpp"
namespace pFlow namespace pFlow
{ {
using int8x3 = triple<int8>; using int8x3 = triple<int8>;
using int32x3 = triple<int32>; using int32x3 = triple<int32>;
using int64x3 = triple<int64>; using int64x3 = triple<int64>;
using uint8x3 = triple<uint8>; using uint8x3 = triple<uint8>;
using uint32x3 = triple<uint32>; using uint32x3 = triple<uint32>;
using uint64x3 = triple<uint64>; using uint64x3 = triple<uint64>;
using realx3 = triple<real>; using realx3 = triple<real>;
using int32x3x3 = triple<int32x3>; using int32x3x3 = triple<int32x3>;
using uint32x3x3= triple<uint32x3>; using uint32x3x3 = triple<uint32x3>;
using realx3x3 = triple<realx3>; using realx3x3 = triple<realx3>;
using realx4 = quadruple<real>; 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 one3;
extern const realx3 zero3;
extern const realx3 one3;
extern const realx3x3 zero33; extern const realx3x3 zero33;
extern const realx3x3 one33; extern const realx3x3 one33;
extern const realx4 zero4; extern const realx4 zero4;
} // pFlow } // pFlow
#endif //__types_hpp__ #endif //__types_hpp__