From d5ff1d7906601d35354ca86c51b75a4c5345d8c1 Mon Sep 17 00:00:00 2001 From: Hamidreza Norouzi Date: Wed, 22 May 2024 09:56:06 +0330 Subject: [PATCH] modifications for MPI+CUDA run --- src/Interaction/CMakeLists.txt | 4 +- .../containers/VectorHD/wordVectorHost.cpp | 77 +++++++++++++++++++ .../containers/VectorHD/wordVectorHost.hpp | 28 +++---- .../boundaries/boundaryList.cpp | 9 ++- .../domain/regularSimulationDomain.cpp | 9 ++- 5 files changed, 101 insertions(+), 26 deletions(-) diff --git a/src/Interaction/CMakeLists.txt b/src/Interaction/CMakeLists.txt index 96197f6a..c0265808 100644 --- a/src/Interaction/CMakeLists.txt +++ b/src/Interaction/CMakeLists.txt @@ -7,8 +7,8 @@ contactSearch/methods/cellBased/NBS/NBS.cpp contactSearch/methods/cellBased/NBS/cellsWallLevel0.cpp contactSearch/boundaries/boundaryContactSearch/boundaryContactSearch.cpp -#contactSearch/boundaries/twoPartContactSearch/twoPartContactSearchKernels.cpp -#contactSearch/boundaries/twoPartContactSearch/twoPartContactSearch.cpp +contactSearch/boundaries/twoPartContactSearch/twoPartContactSearchKernels.cpp +contactSearch/boundaries/twoPartContactSearch/twoPartContactSearch.cpp contactSearch/boundaries/periodicBoundaryContactSearch/ppwBndryContactSearchKernels.cpp contactSearch/boundaries/periodicBoundaryContactSearch/ppwBndryContactSearch.cpp contactSearch/boundaries/periodicBoundaryContactSearch/wallBoundaryContactSearch.cpp diff --git a/src/phasicFlow/containers/VectorHD/wordVectorHost.cpp b/src/phasicFlow/containers/VectorHD/wordVectorHost.cpp index 1941a239..eb1e8515 100644 --- a/src/phasicFlow/containers/VectorHD/wordVectorHost.cpp +++ b/src/phasicFlow/containers/VectorHD/wordVectorHost.cpp @@ -21,3 +21,80 @@ Licence: #include "wordVectorHost.hpp" +bool pFlow::VectorSingle::insertSetElement( + const uint32IndexContainer& indices, + const word& val +) +{ + if(indices.empty()) return true; + + auto maxInd = indices.max(); + + if(this->empty() || maxInd > size()-1 ) + { + resize(maxInd+1); + } + + auto ind = indices.hostView(); + auto s = indices.size(); + + for(uint32 i=0; i< s; i++) + { + container_[ind[i]] = val; + } + + return true; +} + +bool pFlow::VectorSingle::insertSetElement( + const uint32IndexContainer& indices, + const std::vector& vals +) +{ + if(indices.empty())return true; + if(indices.size() != vals.size())return false; + + auto maxInd = indices.max(); + + if(this->empty() || maxInd > size()-1 ) + { + resize(maxInd+1); + } + + auto ind = indices.hostView(); + auto s = indices.size(); + + for(uint32 i=0; i< s; i++) + { + container_[ind[i]] = vals[i]; + } + + return true; +} + +bool pFlow::VectorSingle::insertSetElement( + const uint32IndexContainer& indices, + const ViewType1D vals +) +{ + if(indices.empty())return true; + if(indices.size() != vals.size())return false; + + auto maxInd = indices.max(); + + if(this->empty() || maxInd > size()-1 ) + { + resize(maxInd+1); + } + + auto ind = indices.hostView(); + auto s = indices.size(); + + for(uint32 i=0; i< s; i++) + { + container_[ind[i]] = vals[i]; + } + + return true; +} + diff --git a/src/phasicFlow/containers/VectorHD/wordVectorHost.hpp b/src/phasicFlow/containers/VectorHD/wordVectorHost.hpp index e638bd27..cb6d15b2 100644 --- a/src/phasicFlow/containers/VectorHD/wordVectorHost.hpp +++ b/src/phasicFlow/containers/VectorHD/wordVectorHost.hpp @@ -372,28 +372,20 @@ public: return span(const_cast(container_.data()), container_.size()); } - INLINE_FUNCTION_H - bool insertSetElement(const uint32IndexContainer& indices, const word& val) - { - notImplementedFunction; - return false; - } - INLINE_FUNCTION_H - bool insertSetElement(const uint32IndexContainer& indices, const std::vector& vals) - { - notImplementedFunction; - return false; - } + bool insertSetElement(const uint32IndexContainer& indices, const word& val); + + + + bool insertSetElement(const uint32IndexContainer& indices, const std::vector& vals); + + - INLINE_FUNCTION_H bool insertSetElement( const uint32IndexContainer& indices, - const ViewType1D vals) - { - notImplementedFunction; - return false; - } + const ViewType1D vals + ); + INLINE_FUNCTION_H bool reorderItems(const uint32IndexContainer& indices) diff --git a/src/phasicFlow/structuredData/boundaries/boundaryList.cpp b/src/phasicFlow/structuredData/boundaries/boundaryList.cpp index 473e523d..0e5ddfed 100644 --- a/src/phasicFlow/structuredData/boundaries/boundaryList.cpp +++ b/src/phasicFlow/structuredData/boundaries/boundaryList.cpp @@ -92,9 +92,12 @@ pFlow::boundaryList::boundaryList(pointStructure& pStruct) : ListPtr(pStruct.simDomain().sizeOfBoundaries()), pStruct_(pStruct), neighborListUpdateInterval_( - pStruct.simDomain().subDict("boundaries").getVal( - "neighborListUpdateInterval" - ) + max( + pStruct.simDomain().subDict("boundaries").getVal( + "neighborListUpdateInterval" + ), + 1u + ) ) { } diff --git a/src/phasicFlow/structuredData/domain/regularSimulationDomain.cpp b/src/phasicFlow/structuredData/domain/regularSimulationDomain.cpp index a84325a9..aef3c126 100644 --- a/src/phasicFlow/structuredData/domain/regularSimulationDomain.cpp +++ b/src/phasicFlow/structuredData/domain/regularSimulationDomain.cpp @@ -32,9 +32,12 @@ bool pFlow::regularSimulationDomain::createBoundaryDicts() auto& rbBoundaries = this->subDict("regularBoundaries"); auto neighborLength = boundaries.getVal("neighborLength"); - auto boundaryExtntionLengthRatio = - boundaries.getValOrSet("boundaryExtntionLengthRatio", 0.1); - auto updateIntercal = boundaries.getValOrSet("updateInterval", 1u); + auto boundaryExtntionLengthRatio = max( + boundaries.getValOrSet("boundaryExtntionLengthRatio", 0.1), + 0.0); + auto updateIntercal = max( + boundaries.getValOrSet("updateInterval", 1u), + 1u); for(uint32 i=0; i