From 892f5395bc1c50775494bfcca570e09bcd7523c9 Mon Sep 17 00:00:00 2001 From: Hamidreza Date: Fri, 14 Mar 2025 18:33:02 +0330 Subject: [PATCH] Bug fix for observed in particles, getNth and naming for contact lists --- .../contactLists/sortedContactList.hpp | 16 ++++++++++------ src/Interaction/contactLists/sortedPairs.hpp | 6 +++--- .../contactLists/unsortedContactList.hpp | 9 +++++++-- src/Interaction/contactLists/unsortedPairs.hpp | 2 ++ .../grainInteraction/grainInteraction.cpp | 4 ++-- .../sphereInteraction/sphereInteraction.cpp | 4 ++-- src/Particles/particles/particles.cpp | 6 ++++++ src/Particles/particles/particles.hpp | 2 ++ src/phasicFlow/Kokkos/ViewAlgorithms.hpp | 18 +++++++++++++----- 9 files changed, 47 insertions(+), 20 deletions(-) diff --git a/src/Interaction/contactLists/sortedContactList.hpp b/src/Interaction/contactLists/sortedContactList.hpp index 4f41caac..aee1767e 100644 --- a/src/Interaction/contactLists/sortedContactList.hpp +++ b/src/Interaction/contactLists/sortedContactList.hpp @@ -80,13 +80,17 @@ public: TypeInfoNV("sortedContactList"); - - explicit sortedContactList(uint32 initialSize =1) + sortedContactList(uint32 initialSize =1) : - SortedPairs(initialSize), - values_("values", SortedPairs::capacity()), - sortedPairs0_("sortedPairs0", SortedPairs::capacity()), - values0_("values0", SortedPairs::capacity()) + sortedContactList("sortedContactList", initialSize) + {} + + 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() diff --git a/src/Interaction/contactLists/sortedPairs.hpp b/src/Interaction/contactLists/sortedPairs.hpp index 12593810..1ca30862 100644 --- a/src/Interaction/contactLists/sortedPairs.hpp +++ b/src/Interaction/contactLists/sortedPairs.hpp @@ -110,11 +110,11 @@ public: // constructors - explicit sortedPairs(uint32 initialSize =1) + explicit sortedPairs(const word& name, uint32 initialSize =1) : UnsortedPairs(initialSize), - flags_("flags_",UnsortedPairs::capacity()+1), - sortedPairs_("sortedPairs_",UnsortedPairs::capacity()) + flags_( groupNames(name, "flags_"), UnsortedPairs::capacity()+1), + sortedPairs_(groupNames(name, "sortedPairs_"), UnsortedPairs::capacity()) {} diff --git a/src/Interaction/contactLists/unsortedContactList.hpp b/src/Interaction/contactLists/unsortedContactList.hpp index 7aa98237..202b08ec 100644 --- a/src/Interaction/contactLists/unsortedContactList.hpp +++ b/src/Interaction/contactLists/unsortedContactList.hpp @@ -82,11 +82,16 @@ public: TypeInfoNV("unsortedContactList"); explicit unsortedContactList(uint32 capacity=1) + : + unsortedContactList("unsortedContactList", capacity) + {} + + unsortedContactList(const word& name, uint32 capacity=1) : UnsortedPairs(capacity), - values_("values", UnsortedPairs::capacity()), + values_(groupNames(name, "values"), UnsortedPairs::capacity()), container0_(capacity), - values0_("values0",container0_.capacity()) + values0_(groupNames(name, "values0"),container0_.capacity()) {} diff --git a/src/Interaction/contactLists/unsortedPairs.hpp b/src/Interaction/contactLists/unsortedPairs.hpp index fb622bdb..32898964 100644 --- a/src/Interaction/contactLists/unsortedPairs.hpp +++ b/src/Interaction/contactLists/unsortedPairs.hpp @@ -194,7 +194,9 @@ public: { uint newCap = container_.capacity()+len; this->clear(); + //output<<"----------------before "<::createGrainInteraction() geometryMotion_, timers()); - ppContactList_ = makeUnique(nPrtcl+1); + ppContactList_ = makeUnique("Grain-Grain",nPrtcl+1); - pwContactList_ = makeUnique(nPrtcl/5+1); + pwContactList_ = makeUnique("Grain-wall",nPrtcl/5+1); return true; } diff --git a/src/Interaction/sphereInteraction/sphereInteraction/sphereInteraction.cpp b/src/Interaction/sphereInteraction/sphereInteraction/sphereInteraction.cpp index cd362c66..fe907354 100644 --- a/src/Interaction/sphereInteraction/sphereInteraction/sphereInteraction.cpp +++ b/src/Interaction/sphereInteraction/sphereInteraction/sphereInteraction.cpp @@ -41,9 +41,9 @@ bool pFlow::sphereInteraction::createSphereInteraction() geometryMotion_, timers()); - ppContactList_ = makeUnique(nPrtcl+1); + ppContactList_ = makeUnique("sphere-sphere",nPrtcl+1); - pwContactList_ = makeUnique(nPrtcl/5+1); + pwContactList_ = makeUnique("sphere-wall",nPrtcl/5+1); return true; } diff --git a/src/Particles/particles/particles.cpp b/src/Particles/particles/particles.cpp index 4c50cc53..aefc03ba 100644 --- a/src/Particles/particles/particles.cpp +++ b/src/Particles/particles/particles.cpp @@ -62,6 +62,12 @@ pFlow::particles::particles(systemControl& control, const shape& shapes) //idHandler_().initialIdCheck(); } +pFlow::particles::~particles() +{ + // invalidates / unsobscribe from subscriber before its actual destruction + addToSubscriber(nullptr, message::Empty()); +} + bool pFlow::particles::beforeIteration() { diff --git a/src/Particles/particles/particles.hpp b/src/Particles/particles/particles.hpp index 2e7b508e..8c5f7741 100644 --- a/src/Particles/particles/particles.hpp +++ b/src/Particles/particles/particles.hpp @@ -98,6 +98,8 @@ public: explicit particles(systemControl& control, const shape& shapes); + ~particles() override; + inline const auto& dynPointStruct() const { return dynPointStruct_; diff --git a/src/phasicFlow/Kokkos/ViewAlgorithms.hpp b/src/phasicFlow/Kokkos/ViewAlgorithms.hpp index 28e32abd..280c1c18 100644 --- a/src/phasicFlow/Kokkos/ViewAlgorithms.hpp +++ b/src/phasicFlow/Kokkos/ViewAlgorithms.hpp @@ -269,11 +269,19 @@ template INLINE_FUNCTION_H void getNth(Type& dst, const ViewType1D& src, const uint32 n) { - auto subV = Kokkos::subview(src, Kokkos::make_pair(n, n + 1)); - hostViewType1D dstView("getNth", 1); - // hostViewTypeScalar - Kokkos::deep_copy(dstView, subV); - dst = *dstView.data(); + using exeSpace = ViewType1D::execution_space; + if constexpr(isHostAccessible()) + { + dst = src[n]; + } + else + { + auto subV = Kokkos::subview(src, Kokkos::make_pair(n, n + 1)); + hostViewType1D dstView("getNth", 1); + // hostViewTypeScalar + Kokkos::deep_copy(dstView, subV); + dst = *dstView.data(); + } } template