Commit 13350c58 authored by BRAMAS Berenger's avatar BRAMAS Berenger
Browse files
parents 648e2966 9032b0be
......@@ -517,5 +517,12 @@ void scalfmm_execute_fmm(scalfmm_handle Handle);
*/
void scalfmm_dealloc_handle(scalfmm_handle handle, Callback_free_cell cellDestroyer);
/**
* @brief this function reset all the data of the tree. (i e multipole
* and local development, forces and potentials)
* @param Handle scalfmm_handle provided by scalfmm_init.
*/
void scalfmm_reset_tree(scalfmm_handle handle);
#endif
......@@ -518,6 +518,11 @@ public:
});
}
//Simple call to FScalFMMEngine method with good template
void reset_tree(){
generic_reset_tree<FReal,ContainerClass,InterCell,LeafClass>(octree);
}
void update_tree(){
if(arranger){
arranger->rearrange();
......
......@@ -30,6 +30,7 @@
//For tree
#include "Components/FSimpleLeaf.hpp"
#include "Kernels/P2P/FP2PParticleContainerIndexed.hpp"
#include "Containers/FOctree.hpp"
//For interpolation
#include "Kernels/Interpolation/FInterpMatrixKernel.hpp"
......@@ -201,6 +202,32 @@ public:
FAssertLF(0,"No tree instancied, exiting ...\n");
}
virtual void reset_tree(){
}
template<class FReal,class ContainerClass, class CellClass, class LeafClass>
void generic_reset_tree(FOctree<FReal,CellClass,ContainerClass,LeafClass> * tree){
//Reset forces and potentials
tree->forEachLeaf([&](LeafClass * leaf){
ContainerClass * targets = leaf->getTargets();
FSize nbPartTarget = targets->getNbParticles();
//Set potential to 0
FReal * potentialsTarget = targets->getPotentialsArray();
memset(potentialsTarget,0,sizeof(FReal)*nbPartTarget);
//Set forces to 0
FReal * forcesX = targets->getForcesXArray();
FReal * forcesY = targets->getForcesYArray();
FReal * forcesZ = targets->getForcesZArray();
memset(forcesX,0,sizeof(FReal)*nbPartTarget);
memset(forcesY,0,sizeof(FReal)*nbPartTarget);
memset(forcesZ,0,sizeof(FReal)*nbPartTarget);
});
//Reset multipole and local development
tree->forEachCell([&](CellClass * cell){
cell->resetToInitialState();
});
}
//User define Kernel Part
virtual void user_kernel_config( Scalfmm_Kernel_Descriptor userKernel, void * userDatas){
......@@ -215,6 +242,8 @@ public:
FAssertLF(0,"No kernel set, cannot execute anything, exiting ...\n");
}
};
......@@ -412,6 +441,8 @@ extern "C" void scalfmm_utils_interactionPosition(int interactionPosition, int*
}
extern "C" void scalfmm_reset_tree(scalfmm_handle Handle){
((ScalFmmCoreHandle * ) Handle)->engine->reset_tree();
}
#endif
......@@ -80,7 +80,11 @@ endif()
if (CBLAS_FIND_COMPONENTS)
foreach( component ${CBLAS_FIND_COMPONENTS} )
if(CBLAS_FIND_REQUIRED_${component})
find_package(${component} REQUIRED)
if (CBLAS_FIND_REQUIRED)
find_package(${component} REQUIRED)
else()
find_package(${component})
endif()
else()
find_package(${component})
endif()
......
......@@ -17,11 +17,11 @@
#define FINTERPCELL_HPP
#include "./FInterpTensor.hpp"
#include "../../Components/FBasicCell.hpp"
#include "../../Extensions/FExtendCellType.hpp"
#include "FInterpTensor.hpp"
#include "Components/FBasicCell.hpp"
#include "Extensions/FExtendCellType.hpp"
#include "../../Utils/FComplex.hpp"
#include "Utils/FComplex.hpp"
/**
* @author Pierre Blanchard (pierre.blanchard@inria.fr)
......@@ -177,12 +177,12 @@ public:
+ FBasicCell::getSavedSize());
}
int getSavedSizeUp() const {
FSize getSavedSizeUp() const {
return FSize((NRHS)*NVALS*VectorSize * (int) sizeof(FReal)
+ (NRHS)*NVALS*TransformedVectorSize * (int) sizeof(FComplex<FReal>));
}
int getSavedSizeDown() const {
FSize getSavedSizeDown() const {
return FSize((NLHS)*NVALS*VectorSize * (int) sizeof(FReal)
+ (NLHS)*NVALS*TransformedVectorSize * (int) sizeof(FComplex<FReal>));
}
......
......@@ -63,7 +63,6 @@ struct FInterpAbstractMatrixKernel : FNoCopyable
};
/// One over r
template <class FReal>
struct FInterpMatrixKernelR : FInterpAbstractMatrixKernel<FReal>
......
......@@ -20,12 +20,12 @@
#define FUNIFINTERPOLATOR_HPP
#include "./../Interpolation/FInterpMapping.hpp"
#include "../Interpolation/FInterpMapping.hpp"
#include "./FUnifTensor.hpp"
#include "./FUnifRoots.hpp"
#include "FUnifTensor.hpp"
#include "FUnifRoots.hpp"
#include "../../Utils/FBlas.hpp"
#include "Utils/FBlas.hpp"
......
// ===================================================================================
// Copyright ScalFmm 2011 INRIA, Olivier Coulaud, Bérenger Bramas, Matthias Messner
// Copyright ScalFmm 2011 INRIA, Olivier Coulaud, Berenger Bramas, Matthias Messner
// olivier.coulaud@inria.fr, berenger.bramas@inria.fr
// This software is a computer program whose purpose is to compute the FMM.
//
......@@ -19,12 +19,12 @@
#ifndef FUNIFKERNEL_HPP
#define FUNIFKERNEL_HPP
#include "../../Utils/FGlobal.hpp"
#include "Utils/FGlobal.hpp"
#include "../../Utils/FSmartPointer.hpp"
#include "Utils/FSmartPointer.hpp"
#include "./FAbstractUnifKernel.hpp"
#include "./FUnifM2LHandler.hpp"
#include "FAbstractUnifKernel.hpp"
#include "FUnifM2LHandler.hpp"
class FTreeCoordinate;
......
// ===================================================================================
// Copyright ScalFmm 2011 INRIA, Olivier Coulaud, Bérenger Bramas, Matthias Messner
// Copyright ScalFmm 2011 INRIA, Olivier Coulaud, Berenger Bramas, Matthias Messner
// olivier.coulaud@inria.fr, berenger.bramas@inria.fr
// This software is a computer program whose purpose is to compute the FMM.
//
......@@ -19,10 +19,10 @@
#ifndef FUNIFTENSOR_HPP
#define FUNIFTENSOR_HPP
#include "../../Utils/FMath.hpp"
#include "Utils/FMath.hpp"
#include "./FUnifRoots.hpp"
#include "./../Interpolation/FInterpTensor.hpp"
#include "FUnifRoots.hpp"
#include "../Interpolation/FInterpTensor.hpp"
/**
......
// ===================================================================================
// Copyright ScalFmm 2011 INRIA, Olivier Coulaud, Bérenger Bramas, Matthias Messner
// Copyright ScalFmm 2011 INRIA, Olivier Coulaud, Berenger Bramas, Matthias Messner
// olivier.coulaud@inria.fr, berenger.bramas@inria.fr
// This software is a computer program whose purpose is to compute the FMM.
//
......@@ -80,7 +80,7 @@ class TestBuffer : public FUTester<TestBuffer> {
const int SizeOfInt = int(sizeof(int));
const int NbTest = 5;
for(int idxWrite = 0 ; idxWrite < NbTest ; ++idxWrite){
const int position = writer.getSize();
const FSize position = writer.getSize();
uassert(position == (NbTest * SizeOfInt * idxWrite) + (idxWrite * SizeOfInt));
......
......@@ -30,6 +30,7 @@
#include "Core/FFmmAlgorithmPeriodic.hpp"
#include "FUTester.hpp"
#include "Utils/FMath.hpp"
#include "Kernels/Chebyshev/FChebCell.hpp"
......@@ -110,6 +111,7 @@ class TestChebyshevDirect : public FUTester<TestChebyshevDirect> {
std::cerr << "Sum of charges is not equal zero!!! (sum=<<"<<sum<<" )"<<std::endl;
exit(-1);
}
coeff = FMath::Abs(coeff)* static_cast<int>(NbParticles) ;
/////////////////////////////////////////////////////////////////////////////////////////////////
// Run FMM computation
/////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -219,6 +221,7 @@ class TestChebyshevDirect : public FUTester<TestChebyshevDirect> {
FReal L2error = (fx.getRelativeL2Norm()*fx.getRelativeL2Norm() + fy.getRelativeL2Norm()*fy.getRelativeL2Norm() + fz.getRelativeL2Norm() *fz.getRelativeL2Norm() );
printf(" Total L2 Force Error= %e\n",FMath::Sqrt(L2error)) ;
printf(" Energy Error = %.12e\n",FMath::Abs(energy-energyD));
printf(" R Energy Error = %.12e\n",FMath::Abs(energy-energyD)/FMath::Abs(energyD));
printf(" Energy FMM = %.12e\n",FMath::Abs(energy));
printf(" Energy DIRECT = %.12e\n",FMath::Abs(energyD));
......@@ -236,7 +239,7 @@ class TestChebyshevDirect : public FUTester<TestChebyshevDirect> {
uassert(fz.getL2Norm() < MaximumDiffForces); //8
// uassert(fz.getRMSError() < MaximumDiffForces); //8
uassert(L2error < MaximumDiffForces); //9 Total Force
uassert(FMath::Abs(energy-energyD) < 10*MaximumDiffPotential); //10 Total Energy
uassert(FMath::Abs(energy-energyD) / FMath::Abs(energyD) < coeff*MaximumDiffPotential); //10 Total Energy
......
......@@ -83,6 +83,8 @@ class TestSphericalDirectPeriodic : public FUTester<TestSphericalDirectPeriodic>
particles[idxPart].forces[2] = 0.0;
}
FReal CorErr = FReal(loader.getNumberOfParticles())*value/a;
coeff = FMath::Abs(coeff)* static_cast<int>(NbParticles) ;
// Run FMM
Print("Fmm...");
FmmClass algo(&tree,PeriodicDeep);
......@@ -178,9 +180,10 @@ class TestSphericalDirectPeriodic : public FUTester<TestSphericalDirectPeriodic>
FReal L2error = (fx.getRelativeL2Norm()*fx.getRelativeL2Norm() + fy.getRelativeL2Norm()*fy.getRelativeL2Norm() + fz.getRelativeL2Norm() *fz.getRelativeL2Norm() );
printf(" Total L2 Force Error= %e\n",FMath::Sqrt(L2error)) ;
//
printf(" Energy Error = %.12e\n",FMath::Abs(energy-energyD));
printf(" Energy FMM = %.12e\n",FMath::Abs(energy));
printf(" Energy DIRECT = %.12e\n",FMath::Abs(energyD));
printf(" Energy FMM = %.12e\n",FMath::Abs(energy));
printf(" Energy DIRECT = %.12e\n",FMath::Abs(energyD));
printf(" Error = %.12e\n",FMath::Abs(energy-energyD));
printf(" Relative Error = %.12e\n",FMath::Abs(energy-energyD) /FMath::Abs(energyD));
// ASSERT section
double epsilon = 1.0/FMath::pow2(DevP);
......@@ -207,7 +210,7 @@ class TestSphericalDirectPeriodic : public FUTester<TestSphericalDirectPeriodic>
Print("Test9 - Error Relative L2 norm F ");
uassert(L2error < MaximumDiffForces); //9 Total Force
Print("Test10 - Relative error Energy ");
uassert(FMath::Abs(energy-energyD) /FMath::Abs(energyD)< MaximumDiffPotential); //10 Total Energy
uassert(FMath::Abs(energy-energyD) /FMath::Abs(energyD)< coeff*MaximumDiffPotential); //10 Total Energy
delete[] particles;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment