Merge pull request #37 from PhasicFlow/solvers

Solvers
This commit is contained in:
PhasicFlow 2022-10-05 16:03:06 +03:30 committed by GitHub
commit 2bd6c958a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 73 additions and 4 deletions

View File

@ -481,7 +481,7 @@ public:
} }
template <typename PairsContainer, typename teamMemberType> /*template <typename PairsContainer, typename teamMemberType>
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
int32 addPointsInBoxToList( int32 addPointsInBoxToList(
const teamMemberType& teamMember, const teamMemberType& teamMember,
@ -522,6 +522,40 @@ public:
return getFull; return getFull;
}*/
template <typename PairsContainer>
INLINE_FUNCTION_HD
int32 addPointsInBoxToListModified(
IdType id,
const iBox<IndexType>& triBox,
const PairsContainer& pairs)const
{
int32 getFull = 0;
auto bExtent = boxExtent(triBox);
int32 numCellBox = bExtent.x()*bExtent.y()*bExtent.z();
const auto head = head_;
const auto next = next_;
for(int32 linIndex=0; linIndex<numCellBox; linIndex++)
{
CellType cell;
indexToCell(linIndex, triBox, cell);
int32 n = head_(cell.x(),cell.y(),cell.z());
while( n>-1)
{
// id is wall id the pair is (particle id, wall id)
if( pairs.insert(static_cast<IdType>(n), id) < 0 )
getFull++;
n = next_(n);
}
}
return getFull;
} }
}; };

View File

@ -257,7 +257,7 @@ public:
while (getFull) while (getFull)
{ {
getFull = findPairsElementRange(pairs, particleMap); getFull = findPairsElementRangeModified(pairs, particleMap);
if(getFull) if(getFull)
{ {
@ -280,7 +280,7 @@ public:
return true; return true;
} }
template<typename PairsContainer, typename particleMapType> /*template<typename PairsContainer, typename particleMapType>
int32 findPairsElementRange(PairsContainer& pairs, particleMapType& particleMap) int32 findPairsElementRange(PairsContainer& pairs, particleMapType& particleMap)
{ {
int32 getFull =0; int32 getFull =0;
@ -296,6 +296,7 @@ public:
const typename tpPWContactSearch::member_type & teamMember, const typename tpPWContactSearch::member_type & teamMember,
int32& valueToUpdate){ int32& valueToUpdate){
int32 i = teamMember.league_rank(); int32 i = teamMember.league_rank();
printf("league size %d , league rank %d , team size %d and team rank %d \n", teamMember.league_size(), i, teamMember.team_size(), teamMember.team_rank());
IdType id = i; IdType id = i;
const auto triBox = elementBox[i]; const auto triBox = elementBox[i];
@ -311,9 +312,43 @@ public:
); );
return getFull; return getFull;
}*/
template<typename PairsContainer, typename particleMapType>
int32 findPairsElementRangeModified(PairsContainer& pairs, particleMapType& particleMap)
{
Kokkos::RangePolicy<
Kokkos::IndexType<int32>,
Kokkos::Schedule<Kokkos::Dynamic>,
ExecutionSpace> rPolicy(0,numElements_);
int32 getFull =0;
const auto pwPairs = pairs;
const auto elementBox = elementBox_;
//printf("we are in modified version \n");
Kokkos::parallel_reduce(
"cellsSimple::findPairsElementRangeModified",
rPolicy,
LAMBDA_HD(
int32 i,
int32& valueToUpdate){
IdType id = i;
const auto triBox = elementBox[i];
valueToUpdate +=
particleMap.addPointsInBoxToListModified(
id,
triBox,
pwPairs
);
},
getFull
);
return getFull;
} }
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
void operator()(TagFindCellRange2, int32 i) const void operator()(TagFindCellRange2, int32 i) const
{ {