diff --git a/Addons/CKernelApi/Src/FScalfmmApiInit.cpp b/Addons/CKernelApi/Src/FScalfmmApiInit.cpp index f0382d2f1e073016d8bb5604efa5da53f21eb3e4..8478ed5241c1f4cd20e74da3b9b8e8a05334d334 100644 --- a/Addons/CKernelApi/Src/FScalfmmApiInit.cpp +++ b/Addons/CKernelApi/Src/FScalfmmApiInit.cpp @@ -242,12 +242,15 @@ extern "C" void ChebKernel_L2P(void* leafCell, FSize nbParticles, const FSize* p inKernelStruct->kernel[id_thread]->L2P(leafChebCell,tempContainer); //Then retrieve the results - double * forcesToFill = reinterpret_cast(inKernel)->forcesComputed[id_thread]; + double * forcesToFill = reinterpret_cast(inKernel)->forcesComputed[id_thread]; + double * potentialsToFill = reinterpret_cast(inKernel)->potentials[id_thread]; + const FVector& indexes = tempContainer->getIndexes(); for(FSize idxPart = 0 ; idxPartgetForcesX()[idxPart]; forcesToFill[indexes[idxPart]*3+1] += tempContainer->getForcesY()[idxPart]; forcesToFill[indexes[idxPart]*3+2] += tempContainer->getForcesZ()[idxPart]; + potentialsToFill[indexes[idxPart]] =+ tempContainer->getPotentials()[idxPart]; } delete tempContainer; @@ -305,13 +308,16 @@ void ChebKernel_P2P(FSize nbParticles, const FSize* particleIndexes, inKernelStruct->kernel[id_thread]->P2P(FTreeCoordinate(coord),tempContTarget,nullptr,tempContSources,0); - //get back forces + //get back forces & potentials double * forcesToFill = reinterpret_cast(inKernel)->forcesComputed[id_thread]; + double * potentialsToFill = reinterpret_cast(inKernel)->potentials[id_thread]; + const FVector& indexes = tempContTarget->getIndexes(); for(FSize idxPart = 0 ; idxPartgetForcesX()[idxPart]; forcesToFill[indexes[idxPart]*3+1] += tempContTarget->getForcesY()[idxPart]; forcesToFill[indexes[idxPart]*3+2] += tempContTarget->getForcesZ()[idxPart]; + potentialsToFill[indexes[idxPart]] =+ tempContTarget->getPotentials()[idxPart]; } //Note that sources are also modified. @@ -323,6 +329,7 @@ void ChebKernel_P2P(FSize nbParticles, const FSize* particleIndexes, forcesToFill[indexesSource[idxSourcePart]*3+0] += tempContSources[idSource]->getForcesX()[idxSourcePart]; forcesToFill[indexesSource[idxSourcePart]*3+1] += tempContSources[idSource]->getForcesY()[idxSourcePart]; forcesToFill[indexesSource[idxSourcePart]*3+2] += tempContSources[idSource]->getForcesZ()[idxSourcePart]; + potentialsToFill[indexesSource[idxSourcePart]] =+ tempContSources[idSource]->getPotentials()[idxSourcePart]; } } diff --git a/Addons/CKernelApi/Tests/testChebInterface.c b/Addons/CKernelApi/Tests/testChebInterface.c index 7b9eff8b9bb7f175481f3a65a989fe1862897522..e1ba20606bfd2f479709d9fbe566a97a95ab6ee1 100644 --- a/Addons/CKernelApi/Tests/testChebInterface.c +++ b/Addons/CKernelApi/Tests/testChebInterface.c @@ -226,6 +226,16 @@ int main(int argc, char ** av){ } userDatas.forcesComputed = forcesToStore; + //Same idea with potential -> could be merge with loop just above, + //but it's kept apart in order to simply + double ** potentialToStore = malloc(sizeof(double*)*nb_threads); + //For each array, initialisation + for(idThreads=0 ; idThreads