mirror of
https://github.com/PhasicFlow/phasicFlow.git
synced 2025-06-22 16:28:30 +00:00
Interaction folder is finalized with adjustable box and tested for rotating drum
This commit is contained in:
@ -53,7 +53,7 @@ protected:
|
||||
|
||||
ViewType1D<ValueType,ExecutionSpace> values_;
|
||||
|
||||
int32 size0_ = 0;
|
||||
uint32 size0_ = 0;
|
||||
|
||||
ViewType1D<PairType,ExecutionSpace> sortedPairs0_;
|
||||
|
||||
@ -73,7 +73,7 @@ protected:
|
||||
using rpReFillPairs = Kokkos::RangePolicy<
|
||||
ExecutionSpace,
|
||||
Kokkos::Schedule<Kokkos::Static>,
|
||||
Kokkos::IndexType<int32>,
|
||||
Kokkos::IndexType<uint32>,
|
||||
TagReFillPairs>;
|
||||
|
||||
public:
|
||||
@ -81,7 +81,7 @@ public:
|
||||
TypeInfoNV("sortedContactList");
|
||||
|
||||
|
||||
sortedContactList(int32 initialSize =1)
|
||||
explicit sortedContactList(uint32 initialSize =1)
|
||||
:
|
||||
SortedPairs(initialSize),
|
||||
values_("values", SortedPairs::capacity()),
|
||||
@ -114,31 +114,31 @@ public:
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
ValueType getValue(int32 idx)const
|
||||
ValueType getValue(uint32 idx)const
|
||||
{
|
||||
return values_[idx];
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
void setValue(int32 idx, const ValueType& val)const
|
||||
void setValue(uint32 idx, const ValueType& val)const
|
||||
{
|
||||
values_[idx] = val;
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
void operator()(TagReFillPairs, int32 idx)const
|
||||
void operator()(TagReFillPairs, uint32 idx)const
|
||||
{
|
||||
|
||||
auto searchLen = max(size0_/1000,10);
|
||||
auto start = max(0,idx-searchLen);
|
||||
auto end = min(size0_,idx+searchLen);
|
||||
uint32 searchLen = max(size0_/1000u,10u);
|
||||
uint32 start = idx-min(searchLen,idx);
|
||||
uint32 end = min(size0_,idx+searchLen);
|
||||
auto newPair = this->sortedPairs_[idx];
|
||||
if( auto idx0 = binarySearch(
|
||||
sortedPairs0_,
|
||||
start,
|
||||
end,
|
||||
newPair);
|
||||
idx0>=0)
|
||||
idx0!=-1)
|
||||
{
|
||||
values_[idx] = values0_[idx0];
|
||||
}
|
||||
@ -147,7 +147,7 @@ public:
|
||||
start,
|
||||
end,
|
||||
newPair);
|
||||
idx0>=0)
|
||||
idx0!=-1)
|
||||
{
|
||||
values_[idx] = values0_[idx0];
|
||||
|
||||
|
@ -52,24 +52,24 @@ public:
|
||||
{
|
||||
using PairType = typename sortedPairs::PairType;
|
||||
|
||||
int32 size_;
|
||||
uint32 size_;
|
||||
|
||||
ViewType1D<PairType,ExecutionSpace> sortedParis_;
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
int32 size()const { return size_; }
|
||||
uint32 size()const { return size_; }
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
int32 loopCount()const { return size_; }
|
||||
uint32 loopCount()const { return size_; }
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
bool isValid(int32 i)const { return i<size_; }
|
||||
bool isValid(uint32 i)const { return i<size_; }
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
PairType getPair(int i)const { return sortedParis_[i]; }
|
||||
PairType getPair(uint32 i)const { return sortedParis_[i]; }
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
bool getPair(int32 i, PairType& pair)const {
|
||||
bool getPair(uint32 i, PairType& pair)const {
|
||||
if(i<size_) {
|
||||
pair = sortedParis_[i];
|
||||
return true;
|
||||
@ -85,22 +85,22 @@ public:
|
||||
protected:
|
||||
|
||||
/// size of pair list
|
||||
int32 size_ = 0;
|
||||
uint32 size_ = 0;
|
||||
|
||||
ViewType1D<int32,ExecutionSpace> flags_;
|
||||
ViewType1D<uint32,ExecutionSpace> flags_;
|
||||
|
||||
ViewType1D<PairType,ExecutionSpace> sortedPairs_;
|
||||
|
||||
using rpFillFlag = Kokkos::RangePolicy<
|
||||
ExecutionSpace,
|
||||
Kokkos::Schedule<Kokkos::Static>,
|
||||
Kokkos::IndexType<int32>,
|
||||
Kokkos::IndexType<uint32>,
|
||||
TagFillFlag >;
|
||||
|
||||
using rpFillPairs = Kokkos::RangePolicy<
|
||||
ExecutionSpace,
|
||||
Kokkos::Schedule<Kokkos::Static>,
|
||||
Kokkos::IndexType<int32>,
|
||||
Kokkos::IndexType<uint32>,
|
||||
TagFillPairs>;
|
||||
|
||||
public:
|
||||
@ -110,7 +110,7 @@ public:
|
||||
|
||||
|
||||
// constructors
|
||||
sortedPairs(int32 initialSize =1)
|
||||
explicit sortedPairs(uint32 initialSize =1)
|
||||
:
|
||||
UnsortedPairs(initialSize),
|
||||
flags_("flags_",UnsortedPairs::capacity()+1),
|
||||
@ -134,7 +134,7 @@ public:
|
||||
// return the pair at index idx
|
||||
// perform no check for size and existance
|
||||
INLINE_FUNCTION_HD
|
||||
PairType getPair(int32 idx)const
|
||||
PairType getPair(uint32 idx)const
|
||||
{
|
||||
return sortedPairs_[idx];
|
||||
}
|
||||
@ -142,7 +142,7 @@ public:
|
||||
// - Device/host call
|
||||
// return the pair at index idx
|
||||
INLINE_FUNCTION_HD
|
||||
bool getPair(int32 idx, PairType& p)const
|
||||
bool getPair(uint32 idx, PairType& p)const
|
||||
{
|
||||
if(isValid(idx))
|
||||
{
|
||||
@ -156,7 +156,7 @@ public:
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
bool isValid(int32 idx)const
|
||||
bool isValid(uint32 idx)const
|
||||
{
|
||||
return idx < size_;
|
||||
}
|
||||
@ -164,12 +164,12 @@ public:
|
||||
|
||||
//use this when the value of size_ is updated
|
||||
INLINE_FUNCTION_H
|
||||
int32 size()const
|
||||
uint32 size()const
|
||||
{
|
||||
return size_;
|
||||
}
|
||||
|
||||
int32 loopCount()const
|
||||
uint32 loopCount()const
|
||||
{
|
||||
return size_;
|
||||
}
|
||||
@ -189,7 +189,7 @@ public:
|
||||
void prepareSorted()
|
||||
{
|
||||
// first check the size of flags_
|
||||
int32 capacity = UnsortedPairs::capacity();
|
||||
uint32 capacity = UnsortedPairs::capacity();
|
||||
|
||||
if( capacity+1 > flags_.size() )
|
||||
{
|
||||
@ -218,7 +218,7 @@ public:
|
||||
if( size_>sortedPairs_.size() )
|
||||
{
|
||||
// get more space to prevent reallocations in next iterations
|
||||
int32 len = size_*1.1+1;
|
||||
uint32 len = size_*1.1+1;
|
||||
reallocNoInit(sortedPairs_, len);
|
||||
}
|
||||
|
||||
@ -235,7 +235,7 @@ public:
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
void operator()(TagFillFlag, int32 i)const
|
||||
void operator()(TagFillFlag, uint32 i)const
|
||||
{
|
||||
if(this->container_.valid_at(i) )
|
||||
flags_[i] = 1;
|
||||
@ -244,7 +244,7 @@ public:
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
void operator()(TagFillPairs, int32 i)const
|
||||
void operator()(TagFillPairs, uint32 i)const
|
||||
{
|
||||
auto fi = flags_[i];
|
||||
if(fi!=flags_[i+1])
|
||||
|
@ -72,7 +72,7 @@ protected:
|
||||
using rpFillPairs = Kokkos::RangePolicy<
|
||||
ExecutionSpace,
|
||||
Kokkos::Schedule<Kokkos::Static>,
|
||||
Kokkos::IndexType<int32>,
|
||||
Kokkos::IndexType<uint32>,
|
||||
TagReFillPairs>;
|
||||
|
||||
|
||||
@ -80,7 +80,7 @@ public:
|
||||
|
||||
TypeInfoNV("unsortedContactList");
|
||||
|
||||
unsortedContactList(int32 capacity=1)
|
||||
explicit unsortedContactList(uint32 capacity=1)
|
||||
:
|
||||
UnsortedPairs(capacity),
|
||||
values_("values", UnsortedPairs::capacity()),
|
||||
@ -122,7 +122,7 @@ public:
|
||||
INLINE_FUNCTION_HD
|
||||
bool getValue(const PairType& p, ValueType& val)const
|
||||
{
|
||||
if(auto idx = this->find(p); idx>=0)
|
||||
if(auto idx = this->find(p); idx!=-1)
|
||||
{
|
||||
val = getValue(idx);
|
||||
return true;
|
||||
@ -131,7 +131,7 @@ public:
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
void setValue(int32 idx, const ValueType& val)const
|
||||
void setValue(uint32 idx, const ValueType& val)const
|
||||
{
|
||||
values_[idx] = val;
|
||||
}
|
||||
@ -139,7 +139,7 @@ public:
|
||||
INLINE_FUNCTION_HD
|
||||
bool setValue(const PairType& p, const ValueType& val)const
|
||||
{
|
||||
if(auto idx = this->find(p); idx>=0)
|
||||
if(uint32 idx = this->find(p); idx!=-1)
|
||||
{
|
||||
setValue(idx, val);
|
||||
return true;;
|
||||
@ -148,13 +148,13 @@ public:
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
void operator()(TagReFillPairs, int32 idx)const
|
||||
void operator()(TagReFillPairs, uint32 idx)const
|
||||
{
|
||||
if( this->isValid(idx) )
|
||||
{
|
||||
if( int32 idx0 =
|
||||
if( uint32 idx0 =
|
||||
container0_.find(this->getPair(idx));
|
||||
idx0>=0 )
|
||||
idx0!=-1 )
|
||||
{
|
||||
values_[idx] = values0_[idx0];
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
|
||||
using memory_space = typename ExecutionSpace::memory_space;
|
||||
|
||||
using PairType = kPair<idType,idType>;
|
||||
using PairType = Pair<idType,idType>;
|
||||
|
||||
using ContainerType = unorderedSet<PairType, ExecutionSpace>;
|
||||
|
||||
@ -52,19 +52,19 @@ public:
|
||||
ContainerType Container_;
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
int32 size()const { return Container_.size(); }
|
||||
uint32 size()const { return Container_.size(); }
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
int32 loopCount()const { return Container_.capacity(); }
|
||||
uint32 loopCount()const { return Container_.capacity(); }
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
bool isValid(int32 idx)const { return Container_.valid_at(idx); }
|
||||
bool isValid(uint32 idx)const { return Container_.valid_at(idx); }
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
PairType getPair(int idx)const { return Container_.key_at(idx); }
|
||||
PairType getPair(uint32 idx)const { return Container_.key_at(idx); }
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
bool getPair(int32 idx, PairType& pair)const {
|
||||
bool getPair(uint32 idx, PairType& pair)const {
|
||||
if(Container_.valid_at(idx)) {
|
||||
pair = Container_.key_at(idx);
|
||||
return true;
|
||||
@ -84,7 +84,7 @@ public:
|
||||
TypeInfoNV("unsorderedPairs");
|
||||
|
||||
// constructor
|
||||
unsortedPairs(int32 capacity=1)
|
||||
explicit unsortedPairs(uint32 capacity=1)
|
||||
:
|
||||
container_(capacity) // the minimum capacity would be 128
|
||||
{}
|
||||
@ -102,7 +102,7 @@ public:
|
||||
|
||||
// - Device call
|
||||
INLINE_FUNCTION_HD
|
||||
int32 insert(idType i, idType j)const
|
||||
uint32 insert(idType i, idType j)const
|
||||
{
|
||||
if(auto insertResult = container_.insert(PairType(i,j)); insertResult.failed())
|
||||
return -1;
|
||||
@ -112,7 +112,7 @@ public:
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
int32 insert(const PairType& p)const
|
||||
uint32 insert(const PairType& p)const
|
||||
{
|
||||
if(auto insertResult = container_.insert(p); insertResult.failed())
|
||||
return -1;
|
||||
@ -125,7 +125,7 @@ public:
|
||||
// return the pair at index idx
|
||||
// perform no check for size and existance
|
||||
INLINE_FUNCTION_HD
|
||||
PairType getPair(int32 idx)const
|
||||
PairType getPair(uint32 idx)const
|
||||
{
|
||||
return container_.key_at(idx);
|
||||
}
|
||||
@ -133,7 +133,7 @@ public:
|
||||
// - Device call
|
||||
// return the pair at index idx
|
||||
INLINE_FUNCTION_HD
|
||||
bool getPair(int32 idx, PairType& p)const
|
||||
bool getPair(uint32 idx, PairType& p)const
|
||||
{
|
||||
if(container_.valid_at(idx))
|
||||
{
|
||||
@ -148,7 +148,7 @@ public:
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
int32 find(const PairType & p)const
|
||||
uint32 find(const PairType & p)const
|
||||
{
|
||||
if( auto idx = container_.find(p);
|
||||
idx != Kokkos::UnorderedMapInvalidIndex )
|
||||
@ -158,26 +158,26 @@ public:
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
bool isValid(int32 idx)const
|
||||
bool isValid(uint32 idx)const
|
||||
{
|
||||
return container_.valid_at(idx);
|
||||
}
|
||||
|
||||
|
||||
INLINE_FUNCTION_HD
|
||||
int32 capacity() const
|
||||
uint32 capacity() const
|
||||
{
|
||||
return container_.capacity();
|
||||
}
|
||||
|
||||
int32 loopCount()const
|
||||
uint32 loopCount()const
|
||||
{
|
||||
return container_.capacity();
|
||||
}
|
||||
|
||||
//use this when the value of size_ is updated
|
||||
INLINE_FUNCTION_H
|
||||
int32 size()const
|
||||
uint32 size()const
|
||||
{
|
||||
return container_.size();
|
||||
}
|
||||
@ -190,7 +190,7 @@ public:
|
||||
/// increase the capacity of the container by at-least len
|
||||
/// the content will be erased.
|
||||
INLINE_FUNCTION_H
|
||||
void increaseCapacityBy(int32 len)
|
||||
void increaseCapacityBy(uint32 len)
|
||||
{
|
||||
uint newCap = container_.capacity()+len;
|
||||
this->clear();
|
||||
|
Reference in New Issue
Block a user