# PhasicFlow: src/phasicFlow/containers/VectorHD/VectorDualAlgorithms.hpp Source File
PhasicFlow is an open-source parallel DEM (discrete element method) package for simulating granular flow. It is developed in C++ and can be exectued on both GPU (like CUDA) and CPU.

VectorDualAlgorithms.hpp
Go to the documentation of this file.
/*------------------------------- phasicFlow ---------------------------------
O C enter of
O O E ngineering and
O O M ultiscale modeling of
OOOOOOO F luid flow
------------------------------------------------------------------------------
Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------
Licence:
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
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
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/
#ifndef __VectorDualMath_hpp__
#define __VectorDualMath_hpp__
#include "baseAlgorithms.hpp"
namespace pFlow
{
// - select the side (HostSide or DeviceSide)
template<typename side, typename T, typename MemorySpace>
INLINE_FUNCTION_H
int64 count(const VectorDual<T,MemorySpace>& vec, const T& val)
{
if constexpr (std::is_same<side,HostSide>::value)
{
return count( vec.hostViewAll(), static_cast<size_t>(0), vec.size(), val);
}
else
{
return count( vec.deviceViewAll(), static_cast<size_t>(0), vec.size(), val);
}
return -1;
}
// default to device side
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
int64 count(const VectorDual<T,MemorySpace>& vec, const T& val)
{
return count<DeviceSide>( vec, val);
}
template<typename side, typename T, typename MemorySpace>
INLINE_FUNCTION_H
int64 min(const VectorDual<T,MemorySpace>& vec)
{
if constexpr (std::is_same<side,HostSide>::value)
{
return min( vec.hostViewAll(), static_cast<size_t>(0), vec.size());
}
else
{
return min( vec.deviceViewAll(), static_cast<size_t>(0), vec.size());
}
return 0.0;
}
// default to device side
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
int64 min(const VectorDual<T,MemorySpace>& vec)
{
return min<DeviceSide>( vec);
}
template<typename side, typename T, typename MemorySpace>
INLINE_FUNCTION_H
int64 max(const VectorDual<T,MemorySpace>& vec)
{
if constexpr (std::is_same<side,HostSide>::value)
{
return max( vec.hostViewAll(), static_cast<size_t>(0), vec.size());
}
else
{
return max( vec.deviceViewAll(), static_cast<size_t>(0), vec.size());
}
return 0.0;
}
// default to device side
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
int64 max(const VectorDual<T,MemorySpace>& vec)
{
return max<DeviceSide>( vec);
}
} // pFlow
#endif // __VectorSingleMath_hpp__
pFlow::max
T max(const internalField< T, MemorySpace > &iField)
Definition: internalFieldAlgorithms.hpp:79
pFlow::int64
long long int int64
Definition: builtinTypes.hpp:52
pFlow
Definition: demGeometry.hpp:27
pFlow::VectorDual::deviceViewAll
INLINE_FUNCTION_H deviceViewType & deviceViewAll()
Definition: VectorDual.hpp:335
pFlow::VectorDual
Definition: VectorDual.hpp:43
INLINE_FUNCTION_H
#define INLINE_FUNCTION_H
Definition: pFlowMacros.hpp:57
pFlow::count
auto count(const Vector< T, Allocator > &vec, const T &val)
Definition: VectorAlgorithm.hpp:26
pFlow::min
T min(const internalField< T, MemorySpace > &iField)
Definition: internalFieldAlgorithms.hpp:28
pFlow::VectorDual::size
INLINE_FUNCTION_H size_t size() const
Definition: VectorDual.hpp:391
pFlow::VectorDual::hostViewAll
INLINE_FUNCTION_H hostViewType & hostViewAll()
Definition: VectorDual.hpp:345