From 019236ff304eef1b80a97663733c48bf656f874c Mon Sep 17 00:00:00 2001 From: bramas <berenger.bramas@inria.fr> Date: Mon, 23 Jun 2014 11:01:22 +0200 Subject: [PATCH] add a method to reset the potential and forces of the FP2PParticleContainer --- Src/Components/FBasicParticleContainer.hpp | 5 +++++ Src/Kernels/P2P/FP2PParticleContainer.hpp | 6 ++++++ UTests/utestRotationDirectSeveralTime.cpp | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Src/Components/FBasicParticleContainer.hpp b/Src/Components/FBasicParticleContainer.hpp index 34b5d814b..e30755efe 100755 --- a/Src/Components/FBasicParticleContainer.hpp +++ b/Src/Components/FBasicParticleContainer.hpp @@ -306,6 +306,11 @@ public: memset(attributes[idx], 0, sizeof(AttributeClass) * allocatedParticles); } } + + /** Reset the attributes to zeros */ + void resetToInitialState(const int idxAttribute){ + memset(attributes[idxAttribute], 0, sizeof(AttributeClass) * allocatedParticles); + } }; diff --git a/Src/Kernels/P2P/FP2PParticleContainer.hpp b/Src/Kernels/P2P/FP2PParticleContainer.hpp index e48f2681c..87286d5ed 100644 --- a/Src/Kernels/P2P/FP2PParticleContainer.hpp +++ b/Src/Kernels/P2P/FP2PParticleContainer.hpp @@ -62,6 +62,12 @@ public: const FReal* getForcesZ(const int idxLhs = 0) const { return Parent::getAttribute(NRHS+3*NLHS+idxLhs); } + + void resetForcesAndPotential(){ + for(int idx = 0 ; idx < 4*NLHS ; ++idx){ + Parent::resetToInitialState(idx + NRHS); + } + } }; #endif // FP2PPARTICLECONTAINER_HPP diff --git a/UTests/utestRotationDirectSeveralTime.cpp b/UTests/utestRotationDirectSeveralTime.cpp index 260587bb9..1805c334e 100644 --- a/UTests/utestRotationDirectSeveralTime.cpp +++ b/UTests/utestRotationDirectSeveralTime.cpp @@ -92,7 +92,7 @@ class TestRotationDirectSeveralTime : public FUTester<TestRotationDirectSeveralT }); // If we want to reset the leaf //tree.forEachLeaf([&](LeafClass* leaf){ - // leaf->resetToInitialState(); + // leaf->resetForcesAndPotential(); //} } ///////////////////////////////////////////////////////////////////////////////////////////////// -- GitLab