# PhasicFlow: src/phasicFlow/structuredData/pointStructure/pointStructureKernels.hpp Source File

pointStructureKernels.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 __pointStructureKernels_hpp__
#define __pointStructureKernels_hpp__
#include "pointStructure.hpp"
#include "box.hpp"
namespace pFlow::pointStructureKernels
{
int32 markDeleteOutOfBox(
box domain,
int32 start,
int32 end,
int8 deleteFlag,
deviceViewType1D<realx3> points,
deviceViewType1D<int8> flags,
pointStructure::activePointsDevice activePoint,
int32 & minRange,
int32 & maxRange
)
{
using rpMark =
Kokkos::RangePolicy<Kokkos::IndexType<int32>>;
int32 numMarked = 0;
int32 minR = start-1, maxR = end+1;
if(start<end)
{
Kokkos::parallel_reduce(
"pointStructureKernels::markDeleteOutOfBox",
rpMark(start,end),
LAMBDA_HD(int32 i, int32& minUpdate, int32& maxUpdate, int32& valToUpdate){
if(activePoint(i))
{
if( !domain.isInside(points[i]) )
{
flags[i] = deleteFlag;
valToUpdate++;
}
else
{
minUpdate = min(minUpdate,i);
maxUpdate = max(maxUpdate,i);
}
}
},
Kokkos::Min<int32>(minR),
Kokkos::Max<int32>(maxR),
numMarked);
}
// means either range was empty or all points have been deleted.
if(minR<start || maxR>end)
{
minRange = 0;
maxRange = 0;
}
else
{
minRange = minR;
maxRange = maxR+1; // add one to make it half
}
return numMarked;
}
int32 scanPointFlag(
int32 start,
int32 end,
int8 activeFlag,
deviceViewType1D<int8> flags,
int32 & minRange,
int32 & maxRange
)
{
using rpScanFlag =
Kokkos::RangePolicy<Kokkos::IndexType<int32>>;
int32 numActive = 0;
if(start < end )
Kokkos::parallel_reduce(
"pointStructureKernels::scanPointFlag",
rpScanFlag(start, end),
LAMBDA_HD(
int32 i,
int32& minUpdate,
int32& maxUpdate,
int32& sumToUpdate){
if(flags[i] == activeFlag)
{
sumToUpdate++;
minUpdate = min(minUpdate,i);
maxUpdate = max(maxUpdate,i);
}
},
Kokkos::Min<int32>(minRange),
Kokkos::Max<int32>(maxRange),
numActive);
if(numActive==0)
{
minRange = 0;
maxRange = 0;
}
else
{
// add one to maxRange to make it half-open
maxRange ++;
}
return numActive;
}
}
#endif
pFlow::pointStructureKernels
Definition: pointStructureKernels.hpp:28
box.hpp
pFlow::pointStructureKernels::scanPointFlag
int32 scanPointFlag(int32 start, int32 end, int8 activeFlag, deviceViewType1D< int8 > flags, int32 &minRange, int32 &maxRange)
Definition: pointStructureKernels.hpp:92
pFlow::pointStructure::activePointsDevice
Definition: pointStructure.hpp:59
pFlow::deviceViewType1D
Kokkos::View< T * > deviceViewType1D
Definition: KokkosTypes.hpp:93
pFlow::int32
int int32
Definition: builtinTypes.hpp:53
pFlow::pointStructureKernels::markDeleteOutOfBox
int32 markDeleteOutOfBox(box domain, int32 start, int32 end, int8 deleteFlag, deviceViewType1D< realx3 > points, deviceViewType1D< int8 > flags, pointStructure::activePointsDevice activePoint, int32 &minRange, int32 &maxRange)
Definition: pointStructureKernels.hpp:32
pFlow::max
T max(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:164
pFlow::box
Definition: box.hpp:32
LAMBDA_HD
#define LAMBDA_HD
Definition: pFlowMacros.hpp:54
pFlow::int8
signed char int8
Definition: builtinTypes.hpp:49
pFlow::box::isInside
INLINE_FUNCTION_HD bool isInside(const realx3 &point) const
Definition: box.hpp:82
pointStructure.hpp
pFlow::min
T min(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:138