Bug fix for observed in particles, getNth and naming for contact lists

This commit is contained in:
Hamidreza 2025-03-14 18:33:02 +03:30
parent b65be8881c
commit 892f5395bc
9 changed files with 47 additions and 20 deletions

View File

@ -80,13 +80,17 @@ public:
TypeInfoNV("sortedContactList"); TypeInfoNV("sortedContactList");
sortedContactList(uint32 initialSize =1)
explicit sortedContactList(uint32 initialSize =1)
: :
SortedPairs(initialSize), sortedContactList("sortedContactList", initialSize)
values_("values", SortedPairs::capacity()), {}
sortedPairs0_("sortedPairs0", SortedPairs::capacity()),
values0_("values0", SortedPairs::capacity()) sortedContactList(const word& name, uint32 initialSize =1)
:
SortedPairs(name, initialSize),
values_(groupNames(name, "values"), SortedPairs::capacity()),
sortedPairs0_(groupNames(name, "sortedPairs0"), SortedPairs::capacity()),
values0_(groupNames(name, "values0"), SortedPairs::capacity())
{} {}
bool beforeBroadSearch() bool beforeBroadSearch()

View File

@ -110,11 +110,11 @@ public:
// constructors // constructors
explicit sortedPairs(uint32 initialSize =1) explicit sortedPairs(const word& name, uint32 initialSize =1)
: :
UnsortedPairs(initialSize), UnsortedPairs(initialSize),
flags_("flags_",UnsortedPairs::capacity()+1), flags_( groupNames(name, "flags_"), UnsortedPairs::capacity()+1),
sortedPairs_("sortedPairs_",UnsortedPairs::capacity()) sortedPairs_(groupNames(name, "sortedPairs_"), UnsortedPairs::capacity())
{} {}

View File

@ -82,11 +82,16 @@ public:
TypeInfoNV("unsortedContactList"); TypeInfoNV("unsortedContactList");
explicit unsortedContactList(uint32 capacity=1) explicit unsortedContactList(uint32 capacity=1)
:
unsortedContactList("unsortedContactList", capacity)
{}
unsortedContactList(const word& name, uint32 capacity=1)
: :
UnsortedPairs(capacity), UnsortedPairs(capacity),
values_("values", UnsortedPairs::capacity()), values_(groupNames(name, "values"), UnsortedPairs::capacity()),
container0_(capacity), container0_(capacity),
values0_("values0",container0_.capacity()) values0_(groupNames(name, "values0"),container0_.capacity())
{} {}

View File

@ -194,7 +194,9 @@ public:
{ {
uint newCap = container_.capacity()+len; uint newCap = container_.capacity()+len;
this->clear(); this->clear();
//output<<"----------------before "<<capacity()<< " " << size()<<endl;
container_.rehash(newCap); container_.rehash(newCap);
//output<<"----------------after "<<capacity()<< " " << size()<<endl;
} }
INLINE_FUNCTION_H INLINE_FUNCTION_H

View File

@ -41,9 +41,9 @@ bool pFlow::grainInteraction<cFM,gMM, cLT>::createGrainInteraction()
geometryMotion_, geometryMotion_,
timers()); timers());
ppContactList_ = makeUnique<ContactListType>(nPrtcl+1); ppContactList_ = makeUnique<ContactListType>("Grain-Grain",nPrtcl+1);
pwContactList_ = makeUnique<ContactListType>(nPrtcl/5+1); pwContactList_ = makeUnique<ContactListType>("Grain-wall",nPrtcl/5+1);
return true; return true;
} }

View File

@ -41,9 +41,9 @@ bool pFlow::sphereInteraction<cFM,gMM, cLT>::createSphereInteraction()
geometryMotion_, geometryMotion_,
timers()); timers());
ppContactList_ = makeUnique<ContactListType>(nPrtcl+1); ppContactList_ = makeUnique<ContactListType>("sphere-sphere",nPrtcl+1);
pwContactList_ = makeUnique<ContactListType>(nPrtcl/5+1); pwContactList_ = makeUnique<ContactListType>("sphere-wall",nPrtcl/5+1);
return true; return true;
} }

View File

@ -62,6 +62,12 @@ pFlow::particles::particles(systemControl& control, const shape& shapes)
//idHandler_().initialIdCheck(); //idHandler_().initialIdCheck();
} }
pFlow::particles::~particles()
{
// invalidates / unsobscribe from subscriber before its actual destruction
addToSubscriber(nullptr, message::Empty());
}
bool bool
pFlow::particles::beforeIteration() pFlow::particles::beforeIteration()
{ {

View File

@ -98,6 +98,8 @@ public:
explicit particles(systemControl& control, const shape& shapes); explicit particles(systemControl& control, const shape& shapes);
~particles() override;
inline const auto& dynPointStruct() const inline const auto& dynPointStruct() const
{ {
return dynPointStruct_; return dynPointStruct_;

View File

@ -269,11 +269,19 @@ template<typename Type, typename... sProperties>
INLINE_FUNCTION_H void INLINE_FUNCTION_H void
getNth(Type& dst, const ViewType1D<Type, sProperties...>& src, const uint32 n) getNth(Type& dst, const ViewType1D<Type, sProperties...>& src, const uint32 n)
{ {
using exeSpace = ViewType1D<Type, sProperties...>::execution_space;
if constexpr(isHostAccessible<exeSpace>())
{
dst = src[n];
}
else
{
auto subV = Kokkos::subview(src, Kokkos::make_pair(n, n + 1)); auto subV = Kokkos::subview(src, Kokkos::make_pair(n, n + 1));
hostViewType1D<Type> dstView("getNth", 1); hostViewType1D<Type> dstView("getNth", 1);
// hostViewTypeScalar // hostViewTypeScalar
Kokkos::deep_copy(dstView, subV); Kokkos::deep_copy(dstView, subV);
dst = *dstView.data(); dst = *dstView.data();
}
} }
template<typename T, typename... properties> template<typename T, typename... properties>