From 550d3cff3711e4e14740d429027ef9bc6c30e737 Mon Sep 17 00:00:00 2001 From: Berenger Bramas <Berenger.Bramas@inria.fr> Date: Wed, 25 Mar 2015 11:14:36 +0100 Subject: [PATCH] Make it compile for the new FREal --- Addons/CKernelApi/Src/FInterEngine.hpp | 4 +- Addons/CKernelApi/Src/FUserKernelEngine.hpp | 4 +- Examples/LagrangeInterpolationFMM.cpp | 4 +- Src/Adaptive/FAdaptTools.hpp | 2 +- Src/Adaptive/FAdaptUnifKernel.hpp | 26 +- Src/Arranger/FAbstractMover.hpp | 2 +- Src/Arranger/FArrangerPeriodic.hpp | 4 +- .../FBasicParticleContainerIndexedMover.hpp | 4 +- Src/Arranger/FParticleTypedIndexedMover.hpp | 4 +- Src/Containers/FParForEachOctree.hpp | 8 +- Src/Core/FAlgorithmBuilder.hpp | 4 +- Src/Files/FBasicLoader.hpp | 2 +- Src/Files/FFmaGenericLoader.hpp | 8 +- Src/Files/FTreeBuilder.hpp | 2 +- Src/GroupTree/Uniform/FUnifCellPOD.hpp | 2 +- Src/Kernels/Chebyshev/FChebFlopsSymKernel.hpp | 4 +- Src/Kernels/Chebyshev/FChebInterpolator.hpp | 2 +- .../Chebyshev/FChebTensorialKernel.hpp | 4 +- .../Chebyshev/FChebTensorialM2LHandler.hpp | 8 +- .../Rotation/FRotationOriginalKernel.hpp | 4 +- Src/Kernels/Spherical/FSphericalCell.hpp | 4 +- .../Spherical/FSphericalRotationKernel.hpp | 4 +- Src/Kernels/Taylor/FTaylorKernel.hpp | 1648 ++++++++--------- Src/Kernels/Uniform/FUnifCell.hpp | 12 +- Src/Kernels/Uniform/FUnifDenseKernel.hpp | 10 +- Src/Kernels/Uniform/FUnifInterpolator.hpp | 6 +- Src/Kernels/Uniform/FUnifKernel.hpp | 6 +- Src/Kernels/Uniform/FUnifM2LHandler.hpp | 22 +- Src/Kernels/Uniform/FUnifRoots.hpp | 30 +- Src/Kernels/Uniform/FUnifSymM2LHandler.hpp | 6 +- Src/Kernels/Uniform/FUnifTensorialKernel.hpp | 8 +- .../Uniform/FUnifTensorialM2LHandler.hpp | 30 +- Src/Utils/FDft.hpp | 640 +++---- Tests/Kernels/testChebTensorialAlgorithm.cpp | 4 +- Tests/Kernels/testFlopsChebAlgorithm.cpp | 2 +- Tests/Kernels/testP2PEfficency.cpp | 16 +- Tests/Kernels/testRotationPeriodicBench.cpp | 2 +- Tests/Kernels/testSphericalAlgorithm.cpp | 2 +- Tests/Kernels/testSphericalBench.cpp | 10 +- Tests/Kernels/testSphericalBlasAlgorithm.cpp | 2 +- .../testSphericalBlockBlasAlgorithm.cpp | 2 +- .../Kernels/testSphericalDlpolyAlgorithm.cpp | 22 +- Tests/Kernels/testSphericalGalaxyCsv.cpp | 32 +- Tests/Kernels/testSphericalProcAlgorithm.cpp | 4 +- .../testSphericalRotationAlgorithm.cpp | 2 +- Tests/Kernels/testTaylor.cpp | 4 +- Tests/Kernels/testTaylorKernel.cpp | 5 +- Tests/Kernels/testTaylorSimple.cpp | 4 +- Tests/Kernels/testTsmAlgorithm.cpp | 18 +- Tests/Kernels/testTuneSphericalBlockBlas.cpp | 6 +- Tests/Kernels/testUnifTensorialAlgorithm.cpp | 8 +- Tests/Utils/testChebM2Lprecomputation.cpp | 4 +- Tests/Utils/testChebOctree.cpp | 4 +- Tests/Utils/testChebSymmetries.cpp | 2 +- Tests/Utils/testChebTensorProduct.cpp | 4 +- Tests/Utils/testCompareIOTree.cpp | 10 +- Tests/Utils/testFastDiscreteConvolution.cpp | 2 +- Tests/Utils/testFmmAdaptiveAlgorithm.cpp | 1 + Tests/Utils/testFmmAdaptiveStats.cpp | 3 +- Tests/Utils/testFmmAlgorithm.cpp | 1 + Tests/Utils/testFmmAlgorithmPeriodic.cpp | 4 +- Tests/Utils/testFmmAlgorithmProc.cpp | 3 +- Tests/Utils/testFmmAlgorithmProcPeriodic.cpp | 6 +- Tests/Utils/testFmmAlgorithmProcRotation.cpp | 5 +- Tests/Utils/testFmmAlgorithmTsm.cpp | 5 +- Tests/Utils/testFmmDemonstration.cpp | 17 +- Tests/Utils/testLoader.cpp | 7 +- Tests/Utils/testLoaderFMATsm.cpp | 8 +- Tests/Utils/testMemStats.cpp | 4 +- Tests/Utils/testMpiCsvSaver.cpp | 14 +- Tests/Utils/testOctree.cpp | 5 +- Tests/Utils/testOctreeFuncteur.cpp | 3 +- Tests/Utils/testOctreeIter.cpp | 4 +- Tests/Utils/testOctreeParallelFuncteur.cpp | 3 +- Tests/Utils/testOctreeRearrange.cpp | 6 +- Tests/Utils/testOctreeRearrangePeriodic.cpp | 6 +- Tests/Utils/testOctreeRearrangeProc.cpp | 39 +- Tests/Utils/testOctreeRearrangeTsm.cpp | 8 +- Tests/Utils/testStatsTree.cpp | 4 +- Tests/Utils/testTreeBuilderThread.cpp | 4 +- Tests/Utils/testTreeIO.cpp | 6 +- Tests/Utils/testUnifInterpolator.cpp | 10 +- Tests/Utils/testUnifTensorialInterpolator.cpp | 14 +- Tests/noDist/testAdaptiveUnifFMM.cpp | 4 +- Tests/noDist/testBlockedUniform.cpp | 12 +- Tests/noDist/testCompareKernels.cpp | 4 +- Tests/noDist/testInsert.cpp | 4 +- Tests/noDist/testMpiInsert.cpp | 20 +- Tests/noDist/testNewCompareKernels.cpp | 24 +- Tests/noDist/testP2PAvx.cpp | 242 +-- Tests/noDist/testSmallCase.cpp | 6 +- Tests/noDist/testSphericalBlasBlockProc.cpp | 272 +-- Tests/noDist/testSphericalBlasProc.cpp | 6 +- Tests/noDist/testSphericalDebug.cpp | 26 +- Tests/noDist/testTreeBuilder.cpp | 6 +- Tests/noDist/testUnifMultiRhs.cpp | 4 +- ToRemove/AdaptiveTree/FAdaptTools.hpp | 2 +- ToRemove/AdaptiveTree/FAdaptUnifKernel.hpp | 16 +- ToRemove/AdaptiveTree/statAdaptiveOctree.cpp | 2 +- ToRemove/Olivier/ChebyshevDirectPeriodic.cpp | 6 +- ToRemove/Olivier/adaptiveOctree.cpp | 2 +- ToRemove/Olivier/statAdapt.cpp | 2 +- ToRemove/Olivier/testFMMEwald.cpp | 6 +- ToRemove/Olivier/testSphericalKernel.cpp | 4 +- ToRemove/testDirectStored.cpp | 2 +- ToRemove/testLoaderFMABinResult.cpp | 2 +- ToRemove/utestChebyshevDirectPeriodic.cpp | 4 +- ToRemove/utestSphericalDirect.cpp | 16 +- UTests/utestAlgorithmBuilder.cpp | 12 +- UTests/utestChebyshev.cpp | 4 +- UTests/utestChebyshevAdaptative.cpp | 2 +- UTests/utestChebyshevDirectPeriodic.cpp | 17 +- UTests/utestChebyshevMpi.cpp | 6 +- UTests/utestChebyshevThread.cpp | 4 +- UTests/utestInterpolationMultiRhs.cpp | 18 +- UTests/utestLagrange.cpp | 2 +- UTests/utestLagrangeMpi.cpp | 2 +- UTests/utestLagrangeThread.cpp | 2 +- UTests/utestMpiTreeBuilder.cpp | 28 +- UTests/utestOctree.cpp | 2 +- UTests/utestRotation.cpp | 6 +- UTests/utestRotationDirectPeriodic.cpp | 6 +- UTests/utestRotationDirectSeveralTime.cpp | 6 +- UTests/utestRotationDirectTsm.cpp | 16 +- UTests/utestRotationThread.cpp | 6 +- UTests/utestSpherical.cpp | 20 +- UTests/utestSphericalBlasAlgorithm.cpp | 20 +- UTests/utestSphericalDirect.cpp | 94 +- UTests/utestSphericalDirectPeriodic.cpp | 8 +- UTests/utestSphericalWithPrevious.cpp | 8 +- Utils/noDist/testPrecisionAllKernel.cpp | 48 +- 131 files changed, 1965 insertions(+), 1955 deletions(-) diff --git a/Addons/CKernelApi/Src/FInterEngine.hpp b/Addons/CKernelApi/Src/FInterEngine.hpp index f372276f2..2a427a859 100644 --- a/Addons/CKernelApi/Src/FInterEngine.hpp +++ b/Addons/CKernelApi/Src/FInterEngine.hpp @@ -51,7 +51,7 @@ private: //Typedef on Octree Arranger, in order to clarify following code typedef FBasicParticleContainerIndexedMover<OctreeClass, ContainerClass> MoverClass; - typedef FOctreeArranger<OctreeClass, ContainerClass, MoverClass> ArrangerClass; + typedef FOctreeArranger<FReal,OctreeClass, ContainerClass, MoverClass> ArrangerClass; typedef FArrangerPeriodic<OctreeClass, ContainerClass, MoverClass> ArrangerClassPeriodic; //Pointer to the kernel to be executed @@ -553,7 +553,7 @@ public: } case 2: { - typedef FFmmAlgorithmPeriodic<OctreeClass,InterCell,ContainerClass,InterKernel,LeafClass> AlgoClassPeriodic; + typedef FFmmAlgorithmPeriodic<FReal,OctreeClass,InterCell,ContainerClass,InterKernel,LeafClass> AlgoClassPeriodic; AlgoClassPeriodic algoPeriod(octree,2); algoPeriod.setKernel(kernel); algoPeriod.execute(); diff --git a/Addons/CKernelApi/Src/FUserKernelEngine.hpp b/Addons/CKernelApi/Src/FUserKernelEngine.hpp index 6c2f8e9c3..9b88ce6d1 100644 --- a/Addons/CKernelApi/Src/FUserKernelEngine.hpp +++ b/Addons/CKernelApi/Src/FUserKernelEngine.hpp @@ -210,7 +210,7 @@ private: //For arranger classes typedef FBasicParticleContainerIndexedMover<OctreeClass, ContainerClass> MoverClass; - typedef FOctreeArranger<OctreeClass, ContainerClass, MoverClass> ArrangerClass; + typedef FOctreeArranger<FReal,OctreeClass, ContainerClass, MoverClass> ArrangerClass; typedef FArrangerPeriodic<OctreeClass, ContainerClass, MoverClass> ArrangerClassPeriodic; @@ -479,7 +479,7 @@ public: } case 2: { - typedef FFmmAlgorithmPeriodic<OctreeClass,CoreCell,ContainerClass,CoreKernelClass,LeafClass> AlgoClassPeriodic; + typedef FFmmAlgorithmPeriodic<FReal,OctreeClass,CoreCell,ContainerClass,CoreKernelClass,LeafClass> AlgoClassPeriodic; AlgoClassPeriodic algoPeriod(octree,2); algoPeriod.setKernel(kernel); algoPeriod.execute(); diff --git a/Examples/LagrangeInterpolationFMM.cpp b/Examples/LagrangeInterpolationFMM.cpp index 88fe77b34..815238889 100755 --- a/Examples/LagrangeInterpolationFMM.cpp +++ b/Examples/LagrangeInterpolationFMM.cpp @@ -98,11 +98,11 @@ int main(int argc, char* argv[]) // open particle file //////////////////////////////////////////////////////////////////// // + typedef double FReal; FFmaGenericLoader<FReal> loader(filename); // //////////////////////////////////////////////////////////////////// // begin Lagrange kernel - typedef double FReal; // accuracy const unsigned int ORDER = 7; // typedefs @@ -216,7 +216,7 @@ int main(int argc, char* argv[]) // ----------------------------------------------------- if(FParameters::existParameter(argc, argv, FParameterDefinitions::OutputFile.options)){ std::string name(FParameters::getStr(argc,argv,FParameterDefinitions::OutputFile.options, "output.fma")); - FFmaGenericWriter writer(name) ; + FFmaGenericWriter<FReal> writer(name) ; // int NbPoints = loader.getNumberOfParticles(); FReal * particles ; diff --git a/Src/Adaptive/FAdaptTools.hpp b/Src/Adaptive/FAdaptTools.hpp index 1d2106837..aefc84a70 100644 --- a/Src/Adaptive/FAdaptTools.hpp +++ b/Src/Adaptive/FAdaptTools.hpp @@ -169,7 +169,7 @@ void adaptiveTreeBuildLists(OctreeClass & tree) { } }; ///////////////////////////////////////////////////////////////////////////////////////// -//! \fn setGlobalID(FOctree< FAdaptCell, FBasicParticleContainer<0> , FSimpleLeaf<FReal, FBasicParticleContainer<0>> > & tree) { +//! \fn setGlobalID(FOctree< FAdaptCell, FBasicParticleContainer<FReal,0,FReal> , FSimpleLeaf<FReal, FBasicParticleContainer<FReal,0,FReal>> > & tree) { ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/Src/Adaptive/FAdaptUnifKernel.hpp b/Src/Adaptive/FAdaptUnifKernel.hpp index f047e3d04..af0f7ebdb 100644 --- a/Src/Adaptive/FAdaptUnifKernel.hpp +++ b/Src/Adaptive/FAdaptUnifKernel.hpp @@ -135,10 +135,10 @@ public: // // // set child info // FPoint<FReal> ChildRoots[nnodes], localChildRoots[nnodes]; -// FUnifTensor<ORDER>::setRoots(subCellCenter, subCellWidth, ChildRoots); +// FUnifTensor<FReal,ORDER>::setRoots(subCellCenter, subCellWidth, ChildRoots); // // // map global position of roots to local position in parent cell -// const map_glob_loc map(poleCellCenter, poleCellWidth); +// const map_glob_loc<FReal> map(poleCellCenter, poleCellWidth); // for (unsigned int n=0; n<nnodes; ++n) // map(ChildRoots[n], localChildRoots[n]); // @@ -151,11 +151,11 @@ public: // Set sub-child coords FReal globalChildCoords[3][ORDER]; - FUnifTensor<order>::setPolynomialsRoots(subCellCenter, subCellWidth, globalChildCoords); + FUnifTensor<FReal,order>::setPolynomialsRoots(subCellCenter, subCellWidth, globalChildCoords); // Map global position of sub-child nodes to [-1,1] FReal localChildCoords[3][ORDER]; - const map_glob_loc map(poleCellCenter, poleCellWidth); + const map_glob_loc<FReal> map(poleCellCenter, poleCellWidth); FPoint<FReal> localChildPoints; for (unsigned int n=0; n<ORDER; ++n) { map(FPoint<FReal>(globalChildCoords[0][n],globalChildCoords[1][n],globalChildCoords[2][n]), localChildPoints); @@ -225,7 +225,7 @@ public: // std::cout << " call P2L localLevel "<< localLevel << " localCellCenter "<< localCellCenter <<std::endl; // interpolation points of target (X) cell FPoint<FReal> X[nnodes]; - FUnifTensor<order>::setRoots(localCellCenter, localCellWidth, X); + FUnifTensor<FReal,order>::setRoots(localCellCenter, localCellWidth, X); // read positions const FReal*const positionsX = particles->getPositions()[0]; @@ -265,8 +265,8 @@ public: // interpolation points of source (Y) and target (X) cell FPoint<FReal> X[nnodes], Y[nnodes]; - FUnifTensor<order>::setRoots(poleCellCenter, poleCellWidth, Y); - FUnifTensor<order>::setRoots(localCellCenter, localCellWidth, X); + FUnifTensor<FReal,order>::setRoots(poleCellCenter, poleCellWidth, Y); + FUnifTensor<FReal,order>::setRoots(localCellCenter, localCellWidth, X); for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){ @@ -290,7 +290,7 @@ public: // interpolation points of source (Y) cell FPoint<FReal> Y[nnodes]; - FUnifTensor<order>::setRoots(poleCellCenter, poleCellWidth, Y); + FUnifTensor<FReal,order>::setRoots(poleCellCenter, poleCellWidth, Y); // read positions const FReal*const positionsX = particles->getPositions()[0]; @@ -347,10 +347,10 @@ public: // // // set child info // FPoint<FReal> ChildRoots[nnodes], localChildRoots[nnodes]; -// FUnifTensor<ORDER>::setRoots(subCellCenter, subCellWidth, ChildRoots); +// FUnifTensor<FReal,ORDER>::setRoots(subCellCenter, subCellWidth, ChildRoots); // // // map global position of roots to local position in parent cell -// const map_glob_loc map(localCenter, localWidth); +// const map_glob_loc<FReal> map(localCenter, localWidth); // for (unsigned int n=0; n<nnodes; ++n) // map(ChildRoots[n], localChildRoots[n]); // @@ -361,11 +361,11 @@ public: /// p^4 version // Set sub-child coords FReal globalChildCoords[3][ORDER]; - FUnifTensor<order>::setPolynomialsRoots(subCellCenter, subCellWidth, globalChildCoords); + FUnifTensor<FReal,order>::setPolynomialsRoots(subCellCenter, subCellWidth, globalChildCoords); // Map global position of sub-child nodes to [-1,1] FReal localChildCoords[3][ORDER]; - const map_glob_loc map(localCenter, localWidth); + const map_glob_loc<FReal> map(localCenter, localWidth); FPoint<FReal> localChildPoints; for (unsigned int n=0; n<ORDER; ++n) { map(FPoint<FReal>(globalChildCoords[0][n],globalChildCoords[1][n],globalChildCoords[2][n]), localChildPoints); @@ -448,7 +448,7 @@ public: void P2P(ContainerClass* target, const ContainerClass* sources) override { ContainerClass* sourcesArray[27] = { const_cast<ContainerClass*> (sources) }; - DirectInteractionComputer<MatrixKernelClass::NCMP, NVALS>::template P2PRemote(target,sourcesArray,1,MatrixKernel); + DirectInteractionComputer<FReal,MatrixKernelClass::NCMP, NVALS>::template P2PRemote(target,sourcesArray,1,MatrixKernel); } bool preferP2M(const ContainerClass* const particles) override { diff --git a/Src/Arranger/FAbstractMover.hpp b/Src/Arranger/FAbstractMover.hpp index e4d320926..ac3c35a89 100644 --- a/Src/Arranger/FAbstractMover.hpp +++ b/Src/Arranger/FAbstractMover.hpp @@ -16,7 +16,7 @@ #ifndef FABSTRACTLEAFINTERFACE_HPP #define FABSTRACTLEAFINTERFACE_HPP -template<class OctreeClass,class ParticleClass> +template<class FReal,class OctreeClass,class ParticleClass> class FAbstractMover{ public: virtual void getParticlePosition(ParticleClass* lf, const int idxPart, FPoint<FReal>* particlePos) = 0; diff --git a/Src/Arranger/FArrangerPeriodic.hpp b/Src/Arranger/FArrangerPeriodic.hpp index ce1510d72..73beab040 100644 --- a/Src/Arranger/FArrangerPeriodic.hpp +++ b/Src/Arranger/FArrangerPeriodic.hpp @@ -21,7 +21,7 @@ #include "Arranger/FOctreeArranger.hpp" template <class FReal, class OctreeClass, class ContainerClass, class LeafInterface > -class FArrangerPeriodic : public FOctreeArranger<OctreeClass,ContainerClass,LeafInterface>{ +class FArrangerPeriodic : public FOctreeArranger<FReal,OctreeClass,ContainerClass,LeafInterface>{ FReal getPeriodicPos(FReal pos, PeriodicCondition periodicPlus, PeriodicCondition periodicMinus,FReal maxDir,FReal minDir,const int dir){ FReal res = pos; @@ -41,7 +41,7 @@ class FArrangerPeriodic : public FOctreeArranger<OctreeClass,ContainerClass,Leaf public: - FArrangerPeriodic(OctreeClass * octree) : FOctreeArranger<OctreeClass,ContainerClass,LeafInterface>(octree){ + FArrangerPeriodic(OctreeClass * octree) : FOctreeArranger<FReal,OctreeClass,ContainerClass,LeafInterface>(octree){ } // To put in inhereed class diff --git a/Src/Arranger/FBasicParticleContainerIndexedMover.hpp b/Src/Arranger/FBasicParticleContainerIndexedMover.hpp index 6bfb5cb59..343e89795 100644 --- a/Src/Arranger/FBasicParticleContainerIndexedMover.hpp +++ b/Src/Arranger/FBasicParticleContainerIndexedMover.hpp @@ -7,8 +7,8 @@ * This class should be use with the octree arrange to move particles * that are stored in a FBasicParticleContainer */ -template<class OctreeClass, class ContainerClass > -class FBasicParticleContainerIndexedMover : public FAbstractMover<OctreeClass, ContainerClass>{ +template<class FReal, class OctreeClass, class ContainerClass > +class FBasicParticleContainerIndexedMover : public FAbstractMover<FReal,OctreeClass, ContainerClass>{ private: ContainerClass toStoreRemovedParts; diff --git a/Src/Arranger/FParticleTypedIndexedMover.hpp b/Src/Arranger/FParticleTypedIndexedMover.hpp index fb07ecd49..c1504df13 100644 --- a/Src/Arranger/FParticleTypedIndexedMover.hpp +++ b/Src/Arranger/FParticleTypedIndexedMover.hpp @@ -8,8 +8,8 @@ * This class should be use with the octree arrange to move particles * that are typed (src/tgt) and stored in a FBasicParticleContainer */ -template<class OctreeClass, class ContainerClass > -class FParticleTypedIndexedMover : public FAbstractMover<OctreeClass, ContainerClass>{ +template<class FReal, class OctreeClass, class ContainerClass > +class FParticleTypedIndexedMover : public FAbstractMover<FReal, OctreeClass, ContainerClass>{ private: ContainerClass toStoreRemovedSourceParts; ContainerClass toStoreRemovedTargetParts; diff --git a/Src/Containers/FParForEachOctree.hpp b/Src/Containers/FParForEachOctree.hpp index a10115c0f..3b0a98576 100644 --- a/Src/Containers/FParForEachOctree.hpp +++ b/Src/Containers/FParForEachOctree.hpp @@ -15,7 +15,7 @@ namespace FParForEachOctree { * @brief forEachLeaf iterate on the leaf and apply the function * @param function */ -template< template< class CellClass, class ContainerClass, class LeafClass, class CellAllocatorClass > class FOctree, +template< class FReal, template<class FReal, class CellClass, class ContainerClass, class LeafClass, class CellAllocatorClass > class FOctree, class CellClass, class ContainerClass, class LeafClass, class CellAllocatorClass, class FunctionTemplate> void forEachLeaf(FOctree<FReal, CellClass,ContainerClass,LeafClass,CellAllocatorClass>* tree, FunctionTemplate function){ @@ -43,7 +43,7 @@ void forEachLeaf(FOctree<FReal, CellClass,ContainerClass,LeafClass,CellAllocator * @brief forEachLeaf iterate on the cell and apply the function * @param function */ -template< template< class CellClass, class ContainerClass, class LeafClass, class CellAllocatorClass > class FOctree, +template< class FReal, template<class FReal, class CellClass, class ContainerClass, class LeafClass, class CellAllocatorClass > class FOctree, class CellClass, class ContainerClass, class LeafClass, class CellAllocatorClass, class FunctionTemplate> void forEachCell(FOctree<FReal, CellClass,ContainerClass,LeafClass,CellAllocatorClass>* tree, FunctionTemplate function){ @@ -77,7 +77,7 @@ void forEachCell(FOctree<FReal, CellClass,ContainerClass,LeafClass,CellAllocator * @brief forEachLeaf iterate on the cell and apply the function * @param function */ -template< template< class CellClass, class ContainerClass, class LeafClass, class CellAllocatorClass > class FOctree, +template< class FReal, template<class FReal, class CellClass, class ContainerClass, class LeafClass, class CellAllocatorClass > class FOctree, class CellClass, class ContainerClass, class LeafClass, class CellAllocatorClass, class FunctionTemplate> void forEachCellWithLevel(FOctree<FReal, CellClass,ContainerClass,LeafClass,CellAllocatorClass>* tree, FunctionTemplate function){ @@ -111,7 +111,7 @@ void forEachCellWithLevel(FOctree<FReal, CellClass,ContainerClass,LeafClass,Cell * @brief forEachLeaf iterate on the cell and apply the function * @param function */ -template< template< class CellClass, class ContainerClass, class LeafClass, class CellAllocatorClass > class FOctree, +template< class FReal, template<class FReal, class CellClass, class ContainerClass, class LeafClass, class CellAllocatorClass > class FOctree, class CellClass, class ContainerClass, class LeafClass, class CellAllocatorClass, class FunctionTemplate> void forEachCellLeaf(FOctree<FReal, CellClass,ContainerClass,LeafClass,CellAllocatorClass>* tree, FunctionTemplate function){ diff --git a/Src/Core/FAlgorithmBuilder.hpp b/Src/Core/FAlgorithmBuilder.hpp index 765a974ab..8f2fe12ab 100644 --- a/Src/Core/FAlgorithmBuilder.hpp +++ b/Src/Core/FAlgorithmBuilder.hpp @@ -91,7 +91,7 @@ public: return new FFmmAlgorithmThreadProc<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass>(FMpi::FComm(mpiComm), tree, kernel); } else{ - auto algo = new FFmmAlgorithmThreadProcPeriodic<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass>(FMpi::FComm(mpiComm), tree, periodicUpperlevel); + auto algo = new FFmmAlgorithmThreadProcPeriodic<FReal, OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass>(FMpi::FComm(mpiComm), tree, periodicUpperlevel); algo->setKernel(kernel); return algo; } @@ -100,7 +100,7 @@ public: return new FFmmAlgorithmThread<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass>(tree, kernel); } else{ - auto algo = new FFmmAlgorithmPeriodic<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass>(tree, periodicUpperlevel); + auto algo = new FFmmAlgorithmPeriodic<FReal,OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass>(tree, periodicUpperlevel); algo->setKernel(kernel); return algo; } diff --git a/Src/Files/FBasicLoader.hpp b/Src/Files/FBasicLoader.hpp index ee906a2dc..7b8c94bd8 100644 --- a/Src/Files/FBasicLoader.hpp +++ b/Src/Files/FBasicLoader.hpp @@ -50,7 +50,7 @@ * @endcode */ template <class FReal> -class FBasicLoader : public FAbstractLoader { +class FBasicLoader : public FAbstractLoader<FReal> { protected: std::ifstream file; //< The file to read FPoint<FReal> centerOfBox; //< The center of box read from file diff --git a/Src/Files/FFmaGenericLoader.hpp b/Src/Files/FFmaGenericLoader.hpp index 6df63db3e..2f70bb144 100644 --- a/Src/Files/FFmaGenericLoader.hpp +++ b/Src/Files/FFmaGenericLoader.hpp @@ -511,7 +511,7 @@ private: * * \code * // Instanciate the writer with a binary fma file (extension .bfma). - * FFmaGenericWriter writer ("data.bfma"); + * FFmaGenericWriter<FReal> writer ("data.bfma"); * * // Write the header of the file. * writer.writeHeader(loader.getCenterOfBox(), loader.getBoxWidth(), NbPoints, sizeof(FReal), nbData); @@ -678,7 +678,7 @@ public: * FmaRParticle * particles = new FmaRParticle[nbParticles]; * memset(particles, 0, sizeof(FmaRParticle) * nbParticles) ; * ... - * FFmaGenericWriter writer(filenameOut) ; + * FFmaGenericWriter<FReal> writer(filenameOut) ; * Fwriter.writeHeader(Centre,BoxWith, nbParticles,*particles) ; * Fwriter.writeArrayOfParticles(particles, nbParticles); * \endcode @@ -689,7 +689,7 @@ public: * memset(particles, 0, sizeof(FmaRParticle) * nbParticles) ; * ... * FmaBasicParticle *ppart = (FmaBasicParticle*)(&particles[0]); - * FFmaGenericWriter writer(filenameOut) ; + * FFmaGenericWriter<FReal> writer(filenameOut) ; * writer.writeHeader(Centre,BoxWith, nbParticles,*particles) ; * writer.writeArrayOfParticles(particles, nbParticles); * \endcode @@ -748,7 +748,7 @@ public: * FmaRParticle * const particles = new FmaRParticle[nbParticles]; * memset(particles, 0, sizeof(FmaRParticle) * nbParticles) ; * ... - * FFmaGenericWriter writer(filenameOut) ; + * FFmaGenericWriter<FReal> writer(filenameOut) ; * Fwriter.writeHeader(Centre,BoxWith, nbParticles,*particles) ; * Fwriter.writeArrayOfReal(particles, nbParticles); * \endcode diff --git a/Src/Files/FTreeBuilder.hpp b/Src/Files/FTreeBuilder.hpp index d3eeefc71..d6f3f7b64 100644 --- a/Src/Files/FTreeBuilder.hpp +++ b/Src/Files/FTreeBuilder.hpp @@ -83,7 +83,7 @@ public: /** Should be used to insert a FBasicParticleContainer class */ template < unsigned NbAttributes, class AttributeClass> - static void BuildTreeFromArray(OctreeClass*const tree, const FBasicParticleContainer<NbAttributes, AttributeClass>& particlesContainers, + static void BuildTreeFromArray(OctreeClass*const tree, const FBasicParticleContainer<FReal, NbAttributes, AttributeClass>& particlesContainers, bool isAlreadySorted=false){ const FSize numberOfParticle = particlesContainers.getNbParticles(); // If the parts are already sorted, no need to sort again diff --git a/Src/GroupTree/Uniform/FUnifCellPOD.hpp b/Src/GroupTree/Uniform/FUnifCellPOD.hpp index d6edf531f..8f839063e 100644 --- a/Src/GroupTree/Uniform/FUnifCellPOD.hpp +++ b/Src/GroupTree/Uniform/FUnifCellPOD.hpp @@ -8,7 +8,7 @@ #include "../../Kernels/Uniform//FUnifTensor.hpp" #include "../../Utils/FComplex.hpp" -typedef FBasicCellPOD FTestCellPODCore; +typedef FBasicCellPOD FUnifCellPODCore; template <class FReal, int ORDER, int NRHS = 1, int NLHS = 1, int NVALS = 1> struct alignas(FStarPUDefaultAlign::StructAlign) FUnifCellPODPole { diff --git a/Src/Kernels/Chebyshev/FChebFlopsSymKernel.hpp b/Src/Kernels/Chebyshev/FChebFlopsSymKernel.hpp index d7743b2d0..fa50fa13a 100644 --- a/Src/Kernels/Chebyshev/FChebFlopsSymKernel.hpp +++ b/Src/Kernels/Chebyshev/FChebFlopsSymKernel.hpp @@ -279,11 +279,11 @@ public: * Handler to deal with all symmetries: Stores permutation indices and vectors * to reduce 343 different interactions to 16 only. */ -template < class CellClass, +template <class FReal, class CellClass, class ContainerClass, class MatrixKernelClass, int ORDER> -struct FChebFlopsSymKernel<CellClass, ContainerClass, MatrixKernelClass, ORDER> +struct FChebFlopsSymKernel<FReal, CellClass, ContainerClass, MatrixKernelClass, ORDER> ::SymmetryHandler { // M2L operators diff --git a/Src/Kernels/Chebyshev/FChebInterpolator.hpp b/Src/Kernels/Chebyshev/FChebInterpolator.hpp index ad9403186..fea298cbd 100644 --- a/Src/Kernels/Chebyshev/FChebInterpolator.hpp +++ b/Src/Kernels/Chebyshev/FChebInterpolator.hpp @@ -1632,7 +1632,7 @@ inline void FChebInterpolator<FReal, ORDER,MatrixKernelClass,NVALS>::applyL2PTot //FReal T_of_y[ORDER * (ORDER-1)]; //for (unsigned int o=1; o<ORDER; ++o) // for (unsigned int j=0; j<ORDER; ++j) - // T_of_y[(o-1)*ORDER + j] = FReal(FChebRoots<ORDER>::T(o, FReal(FChebRoots<ORDER>::roots[j]))); + // T_of_y[(o-1)*ORDER + j] = FReal(FChebRoots<FReal,ORDER>::T(o, FReal(FChebRoots<FReal,ORDER>::roots[j]))); //struct SumP2M { // unsigned int f2[3][nnodes], f4[3][nnodes]; diff --git a/Src/Kernels/Chebyshev/FChebTensorialKernel.hpp b/Src/Kernels/Chebyshev/FChebTensorialKernel.hpp index fce12d11e..9d892906d 100644 --- a/Src/Kernels/Chebyshev/FChebTensorialKernel.hpp +++ b/Src/Kernels/Chebyshev/FChebTensorialKernel.hpp @@ -229,14 +229,14 @@ public: ContainerClass* const NeighborSourceParticles[27], const int /* size */) { - DirectInteractionComputer<MatrixKernelClass::NCMP, NVALS>::P2P(TargetParticles,NeighborSourceParticles,MatrixKernel); + DirectInteractionComputer<FReal, MatrixKernelClass::NCMP, NVALS>::P2P(TargetParticles,NeighborSourceParticles,MatrixKernel); } void P2PRemote(const FTreeCoordinate& /*inPosition*/, ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict /*inSources*/, ContainerClass* const inNeighbors[27], const int /*inSize*/){ - DirectInteractionComputer<MatrixKernelClass::NCMP, NVALS>::P2PRemote(inTargets,inNeighbors,27,MatrixKernel); + DirectInteractionComputer<FReal, MatrixKernelClass::NCMP, NVALS>::P2PRemote(inTargets,inNeighbors,27,MatrixKernel); } }; diff --git a/Src/Kernels/Chebyshev/FChebTensorialM2LHandler.hpp b/Src/Kernels/Chebyshev/FChebTensorialM2LHandler.hpp index d4899ae3a..4c39e507a 100644 --- a/Src/Kernels/Chebyshev/FChebTensorialM2LHandler.hpp +++ b/Src/Kernels/Chebyshev/FChebTensorialM2LHandler.hpp @@ -194,8 +194,8 @@ public: }; -template <int ORDER, class MatrixKernelClass> -class FChebTensorialM2LHandler<ORDER,MatrixKernelClass,NON_HOMOGENEOUS> : FNoCopyable +template <class FReal, int ORDER, class MatrixKernelClass> +class FChebTensorialM2LHandler<FReal,ORDER,MatrixKernelClass,NON_HOMOGENEOUS> : FNoCopyable { enum {order = ORDER, nnodes = TensorTraits<ORDER>::nnodes, @@ -264,7 +264,7 @@ public: rank[0]=rank[1]=0; for (unsigned int l=2; l<TreeHeight; ++l) { // compute m2l operator on extended cell - rank[l] = ComputeAndCompress<order>(MatrixKernel, CellWidth, CellWidthExtension, epsilon, U[l], C[l], B[l]); + rank[l] = ComputeAndCompress<FReal, order>(MatrixKernel, CellWidth, CellWidthExtension, epsilon, U[l], C[l], B[l]); // update cell width CellWidth /= FReal(2.); // at level l+1 } @@ -351,7 +351,7 @@ public: -template <int ORDER, class MatrixKernelClass> +template <class FReal, int ORDER, class MatrixKernelClass> unsigned int ComputeAndCompress(const MatrixKernelClass *const MatrixKernel, const FReal CellWidth, const FReal CellWidthExtension, diff --git a/Src/Kernels/Rotation/FRotationOriginalKernel.hpp b/Src/Kernels/Rotation/FRotationOriginalKernel.hpp index bd89c361b..5db94ccfe 100644 --- a/Src/Kernels/Rotation/FRotationOriginalKernel.hpp +++ b/Src/Kernels/Rotation/FRotationOriginalKernel.hpp @@ -800,7 +800,7 @@ public: void P2P(const FTreeCoordinate& /*inPosition*/, ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict /*inSources*/, ContainerClass* const inNeighbors[27], const int /*inSize*/){ - FP2PRT<FReal>::FullMutual<ContainerClass>(inTargets,inNeighbors,14); + FP2PRT<FReal>::template FullMutual<ContainerClass>(inTargets,inNeighbors,14); } @@ -808,7 +808,7 @@ public: void P2PRemote(const FTreeCoordinate& /*inPosition*/, ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict /*inSources*/, ContainerClass* const inNeighbors[27], const int /*inSize*/){ - FP2PRT<FReal>::FullRemote<ContainerClass>(inTargets,inNeighbors,27); + FP2PRT<FReal>::template FullRemote<ContainerClass>(inTargets,inNeighbors,27); } }; diff --git a/Src/Kernels/Spherical/FSphericalCell.hpp b/Src/Kernels/Spherical/FSphericalCell.hpp index ba664a009..dcd9d6d8f 100644 --- a/Src/Kernels/Spherical/FSphericalCell.hpp +++ b/Src/Kernels/Spherical/FSphericalCell.hpp @@ -68,7 +68,7 @@ public: } /** Constructor */ - FSphericalCell(const FSphericalCell& other) + FSphericalCell(const FSphericalCell<FReal>& other) : multipole_exp(nullptr), local_exp(nullptr){ multipole_exp = new FComplex<FReal>[PoleSize]; local_exp = new FComplex<FReal>[LocalSize]; @@ -82,7 +82,7 @@ public: } /** Copy constructor */ - FSphericalCell& operator=(const FSphericalCell& other) { + FSphericalCell<FReal>& operator=(const FSphericalCell<FReal>& other) { FMemUtils::copyall(multipole_exp, other.multipole_exp, PoleSize); FMemUtils::copyall(local_exp, other.local_exp, LocalSize); return *this; diff --git a/Src/Kernels/Spherical/FSphericalRotationKernel.hpp b/Src/Kernels/Spherical/FSphericalRotationKernel.hpp index 5393b8416..d2193d0b5 100644 --- a/Src/Kernels/Spherical/FSphericalRotationKernel.hpp +++ b/Src/Kernels/Spherical/FSphericalRotationKernel.hpp @@ -24,9 +24,9 @@ * This class is the rotation spherical harmonic kernel */ template< class FReal, class CellClass, class ContainerClass> -class FSphericalRotationKernel : public FAbstractSphericalKernel<CellClass,ContainerClass> { +class FSphericalRotationKernel : public FAbstractSphericalKernel<FReal, CellClass,ContainerClass> { protected: - typedef FAbstractSphericalKernel<CellClass,ContainerClass> Parent; + typedef FAbstractSphericalKernel<FReal, CellClass,ContainerClass> Parent; /** This class define some information to use rotation computation */ diff --git a/Src/Kernels/Taylor/FTaylorKernel.hpp b/Src/Kernels/Taylor/FTaylorKernel.hpp index 2e26e990f..30ebffbd5 100644 --- a/Src/Kernels/Taylor/FTaylorKernel.hpp +++ b/Src/Kernels/Taylor/FTaylorKernel.hpp @@ -23,9 +23,9 @@ #include "../P2P/FP2PR.hpp" /** - * @author Cyrille Piacibello - * @class FTaylorKernel - * + * @author Cyrille Piacibello + * @class FTaylorKernel + * * @brief This kernel is an implementation of the different operators * needed to compute the Fast Multipole Method using Taylor Expansion * for the Far fields interaction. @@ -35,679 +35,679 @@ //TODO spécifier les arguments. template< class FReal, class CellClass, class ContainerClass, int P, int order> class FTaylorKernel : public FAbstractKernels<CellClass,ContainerClass> { - + private: - //Size of the multipole and local vectors - static const int SizeVector = ((P+1)*(P+2)*(P+3))*order/6; - - - //////////////////////////////////////////////////// - // Object Attributes - //////////////////////////////////////////////////// - const FReal boxWidth; //< the box width at leaf level - const int treeHeight; //< The height of the tree - const FReal widthAtLeafLevel; //< width of box at leaf level - const FReal widthAtLeafLevelDiv2; //< width of box at leaf leve div 2 - const FPoint<FReal> boxCorner; //< position of the box corner - - //////////////////////////////////////////////////// - // PreComputed values - //////////////////////////////////////////////////// - FReal factorials[2*P+1]; //< This contains the factorial until P - FReal arrayDX[P+2],arrayDY[P+2],arrayDZ[P+2] ; //< Working arrays - static const int sizeDerivative = (2*P+1)*(P+1)*(2*P+3)/3; - FReal _PsiVector[sizeDerivative]; - FSmartPointer< FReal[343][sizeDerivative] > M2LpreComputedDerivatives; - FSmartPointer< int[SizeVector] > preComputedIndirections; - - FReal _coeffPoly[SizeVector]; - - - //////////////////////////////////////////////////// - // Private method - //////////////////////////////////////////////////// - - /////////////////////////////////////////////////////// - // Precomputation - /////////////////////////////////////////////////////// - - /** Compute the factorial from 0 to P + //Size of the multipole and local vectors + static const int SizeVector = ((P+1)*(P+2)*(P+3))*order/6; + + + //////////////////////////////////////////////////// + // Object Attributes + //////////////////////////////////////////////////// + const FReal boxWidth; //< the box width at leaf level + const int treeHeight; //< The height of the tree + const FReal widthAtLeafLevel; //< width of box at leaf level + const FReal widthAtLeafLevelDiv2; //< width of box at leaf leve div 2 + const FPoint<FReal> boxCorner; //< position of the box corner + + //////////////////////////////////////////////////// + // PreComputed values + //////////////////////////////////////////////////// + FReal factorials[2*P+1]; //< This contains the factorial until P + FReal arrayDX[P+2],arrayDY[P+2],arrayDZ[P+2] ; //< Working arrays + static const int sizeDerivative = (2*P+1)*(P+1)*(2*P+3)/3; + FReal _PsiVector[sizeDerivative]; + FSmartPointer< FReal[343][sizeDerivative] > M2LpreComputedDerivatives; + FSmartPointer< int[SizeVector] > preComputedIndirections; + + FReal _coeffPoly[SizeVector]; + + + //////////////////////////////////////////////////// + // Private method + //////////////////////////////////////////////////// + + /////////////////////////////////////////////////////// + // Precomputation + /////////////////////////////////////////////////////// + + /** Compute the factorial from 0 to P * Then the data is accessible in factorials array: * factorials[n] = n! with n <= P */ - void precomputeFactorials(){ - factorials[0] = 1.0; - FReal fidx = 1.0; - for(int idx = 1 ; idx <= 2*P ; ++idx, ++fidx){ - factorials[idx] = fidx * factorials[idx-1]; + void precomputeFactorials(){ + factorials[0] = 1.0; + FReal fidx = 1.0; + for(int idx = 1 ; idx <= 2*P ; ++idx, ++fidx){ + factorials[idx] = fidx * factorials[idx-1]; + } } - } - /** Return the position of a leaf from its tree coordinate */ - FPoint<FReal> getLeafCenter(const FTreeCoordinate coordinate) const { - return FPoint<FReal>( - FReal(coordinate.getX()) * widthAtLeafLevel + widthAtLeafLevelDiv2 + boxCorner.getX(), - FReal(coordinate.getY()) * widthAtLeafLevel + widthAtLeafLevelDiv2 + boxCorner.getY(), - FReal(coordinate.getZ()) * widthAtLeafLevel + widthAtLeafLevelDiv2 + boxCorner.getZ()); - } + /** Return the position of a leaf from its tree coordinate */ + FPoint<FReal> getLeafCenter(const FTreeCoordinate coordinate) const { + return FPoint<FReal>( + FReal(coordinate.getX()) * widthAtLeafLevel + widthAtLeafLevelDiv2 + boxCorner.getX(), + FReal(coordinate.getY()) * widthAtLeafLevel + widthAtLeafLevelDiv2 + boxCorner.getY(), + FReal(coordinate.getZ()) * widthAtLeafLevel + widthAtLeafLevelDiv2 + boxCorner.getZ()); + } - /** + /** * @brief Return the position of the center of a cell from its tree - * coordinate + * coordinate * @param FTreeCoordinate * @param inLevel the current level of Cell */ - FPoint<FReal> getCellCenter(const FTreeCoordinate coordinate, int inLevel) - { - //Set the boxes width needed - FReal widthAtCurrentLevel = widthAtLeafLevel*FReal(1 << (treeHeight-(inLevel+1))); - FReal widthAtCurrentLevelDiv2 = widthAtCurrentLevel/FReal(2); - - //Get the coordinate - int a = coordinate.getX(); - int b = coordinate.getY(); - int c = coordinate.getZ(); - - //Set the center real coordinates from box corner and widths. - FReal X = boxCorner.getX() + FReal(a)*widthAtCurrentLevel + widthAtCurrentLevelDiv2; - FReal Y = boxCorner.getY() + FReal(b)*widthAtCurrentLevel + widthAtCurrentLevelDiv2; - FReal Z = boxCorner.getZ() + FReal(c)*widthAtCurrentLevel + widthAtCurrentLevelDiv2; - - FPoint<FReal> cCenter = FPoint<FReal>(X,Y,Z); - return cCenter; - } - - - /** - * @brief Incrementation of powers in Taylor expansion - * Result : ...,[2,0,0],[1,1,0],[1,0,1],[0,2,0]... 3-tuple are sorted + FPoint<FReal> getCellCenter(const FTreeCoordinate coordinate, int inLevel) + { + //Set the boxes width needed + FReal widthAtCurrentLevel = widthAtLeafLevel*FReal(1 << (treeHeight-(inLevel+1))); + FReal widthAtCurrentLevelDiv2 = widthAtCurrentLevel/FReal(2); + + //Get the coordinate + int a = coordinate.getX(); + int b = coordinate.getY(); + int c = coordinate.getZ(); + + //Set the center real coordinates from box corner and widths. + FReal X = boxCorner.getX() + FReal(a)*widthAtCurrentLevel + widthAtCurrentLevelDiv2; + FReal Y = boxCorner.getY() + FReal(b)*widthAtCurrentLevel + widthAtCurrentLevelDiv2; + FReal Z = boxCorner.getZ() + FReal(c)*widthAtCurrentLevel + widthAtCurrentLevelDiv2; + + FPoint<FReal> cCenter = FPoint<FReal>(X,Y,Z); + return cCenter; + } + + + /** + * @brief Incrementation of powers in Taylor expansion + * Result : ...,[2,0,0],[1,1,0],[1,0,1],[0,2,0]... 3-tuple are sorted * by size then alphabetical order. */ - void incPowers(int * const FRestrict a, int *const FRestrict b, int *const FRestrict c) - { - int t = (*a)+(*b)+(*c); - if(t==0) - {a[0]=1;} - else{ if(t==a[0]) - {a[0]--; b[0]++;} - else{ if(t==c[0]) - {a[0]=t+1; c[0]=0;} - else{ if(b[0]!=0) - {b[0]--; c[0]++;} - else{ - b[0]=c[0]+1; - a[0]--; - c[0]=0; - } - } - } + void incPowers(int * const FRestrict a, int *const FRestrict b, int *const FRestrict c) + { + int t = (*a)+(*b)+(*c); + if(t==0) + {a[0]=1;} + else{ if(t==a[0]) + {a[0]--; b[0]++;} + else{ if(t==c[0]) + {a[0]=t+1; c[0]=0;} + else{ if(b[0]!=0) + {b[0]--; c[0]++;} + else{ + b[0]=c[0]+1; + a[0]--; + c[0]=0; + } + } + } + } } - } - - /** + + /** * @brief Give the index of array from the corresponding 3-tuple - * powers. - */ - int powerToIdx(const int a,const int b,const int c) - { - int t,res,p = a+b+c; - res = p*(p+1)*(p+2)/6; - t = p - a; - res += t*(t+1)/2+c; - return res; - } - - /* Return the factorial of a number + * powers. */ - FReal fact(const int a){ - if(a<0) { - printf("fact :: Error factorial negative!! a=%d\n",a); - return FReal(0); + int powerToIdx(const int a,const int b,const int c) + { + int t,res,p = a+b+c; + res = p*(p+1)*(p+2)/6; + t = p - a; + res += t*(t+1)/2+c; + return res; } - FReal result = 1; - for(int i = 1 ; i <= a ; ++i){ - result *= FReal(i); + + /* Return the factorial of a number + */ + FReal fact(const int a){ + if(a<0) { + printf("fact :: Error factorial negative!! a=%d\n",a); + return FReal(0); + } + FReal result = 1; + for(int i = 1 ; i <= a ; ++i){ + result *= FReal(i); + } + return result; } - return result; - } - /* Return the product of factorial of 3 numbers + /* Return the product of factorial of 3 numbers */ - FReal fact3int(const int a,const int b,const int c) - { - return ( factorials[a]*factorials[b]* factorials[c]) ; - } + FReal fact3int(const int a,const int b,const int c) + { + return ( factorials[a]*factorials[b]* factorials[c]) ; + } - /* Return the combine of a paire of number + /* Return the combine of a paire of number * \f[ C^{b}_{a} \f] */ - FReal combin(const int& a, const int& b){ - if(a<b) {printf("combin :: Error combin negative!! a=%d b=%d\n",a,b); exit(-1) ; } - return factorials[a]/ (factorials[b]* factorials[a-b]) ; - } + FReal combin(const int& a, const int& b){ + if(a<b) {printf("combin :: Error combin negative!! a=%d b=%d\n",a,b); exit(-1) ; } + return factorials[a]/ (factorials[b]* factorials[a-b]) ; + } - /* PreCompute indirection for M2L translations : + /* PreCompute indirection for M2L translations : * * During the M2L, derivative vector isn't accessed in an adjacent * way, so this function aimed at storing all the indirections in * the reading of Derivatives vector. * */ - void preComputeIndirection() - { - this->preComputedIndirections = new int[SizeVector][SizeVector]; - - int al=0,bl=0,cl=0; - int alpha; - //Loop over first index - for(int k=0; k<SizeVector ; ++k) - { - //Loop over multipole expansion coefficients : am, bm, cm. - for( int ord=0, j= 0 ; ord <= P ; ++ord) - { - for(int am=ord ; am >= 0 ; --am) - { - alpha = ord-am; - if ( alpha ==1 ) { - for( int i=0 ; i <=1 ; (++i, ++j) ) - { - preComputedIndirections[k][j] = powerToIdx(al+am,bl+1-i,cl+i); - } - } - else { - for( int bm=ord-am ; bm >= 0 ; --bm, ++j) - { - preComputedIndirections[k][j] = powerToIdx(al+am,bl+bm,cl+(ord-am-bm)); - } - } - } - } - incPowers(&al,&bl,&cl); - } - } - - /* Precomputation of all the derivatives that will be needed for the + void preComputeIndirection() + { + this->preComputedIndirections = new int[SizeVector][SizeVector]; + + int al=0,bl=0,cl=0; + int alpha; + //Loop over first index + for(int k=0; k<SizeVector ; ++k) + { + //Loop over multipole expansion coefficients : am, bm, cm. + for( int ord=0, j= 0 ; ord <= P ; ++ord) + { + for(int am=ord ; am >= 0 ; --am) + { + alpha = ord-am; + if ( alpha ==1 ) { + for( int i=0 ; i <=1 ; (++i, ++j) ) + { + preComputedIndirections[k][j] = powerToIdx(al+am,bl+1-i,cl+i); + } + } + else { + for( int bm=ord-am ; bm >= 0 ; --bm, ++j) + { + preComputedIndirections[k][j] = powerToIdx(al+am,bl+bm,cl+(ord-am-bm)); + } + } + } + } + incPowers(&al,&bl,&cl); + } + } + + /* Precomputation of all the derivatives that will be needed for the * computation of M2L translations : * * Derivatives depends only on the distance between cells, so for * each level, and each possible relative positions (343), we * compute all the values needed. */ - void preComputeDerivative() - { - //Allocation of the memory needed - M2LpreComputedDerivatives = new FReal[treeHeight][343][sizeDerivative]; - //This is the width of a box at each level - FReal boxWidthAtLevel = widthAtLeafLevel; - // from leaf level to the root - for(int idxLevel = treeHeight-1 ; idxLevel > 0 ; --idxLevel){ - // we compute all possibilities - for(int idxX = -3 ; idxX <= 3 ; ++idxX ){ - for(int idxY = -3 ; idxY <= 3 ; ++idxY ){ - for(int idxZ = -3 ; idxZ <= 3 ; ++idxZ ){ - // if this is not a neighbour - if( idxX < -1 || 1 < idxX || idxY < -1 || 1 < idxY || idxZ < -1 || 1 < idxZ ){ - //Compute the relative position - const FPoint<FReal> relativePosition( -FReal(idxX)*boxWidthAtLevel, - -FReal(idxY)*boxWidthAtLevel, - -FReal(idxZ)*boxWidthAtLevel); - // this is the position in the index system from 0 to 343 - const int position = ((( (idxX+3) * 7) + (idxY+3))) * 7 + idxZ + 3; - initDerivative(relativePosition.getX(),relativePosition.getY(),relativePosition.getZ(),M2LpreComputedDerivatives[idxLevel][position]); - computeFullDerivative(relativePosition.getX(),relativePosition.getY(),relativePosition.getZ(),M2LpreComputedDerivatives[idxLevel][position]); - } - } - } - } - boxWidthAtLevel *= FReal(2); + void preComputeDerivative() + { + //Allocation of the memory needed + M2LpreComputedDerivatives = new FReal[treeHeight][343][sizeDerivative]; + //This is the width of a box at each level + FReal boxWidthAtLevel = widthAtLeafLevel; + // from leaf level to the root + for(int idxLevel = treeHeight-1 ; idxLevel > 0 ; --idxLevel){ + // we compute all possibilities + for(int idxX = -3 ; idxX <= 3 ; ++idxX ){ + for(int idxY = -3 ; idxY <= 3 ; ++idxY ){ + for(int idxZ = -3 ; idxZ <= 3 ; ++idxZ ){ + // if this is not a neighbour + if( idxX < -1 || 1 < idxX || idxY < -1 || 1 < idxY || idxZ < -1 || 1 < idxZ ){ + //Compute the relative position + const FPoint<FReal> relativePosition( -FReal(idxX)*boxWidthAtLevel, + -FReal(idxY)*boxWidthAtLevel, + -FReal(idxZ)*boxWidthAtLevel); + // this is the position in the index system from 0 to 343 + const int position = ((( (idxX+3) * 7) + (idxY+3))) * 7 + idxZ + 3; + initDerivative(relativePosition.getX(),relativePosition.getY(),relativePosition.getZ(),M2LpreComputedDerivatives[idxLevel][position]); + computeFullDerivative(relativePosition.getX(),relativePosition.getY(),relativePosition.getZ(),M2LpreComputedDerivatives[idxLevel][position]); + } + } + } + } + boxWidthAtLevel *= FReal(2); + } } - } - - /** @brief Init the derivative array for using of following formula + + /** @brief Init the derivative array for using of following formula * from "A cartesian tree-code for screened coulomb interactions" * - * @todo METTRE les fonctions pour intialiser la recurrence. \f$x_i\f$ ?? \f$x_i\f$ ?? - * @todo LA formule ci-dessous n'utilise pas k! + * @todo METTRE les fonctions pour intialiser la recurrence. \f$x_i\f$ ?? \f$x_i\f$ ?? + * @todo LA formule ci-dessous n'utilise pas k! */ - void initDerivative(const FReal & dx ,const FReal & dy ,const FReal & dz , FReal * tab) - { - FReal R2 = dx*dx+dy*dy+dz*dz; - tab[0]=FReal(1)/FMath::Sqrt(R2); - FReal R3 = tab[0]/(R2); - tab[1]= -dx*R3; //Derivative in (1,0,0) - tab[2]= -dy*R3; //Derivative in (0,1,0) - tab[3]= -dz*R3; //Derivative in (0,0,1) - FReal R5 = R3/R2; - tab[4] = FReal(3)*dx*dx*R5-R3; //Derivative in (2,0,0) - tab[5] = FReal(3)*dx*dy*R5; //Derivative in (1,1,0) - tab[6] = FReal(3)*dx*dz*R5; //Derivative in (1,0,1) - tab[7] = FReal(3)*dy*dy*R5-R3; //Derivative in (0,2,0) - tab[8] = FReal(3)*dy*dz*R5; //Derivative in (0,1,1) - tab[9] = FReal(3)*dz*dz*R5-R3; //Derivative in (0,0,2) - } - - /** @brief Compute and store the derivative for a given tuple. + void initDerivative(const FReal & dx ,const FReal & dy ,const FReal & dz , FReal * tab) + { + FReal R2 = dx*dx+dy*dy+dz*dz; + tab[0]=FReal(1)/FMath::Sqrt(R2); + FReal R3 = tab[0]/(R2); + tab[1]= -dx*R3; //Derivative in (1,0,0) + tab[2]= -dy*R3; //Derivative in (0,1,0) + tab[3]= -dz*R3; //Derivative in (0,0,1) + FReal R5 = R3/R2; + tab[4] = FReal(3)*dx*dx*R5-R3; //Derivative in (2,0,0) + tab[5] = FReal(3)*dx*dy*R5; //Derivative in (1,1,0) + tab[6] = FReal(3)*dx*dz*R5; //Derivative in (1,0,1) + tab[7] = FReal(3)*dy*dy*R5-R3; //Derivative in (0,2,0) + tab[8] = FReal(3)*dy*dz*R5; //Derivative in (0,1,1) + tab[9] = FReal(3)*dz*dz*R5-R3; //Derivative in (0,0,2) + } + + /** @brief Compute and store the derivative for a given tuple. * Derivative are used for the M2L * *\f[ * \Psi_{\mathbf{k}}^{c} \left [\left |\mathbf{k}\right |\times \left | - * \mathbf{x}_i-\mathbf{x}_c\right |^2 \right ]\ + * \mathbf{x}_i-\mathbf{x}_c\right |^2 \right ]\ * = (2\times \left |{\mathbf{k}}\right |-1) * \sum_{j=0}^{3}\left [ k_j (x_{i_j}-x_{c_j}) - * \Psi_{\mathbf{k}-e_j,i}^{c}\right ]\ + * \Psi_{\mathbf{k}-e_j,i}^{c}\right ]\ * -(\left |\mathbf{k}\right |-1) \sum_{j=0}^{3}\left * [ k_j(k_j-1) \Psi_{\mathbf{k}-2 e_j,i}^{c} \right] * \f] - * where \f$ \mathbf{k} = (k_1,k_2,k_3) \f$ + * where \f$ \mathbf{k} = (k_1,k_2,k_3) \f$ */ - void computeFullDerivative( FReal dx, FReal dy, FReal dz, // Distance from distant center to local center - FReal * yetComputed) - { - initDerivative(dx,dy,dz,yetComputed); - FReal dist2 = dx*dx+dy*dy+dz*dz; - int idxTarget; //Index of current yetComputed entry - int idxSrc1, idxSrc2, idxSrc3, //Indexes of needed yetComputed entries - idxSrc4, idxSrc5, idxSrc6; - int a=0,b=0,c=0; //Powers of expansions - - for(c=3 ; c<=2*P ; ++c){ - //Computation of derivatives Psi_{0,0,c} - // |x-y|^2 * Psi_{0,0,c} + (2*c-1) * dz *Psi_{0,0,c-1} + (c-1)^2 * Psi_{0,0,c-2} = 0 - idxTarget = powerToIdx(0,0,c); - idxSrc1 = powerToIdx(0,0,c-1); - idxSrc2 = powerToIdx(0,0,c-2); - yetComputed[idxTarget] = -(FReal(2*c-1)*dz*yetComputed[idxSrc1] + FReal((c-1)*(c-1))*yetComputed[idxSrc2])/dist2; - } - b=1; - for(c=2 ; c<=2*P-1 ; ++c){ - //Computation of derivatives Psi_{0,1,c} - // |x-y|^2 * Psi_{0,1,c} + (2*c) * dz *Psi_{0,1,c-1} + c*(c-1) * Psi_{0,1,c-2} + dy*Psi_{0,0,c} = 0 - idxTarget = powerToIdx(0,1,c); - idxSrc1 = powerToIdx(0,1,c-1); - idxSrc2 = powerToIdx(0,1,c-2); - idxSrc3 = powerToIdx(0,0,c); - yetComputed[idxTarget] = -(FReal(2*c)*dz*yetComputed[idxSrc1] + FReal(c*(c-1))*yetComputed[idxSrc2]+ dy*yetComputed[idxSrc3])/dist2; - } - b=2; - for(c=1 ; c<= 2*P-b ; ++c){ - //Computation of derivatives Psi_{0,2,c} - //|x-y|^2 * Psi_{0,2,c} + (2*c) * dz *Psi_{0,2,c-1} + (c*(c-1)) * Psi_{0,2,c-2} + 3*dy * Psi_{0,1,c} + Psi_{0,0,c} = 0 - idxTarget = powerToIdx(0,2,c); - idxSrc1 = powerToIdx(0,2,c-1); - idxSrc2 = powerToIdx(0,2,c-2); - idxSrc3 = powerToIdx(0,1,c); - idxSrc4 = powerToIdx(0,0,c); - yetComputed[idxTarget] = -(FReal(2*c)*dz*yetComputed[idxSrc1] + FReal(c*(c-1))*yetComputed[idxSrc2] - + FReal(3)*dy*yetComputed[idxSrc3] + yetComputed[idxSrc4])/dist2; - } - for(b=3 ; b<= 2*P ; ++b){ - //Computation of derivatives Psi_{0,b,0} - // |x-y|^2 * Psi_{0,b,0} + (2*b-1) * dy *Psi_{0,b-1,0} + (b-1)^2 * Psi_{0,b-2,c} = 0 - idxTarget = powerToIdx(0,b,0); - idxSrc1 = powerToIdx(0,b-1,0); - idxSrc2 = powerToIdx(0,b-2,0); - yetComputed[idxTarget] = -(FReal(2*b-1)*dy*yetComputed[idxSrc1] + FReal((b-1)*(b-1))*yetComputed[idxSrc2])/dist2; - for(c=1 ; c<= 2*P-b ; ++c) { - //Computation of derivatives Psi_{0,b,c} - //|x-y|^2*Psi_{0,b,c} + (2*c)*dz*Psi_{0,b,c-1} + (c*(c-1))*Psi_{0,b,c-2} + (2*b-1)*dy*Psi_{0,b-1,c} + (b-1)^2 * Psi_{0,b-2,c} = 0 - idxTarget = powerToIdx(0,b,c); - idxSrc1 = powerToIdx(0,b,c-1); - idxSrc2 = powerToIdx(0,b,c-2); - idxSrc3 = powerToIdx(0,b-1,c); - idxSrc4 = powerToIdx(0,b-2,c); - yetComputed[idxTarget] = -(FReal(2*c)*dz*yetComputed[idxSrc1] + FReal(c*(c-1))*yetComputed[idxSrc2] - + FReal(2*b-1)*dy*yetComputed[idxSrc3] + FReal((b-1)*(b-1))*yetComputed[idxSrc4])/dist2; - } - } - a=1; - b=0; - for(c=2 ; c<= 2*P-1 ; ++c){ - //Computation of derivatives Psi_{1,0,c} - //|x-y|^2 * Psi_{1,0,c} + (2*c)*dz*Psi_{1,0,c-1} + c*(c-1)*Psi_{1,0,c-2} + dx*Psi_{0,0,c} - idxTarget = powerToIdx(1,0,c); - idxSrc1 = powerToIdx(1,0,c-1); - idxSrc2 = powerToIdx(1,0,c-2); - idxSrc3 = powerToIdx(0,0,c); - yetComputed[idxTarget] = -(FReal(2*c)*dz*yetComputed[idxSrc1] + FReal(c*(c-1))*yetComputed[idxSrc2] + dx*yetComputed[idxSrc3])/dist2; - } - b=1; - //Computation of derivatives Psi_{1,1,1} - //|x-y|^2 * Psi_{1,1,1} + 2*dz*Psi_{1,1,0} + 2*dy*Psi_{1,0,1} + dx*Psi_{0,1,1} - idxTarget = powerToIdx(1,1,1); - idxSrc1 = powerToIdx(1,1,0); - idxSrc2 = powerToIdx(1,0,1); - idxSrc3 = powerToIdx(0,1,1); - yetComputed[idxTarget] = -(FReal(2)*dz*yetComputed[idxSrc1] + FReal(2)*dy*yetComputed[idxSrc2] + dx*yetComputed[idxSrc3])/dist2; - for(c=2 ; c<= 2*P-2 ; ++c){ - //Computation of derivatives Psi_{1,1,c} - //|x-y|^2 * Psi_{1,1,c} + (2*c)*dz*Psi_{1,1,c-1} + c*(c-1)*Psi_{1,1,c-2} + 2*dy*Psi_{1,0,c} + dx*Psi_{0,1,c} - idxTarget = powerToIdx(1,1,c); - idxSrc1 = powerToIdx(1,1,c-1); - idxSrc2 = powerToIdx(1,1,c-2); - idxSrc3 = powerToIdx(1,0,c); - idxSrc4 = powerToIdx(0,1,c); - yetComputed[idxTarget] = -(FReal(2*c)*dz*yetComputed[idxSrc1] + FReal(c*(c-1))*yetComputed[idxSrc2] - + FReal(2)*dy*yetComputed[idxSrc3]+ dx*yetComputed[idxSrc4])/dist2; - } - for(b=2 ; b<= 2*P-a ; ++b){ - for(c=0 ; c<= 2*P-b-1 ; ++c){ - //Computation of derivatives Psi_{1,b,c} - //|x-y|^2 * Psi_{1,b,c} + (2*b)*dy*Psi_{1,b-1,c} + b*(b-1)*Psi_{1,b-2,c} + (2*c)*dz*Psi_{1,b,c-1} + c*(c-1)*Psi_{1,b,c-2} + dx*Psi_{0,b,c} - idxTarget = powerToIdx(1,b,c); - idxSrc1 = powerToIdx(1,b-1,c); - idxSrc2 = powerToIdx(1,b-2,c); - idxSrc3 = powerToIdx(1,b,c-1); - idxSrc4 = powerToIdx(1,b,c-2); - idxSrc5 = powerToIdx(0,b,c); - yetComputed[idxTarget] = -(FReal(2*b)*dy*yetComputed[idxSrc1] + FReal(b*(b-1))*yetComputed[idxSrc2] - + FReal(2*c)*dz*yetComputed[idxSrc3]+ FReal(c*(c-1))*yetComputed[idxSrc4] - + dx*yetComputed[idxSrc5])/dist2; - } - } - for(a=2 ; a<=2*P ; ++a){ - //Computation of derivatives Psi_{a,0,0} - // |x-y|^2 * Psi_{a,0,0} + (2*a-1) * dx *Psi_{a-1,0,0} + (a-1)^2 * Psi_{a-2,0,0} = 0 - idxTarget = powerToIdx(a,0,0); - idxSrc1 = powerToIdx(a-1,0,0); - idxSrc2 = powerToIdx(a-2,0,0); - yetComputed[idxTarget] = -(FReal(2*a-1)*dx*yetComputed[idxSrc1] + FReal((a-1)*(a-1))*yetComputed[idxSrc2])/dist2; - if(a <= 2*P-1){ - //Computation of derivatives Psi_{a,0,1} - // |x-y|^2 * Psi_{a,0,1} + 2*dz*Psi_{a,0,0} + (2*a-1)*dx*Psi_{a-1,0,1} + (a-1)^2*Psi_{a-2,0,1} = 0 - idxSrc1 = idxTarget; - idxTarget = powerToIdx(a,0,1); - idxSrc2 = powerToIdx(a-1,0,1); - idxSrc3 = powerToIdx(a-2,0,1); - yetComputed[idxTarget] = -(FReal(2)*dz*yetComputed[idxSrc1] + FReal(2*a-1)*dx*yetComputed[idxSrc2] + FReal((a-1)*(a-1))*yetComputed[idxSrc3])/dist2; - //Computation of derivatives Psi_{a,1,0} - // |x-y|^2 * Psi_{a,1,0} + 2*dy*Psi_{a,0,0} + (2*a-1)*dx*Psi_{a-1,1,0} + (a-1)^2*Psi_{a-2,1,0} = 0 - idxTarget = powerToIdx(a,1,0); - idxSrc2 = powerToIdx(a-1,1,0); - idxSrc3 = powerToIdx(a-2,1,0); - yetComputed[idxTarget] = -(FReal(2)*dy*yetComputed[idxSrc1] + FReal(2*a-1)*dx*yetComputed[idxSrc2] + FReal((a-1)*(a-1))*yetComputed[idxSrc3])/dist2; - if(a <= 2*P-2){ - b=0; - for(c=2 ; c <= 2*P-a ; ++c){ - //Computation of derivatives Psi_{a,0,c} - // |x-y|^2 * Psi_{a,0,c} + 2*c*dz*Psi_{a,0,c-1} + c*(c-1)*Psi_{a,0,c-2} + (2*a-1)*dx*Psi_{a-1,0,c} + (a-1)^2*Psi_{a-2,0,c} = 0 - idxTarget = powerToIdx(a,0,c); - idxSrc1 = powerToIdx(a,0,c-1); - idxSrc2 = powerToIdx(a,0,c-2); - idxSrc3 = powerToIdx(a-1,0,c); - idxSrc4 = powerToIdx(a-2,0,c); - yetComputed[idxTarget] = -(FReal(2*c)*dz*yetComputed[idxSrc1] + FReal(c*(c-1))*yetComputed[idxSrc2] - + FReal(2*a-1)*dx*yetComputed[idxSrc3] + FReal((a-1)*(a-1))*yetComputed[idxSrc4])/dist2; - } - b=1; - for(c=1 ; c <= 2*P-a-1 ; ++c){ - //Computation of derivatives Psi_{a,1,c} - // |x-y|^2 * Psi_{a,1,c} + 2*c*dz*Psi_{a,1,c-1} + c*(c-1)*Psi_{a,1,c-2} + 2*a*dx*Psi_{a-1,1,c} + a*(a-1)*Psi_{a-2,1,c} + dy*Psi_{a,0,c}= 0 - idxTarget = powerToIdx(a,1,c); - idxSrc1 = powerToIdx(a,1,c-1); - idxSrc2 = powerToIdx(a,1,c-2); - idxSrc3 = powerToIdx(a-1,1,c); - idxSrc4 = powerToIdx(a-2,1,c); - idxSrc5 = powerToIdx(a,0,c); - yetComputed[idxTarget] = -(FReal(2*c)*dz*yetComputed[idxSrc1] + FReal(c*(c-1))*yetComputed[idxSrc2] - + FReal(2*a)*dx*yetComputed[idxSrc3] + FReal(a*(a-1))*yetComputed[idxSrc4] - + dy*yetComputed[idxSrc5])/dist2; - } - for(b=2 ; b <= 2*P-a ; ++b){ - //Computation of derivatives Psi_{a,b,0} - // |x-y|^2 * Psi_{a,b,0} + 2*b*dy*Psi_{a,b-1,0} + b*(b-1)*Psi_{a,b-2,0} + (2*a-1)*dx*Psi_{a-1,b,0} + (a-1)^2*Psi_{a-2,b,0} = 0 - idxTarget = powerToIdx(a,b,0); - idxSrc1 = powerToIdx(a,b-1,0); - idxSrc2 = powerToIdx(a,b-2,0); - idxSrc3 = powerToIdx(a-1,b,0); - idxSrc4 = powerToIdx(a-2,b,0); - yetComputed[idxTarget] = -(FReal(2*b)*dy*yetComputed[idxSrc1] + FReal(b*(b-1))*yetComputed[idxSrc2] - + FReal(2*a-1)*dx*yetComputed[idxSrc3] + FReal((a-1)*(a-1))*yetComputed[idxSrc4])/dist2; - if(a+b < 2*P){ - //Computation of derivatives Psi_{a,b,1} - // |x-y|^2 * Psi_{a,b,1} + 2*b*dy*Psi_{a,b-1,1} + b*(b-1)*Psi_{a,b-2,1} + 2*a*dx*Psi_{a-1,b,1} + a*(a-1)*Psi_{a-2,b,1} + dz*Psi_{a,b,0}= 0 - idxTarget = powerToIdx(a,b,1); - idxSrc1 = powerToIdx(a,b-1,1); - idxSrc2 = powerToIdx(a,b-2,1); - idxSrc3 = powerToIdx(a-1,b,1); - idxSrc4 = powerToIdx(a-2,b,1); - idxSrc5 = powerToIdx(a,b,0); - yetComputed[idxTarget] = -(FReal(2*b)*dy*yetComputed[idxSrc1] + FReal(b*(b-1))*yetComputed[idxSrc2] - + FReal(2*a)*dx*yetComputed[idxSrc3] + FReal(a*(a-1))*yetComputed[idxSrc4] - + dz*yetComputed[idxSrc5])/dist2; - } - for(c=2 ; c <= 2*P-b-a ; ++c){ - //Computation of derivatives Psi_{a,b,c} with a >= 2 - // |x-y|^2*Psi_{a,b,c} + (2*a-1)*dx*Psi_{a-1,b,c} + a*(a-2)*Psi_{a-2,b,c} + 2*b*dy*Psi_{a,b-1,c} + b*(b-1)*Psi_{a,b-2,c} - // + 2*c*dz*Psi_{a,b,c-1}} = 0 - idxTarget = powerToIdx(a,b,c); - idxSrc1 = powerToIdx(a-1,b,c); - idxSrc2 = powerToIdx(a,b-1,c); - idxSrc3 = powerToIdx(a,b,c-1); - idxSrc4 = powerToIdx(a-2,b,c); - idxSrc5 = powerToIdx(a,b-2,c); - idxSrc6 = powerToIdx(a,b,c-2); - yetComputed[idxTarget] = -(FReal(2*a-1)*dx*yetComputed[idxSrc1] + FReal((a-1)*(a-1))*yetComputed[idxSrc4] - + FReal(2*b)*dy*yetComputed[idxSrc2] + FReal(b*(b-1))*yetComputed[idxSrc5] - + FReal(2*c)*dz*yetComputed[idxSrc3] + FReal(c*(c-1))*yetComputed[idxSrc6])/dist2; - } - } - } - } + void computeFullDerivative( FReal dx, FReal dy, FReal dz, // Distance from distant center to local center + FReal * yetComputed) + { + initDerivative(dx,dy,dz,yetComputed); + FReal dist2 = dx*dx+dy*dy+dz*dz; + int idxTarget; //Index of current yetComputed entry + int idxSrc1, idxSrc2, idxSrc3, //Indexes of needed yetComputed entries + idxSrc4, idxSrc5, idxSrc6; + int a=0,b=0,c=0; //Powers of expansions + + for(c=3 ; c<=2*P ; ++c){ + //Computation of derivatives Psi_{0,0,c} + // |x-y|^2 * Psi_{0,0,c} + (2*c-1) * dz *Psi_{0,0,c-1} + (c-1)^2 * Psi_{0,0,c-2} = 0 + idxTarget = powerToIdx(0,0,c); + idxSrc1 = powerToIdx(0,0,c-1); + idxSrc2 = powerToIdx(0,0,c-2); + yetComputed[idxTarget] = -(FReal(2*c-1)*dz*yetComputed[idxSrc1] + FReal((c-1)*(c-1))*yetComputed[idxSrc2])/dist2; + } + b=1; + for(c=2 ; c<=2*P-1 ; ++c){ + //Computation of derivatives Psi_{0,1,c} + // |x-y|^2 * Psi_{0,1,c} + (2*c) * dz *Psi_{0,1,c-1} + c*(c-1) * Psi_{0,1,c-2} + dy*Psi_{0,0,c} = 0 + idxTarget = powerToIdx(0,1,c); + idxSrc1 = powerToIdx(0,1,c-1); + idxSrc2 = powerToIdx(0,1,c-2); + idxSrc3 = powerToIdx(0,0,c); + yetComputed[idxTarget] = -(FReal(2*c)*dz*yetComputed[idxSrc1] + FReal(c*(c-1))*yetComputed[idxSrc2]+ dy*yetComputed[idxSrc3])/dist2; + } + b=2; + for(c=1 ; c<= 2*P-b ; ++c){ + //Computation of derivatives Psi_{0,2,c} + //|x-y|^2 * Psi_{0,2,c} + (2*c) * dz *Psi_{0,2,c-1} + (c*(c-1)) * Psi_{0,2,c-2} + 3*dy * Psi_{0,1,c} + Psi_{0,0,c} = 0 + idxTarget = powerToIdx(0,2,c); + idxSrc1 = powerToIdx(0,2,c-1); + idxSrc2 = powerToIdx(0,2,c-2); + idxSrc3 = powerToIdx(0,1,c); + idxSrc4 = powerToIdx(0,0,c); + yetComputed[idxTarget] = -(FReal(2*c)*dz*yetComputed[idxSrc1] + FReal(c*(c-1))*yetComputed[idxSrc2] + + FReal(3)*dy*yetComputed[idxSrc3] + yetComputed[idxSrc4])/dist2; + } + for(b=3 ; b<= 2*P ; ++b){ + //Computation of derivatives Psi_{0,b,0} + // |x-y|^2 * Psi_{0,b,0} + (2*b-1) * dy *Psi_{0,b-1,0} + (b-1)^2 * Psi_{0,b-2,c} = 0 + idxTarget = powerToIdx(0,b,0); + idxSrc1 = powerToIdx(0,b-1,0); + idxSrc2 = powerToIdx(0,b-2,0); + yetComputed[idxTarget] = -(FReal(2*b-1)*dy*yetComputed[idxSrc1] + FReal((b-1)*(b-1))*yetComputed[idxSrc2])/dist2; + for(c=1 ; c<= 2*P-b ; ++c) { + //Computation of derivatives Psi_{0,b,c} + //|x-y|^2*Psi_{0,b,c} + (2*c)*dz*Psi_{0,b,c-1} + (c*(c-1))*Psi_{0,b,c-2} + (2*b-1)*dy*Psi_{0,b-1,c} + (b-1)^2 * Psi_{0,b-2,c} = 0 + idxTarget = powerToIdx(0,b,c); + idxSrc1 = powerToIdx(0,b,c-1); + idxSrc2 = powerToIdx(0,b,c-2); + idxSrc3 = powerToIdx(0,b-1,c); + idxSrc4 = powerToIdx(0,b-2,c); + yetComputed[idxTarget] = -(FReal(2*c)*dz*yetComputed[idxSrc1] + FReal(c*(c-1))*yetComputed[idxSrc2] + + FReal(2*b-1)*dy*yetComputed[idxSrc3] + FReal((b-1)*(b-1))*yetComputed[idxSrc4])/dist2; + } + } + a=1; + b=0; + for(c=2 ; c<= 2*P-1 ; ++c){ + //Computation of derivatives Psi_{1,0,c} + //|x-y|^2 * Psi_{1,0,c} + (2*c)*dz*Psi_{1,0,c-1} + c*(c-1)*Psi_{1,0,c-2} + dx*Psi_{0,0,c} + idxTarget = powerToIdx(1,0,c); + idxSrc1 = powerToIdx(1,0,c-1); + idxSrc2 = powerToIdx(1,0,c-2); + idxSrc3 = powerToIdx(0,0,c); + yetComputed[idxTarget] = -(FReal(2*c)*dz*yetComputed[idxSrc1] + FReal(c*(c-1))*yetComputed[idxSrc2] + dx*yetComputed[idxSrc3])/dist2; + } + b=1; + //Computation of derivatives Psi_{1,1,1} + //|x-y|^2 * Psi_{1,1,1} + 2*dz*Psi_{1,1,0} + 2*dy*Psi_{1,0,1} + dx*Psi_{0,1,1} + idxTarget = powerToIdx(1,1,1); + idxSrc1 = powerToIdx(1,1,0); + idxSrc2 = powerToIdx(1,0,1); + idxSrc3 = powerToIdx(0,1,1); + yetComputed[idxTarget] = -(FReal(2)*dz*yetComputed[idxSrc1] + FReal(2)*dy*yetComputed[idxSrc2] + dx*yetComputed[idxSrc3])/dist2; + for(c=2 ; c<= 2*P-2 ; ++c){ + //Computation of derivatives Psi_{1,1,c} + //|x-y|^2 * Psi_{1,1,c} + (2*c)*dz*Psi_{1,1,c-1} + c*(c-1)*Psi_{1,1,c-2} + 2*dy*Psi_{1,0,c} + dx*Psi_{0,1,c} + idxTarget = powerToIdx(1,1,c); + idxSrc1 = powerToIdx(1,1,c-1); + idxSrc2 = powerToIdx(1,1,c-2); + idxSrc3 = powerToIdx(1,0,c); + idxSrc4 = powerToIdx(0,1,c); + yetComputed[idxTarget] = -(FReal(2*c)*dz*yetComputed[idxSrc1] + FReal(c*(c-1))*yetComputed[idxSrc2] + + FReal(2)*dy*yetComputed[idxSrc3]+ dx*yetComputed[idxSrc4])/dist2; + } + for(b=2 ; b<= 2*P-a ; ++b){ + for(c=0 ; c<= 2*P-b-1 ; ++c){ + //Computation of derivatives Psi_{1,b,c} + //|x-y|^2 * Psi_{1,b,c} + (2*b)*dy*Psi_{1,b-1,c} + b*(b-1)*Psi_{1,b-2,c} + (2*c)*dz*Psi_{1,b,c-1} + c*(c-1)*Psi_{1,b,c-2} + dx*Psi_{0,b,c} + idxTarget = powerToIdx(1,b,c); + idxSrc1 = powerToIdx(1,b-1,c); + idxSrc2 = powerToIdx(1,b-2,c); + idxSrc3 = powerToIdx(1,b,c-1); + idxSrc4 = powerToIdx(1,b,c-2); + idxSrc5 = powerToIdx(0,b,c); + yetComputed[idxTarget] = -(FReal(2*b)*dy*yetComputed[idxSrc1] + FReal(b*(b-1))*yetComputed[idxSrc2] + + FReal(2*c)*dz*yetComputed[idxSrc3]+ FReal(c*(c-1))*yetComputed[idxSrc4] + + dx*yetComputed[idxSrc5])/dist2; + } + } + for(a=2 ; a<=2*P ; ++a){ + //Computation of derivatives Psi_{a,0,0} + // |x-y|^2 * Psi_{a,0,0} + (2*a-1) * dx *Psi_{a-1,0,0} + (a-1)^2 * Psi_{a-2,0,0} = 0 + idxTarget = powerToIdx(a,0,0); + idxSrc1 = powerToIdx(a-1,0,0); + idxSrc2 = powerToIdx(a-2,0,0); + yetComputed[idxTarget] = -(FReal(2*a-1)*dx*yetComputed[idxSrc1] + FReal((a-1)*(a-1))*yetComputed[idxSrc2])/dist2; + if(a <= 2*P-1){ + //Computation of derivatives Psi_{a,0,1} + // |x-y|^2 * Psi_{a,0,1} + 2*dz*Psi_{a,0,0} + (2*a-1)*dx*Psi_{a-1,0,1} + (a-1)^2*Psi_{a-2,0,1} = 0 + idxSrc1 = idxTarget; + idxTarget = powerToIdx(a,0,1); + idxSrc2 = powerToIdx(a-1,0,1); + idxSrc3 = powerToIdx(a-2,0,1); + yetComputed[idxTarget] = -(FReal(2)*dz*yetComputed[idxSrc1] + FReal(2*a-1)*dx*yetComputed[idxSrc2] + FReal((a-1)*(a-1))*yetComputed[idxSrc3])/dist2; + //Computation of derivatives Psi_{a,1,0} + // |x-y|^2 * Psi_{a,1,0} + 2*dy*Psi_{a,0,0} + (2*a-1)*dx*Psi_{a-1,1,0} + (a-1)^2*Psi_{a-2,1,0} = 0 + idxTarget = powerToIdx(a,1,0); + idxSrc2 = powerToIdx(a-1,1,0); + idxSrc3 = powerToIdx(a-2,1,0); + yetComputed[idxTarget] = -(FReal(2)*dy*yetComputed[idxSrc1] + FReal(2*a-1)*dx*yetComputed[idxSrc2] + FReal((a-1)*(a-1))*yetComputed[idxSrc3])/dist2; + if(a <= 2*P-2){ + b=0; + for(c=2 ; c <= 2*P-a ; ++c){ + //Computation of derivatives Psi_{a,0,c} + // |x-y|^2 * Psi_{a,0,c} + 2*c*dz*Psi_{a,0,c-1} + c*(c-1)*Psi_{a,0,c-2} + (2*a-1)*dx*Psi_{a-1,0,c} + (a-1)^2*Psi_{a-2,0,c} = 0 + idxTarget = powerToIdx(a,0,c); + idxSrc1 = powerToIdx(a,0,c-1); + idxSrc2 = powerToIdx(a,0,c-2); + idxSrc3 = powerToIdx(a-1,0,c); + idxSrc4 = powerToIdx(a-2,0,c); + yetComputed[idxTarget] = -(FReal(2*c)*dz*yetComputed[idxSrc1] + FReal(c*(c-1))*yetComputed[idxSrc2] + + FReal(2*a-1)*dx*yetComputed[idxSrc3] + FReal((a-1)*(a-1))*yetComputed[idxSrc4])/dist2; + } + b=1; + for(c=1 ; c <= 2*P-a-1 ; ++c){ + //Computation of derivatives Psi_{a,1,c} + // |x-y|^2 * Psi_{a,1,c} + 2*c*dz*Psi_{a,1,c-1} + c*(c-1)*Psi_{a,1,c-2} + 2*a*dx*Psi_{a-1,1,c} + a*(a-1)*Psi_{a-2,1,c} + dy*Psi_{a,0,c}= 0 + idxTarget = powerToIdx(a,1,c); + idxSrc1 = powerToIdx(a,1,c-1); + idxSrc2 = powerToIdx(a,1,c-2); + idxSrc3 = powerToIdx(a-1,1,c); + idxSrc4 = powerToIdx(a-2,1,c); + idxSrc5 = powerToIdx(a,0,c); + yetComputed[idxTarget] = -(FReal(2*c)*dz*yetComputed[idxSrc1] + FReal(c*(c-1))*yetComputed[idxSrc2] + + FReal(2*a)*dx*yetComputed[idxSrc3] + FReal(a*(a-1))*yetComputed[idxSrc4] + + dy*yetComputed[idxSrc5])/dist2; + } + for(b=2 ; b <= 2*P-a ; ++b){ + //Computation of derivatives Psi_{a,b,0} + // |x-y|^2 * Psi_{a,b,0} + 2*b*dy*Psi_{a,b-1,0} + b*(b-1)*Psi_{a,b-2,0} + (2*a-1)*dx*Psi_{a-1,b,0} + (a-1)^2*Psi_{a-2,b,0} = 0 + idxTarget = powerToIdx(a,b,0); + idxSrc1 = powerToIdx(a,b-1,0); + idxSrc2 = powerToIdx(a,b-2,0); + idxSrc3 = powerToIdx(a-1,b,0); + idxSrc4 = powerToIdx(a-2,b,0); + yetComputed[idxTarget] = -(FReal(2*b)*dy*yetComputed[idxSrc1] + FReal(b*(b-1))*yetComputed[idxSrc2] + + FReal(2*a-1)*dx*yetComputed[idxSrc3] + FReal((a-1)*(a-1))*yetComputed[idxSrc4])/dist2; + if(a+b < 2*P){ + //Computation of derivatives Psi_{a,b,1} + // |x-y|^2 * Psi_{a,b,1} + 2*b*dy*Psi_{a,b-1,1} + b*(b-1)*Psi_{a,b-2,1} + 2*a*dx*Psi_{a-1,b,1} + a*(a-1)*Psi_{a-2,b,1} + dz*Psi_{a,b,0}= 0 + idxTarget = powerToIdx(a,b,1); + idxSrc1 = powerToIdx(a,b-1,1); + idxSrc2 = powerToIdx(a,b-2,1); + idxSrc3 = powerToIdx(a-1,b,1); + idxSrc4 = powerToIdx(a-2,b,1); + idxSrc5 = powerToIdx(a,b,0); + yetComputed[idxTarget] = -(FReal(2*b)*dy*yetComputed[idxSrc1] + FReal(b*(b-1))*yetComputed[idxSrc2] + + FReal(2*a)*dx*yetComputed[idxSrc3] + FReal(a*(a-1))*yetComputed[idxSrc4] + + dz*yetComputed[idxSrc5])/dist2; + } + for(c=2 ; c <= 2*P-b-a ; ++c){ + //Computation of derivatives Psi_{a,b,c} with a >= 2 + // |x-y|^2*Psi_{a,b,c} + (2*a-1)*dx*Psi_{a-1,b,c} + a*(a-2)*Psi_{a-2,b,c} + 2*b*dy*Psi_{a,b-1,c} + b*(b-1)*Psi_{a,b-2,c} + // + 2*c*dz*Psi_{a,b,c-1}} = 0 + idxTarget = powerToIdx(a,b,c); + idxSrc1 = powerToIdx(a-1,b,c); + idxSrc2 = powerToIdx(a,b-1,c); + idxSrc3 = powerToIdx(a,b,c-1); + idxSrc4 = powerToIdx(a-2,b,c); + idxSrc5 = powerToIdx(a,b-2,c); + idxSrc6 = powerToIdx(a,b,c-2); + yetComputed[idxTarget] = -(FReal(2*a-1)*dx*yetComputed[idxSrc1] + FReal((a-1)*(a-1))*yetComputed[idxSrc4] + + FReal(2*b)*dy*yetComputed[idxSrc2] + FReal(b*(b-1))*yetComputed[idxSrc5] + + FReal(2*c)*dz*yetComputed[idxSrc3] + FReal(c*(c-1))*yetComputed[idxSrc6])/dist2; + } + } + } + } + } } - } - ///////////////////////////////// - ///////// Public Methods //////// - ///////////////////////////////// + ///////////////////////////////// + ///////// Public Methods //////// + ///////////////////////////////// public: - - /*Constructor, need system information*/ - FTaylorKernel(const int inTreeHeight, const FReal inBoxWidth, const FPoint<FReal>& inBoxCenter) : - boxWidth(inBoxWidth), - treeHeight(inTreeHeight), - widthAtLeafLevel(inBoxWidth/FReal(1 << (inTreeHeight-1))), - widthAtLeafLevelDiv2(widthAtLeafLevel/2), - boxCorner(inBoxCenter.getX()-(inBoxWidth/2),inBoxCenter.getY()-(inBoxWidth/2),inBoxCenter.getZ()-(inBoxWidth/2)) - { - FReal facto; - this->precomputeFactorials() ; - // int a = 0, b = 0, c = 0; - for(int i=0 , a = 0, b = 0, c = 0; i<SizeVector ; ++i) - { - facto = static_cast<FReal>(fact3int(a,b,c)); - _coeffPoly[i] = FReal(1.0)/(facto); - this->incPowers(&a,&b,&c); //inc powers of expansion - } - this->preComputeDerivative(); - this->preComputeIndirection(); - } - - /* Default destructor + + /*Constructor, need system information*/ + FTaylorKernel(const int inTreeHeight, const FReal inBoxWidth, const FPoint<FReal>& inBoxCenter) : + boxWidth(inBoxWidth), + treeHeight(inTreeHeight), + widthAtLeafLevel(inBoxWidth/FReal(1 << (inTreeHeight-1))), + widthAtLeafLevelDiv2(widthAtLeafLevel/2), + boxCorner(inBoxCenter.getX()-(inBoxWidth/2),inBoxCenter.getY()-(inBoxWidth/2),inBoxCenter.getZ()-(inBoxWidth/2)) + { + FReal facto; + this->precomputeFactorials() ; + // int a = 0, b = 0, c = 0; + for(int i=0 , a = 0, b = 0, c = 0; i<SizeVector ; ++i) + { + facto = static_cast<FReal>(fact3int(a,b,c)); + _coeffPoly[i] = FReal(1.0)/(facto); + this->incPowers(&a,&b,&c); //inc powers of expansion + } + this->preComputeDerivative(); + this->preComputeIndirection(); + } + + /* Default destructor */ - virtual ~FTaylorKernel(){ - - } + virtual ~FTaylorKernel(){ + + } - /**P2M + /**P2M * @brief Fill the Multipole with the field created by the cell * particles. - * + * * Formula : * \f[ * M_{k} = \frac{|k|!}{k! k!} \sum_{j=0}^{N}{ q_j (x_c-x_j)^{k}} * \f] * where \f$x_c\f$ is the centre of the cell and \f$x_j\f$ the \f$j^{th}\f$ particles and \f$q_j\f$ its charge and \f$N\f$ the particle number. */ - void P2M(CellClass* const pole, - const ContainerClass* const particles) - { - //Copying cell center position once and for all - const FPoint<FReal>& cellCenter = getLeafCenter(pole->getCoordinate()); - - FReal * FRestrict multipole = pole->getMultipole(); - FMemUtils::memset(multipole,0,SizeVector*sizeof(FReal(0.0))); - - FReal multipole2[SizeVector] ; - - int nbPart = particles->getNbParticles(), i; - const FReal* const * positions = particles->getPositions(); - const FReal* posX = positions[0]; - const FReal* posY = positions[1]; - const FReal* posZ = positions[2]; - - const FReal* phyValue = particles->getPhysicalValues(); - - // Iterating over Particles - FReal xc = cellCenter.getX(), yc = cellCenter.getY(), zc = cellCenter.getZ() ; - FReal dx[3] ; - for(int idPart=0 ; idPart<nbPart ; ++idPart){ - - dx[0] = xc - posX[idPart] ; - dx[1] = yc - posY[idPart] ; - dx[2] = zc - posZ[idPart] ; - - multipole2[0] = phyValue[idPart] ; - - int leading[3] = {0,0,0 } ; - for (int k=1, t=1, tail=1; k <= P; ++k, tail=t) - { - for (i = 0; i < 3; ++i) // dérouler la boucle en I ?? - { - int head = leading[i]; - leading[i] = t; - for ( int j = head; j < tail; ++j, ++t) - { - multipole2[t] = multipole2[j] *dx[i] ; - } - } // for i - }// for k - // - // Does a saxpy be usefull here ? - for( i=0 ; i < SizeVector ; ++i) - { - multipole[i] += multipole2[i] ; - multipole2[i] = 0.0; - } - } // end loop on particles - // Multiply by the coefficient - for( i=0 ; i < SizeVector ; ++i) - { - multipole[i] *=_coeffPoly[i] ; - } - } - - - /** + void P2M(CellClass* const pole, + const ContainerClass* const particles) + { + //Copying cell center position once and for all + const FPoint<FReal>& cellCenter = getLeafCenter(pole->getCoordinate()); + + FReal * FRestrict multipole = pole->getMultipole(); + FMemUtils::memset(multipole,0,SizeVector*sizeof(FReal(0.0))); + + FReal multipole2[SizeVector] ; + + int nbPart = particles->getNbParticles(), i; + const FReal* const * positions = particles->getPositions(); + const FReal* posX = positions[0]; + const FReal* posY = positions[1]; + const FReal* posZ = positions[2]; + + const FReal* phyValue = particles->getPhysicalValues(); + + // Iterating over Particles + FReal xc = cellCenter.getX(), yc = cellCenter.getY(), zc = cellCenter.getZ() ; + FReal dx[3] ; + for(int idPart=0 ; idPart<nbPart ; ++idPart){ + + dx[0] = xc - posX[idPart] ; + dx[1] = yc - posY[idPart] ; + dx[2] = zc - posZ[idPart] ; + + multipole2[0] = phyValue[idPart] ; + + int leading[3] = {0,0,0 } ; + for (int k=1, t=1, tail=1; k <= P; ++k, tail=t) + { + for (i = 0; i < 3; ++i) // dérouler la boucle en I ?? + { + int head = leading[i]; + leading[i] = t; + for ( int j = head; j < tail; ++j, ++t) + { + multipole2[t] = multipole2[j] *dx[i] ; + } + } // for i + }// for k + // + // Does a saxpy be usefull here ? + for( i=0 ; i < SizeVector ; ++i) + { + multipole[i] += multipole2[i] ; + multipole2[i] = 0.0; + } + } // end loop on particles + // Multiply by the coefficient + for( i=0 ; i < SizeVector ; ++i) + { + multipole[i] *=_coeffPoly[i] ; + } + } + + + /** * @brief Fill the parent multipole with the 8 values of child multipoles - * + * * */ - void M2M(CellClass* const FRestrict pole, - const CellClass*const FRestrict *const FRestrict child, - const int inLevel) - { - //Powers of expansions - int a=0,b=0,c=0; - //Indexes of powers - int idx_a,idx_b,idx_c; - //Distance from current child to parent - FReal dx = 0.0; - FReal dy = 0.0; - FReal dz = 0.0; - //Center point of parent cell - const FPoint<FReal>& cellCenter = getCellCenter(pole->getCoordinate(),inLevel); - FReal * FRestrict mult = pole->getMultipole(); + void M2M(CellClass* const FRestrict pole, + const CellClass*const FRestrict *const FRestrict child, + const int inLevel) + { + //Powers of expansions + int a=0,b=0,c=0; + //Indexes of powers + int idx_a,idx_b,idx_c; + //Distance from current child to parent + FReal dx = 0.0; + FReal dy = 0.0; + FReal dz = 0.0; + //Center point of parent cell + const FPoint<FReal>& cellCenter = getCellCenter(pole->getCoordinate(),inLevel); + FReal * FRestrict mult = pole->getMultipole(); - //Iteration over the eight children - int idxChild; - FReal coeff; - for(idxChild=0 ; idxChild<8 ; ++idxChild) - { - if(child[idxChild]){ - const FPoint<FReal>& childCenter = getCellCenter(child[idxChild]->getCoordinate(),inLevel+1); - const FReal * FRestrict multChild = child[idxChild]->getMultipole(); - - //Set the distance between centers of cells - dx = cellCenter.getX() - childCenter.getX(); - dy = cellCenter.getY() - childCenter.getY(); - dz = cellCenter.getZ() - childCenter.getZ(); - - // Precompute the arrays of dx^i - arrayDX[0] = 1.0 ; - arrayDY[0] = 1.0 ; - arrayDZ[0] = 1.0 ; - for (int i = 1 ; i <= P ; ++i) { - arrayDX[i] = dx * arrayDX[i-1] ; - arrayDY[i] = dy * arrayDY[i-1] ; - arrayDZ[i] = dz * arrayDZ[i-1] ; - } - - a=0; - b=0; - c=0; - //FReal value ; - FReal value; - //Iteration over parent multipole array - for(int ordMult = 0,idxMult=0 ; ordMult <= P ; ++ordMult) - { - for(a=ordMult ; a>=0 ; --a) - { - if((ordMult-a) == 1){ - for(int i =0 ; i<= 1 ; ++i,++idxMult) - { - value = 0.0; - int idMultiChild; - b = 1-i; - c = i; - //Iteration over the powers to find the cell multipole - //involved in the computation of the parent multipole - for(idx_a=0 ; idx_a <= a ; ++idx_a){ - for(idx_b=0 ; idx_b <= b ; ++idx_b){ - for(idx_c=0 ; idx_c <= c ; ++idx_c){ - //Computation - //Child multipole involved - idMultiChild = powerToIdx(a-idx_a,b-idx_b,c-idx_c); - coeff = FReal(1.0)/fact3int(idx_a,idx_b,idx_c); - value += multChild[idMultiChild]*coeff*arrayDX[idx_a]*arrayDY[idx_b]*arrayDZ[idx_c]; - } - } - } - mult[idxMult] += value; - } - } - else{ - for(b=ordMult-a ; b>=0 ; --b, ++idxMult) - { - value = 0.0; - int idMultiChild; - c = ordMult-a-b; - //Iteration over the powers to find the cell multipole - //involved in the computation of the parent multipole - for(idx_a=0 ; idx_a <= a ; ++idx_a){ - for(idx_b=0 ; idx_b <= b ; ++idx_b){ - for(idx_c=0 ; idx_c <= c ; ++idx_c){ - //Computation - //Child multipole involved - idMultiChild = powerToIdx(a-idx_a,b-idx_b,c-idx_c); - coeff = FReal(1.0)/fact3int(idx_a,idx_b,idx_c); - value += multChild[idMultiChild]*coeff*arrayDX[idx_a]*arrayDY[idx_b]*arrayDZ[idx_c]; - } - } - } - mult[idxMult] += value; - } - } - } - } - } - } - } - - /** + //Iteration over the eight children + int idxChild; + FReal coeff; + for(idxChild=0 ; idxChild<8 ; ++idxChild) + { + if(child[idxChild]){ + const FPoint<FReal>& childCenter = getCellCenter(child[idxChild]->getCoordinate(),inLevel+1); + const FReal * FRestrict multChild = child[idxChild]->getMultipole(); + + //Set the distance between centers of cells + dx = cellCenter.getX() - childCenter.getX(); + dy = cellCenter.getY() - childCenter.getY(); + dz = cellCenter.getZ() - childCenter.getZ(); + + // Precompute the arrays of dx^i + arrayDX[0] = 1.0 ; + arrayDY[0] = 1.0 ; + arrayDZ[0] = 1.0 ; + for (int i = 1 ; i <= P ; ++i) { + arrayDX[i] = dx * arrayDX[i-1] ; + arrayDY[i] = dy * arrayDY[i-1] ; + arrayDZ[i] = dz * arrayDZ[i-1] ; + } + + a=0; + b=0; + c=0; + //FReal value ; + FReal value; + //Iteration over parent multipole array + for(int ordMult = 0,idxMult=0 ; ordMult <= P ; ++ordMult) + { + for(a=ordMult ; a>=0 ; --a) + { + if((ordMult-a) == 1){ + for(int i =0 ; i<= 1 ; ++i,++idxMult) + { + value = 0.0; + int idMultiChild; + b = 1-i; + c = i; + //Iteration over the powers to find the cell multipole + //involved in the computation of the parent multipole + for(idx_a=0 ; idx_a <= a ; ++idx_a){ + for(idx_b=0 ; idx_b <= b ; ++idx_b){ + for(idx_c=0 ; idx_c <= c ; ++idx_c){ + //Computation + //Child multipole involved + idMultiChild = powerToIdx(a-idx_a,b-idx_b,c-idx_c); + coeff = FReal(1.0)/fact3int(idx_a,idx_b,idx_c); + value += multChild[idMultiChild]*coeff*arrayDX[idx_a]*arrayDY[idx_b]*arrayDZ[idx_c]; + } + } + } + mult[idxMult] += value; + } + } + else{ + for(b=ordMult-a ; b>=0 ; --b, ++idxMult) + { + value = 0.0; + int idMultiChild; + c = ordMult-a-b; + //Iteration over the powers to find the cell multipole + //involved in the computation of the parent multipole + for(idx_a=0 ; idx_a <= a ; ++idx_a){ + for(idx_b=0 ; idx_b <= b ; ++idx_b){ + for(idx_c=0 ; idx_c <= c ; ++idx_c){ + //Computation + //Child multipole involved + idMultiChild = powerToIdx(a-idx_a,b-idx_b,c-idx_c); + coeff = FReal(1.0)/fact3int(idx_a,idx_b,idx_c); + value += multChild[idMultiChild]*coeff*arrayDX[idx_a]*arrayDY[idx_b]*arrayDZ[idx_c]; + } + } + } + mult[idxMult] += value; + } + } + } + } + } + } + } + + /** *@brief Convert the multipole expansion into local expansion The * operator do not use symmetries. * @@ -715,56 +715,56 @@ public: * \sum_{\mathbf{k}=0}^{p} \left [ M_\mathbf{k}^c \, * \Psi_{\mathbf{,n+k}}( \mathbf{x}_c^{target})\right ] \f] * and \f[ \Psi_{\mathbf{,i}}^{c}(\mathbf{x}) = - * \frac{\partial^i}{\partial x^i} \frac{1}{|x-x_c^{src}|} = \frac{\partial^{i_1}}{\partial x_1^{i_1}} \frac{\partial^{i_2}}{\partial x_2^{i_2}} \frac{\partial^{i_3}}{\partial x_3^{i_3}} \frac{1}{|x-x_c^{src}|}\f] + * \frac{\partial^i}{\partial x^i} \frac{1}{|x-x_c^{src}|} = \frac{\partial^{i_1}}{\partial x_1^{i_1}} \frac{\partial^{i_2}}{\partial x_2^{i_2}} \frac{\partial^{i_3}}{\partial x_3^{i_3}} \frac{1}{|x-x_c^{src}|}\f] * * Where \f$x_c^{src}\f$ is the centre of the cell where the * multiplole are considered,\f$x_c^{target}\f$ is the centre of the * current cell. The cell where we compute the local expansion. * */ - void M2L(CellClass* const FRestrict local, // Target cell - const CellClass* distantNeighbors[343], // Sources to be read - const int /*size*/, const int inLevel) - { - //Local expansion to be filled - FReal * FRestrict iterLocal = local->getLocal(); - //index for distant neighbors - int idxNeigh; - FReal tmp1; - int * ind; - FReal * psiVector; - const FReal * multipole; - //Loop over all the possible neighbors - for(idxNeigh=0 ; idxNeigh<343 ; ++idxNeigh){ - //Need to test if current neighbor is one of the interaction list - if(distantNeighbors[idxNeigh]){ - - //Get the preComputed values for the derivative - psiVector = M2LpreComputedDerivatives[inLevel][idxNeigh]; - //Multipole to be read - multipole = distantNeighbors[idxNeigh]->getMultipole(); - - //Iterating over local array : n - for(int i=0 ; i<SizeVector ; ++i) - { - //Get the right indexes set - ind = this->preComputedIndirections[i]; - tmp1 = FReal(0); - - //Iterating over multipole array - for (int j=0 ; j<SizeVector ; ++j) - { - tmp1 += psiVector[ind[j]]*multipole[j]; - } - iterLocal[i] += tmp1*_coeffPoly[i]; - } - } + void M2L(CellClass* const FRestrict local, // Target cell + const CellClass* distantNeighbors[343], // Sources to be read + const int /*size*/, const int inLevel) + { + //Local expansion to be filled + FReal * FRestrict iterLocal = local->getLocal(); + //index for distant neighbors + int idxNeigh; + FReal tmp1; + int * ind; + FReal * psiVector; + const FReal * multipole; + //Loop over all the possible neighbors + for(idxNeigh=0 ; idxNeigh<343 ; ++idxNeigh){ + //Need to test if current neighbor is one of the interaction list + if(distantNeighbors[idxNeigh]){ + + //Get the preComputed values for the derivative + psiVector = M2LpreComputedDerivatives[inLevel][idxNeigh]; + //Multipole to be read + multipole = distantNeighbors[idxNeigh]->getMultipole(); + + //Iterating over local array : n + for(int i=0 ; i<SizeVector ; ++i) + { + //Get the right indexes set + ind = this->preComputedIndirections[i]; + tmp1 = FReal(0); + + //Iterating over multipole array + for (int j=0 ; j<SizeVector ; ++j) + { + tmp1 += psiVector[ind[j]]*multipole[j]; + } + iterLocal[i] += tmp1*_coeffPoly[i]; + } + } + } } - } - - /** + + /** *@brief Translate the local expansion of parent cell to child cell * * One need to translate the local expansion on a father cell @@ -774,95 +774,95 @@ public: * Local expansion for the daughters will be : * \f[ \sum_{\mathbf{k}=0}^{|k|<P} L_k * (\mathbf{x}-\mathbf{x}_f)^{\mathbf{k}} \f] * with : - * + * *\f[ L_{n} = \sum_{\mathbf{k}=\mathbf{n}}^{|k|<P} C_{\mathbf{k}}^{\mathbf{n}} * (\mathbf{x}_f-\mathbf{x}_p)^{\mathbf{k}-\mathbf{n}} \f] */ - void L2L(const CellClass* const FRestrict fatherCell, - CellClass* FRestrict * const FRestrict childCell, - const int inLevel) - { - FPoint<FReal> locCenter = getCellCenter(fatherCell->getCoordinate(),inLevel); - - // Get father local expansion - const FReal* FRestrict fatherExpansion = fatherCell->getLocal() ; - int idxFatherLoc; //index of Father local expansion to be read. - FReal dx, dy, dz, coeff; - int ap, bp, cp, af, bf, cf; //Indexes of expansion for father and child. - - // For all children - for(int idxChild = 0 ; idxChild < 8 ; ++idxChild){ - - if(childCell[idxChild]){ // if child exists - - FReal* FRestrict childExpansion = childCell[idxChild]->getLocal() ; - const FPoint<FReal>& childCenter = getCellCenter(childCell[idxChild]->getCoordinate(),inLevel+1); - - //Set the distance between centers of cells - // Child - father - dx = childCenter.getX()-locCenter.getX(); - dy = childCenter.getY()-locCenter.getY(); - dz = childCenter.getZ()-locCenter.getZ(); - // Precompute the arrays of dx^i - arrayDX[0] = 1.0 ; - arrayDY[0] = 1.0 ; - arrayDZ[0] = 1.0 ; - for (int i = 1 ; i <= P ; ++i) { - arrayDX[i] = dx * arrayDX[i-1] ; - arrayDY[i] = dy * arrayDY[i-1] ; - arrayDZ[i] = dz * arrayDZ[i-1] ; - } - //iterator over child's local expansion (to be filled) - af=0; bf=0; cf=0; - for(int ordChild=0, idxChEx=0 ; ordChild <= P ; ++ordChild) { - for(af=ordChild ; af>=0 ; --af) - { - if((ordChild-af) == 1){ - for(int i=0 ; i <= 1 ; ++i,++idxChEx) - { - bf = 1-i; - cf = i; - //Iterator over parent's local array - for(ap=af ; ap<=P ; ++ap){ - for(bp=bf ; bp<=P ; ++bp){ - for(cp=cf ; ((cp<=P) && (ap+bp+cp) <= P) ; ++cp){ - idxFatherLoc = powerToIdx(ap,bp,cp); - coeff = combin(ap,af) * combin(bp,bf) * combin(cp,cf); - childExpansion[idxChEx] += coeff*fatherExpansion[idxFatherLoc]*arrayDX[ap-af]*arrayDY[bp-bf]*arrayDZ[cp-cf] ; - } - } - } - } - } - else{ - for(bf=ordChild-af ; bf>=0 ; --bf, ++idxChEx) - { - cf = ordChild-af-bf; - //Iterator over parent's local array - for(ap=af ; ap<=P ; ++ap){ - for(bp=bf ; bp<=P ; ++bp){ - for(cp=cf ; ((cp<=P) && (ap+bp+cp) <= P) ; ++cp){ - idxFatherLoc = powerToIdx(ap,bp,cp); - coeff = combin(ap,af) * combin(bp,bf) * combin(cp,cf); - childExpansion[idxChEx] += coeff*fatherExpansion[idxFatherLoc]*arrayDX[ap-af]*arrayDY[bp-bf]*arrayDZ[cp-cf] ; - } - } - } - } - } - } - } - } + void L2L(const CellClass* const FRestrict fatherCell, + CellClass* FRestrict * const FRestrict childCell, + const int inLevel) + { + FPoint<FReal> locCenter = getCellCenter(fatherCell->getCoordinate(),inLevel); + + // Get father local expansion + const FReal* FRestrict fatherExpansion = fatherCell->getLocal() ; + int idxFatherLoc; //index of Father local expansion to be read. + FReal dx, dy, dz, coeff; + int ap, bp, cp, af, bf, cf; //Indexes of expansion for father and child. + + // For all children + for(int idxChild = 0 ; idxChild < 8 ; ++idxChild){ + + if(childCell[idxChild]){ // if child exists + + FReal* FRestrict childExpansion = childCell[idxChild]->getLocal() ; + const FPoint<FReal>& childCenter = getCellCenter(childCell[idxChild]->getCoordinate(),inLevel+1); + + //Set the distance between centers of cells + // Child - father + dx = childCenter.getX()-locCenter.getX(); + dy = childCenter.getY()-locCenter.getY(); + dz = childCenter.getZ()-locCenter.getZ(); + // Precompute the arrays of dx^i + arrayDX[0] = 1.0 ; + arrayDY[0] = 1.0 ; + arrayDZ[0] = 1.0 ; + for (int i = 1 ; i <= P ; ++i) { + arrayDX[i] = dx * arrayDX[i-1] ; + arrayDY[i] = dy * arrayDY[i-1] ; + arrayDZ[i] = dz * arrayDZ[i-1] ; + } + //iterator over child's local expansion (to be filled) + af=0; bf=0; cf=0; + for(int ordChild=0, idxChEx=0 ; ordChild <= P ; ++ordChild) { + for(af=ordChild ; af>=0 ; --af) + { + if((ordChild-af) == 1){ + for(int i=0 ; i <= 1 ; ++i,++idxChEx) + { + bf = 1-i; + cf = i; + //Iterator over parent's local array + for(ap=af ; ap<=P ; ++ap){ + for(bp=bf ; bp<=P ; ++bp){ + for(cp=cf ; ((cp<=P) && (ap+bp+cp) <= P) ; ++cp){ + idxFatherLoc = powerToIdx(ap,bp,cp); + coeff = combin(ap,af) * combin(bp,bf) * combin(cp,cf); + childExpansion[idxChEx] += coeff*fatherExpansion[idxFatherLoc]*arrayDX[ap-af]*arrayDY[bp-bf]*arrayDZ[cp-cf] ; + } + } + } + } + } + else{ + for(bf=ordChild-af ; bf>=0 ; --bf, ++idxChEx) + { + cf = ordChild-af-bf; + //Iterator over parent's local array + for(ap=af ; ap<=P ; ++ap){ + for(bp=bf ; bp<=P ; ++bp){ + for(cp=cf ; ((cp<=P) && (ap+bp+cp) <= P) ; ++cp){ + idxFatherLoc = powerToIdx(ap,bp,cp); + coeff = combin(ap,af) * combin(bp,bf) * combin(cp,cf); + childExpansion[idxChEx] += coeff*fatherExpansion[idxFatherLoc]*arrayDX[ap-af]*arrayDY[bp-bf]*arrayDZ[cp-cf] ; + } + } + } + } + } + } + } + } + } } - } - - - - /**L2P + + + + /**L2P *@brief Apply on the particles the force computed from the local expansion to all particles in the cell * - * + * * Formula : * \f[ * Potential = \sum_{j=0}^{nb_{particles}}{q_j \sum_{k=0}^{P}{ L_k * (x_j-x_c)^{k}}} @@ -871,92 +871,92 @@ public: * where \f$x_c\f$ is the centre of the local cell and \f$x_j\f$ the * \f$j^{th}\f$ particles and \f$q_j\f$ its charge. */ - void L2P(const CellClass* const local, - ContainerClass* const particles) + void L2P(const CellClass* const local, + ContainerClass* const particles) { - FPoint<FReal> locCenter = getLeafCenter(local->getCoordinate()); - //Iterator over particles - int nbPart = particles->getNbParticles(); - - const FReal * iterLocal = local->getLocal(); - const FReal * const * positions = particles->getPositions(); - const FReal * posX = positions[0]; - const FReal * posY = positions[1]; - const FReal * posZ = positions[2]; - - FReal * forceX = particles->getForcesX(); - FReal * forceY = particles->getForcesY(); - FReal * forceZ = particles->getForcesZ(); - - FReal * targetsPotentials = particles->getPotentials(); - - FReal * phyValues = particles->getPhysicalValues(); - - //Iteration over particles - for(int i=0 ; i<nbPart ; ++i){ - - FReal dx = posX[i] - locCenter.getX(); - FReal dy = posY[i] - locCenter.getY(); - FReal dz = posZ[i] - locCenter.getZ(); - - // Precompute an arrays of Array[i] = dx^(i-1) - arrayDX[0] = 0.0 ; - arrayDY[0] = 0.0 ; - arrayDZ[0] = 0.0 ; - - arrayDX[1] = 1.0 ; - arrayDY[1] = 1.0 ; - arrayDZ[1] = 1.0 ; - - for (int d = 2 ; d <= P+1 ; ++d){ //Array is staggered : Array[i] = dx^(i-1) - arrayDX[d] = dx * arrayDX[d-1] ; - arrayDY[d] = dy * arrayDY[d-1] ; - arrayDZ[d] = dz * arrayDZ[d-1] ; - } - FReal partPhyValue = phyValues[i]; - FReal locPot = 0.0, locForceX = 0.0, locForceY = 0.0, locForceZ = 0.0 ; - int a=0,b=0,c=0; - for(int j=0,ord=0 ; ord <= P ; ++ord) - { - for(a=ord ; a>=0 ; --a) - { - if( (ord-a) == 1){ - for(int t=0 ; t<=1 ; ++t,++j) - { - b = 1-t; - c = t; - FReal locForce = iterLocal[j]; - // compute the potential - locPot += iterLocal[j]*arrayDX[a+1]*arrayDY[b+1]*arrayDZ[c+1]; - //Application of forces - locForceX += FReal(a)*locForce*arrayDX[a]*arrayDY[b+1]*arrayDZ[c+1]; - locForceY += FReal(b)*locForce*arrayDX[a+1]*arrayDY[b]*arrayDZ[c+1]; - locForceZ += FReal(c)*locForce*arrayDX[a+1]*arrayDY[b+1]*arrayDZ[c]; - } - } - else{ - for(b=ord-a ; b>=0 ; --b,++j) - { - c = ord-a-b; - FReal locForce = iterLocal[j]; - // compute the potential - locPot += iterLocal[j]*arrayDX[a+1]*arrayDY[b+1]*arrayDZ[c+1]; - //Application of forces - locForceX += FReal(a)*locForce*arrayDX[a]*arrayDY[b+1]*arrayDZ[c+1]; - locForceY += FReal(b)*locForce*arrayDX[a+1]*arrayDY[b]*arrayDZ[c+1]; - locForceZ += FReal(c)*locForce*arrayDX[a+1]*arrayDY[b+1]*arrayDZ[c]; - } - } - } - } - targetsPotentials[i] +=/* partPhyValue*/locPot ; - forceX[i] += partPhyValue*locForceX ; - forceY[i] += partPhyValue*locForceY ; - forceZ[i] += partPhyValue*locForceZ ; - } + FPoint<FReal> locCenter = getLeafCenter(local->getCoordinate()); + //Iterator over particles + int nbPart = particles->getNbParticles(); + + const FReal * iterLocal = local->getLocal(); + const FReal * const * positions = particles->getPositions(); + const FReal * posX = positions[0]; + const FReal * posY = positions[1]; + const FReal * posZ = positions[2]; + + FReal * forceX = particles->getForcesX(); + FReal * forceY = particles->getForcesY(); + FReal * forceZ = particles->getForcesZ(); + + FReal * targetsPotentials = particles->getPotentials(); + + FReal * phyValues = particles->getPhysicalValues(); + + //Iteration over particles + for(int i=0 ; i<nbPart ; ++i){ + + FReal dx = posX[i] - locCenter.getX(); + FReal dy = posY[i] - locCenter.getY(); + FReal dz = posZ[i] - locCenter.getZ(); + + // Precompute an arrays of Array[i] = dx^(i-1) + arrayDX[0] = 0.0 ; + arrayDY[0] = 0.0 ; + arrayDZ[0] = 0.0 ; + + arrayDX[1] = 1.0 ; + arrayDY[1] = 1.0 ; + arrayDZ[1] = 1.0 ; + + for (int d = 2 ; d <= P+1 ; ++d){ //Array is staggered : Array[i] = dx^(i-1) + arrayDX[d] = dx * arrayDX[d-1] ; + arrayDY[d] = dy * arrayDY[d-1] ; + arrayDZ[d] = dz * arrayDZ[d-1] ; + } + FReal partPhyValue = phyValues[i]; + FReal locPot = 0.0, locForceX = 0.0, locForceY = 0.0, locForceZ = 0.0 ; + int a=0,b=0,c=0; + for(int j=0,ord=0 ; ord <= P ; ++ord) + { + for(a=ord ; a>=0 ; --a) + { + if( (ord-a) == 1){ + for(int t=0 ; t<=1 ; ++t,++j) + { + b = 1-t; + c = t; + FReal locForce = iterLocal[j]; + // compute the potential + locPot += iterLocal[j]*arrayDX[a+1]*arrayDY[b+1]*arrayDZ[c+1]; + //Application of forces + locForceX += FReal(a)*locForce*arrayDX[a]*arrayDY[b+1]*arrayDZ[c+1]; + locForceY += FReal(b)*locForce*arrayDX[a+1]*arrayDY[b]*arrayDZ[c+1]; + locForceZ += FReal(c)*locForce*arrayDX[a+1]*arrayDY[b+1]*arrayDZ[c]; + } + } + else{ + for(b=ord-a ; b>=0 ; --b,++j) + { + c = ord-a-b; + FReal locForce = iterLocal[j]; + // compute the potential + locPot += iterLocal[j]*arrayDX[a+1]*arrayDY[b+1]*arrayDZ[c+1]; + //Application of forces + locForceX += FReal(a)*locForce*arrayDX[a]*arrayDY[b+1]*arrayDZ[c+1]; + locForceY += FReal(b)*locForce*arrayDX[a+1]*arrayDY[b]*arrayDZ[c+1]; + locForceZ += FReal(c)*locForce*arrayDX[a+1]*arrayDY[b+1]*arrayDZ[c]; + } + } + } + } + targetsPotentials[i] +=/* partPhyValue*/locPot ; + forceX[i] += partPhyValue*locForceX ; + forceY[i] += partPhyValue*locForceY ; + forceZ[i] += partPhyValue*locForceZ ; + } } - /** + /** * P2P * Particles to particles * @param inLeafPosition tree coordinate of the leaf @@ -965,19 +965,19 @@ public: * @param directNeighborsParticles the particles from direct neighbors (this is an array of list) * @param size the number of direct neighbors */ - void P2P(const FTreeCoordinate& /*inLeafPosition*/, - ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict /*sources*/, - ContainerClass* const directNeighborsParticles[27], const int /*size*/) - { - FP2PRT<FReal>::template FullMutual<ContainerClass>(targets,directNeighborsParticles,14); - } - - /** Use mutual even if it not useful and call particlesMutualInteraction */ - void P2PRemote(const FTreeCoordinate& /*inPosition*/, - ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict /*inSources*/, - ContainerClass* const inNeighbors[27], const int /*inSize*/){ - FP2PRT<FReal>::template FullRemote<ContainerClass>(inTargets,inNeighbors,27); - } + void P2P(const FTreeCoordinate& /*inLeafPosition*/, + ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict /*sources*/, + ContainerClass* const directNeighborsParticles[27], const int /*size*/) + { + FP2PRT<FReal>::template FullMutual<ContainerClass>(targets,directNeighborsParticles,14); + } + + /** Use mutual even if it not useful and call particlesMutualInteraction */ + void P2PRemote(const FTreeCoordinate& /*inPosition*/, + ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict /*inSources*/, + ContainerClass* const inNeighbors[27], const int /*inSize*/){ + FP2PRT<FReal>::template FullRemote<ContainerClass>(inTargets,inNeighbors,27); + } }; diff --git a/Src/Kernels/Uniform/FUnifCell.hpp b/Src/Kernels/Uniform/FUnifCell.hpp index 58086ba1b..2f9f7ac98 100644 --- a/Src/Kernels/Uniform/FUnifCell.hpp +++ b/Src/Kernels/Uniform/FUnifCell.hpp @@ -180,7 +180,7 @@ public: } template <class StreamClass> - friend StreamClass& operator<<(StreamClass& output, const FUnifCell<ORDER, NRHS, NLHS, NVALS>& cell){ + friend StreamClass& operator<<(StreamClass& output, const FUnifCell<FReal,ORDER, NRHS, NLHS, NVALS>& cell){ output <<" Multipole exp NRHS " << NRHS <<" NVALS " <<NVALS << " VectorSize " << cell.getVectorSize() << std::endl; for (int rhs= 0 ; rhs < NRHS ; ++rhs) { const FReal* pole = cell.getMultipole(rhs); @@ -197,21 +197,21 @@ public: }; -template <int ORDER, int NRHS = 1, int NLHS = 1, int NVALS = 1> -class FTypedUnifCell : public FUnifCell<ORDER,NRHS,NLHS,NVALS>, public FExtendCellType { +template <class FReal, int ORDER, int NRHS = 1, int NLHS = 1, int NVALS = 1> +class FTypedUnifCell : public FUnifCell<FReal,ORDER,NRHS,NLHS,NVALS>, public FExtendCellType { public: template <class BufferWriterClass> void save(BufferWriterClass& buffer) const{ - FUnifCell<ORDER,NRHS,NLHS,NVALS>::save(buffer); + FUnifCell<FReal,ORDER,NRHS,NLHS,NVALS>::save(buffer); FExtendCellType::save(buffer); } template <class BufferReaderClass> void restore(BufferReaderClass& buffer){ - FUnifCell<ORDER,NRHS,NLHS,NVALS>::restore(buffer); + FUnifCell<FReal,ORDER,NRHS,NLHS,NVALS>::restore(buffer); FExtendCellType::restore(buffer); } void resetToInitialState(){ - FUnifCell<ORDER,NRHS,NLHS,NVALS>::resetToInitialState(); + FUnifCell<FReal,ORDER,NRHS,NLHS,NVALS>::resetToInitialState(); FExtendCellType::resetToInitialState(); } }; diff --git a/Src/Kernels/Uniform/FUnifDenseKernel.hpp b/Src/Kernels/Uniform/FUnifDenseKernel.hpp index 3ec52af03..2abc73a2d 100644 --- a/Src/Kernels/Uniform/FUnifDenseKernel.hpp +++ b/Src/Kernels/Uniform/FUnifDenseKernel.hpp @@ -73,7 +73,7 @@ public: const FReal inBoxWidth, const FPoint<FReal>& inBoxCenter, const MatrixKernelClass *const inMatrixKernel) - : FAbstractUnifKernel< CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS>(inTreeHeight,inBoxWidth,inBoxCenter), + : FAbstractUnifKernel< FReal, CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS>(inTreeHeight,inBoxWidth,inBoxCenter), MatrixKernel(inMatrixKernel), M2LHandler(MatrixKernel, inTreeHeight, @@ -116,14 +116,14 @@ public: // interpolation points of source (Y) and target (X) cell FPoint<FReal> X[AbstractBaseClass::nnodes], Y[AbstractBaseClass::nnodes]; - FUnifTensor<ORDER>::setRoots(AbstractBaseClass::getCellCenter(TargetCell->getCoordinate(),TreeLevel), CellWidth, X); + FUnifTensor<FReal,ORDER>::setRoots(AbstractBaseClass::getCellCenter(TargetCell->getCoordinate(),TreeLevel), CellWidth, X); for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){ for (int idx=0; idx<343; ++idx){ if (SourceCells[idx]){ - FUnifTensor<ORDER>::setRoots(AbstractBaseClass::getCellCenter(SourceCells[idx]->getCoordinate(),TreeLevel), CellWidth, Y); + FUnifTensor<FReal,ORDER>::setRoots(AbstractBaseClass::getCellCenter(SourceCells[idx]->getCoordinate(),TreeLevel), CellWidth, Y); for (unsigned int m=0; m<AbstractBaseClass::nnodes; ++m) for (unsigned int n=0; n<AbstractBaseClass::nnodes; ++n){ @@ -174,7 +174,7 @@ public: ContainerClass* const NeighborSourceParticles[27], const int /* size */) { - DirectInteractionComputer<MatrixKernelClass::NCMP, NVALS>::P2P(TargetParticles,NeighborSourceParticles,MatrixKernel); + DirectInteractionComputer<FReal,MatrixKernelClass::NCMP, NVALS>::P2P(TargetParticles,NeighborSourceParticles,MatrixKernel); } @@ -182,7 +182,7 @@ public: ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict /*inSources*/, ContainerClass* const inNeighbors[27], const int /*inSize*/) { - DirectInteractionComputer<MatrixKernelClass::NCMP, NVALS>::P2PRemote(inTargets,inNeighbors,27,MatrixKernel); + DirectInteractionComputer<FReal,MatrixKernelClass::NCMP, NVALS>::P2PRemote(inTargets,inNeighbors,27,MatrixKernel); } }; diff --git a/Src/Kernels/Uniform/FUnifInterpolator.hpp b/Src/Kernels/Uniform/FUnifInterpolator.hpp index d2a720c2a..276707693 100644 --- a/Src/Kernels/Uniform/FUnifInterpolator.hpp +++ b/Src/Kernels/Uniform/FUnifInterpolator.hpp @@ -85,7 +85,7 @@ class FUnifInterpolator : FNoCopyable FPoint<FReal> ParentRoots[nnodes], ChildRoots[nnodes]; const FReal ParentWidth(2.); const FPoint<FReal> ParentCenter(0., 0., 0.); - FUnifTensor<ORDER>::setRoots(ParentCenter, ParentWidth, ParentRoots); + FUnifTensor<FReal,ORDER>::setRoots(ParentCenter, ParentWidth, ParentRoots); FPoint<FReal> ChildCenter; const FReal ChildWidth(1.); @@ -97,8 +97,8 @@ class FUnifInterpolator : FNoCopyable ChildParentInterpolator[child] = new FReal [nnodes * nnodes]; // set child info - FUnifTensor<ORDER>::setRelativeChildCenter(child, ChildCenter); - FUnifTensor<ORDER>::setRoots(ChildCenter, ChildWidth, ChildRoots); + FUnifTensor<FReal,ORDER>::setRelativeChildCenter(child, ChildCenter); + FUnifTensor<FReal,ORDER>::setRoots(ChildCenter, ChildWidth, ChildRoots); // assemble child - parent - interpolator assembleInterpolator(nnodes, ChildRoots, ChildParentInterpolator[child]); diff --git a/Src/Kernels/Uniform/FUnifKernel.hpp b/Src/Kernels/Uniform/FUnifKernel.hpp index 0377822d3..841474ea6 100644 --- a/Src/Kernels/Uniform/FUnifKernel.hpp +++ b/Src/Kernels/Uniform/FUnifKernel.hpp @@ -71,7 +71,7 @@ public: const FReal inBoxWidth, const FPoint<FReal>& inBoxCenter, const MatrixKernelClass *const inMatrixKernel) - : FAbstractUnifKernel< CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS>(inTreeHeight,inBoxWidth,inBoxCenter), + : FAbstractUnifKernel< FReal, CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS>(inTreeHeight,inBoxWidth,inBoxCenter), MatrixKernel(inMatrixKernel), M2LHandler(MatrixKernel, inTreeHeight, @@ -186,7 +186,7 @@ public: ContainerClass* const NeighborSourceParticles[27], const int /* size */) { - DirectInteractionComputer<MatrixKernelClass::NCMP, NVALS>::P2P(TargetParticles,NeighborSourceParticles,MatrixKernel); + DirectInteractionComputer<FReal,MatrixKernelClass::NCMP, NVALS>::P2P(TargetParticles,NeighborSourceParticles,MatrixKernel); } @@ -194,7 +194,7 @@ public: ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict /*inSources*/, ContainerClass* const inNeighbors[27], const int /*inSize*/) { - DirectInteractionComputer<MatrixKernelClass::NCMP, NVALS>::P2PRemote(inTargets,inNeighbors,27,MatrixKernel); + DirectInteractionComputer<FReal,MatrixKernelClass::NCMP, NVALS>::P2PRemote(inTargets,inNeighbors,27,MatrixKernel); } }; diff --git a/Src/Kernels/Uniform/FUnifM2LHandler.hpp b/Src/Kernels/Uniform/FUnifM2LHandler.hpp index a79c0586f..92a2abfab 100644 --- a/Src/Kernels/Uniform/FUnifM2LHandler.hpp +++ b/Src/Kernels/Uniform/FUnifM2LHandler.hpp @@ -46,7 +46,7 @@ static void Compute(const MatrixKernelClass *const MatrixKernel, const FReal Cel const unsigned int order = ORDER; const unsigned int nnodes = TensorTraits<ORDER>::nnodes; const unsigned int ninteractions = 316; - typedef FUnifTensor<ORDER> TensorType; + typedef FUnifTensor<FReal,ORDER> TensorType; // interpolation points of source (Y) and target (X) cell FPoint<FReal> X[nnodes], Y[nnodes]; @@ -68,7 +68,7 @@ static void Compute(const MatrixKernelClass *const MatrixKernel, const FReal Cel // init Discrete Fourier Transformator const int dimfft = 1; // unidim FFT since fully circulant embedding const int steps[dimfft] = {rc}; - FFft<dimfft> Dft; + FFft<FReal,dimfft> Dft; Dft.buildDFT(steps); // get first column of K via permutation unsigned int perm[rc]; @@ -81,7 +81,7 @@ static void Compute(const MatrixKernelClass *const MatrixKernel, const FReal Cel if (abs(i)>1 || abs(j)>1 || abs(k)>1) { // set roots of source cell (Y) const FPoint<FReal> cy(CellWidth*FReal(i), CellWidth*FReal(j), CellWidth*FReal(k)); - FUnifTensor<order>::setRoots(cy, CellWidth, Y); + FUnifTensor<FReal,order>::setRoots(cy, CellWidth, Y); // evaluate m2l operator unsigned int ido=0; for(unsigned int l=0; l<2*order-1; ++l) @@ -173,12 +173,12 @@ class FUnifM2LHandler<FReal, ORDER,HOMOGENEOUS> FSmartPointer< FComplex<FReal>,FSmartArrayMemory> FC; /// Utils - typedef FUnifTensor<ORDER> TensorType; + typedef FUnifTensor<FReal,ORDER> TensorType; unsigned int node_diff[nnodes*nnodes]; /// DFT specific static const int dimfft = 1; // unidim FFT since fully circulant embedding - typedef FFft<dimfft> DftClass; // Fast Discrete Fourier Transformator + typedef FFft<FReal,dimfft> DftClass; // Fast Discrete Fourier Transformator DftClass Dft; const unsigned int opt_rc; // specific to real valued kernel @@ -239,7 +239,7 @@ public: // Compute matrix of interactions const FReal ReferenceCellWidth = FReal(2.); FComplex<FReal>* pFC = NULL; - Compute<order>(MatrixKernel,ReferenceCellWidth,pFC); + Compute<FReal,order>(MatrixKernel,ReferenceCellWidth,pFC); FC.assign(pFC); // Compute memory usage @@ -319,8 +319,8 @@ public: /*! Specialization for non-homogeneous kernel functions */ -template <int ORDER> -class FUnifM2LHandler<ORDER,NON_HOMOGENEOUS> +template <class FReal, int ORDER> +class FUnifM2LHandler<FReal,ORDER,NON_HOMOGENEOUS> { enum {order = ORDER, nnodes = TensorTraits<ORDER>::nnodes, @@ -333,11 +333,11 @@ class FUnifM2LHandler<ORDER,NON_HOMOGENEOUS> const unsigned int TreeHeight; const FReal RootCellWidth; /// Utils - typedef FUnifTensor<ORDER> TensorType; + typedef FUnifTensor<FReal,ORDER> TensorType; unsigned int node_diff[nnodes*nnodes]; /// DFT specific static const int dimfft = 1; // unidim FFT since fully circulant embedding - typedef FFft<dimfft> DftClass; // Fast Discrete Fourier Transformator + typedef FFft<FReal,dimfft> DftClass; // Fast Discrete Fourier Transformator DftClass Dft; const unsigned int opt_rc; // specific to real valued kernel @@ -416,7 +416,7 @@ public: // check if already set if (FC[l]) throw std::runtime_error("M2L operator already set"); - Compute<order>(MatrixKernel,CellWidth,FC[l]); + Compute<FReal,order>(MatrixKernel,CellWidth,FC[l]); CellWidth /= FReal(2.); // at level l+1 } diff --git a/Src/Kernels/Uniform/FUnifRoots.hpp b/Src/Kernels/Uniform/FUnifRoots.hpp index f3154cba0..423804372 100644 --- a/Src/Kernels/Uniform/FUnifRoots.hpp +++ b/Src/Kernels/Uniform/FUnifRoots.hpp @@ -145,7 +145,7 @@ const std::array<FReal,ORDER> FUnifRoots<FReal,ORDER>::roots = FUnifRootsCore<OR template<> struct FUnifRootsCore<2>{ template <class FReal> - std::array<FReal,2> Build(){ + static std::array<FReal,2> Build(){ return { -1., 1.}; } }; @@ -154,7 +154,7 @@ struct FUnifRootsCore<2>{ template<> struct FUnifRootsCore<3>{ template <class FReal> - std::array<FReal,3> Build(){ + static std::array<FReal,3> Build(){ return {-1., 0.0, 1.}; } }; @@ -163,7 +163,7 @@ struct FUnifRootsCore<3>{ template<> struct FUnifRootsCore<4>{ template <class FReal> - std::array<FReal,4> Build(){ + static std::array<FReal,4> Build(){ return {-1., -0.333333333333333, 0.333333333333333, 1.}; } }; @@ -172,7 +172,7 @@ struct FUnifRootsCore<4>{ template<> struct FUnifRootsCore<5>{ template <class FReal> - std::array<FReal,5> Build(){ + static std::array<FReal,5> Build(){ return {-1., -0.5, 0., 0.5, 1.}; } }; @@ -181,7 +181,7 @@ struct FUnifRootsCore<5>{ template<> struct FUnifRootsCore<6>{ template <class FReal> - std::array<FReal,6> Build(){ + static std::array<FReal,6> Build(){ return {-1., -0.6, -0.2, 0.2, 0.6, 1.}; } }; @@ -190,7 +190,7 @@ struct FUnifRootsCore<6>{ template<> struct FUnifRootsCore<7>{ template <class FReal> - std::array<FReal,7> Build(){ + static std::array<FReal,7> Build(){ return {-1., -0.666666666666666, -0.333333333333333, 0., 0.333333333333333, 0.666666666666666, 1.}; } @@ -200,7 +200,7 @@ struct FUnifRootsCore<7>{ template<> struct FUnifRootsCore<8>{ template <class FReal> - std::array<FReal,8> Build(){ + static std::array<FReal,8> Build(){ return {-1., -0.714285714285714, -0.428571428571429, @@ -216,7 +216,7 @@ struct FUnifRootsCore<8>{ template<> struct FUnifRootsCore<9>{ template <class FReal> - std::array<FReal,9> Build(){ + static std::array<FReal,9> Build(){ return {-1., -0.75, -0.5, @@ -233,7 +233,7 @@ struct FUnifRootsCore<9>{ template<> struct FUnifRootsCore<10>{ template <class FReal> - std::array<FReal,10> Build(){ + static std::array<FReal,10> Build(){ return {-1., -0.777777777777777, -0.555555555555555, @@ -251,7 +251,7 @@ struct FUnifRootsCore<10>{ template<> struct FUnifRootsCore<11>{ template <class FReal> - std::array<FReal,11> Build(){ + static std::array<FReal,11> Build(){ return {-1., -0.8, -0.6, @@ -270,7 +270,7 @@ struct FUnifRootsCore<11>{ template<> struct FUnifRootsCore<12>{ template <class FReal> - std::array<FReal,12> Build(){ + static std::array<FReal,12> Build(){ return {-1., -0.818181818181818, -0.636363636363636, @@ -291,7 +291,7 @@ struct FUnifRootsCore<12>{ template<> struct FUnifRootsCore<13>{ template <class FReal> - std::array<FReal,13> Build(){ + static std::array<FReal,13> Build(){ return {-1., -0.833333333333333, -0.666666666666666, @@ -312,7 +312,7 @@ struct FUnifRootsCore<13>{ template<> struct FUnifRootsCore<14>{ template <class FReal> - std::array<FReal,14> Build(){ + static std::array<FReal,14> Build(){ return {-1., -0.846153846153846, -0.692307692307692, @@ -335,7 +335,7 @@ struct FUnifRootsCore<14>{ template<> struct FUnifRootsCore<15>{ template <class FReal> - std::array<FReal,15> Build(){ + static std::array<FReal,15> Build(){ return {-1.0, -0.857142857142857, -0.714285714285714, @@ -359,7 +359,7 @@ struct FUnifRootsCore<15>{ template<> struct FUnifRootsCore<16>{ template <class FReal> - std::array<FReal,16> Build(){ + static std::array<FReal,16> Build(){ return {-1.0, -0.8947368421052632, -0.7894736842105263, diff --git a/Src/Kernels/Uniform/FUnifSymM2LHandler.hpp b/Src/Kernels/Uniform/FUnifSymM2LHandler.hpp index 4a67aa367..26c872631 100644 --- a/Src/Kernels/Uniform/FUnifSymM2LHandler.hpp +++ b/Src/Kernels/Uniform/FUnifSymM2LHandler.hpp @@ -52,7 +52,7 @@ static void precompute(const MatrixKernelClass *const MatrixKernel, const FReal // interpolation points of source (Y) and target (X) cell FPoint<FReal> X[nnodes], Y[nnodes]; // set roots of target cell (X) - FUnifTensor<ORDER>::setRoots(FPoint<FReal>(0.,0.,0.), CellWidth, X); + FUnifTensor<FReal,ORDER>::setRoots(FPoint<FReal>(0.,0.,0.), CellWidth, X); // temporary matrices FReal *_C; FComplex<FReal> *_FC; @@ -66,7 +66,7 @@ static void precompute(const MatrixKernelClass *const MatrixKernel, const FReal const int dimfft = 1; // unidim FFT since fully circulant embedding const int steps[dimfft] = {rc}; // FDft Dft(rc); - FFft<dimfft> Dft(steps); + FFft<FReal,dimfft> Dft(steps); // reduce storage if real valued kernel const unsigned int opt_rc = rc/2+1; @@ -92,7 +92,7 @@ static void precompute(const MatrixKernelClass *const MatrixKernel, const FReal // set roots of source cell (Y) const FPoint<FReal> cy(CellWidth*FReal(i), CellWidth*FReal(j), CellWidth*FReal(k)); - FUnifTensor<ORDER>::setRoots(cy, CellWidth, Y); + FUnifTensor<FReal,ORDER>::setRoots(cy, CellWidth, Y); // start timer time.tic(); diff --git a/Src/Kernels/Uniform/FUnifTensorialKernel.hpp b/Src/Kernels/Uniform/FUnifTensorialKernel.hpp index e0186b74b..3becc1174 100644 --- a/Src/Kernels/Uniform/FUnifTensorialKernel.hpp +++ b/Src/Kernels/Uniform/FUnifTensorialKernel.hpp @@ -75,7 +75,7 @@ protected://PB: for OptiDis typedef FUnifTensorialM2LHandler<FReal, ORDER,MatrixKernelClass,MatrixKernelClass::Type> M2LHandlerClass; // using from - typedef FAbstractUnifKernel< CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS> + typedef FAbstractUnifKernel< FReal, CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS> AbstractBaseClass; /// Needed for P2P and M2L operators @@ -95,7 +95,7 @@ public: const FPoint<FReal>& inBoxCenter, const MatrixKernelClass *const inMatrixKernel, const FReal inBoxWidthExtension) - : FAbstractUnifKernel< CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS>(inTreeHeight,inBoxWidth,inBoxCenter,inBoxWidthExtension), + : FAbstractUnifKernel< FReal, CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS>(inTreeHeight,inBoxWidth,inBoxCenter,inBoxWidthExtension), MatrixKernel(inMatrixKernel), M2LHandler(MatrixKernel, inTreeHeight, @@ -254,7 +254,7 @@ public: ContainerClass* const NeighborSourceParticles[27], const int /* size */) { - DirectInteractionComputer<MatrixKernelClass::NCMP, NVALS>::P2P(TargetParticles,NeighborSourceParticles,MatrixKernel); + DirectInteractionComputer<FReal,MatrixKernelClass::NCMP, NVALS>::P2P(TargetParticles,NeighborSourceParticles,MatrixKernel); } @@ -262,7 +262,7 @@ public: ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict /*inSources*/, ContainerClass* const inNeighbors[27], const int /*inSize*/) { - DirectInteractionComputer<MatrixKernelClass::NCMP, NVALS>::P2PRemote(inTargets,inNeighbors,27,MatrixKernel); + DirectInteractionComputer<FReal,MatrixKernelClass::NCMP, NVALS>::P2PRemote(inTargets,inNeighbors,27,MatrixKernel); } }; diff --git a/Src/Kernels/Uniform/FUnifTensorialM2LHandler.hpp b/Src/Kernels/Uniform/FUnifTensorialM2LHandler.hpp index d3fa08583..65a8a1383 100644 --- a/Src/Kernels/Uniform/FUnifTensorialM2LHandler.hpp +++ b/Src/Kernels/Uniform/FUnifTensorialM2LHandler.hpp @@ -51,7 +51,7 @@ static void Compute(const MatrixKernelClass *const MatrixKernel, const unsigned int ncmp = MatrixKernelClass::NCMP; // utils - typedef FUnifTensor<ORDER> TensorType; + typedef FUnifTensor<FReal,ORDER> TensorType; // allocate memory and store compressed M2L operators for (unsigned int d=0; d<ncmp; ++d) @@ -61,7 +61,7 @@ static void Compute(const MatrixKernelClass *const MatrixKernel, FPoint<FReal> X[nnodes], Y[nnodes]; // set roots of target cell (X) const FReal ExtendedCellWidth(CellWidth+CellWidthExtension); - FUnifTensor<order>::setRoots(FPoint<FReal>(0.,0.,0.), ExtendedCellWidth, X); + FUnifTensor<FReal,order>::setRoots(FPoint<FReal>(0.,0.,0.), ExtendedCellWidth, X); // allocate memory and compute 316 m2l operators FReal** _C; @@ -83,7 +83,7 @@ static void Compute(const MatrixKernelClass *const MatrixKernel, // init Discrete Fourier Transformator const int dimfft = 1; // unidim FFT since fully circulant embedding const int steps[dimfft] = {rc}; - FFft<dimfft> Dft; + FFft<FReal,dimfft> Dft; Dft.buildDFT(steps); // get first column of K via permutation @@ -97,7 +97,7 @@ static void Compute(const MatrixKernelClass *const MatrixKernel, if (abs(i)>1 || abs(j)>1 || abs(k)>1) { // set roots of source cell (Y) const FPoint<FReal> cy(CellWidth*FReal(i), CellWidth*FReal(j), CellWidth*FReal(k)); - FUnifTensor<order>::setRoots(cy, ExtendedCellWidth, Y); + FUnifTensor<FReal,order>::setRoots(cy, ExtendedCellWidth, Y); // evaluate m2l operator unsigned int ido=0; for(unsigned int l=0; l<2*order-1; ++l) @@ -181,10 +181,10 @@ static void Compute(const MatrixKernelClass *const MatrixKernel, * * @tparam ORDER interpolation order \f$\ell\f$ */ -template <int ORDER, class MatrixKernelClass, KERNEL_FUNCTION_TYPE TYPE> class FUnifTensorialM2LHandler; +template <class FReal, int ORDER, class MatrixKernelClass, KERNEL_FUNCTION_TYPE TYPE> class FUnifTensorialM2LHandler; -template <int ORDER, class MatrixKernelClass> -class FUnifTensorialM2LHandler<ORDER,MatrixKernelClass,HOMOGENEOUS> +template <class FReal, int ORDER, class MatrixKernelClass> +class FUnifTensorialM2LHandler<FReal, ORDER,MatrixKernelClass,HOMOGENEOUS> { enum {order = ORDER, nnodes = TensorTraits<ORDER>::nnodes, @@ -198,12 +198,12 @@ class FUnifTensorialM2LHandler<ORDER,MatrixKernelClass,HOMOGENEOUS> const FReal CellWidthExtension; //<! extension of cells width /// Utils - typedef FUnifTensor<ORDER> TensorType; + typedef FUnifTensor<FReal,ORDER> TensorType; unsigned int node_diff[nnodes*nnodes]; /// DFT specific static const int dimfft = 1; // unidim FFT since fully circulant embedding - typedef FFft<dimfft> DftClass; // Fast Discrete Fourier Transformator + typedef FFft<FReal,dimfft> DftClass; // Fast Discrete Fourier Transformator DftClass Dft; const unsigned int opt_rc; // specific to real valued kernel @@ -278,7 +278,7 @@ public: // but it NEEDS to match the numerator of the scale factor in matrix kernel! // Therefore box width extension is not yet supported for homog kernels const FReal ReferenceCellWidth = FReal(2.); - Compute<order>(MatrixKernel,ReferenceCellWidth, 0., FC); + Compute<FReal,order>(MatrixKernel,ReferenceCellWidth, 0., FC); // Compute memory usage unsigned long sizeM2L = 343*ncmp*opt_rc*sizeof(FComplex<FReal>); @@ -368,8 +368,8 @@ public: -template <int ORDER, class MatrixKernelClass> -class FUnifTensorialM2LHandler<ORDER,MatrixKernelClass,NON_HOMOGENEOUS> +template <class FReal, int ORDER, class MatrixKernelClass> +class FUnifTensorialM2LHandler<FReal,ORDER,MatrixKernelClass,NON_HOMOGENEOUS> { enum {order = ORDER, nnodes = TensorTraits<ORDER>::nnodes, @@ -387,12 +387,12 @@ class FUnifTensorialM2LHandler<ORDER,MatrixKernelClass,NON_HOMOGENEOUS> const FReal CellWidthExtension; //<! extension of cells width /// Utils - typedef FUnifTensor<ORDER> TensorType; + typedef FUnifTensor<FReal,ORDER> TensorType; unsigned int node_diff[nnodes*nnodes]; /// DFT specific static const int dimfft = 1; // unidim FFT since fully circulant embedding - typedef FFft<dimfft> DftClass; // Fast Discrete Fourier Transformator + typedef FFft<FReal,dimfft> DftClass; // Fast Discrete Fourier Transformator DftClass Dft; const unsigned int opt_rc; // specific to real valued kernel @@ -474,7 +474,7 @@ public: // check if already set for (unsigned int d=0; d<ncmp; ++d) if (FC[l][d]) throw std::runtime_error("M2L operator already set"); - Compute<order>(MatrixKernel,CellWidth,CellWidthExtension,FC[l]); + Compute<FReal,order>(MatrixKernel,CellWidth,CellWidthExtension,FC[l]); CellWidth /= FReal(2.); // at level l+1 } diff --git a/Src/Utils/FDft.hpp b/Src/Utils/FDft.hpp index 2fa6db094..cf19d063b 100644 --- a/Src/Utils/FDft.hpp +++ b/Src/Utils/FDft.hpp @@ -39,22 +39,22 @@ * @class FDft, @class FFft and @class FCFft * Please read the license * - * These classes handle the forward and backward Discete Fourier Transform + * These classes handle the forward and backward Discete Fourier Transform * (DFT). - * @class FDft implements a direct method while @class FFft uses the Fast - * Fourier Transform (FFT). The FFT algorithm can either be provided by the + * @class FDft implements a direct method while @class FFft uses the Fast + * Fourier Transform (FFT). The FFT algorithm can either be provided by the * FFTW(3) library itself or a version that is wrapped in Intel MKL. * * The direct DFT is templatized with the input value type (FReal or FComplex<FReal>), - * while 2 distinct classes resp. @class FFft and @class FCFft are defined + * while 2 distinct classes resp. @class FFft and @class FCFft are defined * resp. for the real and complex valued FFT. * - * The aim of writing these specific classes is to allow further customization - * of the DFT such as implementing a tensorial variant, a weighted variant + * The aim of writing these specific classes is to allow further customization + * of the DFT such as implementing a tensorial variant, a weighted variant * or any other feature. * * TODO: some copies might slow down the routines, this needs to be optimized. - * + * */ @@ -67,146 +67,146 @@ template< class FReal, typename ValueType = FReal> class FDft { - ValueType* data_; //< data in physical space - FComplex<FReal>* dataF_; //< data in Fourier space + ValueType* data_; //< data in physical space + FComplex<FReal>* dataF_; //< data in Fourier space - FReal *cosRS_, *sinRS_; + FReal *cosRS_, *sinRS_; private: - unsigned int nsteps_; //< number of steps - - void initDFT() - { - // allocate arrays - data_ = new ValueType[nsteps_]; - dataF_ = new FComplex<FReal>[nsteps_]; - - // Beware this is extremely HEAVY to store!!! => Use FDft only for debug! - cosRS_ = new FReal[nsteps_*nsteps_]; - sinRS_ = new FReal[nsteps_*nsteps_]; - - for(unsigned int r=0; r<nsteps_; ++r) - for(unsigned int s=0; s<nsteps_; ++s){ - FReal thetaRS = 2*M_PI*r*s/nsteps_; - cosRS_[r*nsteps_+s]=FMath::Cos(thetaRS); - sinRS_[r*nsteps_+s]=FMath::Sin(thetaRS); - } - } + unsigned int nsteps_; //< number of steps + + void initDFT() + { + // allocate arrays + data_ = new ValueType[nsteps_]; + dataF_ = new FComplex<FReal>[nsteps_]; + + // Beware this is extremely HEAVY to store!!! => Use FDft only for debug! + cosRS_ = new FReal[nsteps_*nsteps_]; + sinRS_ = new FReal[nsteps_*nsteps_]; + + for(unsigned int r=0; r<nsteps_; ++r) + for(unsigned int s=0; s<nsteps_; ++s){ + FReal thetaRS = 2*M_PI*r*s/nsteps_; + cosRS_[r*nsteps_+s]=FMath::Cos(thetaRS); + sinRS_[r*nsteps_+s]=FMath::Sin(thetaRS); + } + } public: - FDft(const unsigned int nsteps) - : nsteps_(nsteps) - { - // init DFT - initDFT(); - } - - FDft(const FDft& other) - : nsteps_(other.nsteps_) - { - // init DFT - initDFT(); - } - - virtual ~FDft() - { - delete [] data_; - delete [] dataF_; - delete [] cosRS_; - delete [] sinRS_; - } - - /// Forward DFT - // Real valued DFT - void applyDFT(const FReal* sampledData, - FComplex<FReal>* transformedData) const - { - // read sampled data - FBlas::c_setzero(nsteps_,reinterpret_cast<FReal*>(dataF_)); - FBlas::copy(nsteps_, sampledData,data_); - - // perform direct forward transformation - for(unsigned int r=0; r<nsteps_; ++r) - for(unsigned int s=0; s<nsteps_; ++s){ - dataF_[r] += FComplex<FReal>(data_[s]*cosRS_[r*nsteps_+s], - -data_[s]*sinRS_[r*nsteps_+s]); - } - - // write transformed data - FBlas::c_copy(nsteps_,reinterpret_cast<FReal*>(dataF_), - reinterpret_cast<FReal*>(transformedData)); - } - // Complexe valued DFT - void applyDFT(const FComplex<FReal>* sampledData, - FComplex<FReal>* transformedData) const - { - // read sampled data - FBlas::c_setzero(nsteps_,reinterpret_cast<FReal*>(dataF_)); - FBlas::c_copy(nsteps_,reinterpret_cast<const FReal*>(sampledData), - reinterpret_cast<FReal*>(data_)); - - // perform direct forward transformation - for(unsigned int r=0; r<nsteps_; ++r) - for(unsigned int s=0; s<nsteps_; ++s){ - dataF_[r] += FComplex<FReal>(data_[s].getReal()*cosRS_[r*nsteps_+s] - + data_[s].getImag()*sinRS_[r*nsteps_+s], - data_[s].getImag()*cosRS_[r*nsteps_+s] - - data_[s].getReal()*sinRS_[r*nsteps_+s]); - } - - // write transformed data - FBlas::c_copy(nsteps_,reinterpret_cast<FReal*>(dataF_), - reinterpret_cast<FReal*>(transformedData)); - } - - /// Backward DFT - // Real valued IDFT - void applyIDFT(const FComplex<FReal>* transformedData, - FReal* sampledData) const - { - // read transformed data - FBlas::setzero(nsteps_,data_); - FBlas::c_copy(nsteps_,reinterpret_cast<const FReal*>(transformedData), - reinterpret_cast<FReal*>(dataF_)); - - // perform direct backward transformation - for(unsigned int r=0; r<nsteps_; ++r){ - for(unsigned int s=0; s<nsteps_; ++s){ - data_[r] += dataF_[s].getReal()*cosRS_[r*nsteps_+s] - + dataF_[s].getImag()*sinRS_[r*nsteps_+s]; - } - data_[r]*=1./nsteps_; - } - - // write sampled data - FBlas::copy(nsteps_,data_,sampledData); - } - - // Complexe valued IDFT - void applyIDFT(const FComplex<FReal>* transformedData, - FComplex<FReal>* sampledData) const - { - // read transformed data - FBlas::c_setzero(nsteps_,reinterpret_cast<FReal*>(data_)); - FBlas::c_copy(nsteps_,reinterpret_cast<const FReal*>(transformedData), - reinterpret_cast<FReal*>(dataF_)); - - // perform direct backward transformation - for(unsigned int r=0; r<nsteps_; ++r){ - for(unsigned int s=0; s<nsteps_; ++s){ - data_[r] += FComplex<FReal>(dataF_[s].getReal()*cosRS_[r*nsteps_+s] - - dataF_[s].getImag()*sinRS_[r*nsteps_+s], - dataF_[s].getImag()*cosRS_[r*nsteps_+s] - + dataF_[s].getReal()*sinRS_[r*nsteps_+s]); - } - data_[r]*=1./nsteps_; - } - - // write sampled data - FBlas::c_copy(nsteps_,reinterpret_cast<FReal*>(data_), - reinterpret_cast<FReal*>(sampledData)); - } + FDft(const unsigned int nsteps) + : nsteps_(nsteps) + { + // init DFT + initDFT(); + } + + FDft(const FDft& other) + : nsteps_(other.nsteps_) + { + // init DFT + initDFT(); + } + + virtual ~FDft() + { + delete [] data_; + delete [] dataF_; + delete [] cosRS_; + delete [] sinRS_; + } + + /// Forward DFT + // Real valued DFT + void applyDFT(const FReal* sampledData, + FComplex<FReal>* transformedData) const + { + // read sampled data + FBlas::c_setzero(nsteps_,reinterpret_cast<FReal*>(dataF_)); + FBlas::copy(nsteps_, sampledData,data_); + + // perform direct forward transformation + for(unsigned int r=0; r<nsteps_; ++r) + for(unsigned int s=0; s<nsteps_; ++s){ + dataF_[r] += FComplex<FReal>(data_[s]*cosRS_[r*nsteps_+s], + -data_[s]*sinRS_[r*nsteps_+s]); + } + + // write transformed data + FBlas::c_copy(nsteps_,reinterpret_cast<FReal*>(dataF_), + reinterpret_cast<FReal*>(transformedData)); + } + // Complexe valued DFT + void applyDFT(const FComplex<FReal>* sampledData, + FComplex<FReal>* transformedData) const + { + // read sampled data + FBlas::c_setzero(nsteps_,reinterpret_cast<FReal*>(dataF_)); + FBlas::c_copy(nsteps_,reinterpret_cast<const FReal*>(sampledData), + reinterpret_cast<FReal*>(data_)); + + // perform direct forward transformation + for(unsigned int r=0; r<nsteps_; ++r) + for(unsigned int s=0; s<nsteps_; ++s){ + dataF_[r] += FComplex<FReal>(data_[s].getReal()*cosRS_[r*nsteps_+s] + + data_[s].getImag()*sinRS_[r*nsteps_+s], + data_[s].getImag()*cosRS_[r*nsteps_+s] + - data_[s].getReal()*sinRS_[r*nsteps_+s]); + } + + // write transformed data + FBlas::c_copy(nsteps_,reinterpret_cast<FReal*>(dataF_), + reinterpret_cast<FReal*>(transformedData)); + } + + /// Backward DFT + // Real valued IDFT + void applyIDFT(const FComplex<FReal>* transformedData, + FReal* sampledData) const + { + // read transformed data + FBlas::setzero(nsteps_,data_); + FBlas::c_copy(nsteps_,reinterpret_cast<const FReal*>(transformedData), + reinterpret_cast<FReal*>(dataF_)); + + // perform direct backward transformation + for(unsigned int r=0; r<nsteps_; ++r){ + for(unsigned int s=0; s<nsteps_; ++s){ + data_[r] += dataF_[s].getReal()*cosRS_[r*nsteps_+s] + + dataF_[s].getImag()*sinRS_[r*nsteps_+s]; + } + data_[r]*=1./nsteps_; + } + + // write sampled data + FBlas::copy(nsteps_,data_,sampledData); + } + + // Complexe valued IDFT + void applyIDFT(const FComplex<FReal>* transformedData, + FComplex<FReal>* sampledData) const + { + // read transformed data + FBlas::c_setzero(nsteps_,reinterpret_cast<FReal*>(data_)); + FBlas::c_copy(nsteps_,reinterpret_cast<const FReal*>(transformedData), + reinterpret_cast<FReal*>(dataF_)); + + // perform direct backward transformation + for(unsigned int r=0; r<nsteps_; ++r){ + for(unsigned int s=0; s<nsteps_; ++s){ + data_[r] += FComplex<FReal>(dataF_[s].getReal()*cosRS_[r*nsteps_+s] + - dataF_[s].getImag()*sinRS_[r*nsteps_+s], + dataF_[s].getImag()*cosRS_[r*nsteps_+s] + + dataF_[s].getReal()*sinRS_[r*nsteps_+s]); + } + data_[r]*=1./nsteps_; + } + + // write sampled data + FBlas::c_copy(nsteps_,reinterpret_cast<FReal*>(data_), + reinterpret_cast<FReal*>(sampledData)); + } }; @@ -216,128 +216,128 @@ public: * * @tparam nsteps number of sampled values \f$N\f$ */ -template<int DIM = 1> +template<class FReal, int DIM = 1> class FFft { - enum{dim = DIM}; + enum{dim = DIM}; - // arrays - FReal* data_; //< data in physical space - FComplex<FReal>* dataF_; //< data in Fourier space + // arrays + FReal* data_; //< data in physical space + FComplex<FReal>* dataF_; //< data in Fourier space - // plans - fftw_plan plan_c2r_; //< backward FFT plan - fftw_plan plan_r2c_; //< forward FFT plan + // plans + fftw_plan plan_c2r_; //< backward FFT plan + fftw_plan plan_r2c_; //< forward FFT plan private: - int steps_[dim]; //< number of steps per dimension - int nsteps_; //< total number of steps - int nsteps_opt_; //< reduced number of steps for real valued FFT - - void initDFT() - { - // allocate arrays - data_ = (FReal*) fftw_malloc(sizeof(FReal) * nsteps_); - dataF_ = (FComplex<FReal>*) fftw_malloc(sizeof(FComplex<FReal>) * nsteps_opt_); - -// // unidim fftw plans -// plan_c2r_ = -// fftw_plan_dft_c2r_1d(nsteps_, -// reinterpret_cast<fftw_complex*>(dataF_), -// data_, -// FFTW_MEASURE);// TODO: test FFTW_ESTIMATE -// plan_r2c_ = -// fftw_plan_dft_r2c_1d(nsteps_, -// data_, -// reinterpret_cast<fftw_complex*>(dataF_), -// FFTW_MEASURE); - - // multidim fftw plans - plan_c2r_ = - fftw_plan_dft_c2r(dim, steps_, - reinterpret_cast<fftw_complex*>(dataF_), - data_, - FFTW_MEASURE);// TODO: test FFTW_ESTIMATE - plan_r2c_ = - fftw_plan_dft_r2c(dim, steps_, - data_, - reinterpret_cast<fftw_complex*>(dataF_), - FFTW_MEASURE); - } + int steps_[dim]; //< number of steps per dimension + int nsteps_; //< total number of steps + int nsteps_opt_; //< reduced number of steps for real valued FFT + + void initDFT() + { + // allocate arrays + data_ = (FReal*) fftw_malloc(sizeof(FReal) * nsteps_); + dataF_ = (FComplex<FReal>*) fftw_malloc(sizeof(FComplex<FReal>) * nsteps_opt_); + + // // unidim fftw plans + // plan_c2r_ = + // fftw_plan_dft_c2r_1d(nsteps_, + // reinterpret_cast<fftw_complex*>(dataF_), + // data_, + // FFTW_MEASURE);// TODO: test FFTW_ESTIMATE + // plan_r2c_ = + // fftw_plan_dft_r2c_1d(nsteps_, + // data_, + // reinterpret_cast<fftw_complex*>(dataF_), + // FFTW_MEASURE); + + // multidim fftw plans + plan_c2r_ = + fftw_plan_dft_c2r(dim, steps_, + reinterpret_cast<fftw_complex*>(dataF_), + data_, + FFTW_MEASURE);// TODO: test FFTW_ESTIMATE + plan_r2c_ = + fftw_plan_dft_r2c(dim, steps_, + data_, + reinterpret_cast<fftw_complex*>(dataF_), + FFTW_MEASURE); + } public: - FFft() - : nsteps_(0), nsteps_opt_(0) - { - for(int d = 0; d<dim;++d){steps_[d]=0;} - } - - void buildDFT(const int steps[dim]) - { - // init number of steps - nsteps_=1; nsteps_opt_=1; - for(int d = 0; d<dim;++d){ - steps_[d]=steps[d]; - nsteps_*=steps[d]; - nsteps_opt_*=steps[d]/2+1; // real valued DFT specific + FFft() + : nsteps_(0), nsteps_opt_(0) + { + for(int d = 0; d<dim;++d){steps_[d]=0;} } - // init DFT - initDFT(); + void buildDFT(const int steps[dim]) + { + // init number of steps + nsteps_=1; nsteps_opt_=1; + for(int d = 0; d<dim;++d){ + steps_[d]=steps[d]; + nsteps_*=steps[d]; + nsteps_opt_*=steps[d]/2+1; // real valued DFT specific + } - } + // init DFT + initDFT(); + + } - FFft(const FFft& other) - : nsteps_(other.nsteps_),nsteps_opt_(other.nsteps_opt_) - { - // mem copies - memcpy(steps_,other.steps_,dim*sizeof(int)); - // init DFT - initDFT(); - } + FFft(const FFft& other) + : nsteps_(other.nsteps_),nsteps_opt_(other.nsteps_opt_) + { + // mem copies + memcpy(steps_,other.steps_,dim*sizeof(int)); + // init DFT + initDFT(); + } - virtual ~FFft() - { - fftw_destroy_plan(plan_c2r_); - fftw_destroy_plan(plan_r2c_); - fftw_free(data_); - fftw_free(dataF_); - } + virtual ~FFft() + { + fftw_destroy_plan(plan_c2r_); + fftw_destroy_plan(plan_r2c_); + fftw_free(data_); + fftw_free(dataF_); + } - void applyDFT(const FReal* sampledData, - FComplex<FReal>* transformedData) const - { - FBlas::c_setzero(nsteps_opt_,reinterpret_cast<FReal*>(dataF_)); - FBlas::copy(nsteps_, sampledData,data_); + void applyDFT(const FReal* sampledData, + FComplex<FReal>* transformedData) const + { + FBlas::c_setzero(nsteps_opt_,reinterpret_cast<FReal*>(dataF_)); + FBlas::copy(nsteps_, sampledData,data_); - // perform fft - fftw_execute( plan_r2c_ ); + // perform fft + fftw_execute( plan_r2c_ ); - // write transformed data - FBlas::c_copy(nsteps_opt_,reinterpret_cast<FReal*>(dataF_), - reinterpret_cast<FReal*>(transformedData)); - } + // write transformed data + FBlas::c_copy(nsteps_opt_,reinterpret_cast<FReal*>(dataF_), + reinterpret_cast<FReal*>(transformedData)); + } - void applyIDFT(const FComplex<FReal>* transformedData, - FReal* sampledData) const - { - // read transformed data - FBlas::setzero(nsteps_,data_); - FBlas::c_copy(nsteps_opt_,reinterpret_cast<const FReal*>(transformedData), - reinterpret_cast<FReal*>(dataF_)); + void applyIDFT(const FComplex<FReal>* transformedData, + FReal* sampledData) const + { + // read transformed data + FBlas::setzero(nsteps_,data_); + FBlas::c_copy(nsteps_opt_,reinterpret_cast<const FReal*>(transformedData), + reinterpret_cast<FReal*>(dataF_)); - // perform ifft - fftw_execute( plan_c2r_ ); + // perform ifft + fftw_execute( plan_c2r_ ); - for( int s=0; s<dim*nsteps_; ++s) - data_[s]/=nsteps_; // the fft from fftw is not scaled !!!!!!!! + for( int s=0; s<dim*nsteps_; ++s) + data_[s]/=nsteps_; // the fft from fftw is not scaled !!!!!!!! - // write sampled data - FBlas::copy(nsteps_,data_,sampledData); + // write sampled data + FBlas::copy(nsteps_,data_,sampledData); - } + } }; @@ -348,96 +348,96 @@ public: * * @tparam nsteps number of sampled values \f$N\f$ */ -template<int DIM = 1> +template<class FReal, int DIM = 1> class FCFft { - enum{dim = DIM}; + enum{dim = DIM}; - // arrays - FComplex<FReal>* data_; //< data in physical space - FComplex<FReal>* dataF_; //< data in Fourier space + // arrays + FComplex<FReal>* data_; //< data in physical space + FComplex<FReal>* dataF_; //< data in Fourier space - // plans - fftw_plan plan_b_; // backward FFT plan - fftw_plan plan_f_; // forward FFT plan + // plans + fftw_plan plan_b_; // backward FFT plan + fftw_plan plan_f_; // forward FFT plan private: - int steps_[dim]; //< number of steps per dimension - int nsteps_; //< total number of steps + int steps_[dim]; //< number of steps per dimension + int nsteps_; //< total number of steps public: - FCFft(const int steps[dim]) - { - // init number of steps - nsteps_=1; - for(int d = 0; d<dim;++d){ - steps_[d]=steps[d]; - nsteps_*=steps[d]; + FCFft(const int steps[dim]) + { + // init number of steps + nsteps_=1; + for(int d = 0; d<dim;++d){ + steps_[d]=steps[d]; + nsteps_*=steps[d]; + } + + // allocate arrays + data_ = (FComplex<FReal>*) fftw_malloc(sizeof(FComplex<FReal>) * nsteps_); + dataF_ = (FComplex<FReal>*) fftw_malloc(sizeof(FComplex<FReal>) * nsteps_); + + // multidim fftw plans + plan_b_ = + fftw_plan_dft(dim, steps_, + reinterpret_cast<fftw_complex*>(dataF_), + reinterpret_cast<fftw_complex*>(data_), + FFTW_BACKWARD, + FFTW_MEASURE);// TODO: test FFTW_ESTIMATE + plan_f_ = + fftw_plan_dft(dim, steps_, + reinterpret_cast<fftw_complex*>(data_), + reinterpret_cast<fftw_complex*>(dataF_), + FFTW_FORWARD, + FFTW_MEASURE); + } - // allocate arrays - data_ = (FComplex<FReal>*) fftw_malloc(sizeof(FComplex<FReal>) * nsteps_); - dataF_ = (FComplex<FReal>*) fftw_malloc(sizeof(FComplex<FReal>) * nsteps_); - - // multidim fftw plans - plan_b_ = - fftw_plan_dft(dim, steps_, - reinterpret_cast<fftw_complex*>(dataF_), - reinterpret_cast<fftw_complex*>(data_), - FFTW_BACKWARD, - FFTW_MEASURE);// TODO: test FFTW_ESTIMATE - plan_f_ = - fftw_plan_dft(dim, steps_, - reinterpret_cast<fftw_complex*>(data_), - reinterpret_cast<fftw_complex*>(dataF_), - FFTW_FORWARD, - FFTW_MEASURE); - - } - - virtual ~FCFft() - { - fftw_destroy_plan(plan_b_); - fftw_destroy_plan(plan_f_); - fftw_free(data_); - fftw_free(dataF_); - } - - void applyDFT(const FComplex<FReal>* sampledData, - FComplex<FReal>* transformedData) const - { - FBlas::c_setzero(nsteps_,reinterpret_cast<FReal*>(dataF_)); - FBlas::c_copy(nsteps_, reinterpret_cast<const FReal*>(sampledData), - reinterpret_cast<FReal*>(data_)); - - // perform fft - fftw_execute( plan_f_ ); - - // write transformed data - FBlas::c_copy(nsteps_,reinterpret_cast<FReal*>(dataF_), - reinterpret_cast<FReal*>(transformedData)); - } - - - void applyIDFT(const FComplex<FReal>* transformedData, - FComplex<FReal>* sampledData) const - { - // read transformed data - FBlas::c_setzero(nsteps_,reinterpret_cast<FReal*>(data_)); - FBlas::c_copy(nsteps_,reinterpret_cast<const FReal*>(transformedData), - reinterpret_cast<FReal*>(dataF_)); - - // perform ifft - fftw_execute( plan_b_ ); - - for(unsigned int s=0; s<nsteps_; ++s) - data_[s]*=1./(nsteps_); // the fft from fftw is not scaled !!!!!!!! - - // write sampled data - FBlas::c_copy(nsteps_,reinterpret_cast<FReal*>(data_), - reinterpret_cast<FReal*>(sampledData)); - - } + virtual ~FCFft() + { + fftw_destroy_plan(plan_b_); + fftw_destroy_plan(plan_f_); + fftw_free(data_); + fftw_free(dataF_); + } + + void applyDFT(const FComplex<FReal>* sampledData, + FComplex<FReal>* transformedData) const + { + FBlas::c_setzero(nsteps_,reinterpret_cast<FReal*>(dataF_)); + FBlas::c_copy(nsteps_, reinterpret_cast<const FReal*>(sampledData), + reinterpret_cast<FReal*>(data_)); + + // perform fft + fftw_execute( plan_f_ ); + + // write transformed data + FBlas::c_copy(nsteps_,reinterpret_cast<FReal*>(dataF_), + reinterpret_cast<FReal*>(transformedData)); + } + + + void applyIDFT(const FComplex<FReal>* transformedData, + FComplex<FReal>* sampledData) const + { + // read transformed data + FBlas::c_setzero(nsteps_,reinterpret_cast<FReal*>(data_)); + FBlas::c_copy(nsteps_,reinterpret_cast<const FReal*>(transformedData), + reinterpret_cast<FReal*>(dataF_)); + + // perform ifft + fftw_execute( plan_b_ ); + + for(unsigned int s=0; s<nsteps_; ++s) + data_[s]*=1./(nsteps_); // the fft from fftw is not scaled !!!!!!!! + + // write sampled data + FBlas::c_copy(nsteps_,reinterpret_cast<FReal*>(data_), + reinterpret_cast<FReal*>(sampledData)); + + } }; diff --git a/Tests/Kernels/testChebTensorialAlgorithm.cpp b/Tests/Kernels/testChebTensorialAlgorithm.cpp index 3ae52d58d..9b55bdea1 100644 --- a/Tests/Kernels/testChebTensorialAlgorithm.cpp +++ b/Tests/Kernels/testChebTensorialAlgorithm.cpp @@ -74,7 +74,7 @@ int main(int argc, char* argv[]) // typedefs - typedef FInterpMatrixKernel_R_IJ MatrixKernelClass; + typedef FInterpMatrixKernel_R_IJ<FReal> MatrixKernelClass; const unsigned int NPV = MatrixKernelClass::NPV; const unsigned int NPOT = MatrixKernelClass::NPOT; @@ -167,7 +167,7 @@ int main(int argc, char* argv[]) if(MatrixKernelClass::Type==HOMOGENEOUS && BoxWidthExtension>0.) throw std::runtime_error("Extension of box width is not yet supported for homogeneous kernels! Work-around: artificially set Type to NON_HOMOGENEOUS."); - typedef FP2PParticleContainerIndexed<NRHS,NLHS> ContainerClass; + typedef FP2PParticleContainerIndexed<FReal, NRHS,NLHS> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FChebCell<FReal,ORDER,NRHS,NLHS> CellClass; diff --git a/Tests/Kernels/testFlopsChebAlgorithm.cpp b/Tests/Kernels/testFlopsChebAlgorithm.cpp index 64f864579..114f6478d 100644 --- a/Tests/Kernels/testFlopsChebAlgorithm.cpp +++ b/Tests/Kernels/testFlopsChebAlgorithm.cpp @@ -80,7 +80,7 @@ int main(int argc, char* argv[]) std::cout << ">> Testing the Chebyshev interpolation base FMM algorithm.\n"; // open particle file - FFmaScanfLoader loader(filename); + FFmaScanfLoader<FReal> loader(filename); // if(!loader.isOpen()) throw std::runtime_error("Particle file couldn't be opened!"); diff --git a/Tests/Kernels/testP2PEfficency.cpp b/Tests/Kernels/testP2PEfficency.cpp index e9ae7ac27..5dccb15b5 100644 --- a/Tests/Kernels/testP2PEfficency.cpp +++ b/Tests/Kernels/testP2PEfficency.cpp @@ -50,6 +50,8 @@ int main(int argc, char ** argv){ ////////////////////////////////////////////////////////// + typedef double FReal; + FRandomLoader<FReal> loader(nbParticles*2); FTic timer; @@ -85,19 +87,5 @@ int main(int argc, char ** argv){ ////////////////////////////////////////////////////////// - std::cout << "Single pricision:" << std::endl; - - timer.tic(); - FP2PRT<float>::FullMutual<FP2PParticleContainer<FReal>>( &leaf1, &pleaf2, 1); - timer.tac(); - std::cout << "Timer taken by FullMutual = " << timer.elapsed() << "s" << std::endl; - - timer.tic(); - FP2PRT<float>::FullRemote<FP2PParticleContainer<FReal>>( &leaf1, &pleaf2, 1); - timer.tac(); - std::cout << "Timer taken by FullRemote = " << timer.elapsed() << "s" << std::endl; - - ////////////////////////////////////////////////////////// - return 0; } diff --git a/Tests/Kernels/testRotationPeriodicBench.cpp b/Tests/Kernels/testRotationPeriodicBench.cpp index 3eed198f8..113b05d20 100644 --- a/Tests/Kernels/testRotationPeriodicBench.cpp +++ b/Tests/Kernels/testRotationPeriodicBench.cpp @@ -67,7 +67,7 @@ int main(int argc, char** argv){ typedef FRotationKernel<FReal, CellClass, ContainerClass, P > KernelClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal,CellClass,ContainerClass,LeafClass> OctreeClass; - typedef FFmmAlgorithmPeriodic<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClassPer; + typedef FFmmAlgorithmPeriodic<FReal,OctreeClass , CellClass, ContainerClass, KernelClass, LeafClass > FmmClassPer; ///////////////////////////////////////////////// // Parameters diff --git a/Tests/Kernels/testSphericalAlgorithm.cpp b/Tests/Kernels/testSphericalAlgorithm.cpp index 4eca82af4..621d63a86 100644 --- a/Tests/Kernels/testSphericalAlgorithm.cpp +++ b/Tests/Kernels/testSphericalAlgorithm.cpp @@ -54,7 +54,7 @@ int main(int argc, char ** argv){ FParameterDefinitions::TaskFmm); typedef double FReal; - typedef FSphericalCell CellClass; + typedef FSphericalCell<FReal> CellClass; typedef FP2PParticleContainer<FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; diff --git a/Tests/Kernels/testSphericalBench.cpp b/Tests/Kernels/testSphericalBench.cpp index 292edcc2b..0051ab0c6 100644 --- a/Tests/Kernels/testSphericalBench.cpp +++ b/Tests/Kernels/testSphericalBench.cpp @@ -64,7 +64,7 @@ typedef FP2PParticleContainerIndexed<FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; -typedef FSphericalKernel< CellClass, ContainerClass > KernelClass; +typedef FSphericalKernel< FReal, CellClass, ContainerClass > KernelClass; typedef FFmmAlgorithm<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; @@ -78,7 +78,7 @@ void doATest(const int NbParticles, const int minP, const int maxP, const int mi - Particle*const particles = new Particle[loader.getNumberOfParticles()]; + Particle<FReal>*const particles = new Particle<FReal>[loader.getNumberOfParticles()]; const bool computeDirectAndDiff = timeForDirect || allAbsoluteDiff || allPotentialDiff; { @@ -289,11 +289,11 @@ int main(int argc, char ** argv){ for(int idxP = 1 ; idxP <= DevP ; ++idxP){ for(int idxStep = 0 ; idxStep <= nbStep ; ++idxStep){ - Particle centeredParticle; + Particle<FReal> centeredParticle; centeredParticle.position.setPosition(0.0,0.0,0.5); centeredParticle.physicalValue = physicalValue; - Particle otherParticle; + Particle<FReal> otherParticle; otherParticle.position.setPosition(0.0,0.0,startPosition + (idxStep*stepValue)); otherParticle.physicalValue = physicalValue; @@ -325,7 +325,7 @@ int main(int argc, char ** argv){ for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ const int indexPartOrig = indexes[idxPart]; - const Particle& other = (indexPartOrig==0?centeredParticle:otherParticle); + const Particle<FReal>& other = (indexPartOrig==0?centeredParticle:otherParticle); potentialDiff[idxP].add(other.potential,potentials[idxPart]); } }); diff --git a/Tests/Kernels/testSphericalBlasAlgorithm.cpp b/Tests/Kernels/testSphericalBlasAlgorithm.cpp index 34c316088..1b940b36e 100644 --- a/Tests/Kernels/testSphericalBlasAlgorithm.cpp +++ b/Tests/Kernels/testSphericalBlasAlgorithm.cpp @@ -81,7 +81,7 @@ int main(int argc, char ** argv){ const char* const filename = FParameters::getStr(argc,argv,FParameterDefinitions::InputFile.options, "../Data/test20k.fma"); std::cout << "Opening : " << filename << "\n"; - FFmaScanfLoader loader(filename); + FFmaScanfLoader<FReal> loader(filename); if(!loader.isOpen()){ std::cout << "Loader Error, " << filename << " is missing\n"; return 1; diff --git a/Tests/Kernels/testSphericalBlockBlasAlgorithm.cpp b/Tests/Kernels/testSphericalBlockBlasAlgorithm.cpp index f1bd94e62..85be35759 100644 --- a/Tests/Kernels/testSphericalBlockBlasAlgorithm.cpp +++ b/Tests/Kernels/testSphericalBlockBlasAlgorithm.cpp @@ -84,7 +84,7 @@ int main(int argc, char ** argv){ const char* const filename = FParameters::getStr(argc,argv,FParameterDefinitions::InputFile.options, "../Data/test20k.fma"); std::cout << "Opening : " << filename << "\n"; - FFmaScanfLoader loader(filename); + FFmaScanfLoader<FReal> loader(filename); if(!loader.isOpen()){ std::cout << "Loader Error, " << filename << " is missing\n"; return 1; diff --git a/Tests/Kernels/testSphericalDlpolyAlgorithm.cpp b/Tests/Kernels/testSphericalDlpolyAlgorithm.cpp index 196155206..002cbfef5 100644 --- a/Tests/Kernels/testSphericalDlpolyAlgorithm.cpp +++ b/Tests/Kernels/testSphericalDlpolyAlgorithm.cpp @@ -93,7 +93,7 @@ int main(int argc, char ** argv){ const int DevP = FParameters::getValue(argc,argv,"-P", 9); #endif - typedef FFmmAlgorithmPeriodic<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; + typedef FFmmAlgorithmPeriodic<FReal,OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; typedef FFmmAlgorithm<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClassNoPer; ///////////////////////What we do///////////////////////////// if( FParameters::existParameter(argc, argv, "-help")){ @@ -125,12 +125,12 @@ int main(int argc, char ** argv){ // LOADER // ----------------------------------------------------- std::cout << "Opening : " << filename << "\n"; - FDlpolyLoader *loader = nullptr ; + FDlpolyLoader<FReal> *loader = nullptr ; if(FParameters::existParameter(argc, argv, "-bin")){ - loader = new FDlpolyBinLoader(filename); + loader = new FDlpolyBinLoader<FReal>(filename); } else { - loader = new FDlpolyAsciiLoader(filename); + loader = new FDlpolyAsciiLoader<FReal>(filename); } if(! loader->isOpen()){ @@ -171,8 +171,8 @@ int main(int argc, char ** argv){ counter.tic(); FPoint<FReal> electricMoment(0.0,0.0,0.0) ; - EwalParticle * const particles = new EwalParticle[loader->getNumberOfParticles()]; - memset(particles, 0, sizeof(EwalParticle) * loader->getNumberOfParticles()); + EwalParticle<FReal> * const particles = new EwalParticle<FReal>[loader->getNumberOfParticles()]; + memset(particles, 0, sizeof(EwalParticle<FReal>) * loader->getNumberOfParticles()); double totalCharge = 0.0; for(int idxPart = 0 ; idxPart < loader->getNumberOfParticles() ; ++idxPart){ // @@ -229,7 +229,7 @@ int main(int argc, char ** argv){ << std::endl ; } while(octreeIterator.moveRight()); // - FIOVtk vtkfile ; + FIOVtk<FReal> vtkfile ; vtkfile.writeOctree("octreeFile.vtk","Octree ", tree) ; // // --------------------------------------------------------------------------------- @@ -274,7 +274,7 @@ int main(int argc, char ** argv){ // ---------------------------------------------------------------------------------------------------------- // DIRECT COMPUTATION // ---------------------------------------------------------------------------------------------------------- - EwalParticle* particlesDirect = nullptr; + EwalParticle<FReal>* particlesDirect = nullptr; FReal directEnergy = 0.0; // @@ -287,7 +287,7 @@ int main(int argc, char ** argv){ printf("Box [%d;%d][%d;%d][%d;%d]\n", min.getX(), max.getX(), min.getY(), max.getY(), min.getZ(), max.getZ()); - particlesDirect = new EwalParticle[loader->getNumberOfParticles()]; + particlesDirect = new EwalParticle<FReal>[loader->getNumberOfParticles()]; FReal denergy = 0.0; FMath::FAccurater<FReal> dfx, dfy, dfz ; @@ -299,7 +299,7 @@ int main(int argc, char ** argv){ counter.tic(); for(int idxTarget = 0 ; idxTarget < loader->getNumberOfParticles() ; ++idxTarget){ particlesDirect[idxTarget] = particles[idxTarget]; - EwalParticle & part = particlesDirect[idxTarget]; + EwalParticle<FReal> & part = particlesDirect[idxTarget]; part.forces[0] = part.forces[1] = part.forces[2] = 0.0; part.potential = 0.0; // @@ -337,7 +337,7 @@ int main(int argc, char ** argv){ loader->getBoxWidth() * FReal(idxZ)); // std::cout <<" ( "<< idxX<<" , "<<idxY << " , "<< idxZ << " ) "<< offset <<std::endl; for(int idxSource = 0 ; idxSource < loader->getNumberOfParticles() ; ++idxSource){ - EwalParticle source = particles[idxSource]; + EwalParticle<FReal> source = particles[idxSource]; source.position += offset; // std::cout << "Part "<<idxSource<< " " <<source.position.getX()<< " " << source.position.getY()<< " " <<source.position.getZ()<< " " <<source.physicalValue <<std::endl ; FP2P::NonMutualParticles( diff --git a/Tests/Kernels/testSphericalGalaxyCsv.cpp b/Tests/Kernels/testSphericalGalaxyCsv.cpp index f808a1a41..5db21b8e0 100644 --- a/Tests/Kernels/testSphericalGalaxyCsv.cpp +++ b/Tests/Kernels/testSphericalGalaxyCsv.cpp @@ -81,17 +81,17 @@ public: void fillParticle(FPoint<FReal>* position, FReal* physivalValue, FPoint<FReal>* velocity){ FReal x,y,z,data, vx, vy, vz; - *(FFmaGenericLoader<FReal>file) >> x >> y >> z >> data >> vx >> vy >> vz; + *(FFmaGenericLoader<FReal>::file) >> x >> y >> z >> data >> vx >> vy >> vz; position->setPosition(x,y,z); *physivalValue = (data); velocity->setPosition(vx,vy,vz); } }; -template<class OctreeClass> -class GalaxyMover : public FAbstractMover<OctreeClass, VelocityContainer>{ +template<class FReal, class OctreeClass> +class GalaxyMover : public FAbstractMover<FReal, OctreeClass, VelocityContainer<FReal>>{ private: - VelocityContainer toStoreRemovedParts; + VelocityContainer<FReal> toStoreRemovedParts; public: GalaxyMover() { @@ -101,14 +101,14 @@ public: } /** To get the position of the particle at idx idxPart in leaf lf */ - void getParticlePosition(VelocityContainer* lf, const int idxPart, FPoint<FReal>* particlePos){ + void getParticlePosition(VelocityContainer<FReal>* lf, const int idxPart, FPoint<FReal>* particlePos){ (*particlePos) = FPoint<FReal>(lf->getPositions()[0][idxPart],lf->getPositions()[1][idxPart],lf->getPositions()[2][idxPart]); } /** Remove a particle but keep it to reinsert it later*/ - void removeFromLeafAndKeep(VelocityContainer* lf, const FPoint<FReal>& particlePos, const int idxPart,FParticleType /*type*/){ - std::array<typename VelocityContainer::AttributesClass, VelocityContainer::NbAttributes> particleValues; - for(int idxAttr = 0 ; idxAttr < VelocityContainer::NbAttributes ; ++idxAttr){ + void removeFromLeafAndKeep(VelocityContainer<FReal>* lf, const FPoint<FReal>& particlePos, const int idxPart,FParticleType /*type*/){ + std::array<typename VelocityContainer<FReal>::AttributesClass, VelocityContainer<FReal>::NbAttributes> particleValues; + for(int idxAttr = 0 ; idxAttr < VelocityContainer<FReal>::NbAttributes ; ++idxAttr){ particleValues[idxAttr] = lf->getAttribute(idxAttr)[idxPart]; } @@ -120,10 +120,10 @@ public: /** Reinsert the previously saved particles */ void insertAllParticles(OctreeClass* tree){ - std::array<typename VelocityContainer::AttributesClass, VelocityContainer::NbAttributes> particleValues; + std::array<typename VelocityContainer<FReal>::AttributesClass, VelocityContainer<FReal>::NbAttributes> particleValues; for(int idxToInsert = 0; idxToInsert<toStoreRemovedParts.getNbParticles() ; ++idxToInsert){ - for(int idxAttr = 0 ; idxAttr < VelocityContainer::NbAttributes ; ++idxAttr){ + for(int idxAttr = 0 ; idxAttr < VelocityContainer<FReal>::NbAttributes ; ++idxAttr){ particleValues[idxAttr] = toStoreRemovedParts.getAttribute(idxAttr)[idxToInsert]; } const FPoint<FReal> particlePos(toStoreRemovedParts.getPositions()[0][idxToInsert], @@ -149,7 +149,7 @@ int main(int argc, char ** argv){ typedef double FReal; typedef FSphericalCell<FReal> CellClass; - typedef VelocityContainer ContainerClass; + typedef VelocityContainer<FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; @@ -157,8 +157,8 @@ int main(int argc, char ** argv){ typedef FFmmAlgorithmThread<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; - typedef GalaxyMover<OctreeClass> MoverClass; - typedef FOctreeArranger<OctreeClass, ContainerClass, MoverClass> ArrangerClass; + typedef GalaxyMover<FReal, OctreeClass> MoverClass; + typedef FOctreeArranger<FReal,OctreeClass, ContainerClass, MoverClass> ArrangerClass; ///////////////////////What we do///////////////////////////// std::cout << ">> This executable has to be used to test Spherical algorithm.\n"; ////////////////////////////////////////////////////////////// @@ -168,9 +168,9 @@ int main(int argc, char ** argv){ const FReal DT = FParameters::getValue(argc,argv,FParameterDefinitions::DeltaT.options, FReal(0.1)); const int DevP = FParameters::getValue(argc,argv,FParameterDefinitions::SHDevelopment.options, 5); - FSphericalCell::Init(DevP); + FSphericalCell<FReal>::Init(DevP); - GalaxyLoader loader(FParameters::getStr(argc,argv,FParameterDefinitions::InputFile.options, "../Data/galaxy.fma.tmp")); + GalaxyLoader<FReal> loader(FParameters::getStr(argc,argv,FParameterDefinitions::InputFile.options, "../Data/galaxy.fma.tmp")); // ----------------------------------------------------- @@ -196,7 +196,7 @@ int main(int argc, char ** argv){ KernelClass kernels( DevP, NbLevels, loader.getBoxWidth(), loader.getCenterOfBox()); FmmClass algo( &tree, &kernels); ArrangerClass arranger(&tree); - FTreeCsvSaver<OctreeClass, ContainerClass> saver(FParameters::getStr(argc,argv,FParameterDefinitions::OutputFile.options, "/tmp/test%d.csv")); + FTreeCsvSaver<FReal, OctreeClass, ContainerClass> saver(FParameters::getStr(argc,argv,FParameterDefinitions::OutputFile.options, "/tmp/test%d.csv")); for(int idx = 0; idx < 100 ; ++idx){ algo.execute(); diff --git a/Tests/Kernels/testSphericalProcAlgorithm.cpp b/Tests/Kernels/testSphericalProcAlgorithm.cpp index c915ffe1e..19f322a29 100644 --- a/Tests/Kernels/testSphericalProcAlgorithm.cpp +++ b/Tests/Kernels/testSphericalProcAlgorithm.cpp @@ -80,9 +80,9 @@ bool isEqualPole(const CellClass& me, const CellClass& other, FReal*const cumul) } /** To compare data */ -bool isEqualLocal(const FSphericalCell& me, const FSphericalCell& other,FReal*const cumul){ +bool isEqualLocal(const FSphericalCell<FReal>& me, const FSphericalCell<FReal>& other,FReal*const cumul){ FMath::FAccurater<FReal> accurate; - for(int idx = 0; idx < FSphericalCell::GetLocalSize(); ++idx){ + for(int idx = 0; idx < FSphericalCell<FReal>::GetLocalSize(); ++idx){ accurate.add(me.getLocal()[idx].getImag(),other.getLocal()[idx].getImag()); accurate.add(me.getLocal()[idx].getReal(),other.getLocal()[idx].getReal()); } diff --git a/Tests/Kernels/testSphericalRotationAlgorithm.cpp b/Tests/Kernels/testSphericalRotationAlgorithm.cpp index 6aa1cea35..ef6650d67 100644 --- a/Tests/Kernels/testSphericalRotationAlgorithm.cpp +++ b/Tests/Kernels/testSphericalRotationAlgorithm.cpp @@ -78,7 +78,7 @@ int main(int argc, char ** argv){ const char* const filename = FParameters::getStr(argc,argv,FParameterDefinitions::InputFile.options, "../Data/test20k.fma"); std::cout << "Opening : " << filename << "\n"; - FFmaScanfLoader loader(filename); + FFmaScanfLoader<FReal> loader(filename); if(!loader.isOpen()){ std::cout << "Loader Error, " << filename << " is missing\n"; return 1; diff --git a/Tests/Kernels/testTaylor.cpp b/Tests/Kernels/testTaylor.cpp index da814c10d..e5590cc7d 100644 --- a/Tests/Kernels/testTaylor.cpp +++ b/Tests/Kernels/testTaylor.cpp @@ -80,7 +80,7 @@ int main(int argc, char* argv[]) FReal potential; }; // open particle file - FFmaScanfLoader loader(filename); + FFmaScanfLoader<FReal> loader(filename); if(!loader.isOpen()) throw std::runtime_error("Particle file couldn't be opened!"); TestParticle* const particles = new TestParticle[loader.getNumberOfParticles()]; @@ -124,7 +124,7 @@ int main(int argc, char* argv[]) typedef FP2PParticleContainerIndexed<FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; - typedef FTaylorKernel<CellClass,ContainerClass,ORDER,1> KernelClass; + typedef FTaylorKernel<FReal,CellClass,ContainerClass,ORDER,1> KernelClass; typedef FFmmAlgorithm<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; // typedef FFmmAlgorithmThread<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; diff --git a/Tests/Kernels/testTaylorKernel.cpp b/Tests/Kernels/testTaylorKernel.cpp index fbb37637e..3ccb72c5c 100644 --- a/Tests/Kernels/testTaylorKernel.cpp +++ b/Tests/Kernels/testTaylorKernel.cpp @@ -40,11 +40,12 @@ int main(int argc,char** argv){ "Compile a Taylor Kernel (but do nothing)."); const int P = 10; const int order = 1; + typedef double FReal; FPoint<FReal> centerBox = FPoint<FReal>(0,0,0); - typedef FTaylorCell<P,order> CellClass; + typedef FTaylorCell<FReal, P,order> CellClass; typedef FP2PParticleContainer<FReal> ContainerClass; - typedef FTaylorKernel<CellClass,ContainerClass,P,order> KernelClass; + typedef FTaylorKernel<FReal,CellClass,ContainerClass,P,order> KernelClass; //typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; //typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; diff --git a/Tests/Kernels/testTaylorSimple.cpp b/Tests/Kernels/testTaylorSimple.cpp index 39cd9325e..3f43eb3ea 100644 --- a/Tests/Kernels/testTaylorSimple.cpp +++ b/Tests/Kernels/testTaylorSimple.cpp @@ -37,12 +37,12 @@ int main(int argc,char* argv[]){ FPoint<FReal> rootCenter(FReal(0.0),FReal(0.0),FReal(0.0)); FReal boxWidth = FReal(4); - typedef FTaylorCell<P,order> CellClass; + typedef FTaylorCell<FReal,P,order> CellClass; typedef FP2PParticleContainer<FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; - typedef FTaylorKernel<CellClass,ContainerClass,P,order> KernelClass; + typedef FTaylorKernel<FReal,CellClass,ContainerClass,P,order> KernelClass; typedef FFmmAlgorithm<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; diff --git a/Tests/Kernels/testTsmAlgorithm.cpp b/Tests/Kernels/testTsmAlgorithm.cpp index 881a35464..2a535eb94 100644 --- a/Tests/Kernels/testTsmAlgorithm.cpp +++ b/Tests/Kernels/testTsmAlgorithm.cpp @@ -60,7 +60,7 @@ int testFunction(int argc, char ** argv, Args ... kernelPreArgs){ const char* const filename = FParameters::getStr(argc,argv,FParameterDefinitions::InputFile.options, "../Data/test20k.tsm.fma"); std::cout << "Opening : " << filename << "\n"; // Create particles loader - FFmaTsmLoader loader(filename); + FFmaTsmLoader<FReal> loader(filename); if(!loader.isOpen()){ std::cout << "Loader Error, " << filename << " is missing\n"; return 1; @@ -153,12 +153,12 @@ int main(int argc, char ** argv){ std::cout << "[INFO] -spherical is used\n"; // Create template typedef double FReal; - typedef FTypedSphericalCell CellClass; + typedef FTypedSphericalCell< FReal> CellClass; typedef FP2PParticleContainer<FReal> ContainerClass; - typedef FTypedLeaf< ContainerClass > LeafClass; + typedef FTypedLeaf< FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; - typedef FSphericalKernel< CellClass, ContainerClass > KernelClass; + typedef FSphericalKernel< FReal, CellClass, ContainerClass > KernelClass; typedef FFmmAlgorithmTsm<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; @@ -166,7 +166,7 @@ int main(int argc, char ** argv){ CellClass::Init(DevP); // Call Main function - testFunction< CellClass, ContainerClass, LeafClass, OctreeClass, KernelClass, FmmClass>(argc, argv, DevP,NbLevels); + testFunction< FReal, CellClass, ContainerClass, LeafClass, OctreeClass, KernelClass, FmmClass>(argc, argv, DevP,NbLevels); } if( FParameters::existParameter(argc,argv,FParameterDefinitions::RotationKernel.options) ){ @@ -174,17 +174,17 @@ int main(int argc, char ** argv){ // Create template typedef double FReal; static const int P = 9; - typedef FTypedRotationCell<P> CellClass; + typedef FTypedRotationCell<FReal,P> CellClass; typedef FP2PParticleContainer<FReal> ContainerClass; - typedef FTypedLeaf< ContainerClass > LeafClass; + typedef FTypedLeaf< FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; - typedef FRotationKernel< CellClass, ContainerClass, P > KernelClass; + typedef FRotationKernel< FReal, CellClass, ContainerClass, P > KernelClass; typedef FFmmAlgorithmTsm<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; // Call Main function - testFunction< CellClass, ContainerClass, LeafClass, OctreeClass, KernelClass, FmmClass>(argc, argv,NbLevels); + testFunction< FReal, CellClass, ContainerClass, LeafClass, OctreeClass, KernelClass, FmmClass>(argc, argv,NbLevels); } return 0; diff --git a/Tests/Kernels/testTuneSphericalBlockBlas.cpp b/Tests/Kernels/testTuneSphericalBlockBlas.cpp index c8f7f8205..3a6c55ed7 100644 --- a/Tests/Kernels/testTuneSphericalBlockBlas.cpp +++ b/Tests/Kernels/testTuneSphericalBlockBlas.cpp @@ -63,12 +63,12 @@ int main(int argc, char ** argv){ typedef double FReal; - typedef FSphericalCell CellClass; + typedef FSphericalCell<FReal> CellClass; typedef FP2PParticleContainer<FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; - typedef FSphericalBlockBlasKernel< CellClass, ContainerClass > KernelClass; + typedef FSphericalBlockBlasKernel< FReal, CellClass, ContainerClass > KernelClass; typedef FFmmAlgorithm<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; ///////////////////////What we do///////////////////////////// @@ -89,7 +89,7 @@ int main(int argc, char ** argv){ CellClass::Init(DevP, true); for(int idxBlockSize = 1 ; idxBlockSize < MaxBlockSize ; idxBlockSize *= 2){ - FFmaScanfLoader loader(filename); + FFmaScanfLoader<FReal> loader(filename); if(!loader.isOpen()){ std::cout << "Loader Error, " << filename << " is missing\n"; return 1; diff --git a/Tests/Kernels/testUnifTensorialAlgorithm.cpp b/Tests/Kernels/testUnifTensorialAlgorithm.cpp index ae331812e..046e37254 100644 --- a/Tests/Kernels/testUnifTensorialAlgorithm.cpp +++ b/Tests/Kernels/testUnifTensorialAlgorithm.cpp @@ -79,7 +79,7 @@ int main(int argc, char* argv[]) // typedefs - typedef FInterpMatrixKernel_R_IJ MatrixKernelClass; + typedef FInterpMatrixKernel_R_IJ<FReal> MatrixKernelClass; // useful features of matrix kernel const unsigned int NPV = MatrixKernelClass::NPV; @@ -173,12 +173,12 @@ int main(int argc, char* argv[]) if(MatrixKernelClass::Type==HOMOGENEOUS && BoxWidthExtension>0.) throw std::runtime_error("Extension of box width is not yet supported for homogeneous kernels! Work-around: artificially set Type to NON_HOMOGENEOUS."); - typedef FP2PParticleContainerIndexed<NRHS,NLHS> ContainerClass; + typedef FP2PParticleContainerIndexed<FReal,NRHS,NLHS> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; - typedef FUnifCell<ORDER,NRHS,NLHS> CellClass; + typedef FUnifCell<FReal,ORDER,NRHS,NLHS> CellClass; typedef FOctree<FReal, CellClass,ContainerClass,LeafClass> OctreeClass; - typedef FUnifTensorialKernel<CellClass,ContainerClass,MatrixKernelClass,ORDER> KernelClass; + typedef FUnifTensorialKernel<FReal,CellClass,ContainerClass,MatrixKernelClass,ORDER> KernelClass; typedef FFmmAlgorithm<OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass; // typedef FFmmAlgorithmThread<OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass; diff --git a/Tests/Utils/testChebM2Lprecomputation.cpp b/Tests/Utils/testChebM2Lprecomputation.cpp index b4a349add..dbd06e109 100644 --- a/Tests/Utils/testChebM2Lprecomputation.cpp +++ b/Tests/Utils/testChebM2Lprecomputation.cpp @@ -154,7 +154,7 @@ int main(int argc, char* argv[]) //////////////////////////////////////////////// std::cout << "\nSVD compression of K "; time.tic(); - const unsigned int rank1 = Compress<order>(epsilon, 1, Qu1, C1, Qb1); + const unsigned int rank1 = Compress<FReal,order>(epsilon, 1, Qu1, C1, Qb1); std::cout << "to low rank = " << rank1 << " (eps = " << epsilon << ") took " << time.tacAndElapsed() << " sec." << std::endl; //////////////////////////////////////////////// @@ -162,7 +162,7 @@ int main(int argc, char* argv[]) //////////////////////////////////////////////// std::cout << "SVD compression of Omega_x^{1/2} K Omega_y^{1/2} "; time.tic(); - const unsigned int rank2 = Compress<order>(epsilon, 1, Qu2, C2, Qb2); + const unsigned int rank2 = Compress<FReal,order>(epsilon, 1, Qu2, C2, Qb2); std::cout << "to low rank = " << rank2 << " (eps = " << epsilon << ") took " << time.tacAndElapsed() << " sec." << std::endl; //////////////////////////////////////////////// diff --git a/Tests/Utils/testChebOctree.cpp b/Tests/Utils/testChebOctree.cpp index b0e4fb134..46a953b95 100644 --- a/Tests/Utils/testChebOctree.cpp +++ b/Tests/Utils/testChebOctree.cpp @@ -49,6 +49,7 @@ int main(int argc, char ** argv){ const int ORDER = 5; + typedef double FReal; typedef FP2PParticleContainer<FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass> LeafClass; typedef FChebCell<FReal,ORDER> CellClass; @@ -64,8 +65,7 @@ int main(int argc, char ** argv){ FTic counter; srand48( static_cast<unsigned int>(time(NULL)) ); - - typedef double FReal; + const FReal BoxWidth = 1.; const FPoint<FReal> BoxCenter(.5, .5, .5); const unsigned int TreeHeight = 10; diff --git a/Tests/Utils/testChebSymmetries.cpp b/Tests/Utils/testChebSymmetries.cpp index ed4b8ebda..ee8fb59f0 100644 --- a/Tests/Utils/testChebSymmetries.cpp +++ b/Tests/Utils/testChebSymmetries.cpp @@ -133,7 +133,7 @@ int main(int argc, char* argv[]) // permute const unsigned int pidx = permuter.getPermutationArrayAndIndex(i, j, k, perm); - permuteMatrix<order>(perm, K0); + permuteMatrix<FReal,order>(perm, K0); if (K[pidx]==NULL) std::cout << " - not existing index " << pidx << std::endl; diff --git a/Tests/Utils/testChebTensorProduct.cpp b/Tests/Utils/testChebTensorProduct.cpp index e599eec8a..227e3b312 100644 --- a/Tests/Utils/testChebTensorProduct.cpp +++ b/Tests/Utils/testChebTensorProduct.cpp @@ -284,7 +284,7 @@ int main(int argc, char* argv[]) FReal T_of_y[ORDER * (ORDER-1)]; for (unsigned int o=1; o<ORDER; ++o) for (unsigned int j=0; j<ORDER; ++j) - T_of_y[(o-1)*ORDER + j] = FReal(FChebRoots<ORDER>::T(o, FReal(FChebRoots<ORDER>::roots[j]))); + T_of_y[(o-1)*ORDER + j] = FReal(FChebRoots<FReal,ORDER>::T(o, FReal(FChebRoots<FReal,ORDER>::roots[j]))); for (unsigned int l=0; l<ORDER-1; ++l) for (unsigned int i=0; i<ORDER; ++i) { @@ -361,7 +361,7 @@ int main(int argc, char* argv[]) FReal T_of_y[ORDER * (ORDER-1)]; for (unsigned int o=1; o<ORDER; ++o) for (unsigned int j=0; j<ORDER; ++j) - T_of_y[(o-1)*ORDER + j] = FReal(FChebRoots<ORDER>::T(o, FReal(FChebRoots<ORDER>::roots[j]))); + T_of_y[(o-1)*ORDER + j] = FReal(FChebRoots<FReal,ORDER>::T(o, FReal(FChebRoots<FReal,ORDER>::roots[j]))); // set everything to zero f1 = FReal(0.); diff --git a/Tests/Utils/testCompareIOTree.cpp b/Tests/Utils/testCompareIOTree.cpp index 1de43f3eb..8aa19f252 100644 --- a/Tests/Utils/testCompareIOTree.cpp +++ b/Tests/Utils/testCompareIOTree.cpp @@ -46,7 +46,7 @@ int main(int argc, char ** argv){ ); typedef double FReal; - typedef FSphericalCell CellClass; + typedef FSphericalCell<FReal> CellClass; typedef FP2PParticleContainer<FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; @@ -66,8 +66,8 @@ int main(int argc, char ** argv){ const char* const filename2 = FParameters::getStr(argc,argv,FParameterDefinitions::InputFileOne.options, "dtree.data"); std::cout << "Compare tree " << filename1 << " and " << filename2 << std::endl; - FTreeIO::Load<OctreeClass, CellClass, LeafClass, ContainerClass >(filename1, tree1); - FTreeIO::Load<OctreeClass, CellClass, LeafClass, ContainerClass >(filename2, tree2); + FTreeIO<FReal>::Load<OctreeClass, CellClass, LeafClass, ContainerClass >(filename1, tree1); + FTreeIO<FReal>::Load<OctreeClass, CellClass, LeafClass, ContainerClass >(filename2, tree2); // ----------------------------------------------------- std::cout << "Check Result\n"; @@ -130,7 +130,7 @@ int main(int argc, char ** argv){ const CellClass*const cell2 = octreeIterator2.getCurrentCell(); FReal cumul = 0; - for(int idx = 0; idx < FSphericalCell::GetPoleSize(); ++idx){ + for(int idx = 0; idx < FSphericalCell<FReal>::GetPoleSize(); ++idx){ cumul += FMath::Abs( cell1->getMultipole()[idx].getImag() - cell2->getMultipole()[idx].getImag() ); cumul += FMath::Abs( cell1->getMultipole()[idx].getReal() - cell2->getMultipole()[idx].getReal() ); } @@ -139,7 +139,7 @@ int main(int argc, char ** argv){ << " index is " << octreeIterator1.getCurrentGlobalIndex() << std::endl; } cumul = 0; - for(int idx = 0; idx < FSphericalCell::GetLocalSize(); ++idx){ + for(int idx = 0; idx < FSphericalCell<FReal>::GetLocalSize(); ++idx){ cumul += FMath::Abs( cell1->getLocal()[idx].getImag() - cell2->getLocal()[idx].getImag() ); cumul += FMath::Abs( cell1->getLocal()[idx].getReal() - cell2->getLocal()[idx].getReal() ); } diff --git a/Tests/Utils/testFastDiscreteConvolution.cpp b/Tests/Utils/testFastDiscreteConvolution.cpp index 1247433e4..a442d18bf 100644 --- a/Tests/Utils/testFastDiscreteConvolution.cpp +++ b/Tests/Utils/testFastDiscreteConvolution.cpp @@ -112,7 +112,7 @@ int main(int argc, char ** argv){ const int dim = 1; const int steps[dim] = {N}; //FDft<FReal> Dft(N);// direct version (Beware! Ordering of output differs from REAL valued-FFT) - FFft<dim> Dft;// fast version + FFft<FReal,dim> Dft;// fast version Dft.buildDFT(steps);// fast version std::cout << "took " << time.tacAndElapsed() << "sec." << std::endl; diff --git a/Tests/Utils/testFmmAdaptiveAlgorithm.cpp b/Tests/Utils/testFmmAdaptiveAlgorithm.cpp index 940069345..549a13947 100644 --- a/Tests/Utils/testFmmAdaptiveAlgorithm.cpp +++ b/Tests/Utils/testFmmAdaptiveAlgorithm.cpp @@ -63,6 +63,7 @@ int main(int argc, char ** argv){ FParameterDefinitions::NbParticles, FParameterDefinitions::OctreeHeight, FParameterDefinitions::OctreeSubHeight,); + typedef double FReal; typedef FTestCell CellClass; typedef FTestParticleContainer<FReal> ContainerClass; diff --git a/Tests/Utils/testFmmAdaptiveStats.cpp b/Tests/Utils/testFmmAdaptiveStats.cpp index 24dc7f073..915ca62de 100644 --- a/Tests/Utils/testFmmAdaptiveStats.cpp +++ b/Tests/Utils/testFmmAdaptiveStats.cpp @@ -257,8 +257,9 @@ int main(int argc, char ** argv){ FParameterDefinitions::NbParticles, FParameterDefinitions::OctreeHeight, FParameterDefinitions::OctreeSubHeight); + typedef double FReal; typedef FBasicCell CellClass; - typedef FBasicParticleContainer<0> ContainerClass; + typedef FBasicParticleContainer<FReal, 0, FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FAdaptiveStatsKernel< CellClass, ContainerClass > KernelClass; diff --git a/Tests/Utils/testFmmAlgorithm.cpp b/Tests/Utils/testFmmAlgorithm.cpp index 03838d688..007f371ca 100644 --- a/Tests/Utils/testFmmAlgorithm.cpp +++ b/Tests/Utils/testFmmAlgorithm.cpp @@ -53,6 +53,7 @@ int main(int argc, char ** argv){ FParameterDefinitions::OctreeHeight, FParameterDefinitions::OctreeSubHeight, FParameterDefinitions::NbParticles); + typedef double FReal; typedef FTestCell CellClass; typedef FTestParticleContainer<FReal> ContainerClass; diff --git a/Tests/Utils/testFmmAlgorithmPeriodic.cpp b/Tests/Utils/testFmmAlgorithmPeriodic.cpp index c78e76d9a..ec6be8a55 100644 --- a/Tests/Utils/testFmmAlgorithmPeriodic.cpp +++ b/Tests/Utils/testFmmAlgorithmPeriodic.cpp @@ -56,7 +56,7 @@ int main(int argc, char ** argv){ FParameterDefinitions::OctreeHeight, FParameterDefinitions::OctreeSubHeight, FParameterDefinitions::NbParticles, FParameterDefinitions::PeriodicityNbLevels); - + typedef double FReal; typedef FTestCell CellClass; typedef FTestParticleContainer<FReal> ContainerClass; @@ -64,7 +64,7 @@ int main(int argc, char ** argv){ typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; typedef FTestKernels< CellClass, ContainerClass > KernelClass; - typedef FFmmAlgorithmPeriodic<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; + typedef FFmmAlgorithmPeriodic<FReal, OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; ///////////////////////What we do///////////////////////////// std::cout << ">> This executable has to be used to test the FMM algorithm.\n"; ////////////////////////////////////////////////////////////// diff --git a/Tests/Utils/testFmmAlgorithmProc.cpp b/Tests/Utils/testFmmAlgorithmProc.cpp index 1cc43804a..43071a511 100644 --- a/Tests/Utils/testFmmAlgorithmProc.cpp +++ b/Tests/Utils/testFmmAlgorithmProc.cpp @@ -290,6 +290,8 @@ void print(OctreeClass* const valideTree){ // Define the classes to use ///////////////////////////////////////////////////////////////////// +typedef double FReal; + typedef FTestCell CellClass; typedef FTestParticleContainer<FReal> ContainerClass; @@ -316,7 +318,6 @@ int main(int argc, char ** argv){ FMpi app( argc, argv); - typedef double FReal; const int NbLevels = FParameters::getValue(argc,argv,FParameterDefinitions::OctreeHeight.options, 5); const int SizeSubLevels = FParameters::getValue(argc,argv,FParameterDefinitions::OctreeSubHeight.options, 3); FTic counter; diff --git a/Tests/Utils/testFmmAlgorithmProcPeriodic.cpp b/Tests/Utils/testFmmAlgorithmProcPeriodic.cpp index e0187600f..2d3dea1d1 100644 --- a/Tests/Utils/testFmmAlgorithmProcPeriodic.cpp +++ b/Tests/Utils/testFmmAlgorithmProcPeriodic.cpp @@ -60,6 +60,7 @@ int main(int argc, char ** argv){ FParameterDefinitions::OctreeHeight, FParameterDefinitions::OctreeSubHeight, FParameterDefinitions::NbParticles); + typedef double FReal; typedef FTestCell CellClass; typedef FTestParticleContainer<FReal> ContainerClass; @@ -68,8 +69,8 @@ int main(int argc, char ** argv){ typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; typedef FTestKernels< CellClass, ContainerClass > KernelClass; - typedef FFmmAlgorithmThreadProcPeriodic<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; - typedef FFmmAlgorithmPeriodic<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClassSeq; + typedef FFmmAlgorithmThreadProcPeriodic<FReal, OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; + typedef FFmmAlgorithmPeriodic<FReal, OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClassSeq; ///////////////////////What we do///////////////////////////// std::cout << ">> This executable has to be used to test the FMM algorithm.\n"; ////////////////////////////////////////////////////////////// @@ -91,7 +92,6 @@ int main(int argc, char ** argv){ std::cout << "\tHeight : " << NbLevels << " \t sub-height : " << SizeSubLevels << std::endl; counter.tic(); - typedef double FReal; FRandomLoader<FReal> loader(NbParticles,FReal(1.0),FPoint<FReal>(0,0,0), app.global().processId()); OctreeClass tree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox()); diff --git a/Tests/Utils/testFmmAlgorithmProcRotation.cpp b/Tests/Utils/testFmmAlgorithmProcRotation.cpp index b3f25e68b..7d2b20b49 100644 --- a/Tests/Utils/testFmmAlgorithmProcRotation.cpp +++ b/Tests/Utils/testFmmAlgorithmProcRotation.cpp @@ -223,13 +223,14 @@ int main(int argc, char ** argv){ FParameterDefinitions::OctreeHeight, FParameterDefinitions::OctreeSubHeight, FParameterDefinitions::InputFile); + const int P = 7; // For Rotation test :: - typedef FRotationCell<7> CellClass; + typedef FRotationCell<FReal,P> CellClass; typedef FP2PParticleContainer<FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; - typedef FRotationKernel< CellClass, ContainerClass,7 > KernelClass; + typedef FRotationKernel< FReal, CellClass, ContainerClass,P > KernelClass; typedef FFmmAlgorithmThreadProc<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; #ifdef VALIDATE_FMM diff --git a/Tests/Utils/testFmmAlgorithmTsm.cpp b/Tests/Utils/testFmmAlgorithmTsm.cpp index 16eeca3d8..1557a4182 100644 --- a/Tests/Utils/testFmmAlgorithmTsm.cpp +++ b/Tests/Utils/testFmmAlgorithmTsm.cpp @@ -59,10 +59,11 @@ int main(int argc, char ** argv){ FParameterDefinitions::OctreeHeight, FParameterDefinitions::OctreeSubHeight, FParameterDefinitions::NbParticles); + typedef double FReal; typedef FTestCellTsm CellClassTyped; typedef FTestParticleContainer<FReal> ContainerClassTyped; - typedef FTypedLeaf< ContainerClassTyped > LeafClassTyped; + typedef FTypedLeaf< FReal, ContainerClassTyped > LeafClassTyped; typedef FOctree<FReal, CellClassTyped, ContainerClassTyped , LeafClassTyped > OctreeClassTyped; typedef FTestKernels< CellClassTyped, ContainerClassTyped > KernelClassTyped; @@ -79,7 +80,7 @@ int main(int argc, char ** argv){ ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// - FRandomLoaderTsm loader(NbPart, 1, FPoint<FReal>(0.5,0.5,0.5), 1); + FRandomLoaderTsm<FReal> loader(NbPart, 1, FPoint<FReal>(0.5,0.5,0.5), 1); OctreeClassTyped tree(NbLevels, SizeSubLevels,loader.getBoxWidth(),loader.getCenterOfBox()); ////////////////////////////////////////////////////////////////////////////////// diff --git a/Tests/Utils/testFmmDemonstration.cpp b/Tests/Utils/testFmmDemonstration.cpp index 2fe991b69..dd8db7b44 100644 --- a/Tests/Utils/testFmmDemonstration.cpp +++ b/Tests/Utils/testFmmDemonstration.cpp @@ -50,7 +50,8 @@ class MyCell : public FBasicCell { // My fack Container is simply saving the indexes of each // particles (nothing more!) -class MyContainer : public FAbstractParticleContainer { +template <class FReal> +class MyContainer : public FAbstractParticleContainer<FReal> { FVector<int> indexes; public: template<typename... Args> @@ -69,18 +70,19 @@ public: // My leaf process the particles and save only // those where keepIt is true (during the push method) -class MyLeaf : public FAbstractLeaf< MyContainer > { - MyContainer particles; +template <class FReal> +class MyLeaf : public FAbstractLeaf< FReal, MyContainer<FReal> > { + MyContainer<FReal> particles; public: template<typename... Args> void push(const FPoint<FReal>& inParticlePosition, const bool keepIt, Args ... args){ if(keepIt) particles.push(inParticlePosition, args...); } - MyContainer* getSrc(){ + MyContainer<FReal>* getSrc(){ return &particles; } - MyContainer* getTargets(){ + MyContainer<FReal>* getTargets(){ return &particles; } }; @@ -138,10 +140,11 @@ int main(int argc, char ** argv){ FParameterDefinitions::OctreeHeight, FParameterDefinitions::OctreeSubHeight, FParameterDefinitions::NbParticles); + typedef double FReal; // Custom data structure here typedef MyCell CellClass; - typedef MyContainer ContainerClass; - typedef MyLeaf LeafClass; + typedef MyContainer<FReal> ContainerClass; + typedef MyLeaf<FReal> LeafClass; // Standard things here typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; diff --git a/Tests/Utils/testLoader.cpp b/Tests/Utils/testLoader.cpp index e857f5c5e..f0cfec19a 100644 --- a/Tests/Utils/testLoader.cpp +++ b/Tests/Utils/testLoader.cpp @@ -51,9 +51,10 @@ int main(int argc, char ** argv){ FHelpDescribeAndExit(argc, argv, "Load a file and put the particles in a tree", FParameterDefinitions::InputFile, FParameterDefinitions::OctreeHeight); - typedef FBasicParticleContainer<0> ContainerClass; + typedef double FReal; + typedef FBasicParticleContainer<FReal,0,FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; - typedef FOctree< FBasicCell, ContainerClass , LeafClass > OctreeClass; + typedef FOctree< FReal, FBasicCell, ContainerClass , LeafClass > OctreeClass; ///////////////////////What we do///////////////////////////// std::cout << ">> This executable is useless to execute.\n"; std::cout << ">> It is only interesting to wath the code to understand\n"; @@ -67,7 +68,7 @@ int main(int argc, char ** argv){ std::cout << "Opening : " << filename << "\n"; // open basic particles loader - FBasicLoader loader(filename); + FBasicLoader<FReal> loader(filename); if(!loader.isOpen()){ std::cout << "Loader Error, " << filename << "is missing\n"; return 1; diff --git a/Tests/Utils/testLoaderFMATsm.cpp b/Tests/Utils/testLoaderFMATsm.cpp index df0452a18..f9360bf88 100644 --- a/Tests/Utils/testLoaderFMATsm.cpp +++ b/Tests/Utils/testLoaderFMATsm.cpp @@ -46,9 +46,9 @@ int main(int argc, char ** argv ){ FParameterDefinitions::InputFile, FParameterDefinitions::OctreeHeight); typedef double FReal; - typedef FBasicParticleContainer<1> ContainerClass; - typedef FTypedLeaf< ContainerClass > LeafClass; - typedef FOctree< FBasicCell, ContainerClass , LeafClass > OctreeClass; + typedef FBasicParticleContainer<FReal,1,FReal> ContainerClass; + typedef FTypedLeaf< FReal, ContainerClass > LeafClass; + typedef FOctree< FReal, FBasicCell, ContainerClass , LeafClass > OctreeClass; ///////////////////////What we do///////////////////////////// std::cout << ">> This executable is useless to execute.\n"; std::cout << ">> It is only interesting to wath the code to understand\n"; @@ -61,7 +61,7 @@ int main(int argc, char ** argv ){ std::cout << "Opening : " << filename << "\n"; // open basic particles loader - FFmaTsmLoader loader(filename); + FFmaTsmLoader<FReal> loader(filename); if(!loader.isOpen()){ std::cout << "Loader Error, " << filename << "is missing\n"; return 1; diff --git a/Tests/Utils/testMemStats.cpp b/Tests/Utils/testMemStats.cpp index 93be45af9..bb8d44a50 100644 --- a/Tests/Utils/testMemStats.cpp +++ b/Tests/Utils/testMemStats.cpp @@ -55,14 +55,14 @@ int main(int argc, char ** argv){ FParameterDefinitions::NbParticles, FParameterDefinitions::SHDevelopment); typedef double FReal; - typedef FSphericalCell CellClass; + typedef FSphericalCell<FReal> CellClass; typedef FP2PParticleContainer<FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; //typedef FTestKernels< CellClass, ContainerClass > KernelClass; - typedef FSphericalKernel< CellClass, ContainerClass > KernelClass; + typedef FSphericalKernel<FReal, CellClass, ContainerClass > KernelClass; typedef FFmmAlgorithm<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; ///////////////////////What we do///////////////////////////// diff --git a/Tests/Utils/testMpiCsvSaver.cpp b/Tests/Utils/testMpiCsvSaver.cpp index 80617b061..4a8300b59 100644 --- a/Tests/Utils/testMpiCsvSaver.cpp +++ b/Tests/Utils/testMpiCsvSaver.cpp @@ -73,12 +73,12 @@ public: template <class FReal> class GalaxyLoader : public FFmaGenericLoader<FReal> { public: - GalaxyLoader(const std::string & filename) : FFmaGenericLoader(filename) { + GalaxyLoader(const std::string & filename) : FFmaGenericLoader<FReal>(filename) { } void fillParticle(FPoint<FReal>* position, FReal* physivalValue, FPoint<FReal>* velocity){ FReal x,y,z,data, vx, vy, vz; - (*this->file) >> x >> y >> z >> data >> vx >> vy >> vz; + (*FFmaGenericLoader<FReal>::file) >> x >> y >> z >> data >> vx >> vy >> vz; position->setPosition(x,y,z); *physivalValue = (data); velocity->setPosition(vx,vy,vz); @@ -112,7 +112,7 @@ public: const FReal*const potentials = containers->getPotentials(); FVector<FPoint<FReal>> velocites = containers->getVelocities(); - TestParticle part; + TestParticle<FReal> part; part.position.setPosition( positionsX[idxExtract],positionsY[idxExtract],positionsZ[idxExtract]); part.physicalValue = physicalValues[idxExtract]; part.forces[0] = forcesX[idxExtract]; @@ -141,7 +141,7 @@ int main(int argc, char ** argv){ typedef double FReal; typedef FBasicCell CellClass; - typedef VelocityContainer ContainerClass; + typedef VelocityContainer<FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; @@ -153,7 +153,7 @@ int main(int argc, char ** argv){ const int NbLevels = FParameters::getValue(argc,argv,FParameterDefinitions::OctreeHeight.options, 6); const int SizeSubLevels = FParameters::getValue(argc,argv,FParameterDefinitions::OctreeSubHeight.options, 3); - GalaxyLoader loader(FParameters::getStr(argc,argv,FParameterDefinitions::InputFile.options, "../Data/galaxy.fma")); + GalaxyLoader<FReal> loader(FParameters::getStr(argc,argv,FParameterDefinitions::InputFile.options, "../Data/galaxy.fma")); // ----------------------------------------------------- @@ -177,14 +177,14 @@ int main(int argc, char ** argv){ // ----------------------------------------------------- { - FTreeMpiCsvSaver<OctreeClass, ContainerClass> saver("/tmp/test%d.csv", app.global() , false); + FTreeMpiCsvSaver<FReal, OctreeClass, ContainerClass> saver("/tmp/test%d.csv", app.global() , false); saver.exportTree(&tree); } // ----------------------------------------------------- { - FTreeMpiCsvSaver<OctreeClass, ContainerClass> saver("/tmp/htest%d.csv", app.global() , true); + FTreeMpiCsvSaver<FReal, OctreeClass, ContainerClass> saver("/tmp/htest%d.csv", app.global() , true); saver.exportTree(&tree); } diff --git a/Tests/Utils/testOctree.cpp b/Tests/Utils/testOctree.cpp index 098a161ef..37cdc726b 100644 --- a/Tests/Utils/testOctree.cpp +++ b/Tests/Utils/testOctree.cpp @@ -46,9 +46,10 @@ int main(int argc, char ** argv){ "Show how to use an octree (only the code is interesting)", FParameterDefinitions::NbParticles); - typedef FBasicParticleContainer<0> ContainerClass; + typedef double FReal; + typedef FBasicParticleContainer<FReal,0,FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; - typedef FOctree< FBasicCell, ContainerClass , LeafClass > OctreeClass; + typedef FOctree<FReal, FBasicCell, ContainerClass , LeafClass > OctreeClass; ///////////////////////What we do///////////////////////////// std::cout << ">> This executable is useless to execute.\n"; std::cout << ">> It is only interesting to wath the code to understand\n"; diff --git a/Tests/Utils/testOctreeFuncteur.cpp b/Tests/Utils/testOctreeFuncteur.cpp index 273d4e9a2..310798f97 100644 --- a/Tests/Utils/testOctreeFuncteur.cpp +++ b/Tests/Utils/testOctreeFuncteur.cpp @@ -46,8 +46,9 @@ int main(int argc, char ** argv){ "Show how to use an octree functeur (only the code is interesting)", FParameterDefinitions::NbParticles); + typedef double FReal; typedef FBasicCell CellClass; - typedef FBasicParticleContainer<0> ContainerClass; + typedef FBasicParticleContainer<FReal,0,FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; ///////////////////////What we do///////////////////////////// diff --git a/Tests/Utils/testOctreeIter.cpp b/Tests/Utils/testOctreeIter.cpp index b89baeabf..05de4e53a 100644 --- a/Tests/Utils/testOctreeIter.cpp +++ b/Tests/Utils/testOctreeIter.cpp @@ -49,9 +49,9 @@ int main(int argc, char ** argv){ FParameterDefinitions::OctreeSubHeight); typedef double FReal; - typedef FBasicParticleContainer<0> ContainerClass; + typedef FBasicParticleContainer<FReal,0,FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; - typedef FOctree< FBasicCell, ContainerClass , LeafClass > OctreeClass; + typedef FOctree<FReal, FBasicCell, ContainerClass , LeafClass > OctreeClass; ///////////////////////What we do///////////////////////////// std::cout << ">> This executable is useless to execute.\n"; std::cout << ">> It is only interesting to wath the code to understand\n"; diff --git a/Tests/Utils/testOctreeParallelFuncteur.cpp b/Tests/Utils/testOctreeParallelFuncteur.cpp index bdf47a2d1..207ffda57 100644 --- a/Tests/Utils/testOctreeParallelFuncteur.cpp +++ b/Tests/Utils/testOctreeParallelFuncteur.cpp @@ -48,8 +48,9 @@ int main(int argc, char ** argv){ "Show how to use an octree functeur parallelized (only the code is interesting)", FParameterDefinitions::NbParticles); + typedef double FReal; typedef FBasicCell CellClass; - typedef FBasicParticleContainer<0> ContainerClass; + typedef FBasicParticleContainer<FReal,0,FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; ///////////////////////What we do///////////////////////////// diff --git a/Tests/Utils/testOctreeRearrange.cpp b/Tests/Utils/testOctreeRearrange.cpp index 4ac961bd3..260405b0f 100644 --- a/Tests/Utils/testOctreeRearrange.cpp +++ b/Tests/Utils/testOctreeRearrange.cpp @@ -55,8 +55,8 @@ int main(int argc, char ** argv){ typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; - typedef FBasicParticleContainerIndexedMover<OctreeClass, ContainerClass> MoverClass; - typedef FOctreeArranger<OctreeClass, ContainerClass, MoverClass> ArrangerClass; + typedef FBasicParticleContainerIndexedMover<FReal,OctreeClass, ContainerClass> MoverClass; + typedef FOctreeArranger<FReal, OctreeClass, ContainerClass, MoverClass> ArrangerClass; ///////////////////////What we do///////////////////////////// std::cout << ">> This executable has to be used to test the FMM algorithm.\n"; @@ -133,7 +133,7 @@ int main(int argc, char ** argv){ std::cout << "Arrange ..." << std::endl; counter.tic(); - //FOctreeArranger<OctreeClass, ContainerClass, TestParticle, Converter<TestParticle> > arrange(&tree); + //FOctreeArranger<FReal,OctreeClass, ContainerClass, TestParticle, Converter<TestParticle> > arrange(&tree); arrange.rearrange(); diff --git a/Tests/Utils/testOctreeRearrangePeriodic.cpp b/Tests/Utils/testOctreeRearrangePeriodic.cpp index bafd61ffb..bace9448a 100644 --- a/Tests/Utils/testOctreeRearrangePeriodic.cpp +++ b/Tests/Utils/testOctreeRearrangePeriodic.cpp @@ -57,8 +57,8 @@ int main(int argc, char ** argv){ typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; - typedef FBasicParticleContainerIndexedMover<OctreeClass, ContainerClass> MoverClass; - typedef FArrangerPeriodic<OctreeClass, ContainerClass, MoverClass> ArrangerClassPeriodic; + typedef FBasicParticleContainerIndexedMover<FReal, OctreeClass, ContainerClass> MoverClass; + typedef FArrangerPeriodic<FReal, OctreeClass, ContainerClass, MoverClass> ArrangerClassPeriodic; ///////////////////////What we do///////////////////////////// std::cout << ">> This executable has to be used to test the FMM algorithm.\n"; @@ -134,7 +134,7 @@ int main(int argc, char ** argv){ std::cout << "Arrange ..." << std::endl; counter.tic(); - //FOctreeArranger<OctreeClass, ContainerClass, TestParticle, Converter<TestParticle> > arrange(&tree); + //FOctreeArranger<FReal,OctreeClass, ContainerClass, TestParticle, Converter<TestParticle> > arrange(&tree); arrange.rearrange(); diff --git a/Tests/Utils/testOctreeRearrangeProc.cpp b/Tests/Utils/testOctreeRearrangeProc.cpp index f90f64fa5..bfa636a82 100644 --- a/Tests/Utils/testOctreeRearrangeProc.cpp +++ b/Tests/Utils/testOctreeRearrangeProc.cpp @@ -44,6 +44,7 @@ #include "../../Src/Utils/FParameterNames.hpp" +template <class FReal> struct TestParticle{ FPoint<FReal> position; const FPoint<FReal>& getPosition(){ @@ -51,16 +52,16 @@ struct TestParticle{ } }; -template <class ParticleClass> +template <class FReal, class ParticleClass> class Converter { public: template <class ContainerClass> static ParticleClass GetParticleAndRemove(ContainerClass* container, const int idxExtract){ - TestParticle part; + TestParticle<FReal> part; part.position.setPosition( container->getPositions()[0][idxExtract], - container->getPositions()[1][idxExtract], - container->getPositions()[2][idxExtract]); + container->getPositions()[1][idxExtract], + container->getPositions()[2][idxExtract]); container->removeParticles(&idxExtract, 1); return part; } @@ -85,7 +86,7 @@ int main(int argc, char ** argv){ typedef double FReal; typedef FTestCell CellClass; - typedef FBasicParticleContainer<0> ContainerClass; + typedef FBasicParticleContainer<FReal,0,FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; @@ -120,7 +121,7 @@ int main(int argc, char ** argv){ { - TestParticle* particles = new TestParticle[NbPart]; + TestParticle<FReal>* particles = new TestParticle<FReal>[NbPart]; for(int idxPart = 0 ; idxPart < NbPart ; ++idxPart){ particles[idxPart].position.setPosition( (BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/FReal(2.0))), @@ -128,16 +129,16 @@ int main(int argc, char ** argv){ (BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/FReal(2.0)))); } - FVector<TestParticle> finalParticles; - FLeafBalance balancer; - // FMpiTreeBuilder< FReal,TestParticle >::ArrayToTree(app.global(), particles, NbPart, - // FPoint<FReal>(BoxCenter,BoxCenter,BoxCenter), - // BoxWidth, tree.getHeight(), &finalParticles,&balancer); - FMpiTreeBuilder< FReal,TestParticle >::DistributeArrayToContainer(app.global(),particles, - NbPart, - FPoint<FReal>(BoxCenter,BoxCenter,BoxCenter), - BoxWidth,NbLevels, - &finalParticles, &balancer); + FVector<TestParticle<FReal>> finalParticles; + FLeafBalance balancer; + // FMpiTreeBuilder< FReal,TestParticle<FReal> >::ArrayToTree(app.global(), particles, NbPart, + // FPoint<FReal>(BoxCenter,BoxCenter,BoxCenter), + // BoxWidth, tree.getHeight(), &finalParticles,&balancer); + FMpiTreeBuilder< FReal,TestParticle<FReal> >::DistributeArrayToContainer(app.global(),particles, + NbPart, + FPoint<FReal>(BoxCenter,BoxCenter,BoxCenter), + BoxWidth,NbLevels, + &finalParticles, &balancer); for(int idx = 0 ; idx < finalParticles.getSize(); ++idx){ tree.insert(finalParticles[idx].position); } @@ -176,7 +177,7 @@ int main(int argc, char ** argv){ std::cout << "Arrange ..." << std::endl; counter.tic(); - FOctreeArrangerProc<OctreeClass, ContainerClass, TestParticle, Converter<TestParticle> > arrange(&tree); + FOctreeArrangerProc<FReal, OctreeClass, ContainerClass, TestParticle<FReal>, Converter<FReal, TestParticle<FReal>> > arrange(&tree); arrange.rearrange(app.global()); counter.tac(); @@ -203,8 +204,8 @@ int main(int argc, char ** argv){ ContainerClass* particles = octreeIterator.getCurrentListTargets(); for(int idxPart = 0; idxPart < particles->getNbParticles() ; ++idxPart){ const FPoint<FReal> particlePosition( particles->getWPositions()[0][idxPart], - particles->getWPositions()[1][idxPart], - particles->getWPositions()[2][idxPart]); + particles->getWPositions()[1][idxPart], + particles->getWPositions()[2][idxPart]); const MortonIndex particleIndex = tree.getMortonFromPosition( particlePosition ); if( leafIndex != particleIndex){ diff --git a/Tests/Utils/testOctreeRearrangeTsm.cpp b/Tests/Utils/testOctreeRearrangeTsm.cpp index ed2a871f5..4f6f8cb80 100644 --- a/Tests/Utils/testOctreeRearrangeTsm.cpp +++ b/Tests/Utils/testOctreeRearrangeTsm.cpp @@ -55,11 +55,11 @@ int main(int argc, char ** argv){ typedef FBasicCell CellClass; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; - typedef FTypedLeaf< ContainerClass > LeafClass; + typedef FTypedLeaf< FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; - typedef FParticleTypedIndexedMover<OctreeClass, ContainerClass> MoverClass; - typedef FOctreeArranger<OctreeClass, ContainerClass, MoverClass> ArrangerClass; + typedef FParticleTypedIndexedMover<FReal, OctreeClass, ContainerClass> MoverClass; + typedef FOctreeArranger<FReal, OctreeClass, ContainerClass, MoverClass> ArrangerClass; ///////////////////////What we do///////////////////////////// std::cout << ">> This executable has to be used to test the FMM algorithm.\n"; @@ -153,7 +153,7 @@ int main(int argc, char ** argv){ std::cout << "Arrange ..." << std::endl; counter.tic(); - //FOctreeArranger<OctreeClass, ContainerClass, TestParticle, Converter<TestParticle> > arrange(&tree); + //FOctreeArranger<FReal,OctreeClass, ContainerClass, TestParticle, Converter<TestParticle> > arrange(&tree); arrange.rearrange(); diff --git a/Tests/Utils/testStatsTree.cpp b/Tests/Utils/testStatsTree.cpp index 4b6d0d3a7..597289dd0 100644 --- a/Tests/Utils/testStatsTree.cpp +++ b/Tests/Utils/testStatsTree.cpp @@ -58,9 +58,9 @@ int main(int argc, char ** argv){ typedef double FReal; - typedef FBasicParticleContainer<0> ContainerClass; + typedef FBasicParticleContainer<FReal,0,FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; - typedef FOctree< FBasicCell, ContainerClass , LeafClass > OctreeClass; + typedef FOctree<FReal, FBasicCell, ContainerClass , LeafClass > OctreeClass; ///////////////////////What we do///////////////////////////// std::cout << ">> This executable has to be used to show some stat about the tree.\n"; ////////////////////////////////////////////////////////////// diff --git a/Tests/Utils/testTreeBuilderThread.cpp b/Tests/Utils/testTreeBuilderThread.cpp index cbfc95f60..b9215ab70 100644 --- a/Tests/Utils/testTreeBuilderThread.cpp +++ b/Tests/Utils/testTreeBuilderThread.cpp @@ -48,7 +48,7 @@ int main(int argc, char** argv){ static const int P = 9; - typedef FRotationCell<P> CellClass; + typedef FRotationCell<FReal,P> CellClass; typedef FP2PParticleContainer<FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; @@ -82,7 +82,7 @@ int main(int argc, char** argv){ particles.push(particlePosition, physicalValue ); } - FTreeBuilder<OctreeClass, LeafClass>::BuildTreeFromArray(&tree, particles); + FTreeBuilder<FReal,OctreeClass, LeafClass>::BuildTreeFromArray(&tree, particles); } // ----------------------------------------------------- diff --git a/Tests/Utils/testTreeIO.cpp b/Tests/Utils/testTreeIO.cpp index dd02aeb67..00bdf848b 100644 --- a/Tests/Utils/testTreeIO.cpp +++ b/Tests/Utils/testTreeIO.cpp @@ -54,7 +54,7 @@ int main(int argc, char ** argv){ typedef double FReal; - typedef FSphericalCell CellClass; + typedef FSphericalCell<FReal> CellClass; typedef FP2PParticleContainer<FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; @@ -97,13 +97,13 @@ int main(int argc, char ** argv){ std::cout << "Save tree in binary format ..." << std::endl; - FTreeIO::Save<OctreeClass, CellClass, LeafClass, ContainerClass >(filenameOUT.c_str(), tree); + FTreeIO<FReal>::Save<OctreeClass, CellClass, LeafClass, ContainerClass >(filenameOUT.c_str(), tree); // ----------------------------------------------------- std::cout << "Load tree in binary format ..." << std::endl; - FTreeIO::Load<OctreeClass, CellClass, LeafClass, ContainerClass >(filenameOUT.c_str(),tree); + FTreeIO<FReal>::Load<OctreeClass, CellClass, LeafClass, ContainerClass >(filenameOUT.c_str(),tree); return 0; } diff --git a/Tests/Utils/testUnifInterpolator.cpp b/Tests/Utils/testUnifInterpolator.cpp index bea5b8036..59dad5df2 100644 --- a/Tests/Utils/testUnifInterpolator.cpp +++ b/Tests/Utils/testUnifInterpolator.cpp @@ -119,7 +119,7 @@ int main(int argc, char ** argv){ // approximative computation const unsigned int ORDER = 4; const unsigned int nnodes = TensorTraits<ORDER>::nnodes; - typedef FUnifInterpolator<ORDER,MatrixKernelClass> InterpolatorClass; + typedef FUnifInterpolator<FReal,ORDER,MatrixKernelClass> InterpolatorClass; InterpolatorClass S; std::cout << "\nCompute interactions approximatively, interpolation order = " << ORDER << " ..." << std::endl; @@ -135,8 +135,8 @@ int main(int argc, char ** argv){ time.tic(); // Multipole to local: F_m = \sum_n^L K(\bar x_m, \bar y_n) * W_n FPoint<FReal> rootsX[nnodes], rootsY[nnodes]; - FUnifTensor<ORDER>::setRoots(cx, width, rootsX); - FUnifTensor<ORDER>::setRoots(cy, width, rootsY); + FUnifTensor<FReal,ORDER>::setRoots(cx, width, rootsX); + FUnifTensor<FReal,ORDER>::setRoots(cy, width, rootsY); FReal F[nnodes]; // local expansion for (unsigned int i=0; i<nnodes; ++i) { @@ -178,7 +178,7 @@ int main(int argc, char ** argv){ const unsigned int rc = (2*ORDER-1)*(2*ORDER-1)*(2*ORDER-1); FReal C[rc]; - typedef FUnifTensor<ORDER> TensorType; + typedef FUnifTensor<FReal,ORDER> TensorType; unsigned int node_diff[nnodes*nnodes]; TensorType::setNodeIdsDiff(node_diff); unsigned int node_ids[nnodes][3]; @@ -336,7 +336,7 @@ int main(int argc, char ** argv){ const int dimfft = 1; const int steps[dimfft] = {rc}; //FDft Dft(rc); // direct version - FFft<dimfft> Dft; // fast version + FFft<FReal,dimfft> Dft; // fast version Dft.buildDFT(steps); // Get first COLUMN of K and Store in T diff --git a/Tests/Utils/testUnifTensorialInterpolator.cpp b/Tests/Utils/testUnifTensorialInterpolator.cpp index c6f8e8d45..de102c94e 100644 --- a/Tests/Utils/testUnifTensorialInterpolator.cpp +++ b/Tests/Utils/testUnifTensorialInterpolator.cpp @@ -63,7 +63,7 @@ int main(int argc, char ** argv){ typedef double FReal; - typedef FInterpMatrixKernel_R_IJ MatrixKernelClass; + typedef FInterpMatrixKernel_R_IJ<FReal> MatrixKernelClass; const double a = 0.0; // core width (Beware! if diff from 0. then Kernel should be NON HOMOGENEOUS !!!) const unsigned int ncmp = MatrixKernelClass::NCMP; @@ -71,7 +71,7 @@ int main(int argc, char ** argv){ const unsigned int nlhs = MatrixKernelClass::NLHS; const unsigned int npot = MatrixKernelClass::NPOT; - typedef FP2PParticleContainer<nrhs,nlhs> ContainerClass; + typedef FP2PParticleContainer<FReal,nrhs,nlhs> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass> LeafClass; ///////////////////////What we do///////////////////////////// @@ -129,7 +129,7 @@ int main(int argc, char ** argv){ // approximative computation const unsigned int ORDER = 6; const unsigned int nnodes = TensorTraits<ORDER>::nnodes; - typedef FUnifInterpolator<ORDER,MatrixKernelClass> InterpolatorClass; + typedef FUnifInterpolator<FReal,ORDER,MatrixKernelClass> InterpolatorClass; InterpolatorClass S; MatrixKernelClass MatrixKernel; @@ -147,8 +147,8 @@ int main(int argc, char ** argv){ time.tic(); // Multipole to local: F_m = \sum_n^L K(\bar x_m, \bar y_n) * W_n FPoint<FReal> rootsX[nnodes], rootsY[nnodes]; - FUnifTensor<ORDER>::setRoots(cx, width, rootsX); - FUnifTensor<ORDER>::setRoots(cy, width, rootsY); + FUnifTensor<FReal,ORDER>::setRoots(cx, width, rootsX); + FUnifTensor<FReal,ORDER>::setRoots(cy, width, rootsY); FReal F[nlhs*nnodes]; // local expansion for (unsigned int i=0; i<nnodes*nlhs; ++i) F[i] = FReal(0.); @@ -220,7 +220,7 @@ int main(int argc, char ** argv){ const unsigned int rc = (2*ORDER-1)*(2*ORDER-1)*(2*ORDER-1); FReal C[ncmp*rc]; - typedef FUnifTensor<ORDER> TensorType; + typedef FUnifTensor<FReal,ORDER> TensorType; unsigned int node_diff[nnodes*nnodes]; TensorType::setNodeIdsDiff(node_diff); unsigned int node_ids_pairs[rc][2]; @@ -363,7 +363,7 @@ int main(int argc, char ** argv){ const int dimfft = 1; const int steps[dimfft] = {rc}; //FDft Dft(rc); // direct version - FFft<dimfft> Dft; // fast version + FFft<FReal,dimfft> Dft; // fast version Dft.buildDFT(steps); // Get first COLUMN of K and Store in T diff --git a/Tests/noDist/testAdaptiveUnifFMM.cpp b/Tests/noDist/testAdaptiveUnifFMM.cpp index 8e71d1256..c83ab1357 100644 --- a/Tests/noDist/testAdaptiveUnifFMM.cpp +++ b/Tests/noDist/testAdaptiveUnifFMM.cpp @@ -106,12 +106,12 @@ int main(int argc, char ** argv){ const int sminL = FParameters::getValue(argc,argv,LocalOptionMinLocalThreshod.options, P*P*P); // typedef double FReal; - typedef FUnifCell<P> CellClass; + typedef FUnifCell<FReal,P> CellClass; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; typedef FSimpleIndexedLeaf<FReal,ContainerClass> LeafClass; typedef FInterpMatrixKernelR<FReal> MatrixKernelClass; // - typedef FAdaptiveUnifKernel<CellClass,ContainerClass,MatrixKernelClass,P> KernelClass; + typedef FAdaptiveUnifKernel<FReal,CellClass,ContainerClass,MatrixKernelClass,P> KernelClass; // // typedef FAdaptiveCell< CellClass, ContainerClass > CellWrapperClass; diff --git a/Tests/noDist/testBlockedUniform.cpp b/Tests/noDist/testBlockedUniform.cpp index de3d70a03..765a15129 100644 --- a/Tests/noDist/testBlockedUniform.cpp +++ b/Tests/noDist/testBlockedUniform.cpp @@ -65,24 +65,24 @@ int main(int argc, char* argv[]){ typedef FInterpMatrixKernelR<FReal> MatrixKernelClass; typedef FUnifCellPODCore GroupCellSymbClass; - typedef FUnifCellPODPole<ORDER> GroupCellUpClass; - typedef FUnifCellPODLocal<ORDER> GroupCellDownClass; - typedef FUnifCellPOD<ORDER> GroupCellClass; + typedef FUnifCellPODPole<FReal,ORDER> GroupCellUpClass; + typedef FUnifCellPODLocal<FReal,ORDER> GroupCellDownClass; + typedef FUnifCellPOD<FReal,ORDER> GroupCellClass; typedef FP2PGroupParticleContainer<FReal> GroupContainerClass; typedef FGroupTree< FReal, GroupCellClass, GroupCellSymbClass, GroupCellUpClass, GroupCellDownClass, GroupContainerClass, 1, 4, FReal> GroupOctreeClass; #ifdef ScalFMM_USE_STARPU - typedef FStarPUAllCpuCapacities<FUnifKernel<GroupCellClass,GroupContainerClass,MatrixKernelClass,ORDER>> GroupKernelClass; + typedef FStarPUAllCpuCapacities<FUnifKernel<FReal,GroupCellClass,GroupContainerClass,MatrixKernelClass,ORDER>> GroupKernelClass; typedef FStarPUCpuWrapper<typename GroupOctreeClass::CellGroupClass, GroupCellClass, GroupKernelClass, typename GroupOctreeClass::ParticleGroupClass, GroupContainerClass> GroupCpuWrapper; typedef FGroupTaskStarPUAlgorithm<GroupOctreeClass, typename GroupOctreeClass::CellGroupClass, GroupKernelClass, typename GroupOctreeClass::ParticleGroupClass, GroupCpuWrapper > GroupAlgorithm; #elif defined(ScalFMM_USE_OMP4) - typedef FUnifKernel<GroupCellClass,GroupContainerClass,MatrixKernelClass,ORDER> GroupKernelClass; + typedef FUnifKernel<FReal,GroupCellClass,GroupContainerClass,MatrixKernelClass,ORDER> GroupKernelClass; // Set the number of threads omp_set_num_threads(FParameters::getValue(argc,argv,FParameterDefinitions::NbThreads.options, omp_get_max_threads())); typedef FGroupTaskDepAlgorithm<GroupOctreeClass, typename GroupOctreeClass::CellGroupClass, GroupCellClass, GroupCellSymbClass, GroupCellUpClass, GroupCellDownClass, GroupKernelClass, typename GroupOctreeClass::ParticleGroupClass, GroupContainerClass > GroupAlgorithm; #else - typedef FUnifKernel<GroupCellClass,GroupContainerClass,MatrixKernelClass,ORDER> GroupKernelClass; + typedef FUnifKernel<FReal,GroupCellClass,GroupContainerClass,MatrixKernelClass,ORDER> GroupKernelClass; //typedef FGroupSeqAlgorithm<GroupOctreeClass, typename GroupOctreeClass::CellGroupClass, GroupCellClass, GroupKernelClass, typename GroupOctreeClass::ParticleGroupClass, GroupContainerClass > GroupAlgorithm; typedef FGroupTaskAlgorithm<GroupOctreeClass, typename GroupOctreeClass::CellGroupClass, GroupCellClass, GroupKernelClass, typename GroupOctreeClass::ParticleGroupClass, GroupContainerClass > GroupAlgorithm; #endif diff --git a/Tests/noDist/testCompareKernels.cpp b/Tests/noDist/testCompareKernels.cpp index 35d812ba1..8812ac3f2 100644 --- a/Tests/noDist/testCompareKernels.cpp +++ b/Tests/noDist/testCompareKernels.cpp @@ -213,11 +213,11 @@ int main(int argc, char* argv[]) const int DevP = FParameters::getValue(argc, argv, FParameterDefinitions::SHDevelopment.options, 11); // typedefs - typedef FSphericalCell CellClass; + typedef FSphericalCell<FReal> CellClass; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; - typedef FSphericalBlockBlasKernel< CellClass, ContainerClass > KernelClass; + typedef FSphericalBlockBlasKernel<FReal, CellClass, ContainerClass > KernelClass; typedef FFmmAlgorithmThread<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; // init cell class and oct-tree diff --git a/Tests/noDist/testInsert.cpp b/Tests/noDist/testInsert.cpp index 39993f370..2aac44c5f 100644 --- a/Tests/noDist/testInsert.cpp +++ b/Tests/noDist/testInsert.cpp @@ -115,10 +115,10 @@ int main(int argc, char** argv){ }; - + typedef double FReal; static const int P = 9; - typedef FRotationCell<P> CellClass; + typedef FRotationCell<FReal,P> CellClass; typedef FP2PParticleContainer<FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; diff --git a/Tests/noDist/testMpiInsert.cpp b/Tests/noDist/testMpiInsert.cpp index 01056baec..8887a9b66 100644 --- a/Tests/noDist/testMpiInsert.cpp +++ b/Tests/noDist/testMpiInsert.cpp @@ -109,7 +109,7 @@ int main(int argc, char** argv){ static const int P = 9; - typedef FRotationCell<P> CellClass; + typedef FRotationCell<FReal,P> CellClass; typedef FP2PParticleContainer<FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; @@ -143,8 +143,8 @@ int main(int argc, char** argv){ //Store the parts - FmaRWParticle<4,4>* particles = new FmaRWParticle<4,4>[loaderRef.getNumberOfParticles()]; - memset(particles, 0, sizeof(FmaRWParticle<4,4>) * loaderRef.getNumberOfParticles()); + FmaRWParticle<FReal, 4,4>* particles = new FmaRWParticle<FReal,4,4>[loaderRef.getNumberOfParticles()]; + memset(particles, 0, sizeof(FmaRWParticle<FReal,4,4>) * loaderRef.getNumberOfParticles()); for(int idxPart = 0 ; idxPart < loaderRef.getNumberOfParticles() ; ++idxPart){ FPoint<FReal> pos; @@ -152,9 +152,9 @@ int main(int argc, char** argv){ particles[idxPart].setPosition(pos); } - FVector<FmaRWParticle<4,4>> finalParticles; + FVector<FmaRWParticle<FReal,4,4>> finalParticles; FLeafBalance balancer; - FMpiTreeBuilder< FReal,FmaRWParticle<4,4> >::DistributeArrayToContainer(app.global(),particles, + FMpiTreeBuilder< FReal,FmaRWParticle<FReal,4,4> >::DistributeArrayToContainer(app.global(),particles, loaderRef.getMyNumberOfParticles(), treeRef.getBoxCenter(), treeRef.getBoxWidth(),treeRef.getHeight(), @@ -190,8 +190,8 @@ int main(int argc, char** argv){ //Temporary TreeCoordinate FTreeCoordinate host; - FmaRWParticle<4,4> * arrayOfParts = new FmaRWParticle<4,4>[nbOfParticles]; - memset(arrayOfParts,0,sizeof(FmaRWParticle<4,4>)*nbOfParticles); + FmaRWParticle<FReal,4,4> * arrayOfParts = new FmaRWParticle<FReal,4,4>[nbOfParticles]; + memset(arrayOfParts,0,sizeof(FmaRWParticle<FReal,4,4>)*nbOfParticles); fillTimer.tic(); @@ -206,11 +206,11 @@ int main(int argc, char** argv){ std::cout << "Time needed for filling the array : "<< fillTimer.elapsed() << " secondes !" << std::endl; OctreeClass tree(NbLevels, SizeSubLevels, loaderRef.getBoxWidth(), loaderRef.getCenterOfBox()); - FVector< FmaRWParticle<4,4> > finalParticles; + FVector< FmaRWParticle<FReal,4,4> > finalParticles; FLeafBalance balancer; FTic paraSort; paraSort.tic(); - FMpiTreeBuilder< FReal,FmaRWParticle<4,4> >::DistributeArrayToContainer(app.global(),arrayOfParts, + FMpiTreeBuilder< FReal,FmaRWParticle<FReal,4,4> >::DistributeArrayToContainer(app.global(),arrayOfParts, loader.getMyNumberOfParticles(), tree.getBoxCenter(), tree.getBoxWidth(),tree.getHeight(), @@ -229,7 +229,7 @@ int main(int argc, char** argv){ FTic treeBuilder; treeBuilder.tic(); - FTreeBuilder<OctreeClass,LeafClass>::BuildTreeFromArray(&tree,parts,true); + FTreeBuilder<FReal,OctreeClass,LeafClass>::BuildTreeFromArray(&tree,parts,true); treeBuilder.tac(); std::cout << "Time needed for TreeBuilder : "<< treeBuilder.elapsed() << " secondes !" << std::endl; #define CHECK_TREE diff --git a/Tests/noDist/testNewCompareKernels.cpp b/Tests/noDist/testNewCompareKernels.cpp index d9d8cfc04..d789498cb 100644 --- a/Tests/noDist/testNewCompareKernels.cpp +++ b/Tests/noDist/testNewCompareKernels.cpp @@ -312,11 +312,11 @@ int main(int argc, char* argv[]) std::cout << "\n FFmaBlas FMM ... P: " <<DevP << std::endl; // typedefs - typedef FSphericalCell CellClass; + typedef FSphericalCell<FReal> CellClass; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; - typedef FSphericalBlockBlasKernel< CellClass, ContainerClass > KernelClass; + typedef FSphericalBlockBlasKernel<FReal, CellClass, ContainerClass > KernelClass; typedef FFmmAlgorithmThread<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; // init cell class and oct-tree @@ -380,11 +380,11 @@ int main(int argc, char* argv[]) std::cout << "\nFFmaBlas FMM ... P: " <<DevP << std::endl; // typedefs - typedef FSphericalCell CellClass; + typedef FSphericalCell<FReal> CellClass; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; - typedef FSphericalBlasKernel< CellClass, ContainerClass > KernelClass; + typedef FSphericalBlasKernel<FReal, CellClass, ContainerClass > KernelClass; typedef FFmmAlgorithmThread<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; // init cell class and oct-tree @@ -448,11 +448,11 @@ int main(int argc, char* argv[]) std::cout << "\nFFmaBlockBlas FMM ... P: " <<DevP << std::endl; // typedefs - typedef FSphericalCell CellClass; + typedef FSphericalCell<FReal> CellClass; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; - typedef FSphericalBlockBlasKernel< CellClass, ContainerClass > KernelClass; + typedef FSphericalBlockBlasKernel< FReal, CellClass, ContainerClass > KernelClass; typedef FFmmAlgorithmThread<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; // init cell class and oct-tree @@ -604,11 +604,11 @@ int main(int argc, char* argv[]) // { //const static int P = 10; - typedef FSphericalCell CellClass; + typedef FSphericalCell<FReal> CellClass; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; - typedef FSphericalKernel< CellClass, ContainerClass > KernelClass; + typedef FSphericalKernel< FReal, CellClass, ContainerClass > KernelClass; typedef FFmmAlgorithmThread<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; OctreeClass tree(TreeHeight, SubTreeHeight, loader.getBoxWidth(), loader.getCenterOfBox()); @@ -676,11 +676,11 @@ int main(int argc, char* argv[]) // { const static int P = 11; - typedef FRotationCell<P> CellClass; + typedef FRotationCell<FReal,P> CellClass; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; - typedef FRotationKernel< CellClass, ContainerClass , P> KernelClass; + typedef FRotationKernel< FReal, CellClass, ContainerClass , P> KernelClass; typedef FFmmAlgorithmThread<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; OctreeClass tree(TreeHeight, SubTreeHeight, loader.getBoxWidth(), loader.getCenterOfBox()); @@ -750,13 +750,13 @@ int main(int argc, char* argv[]) const unsigned int ORDER = 10; // typedefs - typedef FTaylorCell<ORDER,1> CellClass; + typedef FTaylorCell<FReal,ORDER,1> CellClass; std::cout << "\nFFmaTaylor FMM ... ORDER: " << ORDER << std::endl; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; - typedef FTaylorKernel<CellClass,ContainerClass,ORDER,1> KernelClass; + typedef FTaylorKernel<FReal,CellClass,ContainerClass,ORDER,1> KernelClass; typedef FFmmAlgorithmThread<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; // init cell class and oct-tree diff --git a/Tests/noDist/testP2PAvx.cpp b/Tests/noDist/testP2PAvx.cpp index 2a49631e0..9bbe0f2fa 100644 --- a/Tests/noDist/testP2PAvx.cpp +++ b/Tests/noDist/testP2PAvx.cpp @@ -56,125 +56,125 @@ // Simply create particles and try the kernels int main(int argc, char ** argv){ - // - ///////////////////////What we do///////////////////////////// - FHelpDescribeAndExit(argc, argv, - "This executable has to be used to compute interaction either for periodic or non periodic system.\n" - "Example -fin filenameIN.{fma or bfma)\n" - "Default input file : ../Data/unitCubeXYZQ20k.fma\n" - "For the input file, the extension specifies if the file is binary or not.\n", - FParameterDefinitions::InputFile); - - ////////////////////////////////////////////////////////////// - - const std::string defaultFile(/*SCALFMMDataPath+*/"../Data/unitCubeXYZQ20k.fma"); - const std::string filenameIn(FParameters::getStr(argc,argv,FParameterDefinitions::InputFile.options, defaultFile.c_str())); - - typedef double FReal; - - FTic counter; - - // ----------------------------------------------------- - // LOADER - // ----------------------------------------------------- - // --------------------------------------------------------------------------------- - // Read particles in the Octree - // --------------------------------------------------------------------------------- - std::cout << "Opening : " << filenameIn << "\n"; - // - FFmaGenericLoader<FReal> loader(filenameIn); - // - int nbParticles = static_cast<int>(loader.getNumberOfParticles()); - std::cout << "Read " << nbParticles << " particles ..." << std::endl; - double BoxWith=loader.getBoxWidth(); - FPoint<FReal> Centre(loader.getCenterOfBox().getX(), loader.getCenterOfBox().getY() , loader.getCenterOfBox().getZ()); - std::cout << "\tWidth : " <<BoxWith << " \t center x : " << loader.getCenterOfBox().getX() - << " y : " << loader.getCenterOfBox().getY() << " z : " << loader.getCenterOfBox().getZ() << std::endl; - - counter.tic(); - FmaRParticle * particles = new FmaRParticle[nbParticles]; - memset(particles, 0, sizeof(FmaRParticle) * nbParticles) ; - // - double totalCharge = 0.0; - // -// int nbDataToRead = particles[0].getReadDataNumber(); - for(int idx = 0 ; idx<nbParticles ; ++idx){ - // - loader.fillParticle(particles[idx].getPtrFirstData(), particles[idx].getReadDataNumber()); - totalCharge += particles[idx].getPhysicalValue() ; - } - - counter.tac(); - - std::cout << std::endl; - std::cout << "Total Charge = "<< totalCharge <<std::endl; - std::cout << std::endl; - - std::cout << "Done " << "(@ reading Particles " << counter.elapsed() << " s)." << std::endl; - //Need to copy particles to ContainerClass -> FP2PParticleContainer - typedef FBasicCell CellClass; - typedef FP2PParticleContainer<FReal> ContainerClass; - - typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; - typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; - - OctreeClass tree(2, 1, loader.getBoxWidth(), loader.getCenterOfBox()); - for(int idxP=0 ; idxP<nbParticles ; ++idxP){ - tree.insert(particles[idxP].getPosition(),particles[idxP].getPhysicalValue()); - } - int k=0; - // tree.forEachLeaf([&](LeafClass * leaf){ - // printf("leaf : %d\n",k++ ); - // }); - // - // ---------------------------------------------------------------------------------------------------------- - // COMPUTATION - // ---------------------------------------------------------------------------------------------------------- - // - // computation - // - printf("Precision, sizeof Real %lu\n", sizeof(FReal)); - -#ifdef ScalFMM_USE_AVX - printf("AVX incomming .......\n\n"); -#endif - -#ifdef ScalFMM_USE_SSE - printf("SSE incomming .......\n\n"); -#endif - -#ifndef ScalFMM_USE_SSE -#ifndef ScalFMM_USE_AVX - printf("Classic incomming ...\n\n"); -#endif -#endif - counter.tic(); - { - typename OctreeClass::Iterator iterator(&tree); - iterator.gotoBottomLeft(); - - do{ - FTreeCoordinate coord = iterator.getCurrentGlobalCoordinate(); - ContainerClass** neighbors = new ContainerClass*[27]; - tree.getLeafsNeighbors(neighbors,coord,1); - FP2PRT<FReal>::FullMutual<ContainerClass>(iterator.getCurrentLeaf()->getTargets(),neighbors,27); - - }while(iterator.moveRight()); - } - counter.tac(); - std::cout << "Done " << "(@ Computation " << counter.elapsed() << " s)." << std::endl; - FReal cumulPot = 0.0; - k=0; - tree.forEachLeaf([&](LeafClass * leaf){ - int maxParts = leaf->getSrc()->getNbParticles(); - FReal* datas = leaf->getSrc()->getPotentials(); - for(int i=0 ; i<maxParts ; ++i){ - cumulPot += datas[i]; - } - printf("leaf : %d --> cumul pot %e : \n",k++, cumulPot); - }); - - - delete[] particles; - return 0; +// // +// ///////////////////////What we do///////////////////////////// +// FHelpDescribeAndExit(argc, argv, +// "This executable has to be used to compute interaction either for periodic or non periodic system.\n" +// "Example -fin filenameIN.{fma or bfma)\n" +// "Default input file : ../Data/unitCubeXYZQ20k.fma\n" +// "For the input file, the extension specifies if the file is binary or not.\n", +// FParameterDefinitions::InputFile); + +// ////////////////////////////////////////////////////////////// + +// const std::string defaultFile(/*SCALFMMDataPath+*/"../Data/unitCubeXYZQ20k.fma"); +// const std::string filenameIn(FParameters::getStr(argc,argv,FParameterDefinitions::InputFile.options, defaultFile.c_str())); + +// typedef double FReal; + +// FTic counter; + +// // ----------------------------------------------------- +// // LOADER +// // ----------------------------------------------------- +// // --------------------------------------------------------------------------------- +// // Read particles in the Octree +// // --------------------------------------------------------------------------------- +// std::cout << "Opening : " << filenameIn << "\n"; +// // +// FFmaGenericLoader<FReal> loader(filenameIn); +// // +// int nbParticles = static_cast<int>(loader.getNumberOfParticles()); +// std::cout << "Read " << nbParticles << " particles ..." << std::endl; +// double BoxWith=loader.getBoxWidth(); +// FPoint<FReal> Centre(loader.getCenterOfBox().getX(), loader.getCenterOfBox().getY() , loader.getCenterOfBox().getZ()); +// std::cout << "\tWidth : " <<BoxWith << " \t center x : " << loader.getCenterOfBox().getX() +// << " y : " << loader.getCenterOfBox().getY() << " z : " << loader.getCenterOfBox().getZ() << std::endl; + +// counter.tic(); +// FmaRParticle * particles = new FmaRParticle[nbParticles]; +// memset(particles, 0, sizeof(FmaRParticle) * nbParticles) ; +// // +// double totalCharge = 0.0; +// // +// // int nbDataToRead = particles[0].getReadDataNumber(); +// for(int idx = 0 ; idx<nbParticles ; ++idx){ +// // +// loader.fillParticle(particles[idx].getPtrFirstData(), particles[idx].getReadDataNumber()); +// totalCharge += particles[idx].getPhysicalValue() ; +// } + +// counter.tac(); + +// std::cout << std::endl; +// std::cout << "Total Charge = "<< totalCharge <<std::endl; +// std::cout << std::endl; + +// std::cout << "Done " << "(@ reading Particles " << counter.elapsed() << " s)." << std::endl; +// //Need to copy particles to ContainerClass -> FP2PParticleContainer +// typedef FBasicCell CellClass; +// typedef FP2PParticleContainer<FReal> ContainerClass; + +// typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; +// typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; + +// OctreeClass tree(2, 1, loader.getBoxWidth(), loader.getCenterOfBox()); +// for(int idxP=0 ; idxP<nbParticles ; ++idxP){ +// tree.insert(particles[idxP].getPosition(),particles[idxP].getPhysicalValue()); +// } +// int k=0; +// // tree.forEachLeaf([&](LeafClass * leaf){ +// // printf("leaf : %d\n",k++ ); +// // }); +// // +// // ---------------------------------------------------------------------------------------------------------- +// // COMPUTATION +// // ---------------------------------------------------------------------------------------------------------- +// // +// // computation +// // +// printf("Precision, sizeof Real %lu\n", sizeof(FReal)); + +//#ifdef ScalFMM_USE_AVX +// printf("AVX incomming .......\n\n"); +//#endif + +//#ifdef ScalFMM_USE_SSE +// printf("SSE incomming .......\n\n"); +//#endif + +//#ifndef ScalFMM_USE_SSE +//#ifndef ScalFMM_USE_AVX +// printf("Classic incomming ...\n\n"); +//#endif +//#endif +// counter.tic(); +// { +// typename OctreeClass::Iterator iterator(&tree); +// iterator.gotoBottomLeft(); + +// do{ +// FTreeCoordinate coord = iterator.getCurrentGlobalCoordinate(); +// ContainerClass** neighbors = new ContainerClass*[27]; +// tree.getLeafsNeighbors(neighbors,coord,1); +// FP2PRT<FReal>::FullMutual<ContainerClass>(iterator.getCurrentLeaf()->getTargets(),neighbors,27); + +// }while(iterator.moveRight()); +// } +// counter.tac(); +// std::cout << "Done " << "(@ Computation " << counter.elapsed() << " s)." << std::endl; +// FReal cumulPot = 0.0; +// k=0; +// tree.forEachLeaf([&](LeafClass * leaf){ +// int maxParts = leaf->getSrc()->getNbParticles(); +// FReal* datas = leaf->getSrc()->getPotentials(); +// for(int i=0 ; i<maxParts ; ++i){ +// cumulPot += datas[i]; +// } +// printf("leaf : %d --> cumul pot %e : \n",k++, cumulPot); +// }); + + +// delete[] particles; + return 0; } diff --git a/Tests/noDist/testSmallCase.cpp b/Tests/noDist/testSmallCase.cpp index f8f4333f4..06a2f8563 100644 --- a/Tests/noDist/testSmallCase.cpp +++ b/Tests/noDist/testSmallCase.cpp @@ -81,15 +81,16 @@ int main(int argc, char ** argv){ LocalOptionMinLocalThreshod); + typedef double FReal; const unsigned int P = 5 ; typedef FChebCell<FReal,P> CellClass; - //typedef FUnifCell<P> CellClass; + //typedef FUnifCell<FReal,P> CellClass; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; typedef FSimpleIndexedLeaf<FReal,ContainerClass> LeafClass; typedef FInterpMatrixKernelR<FReal> MatrixKernelClass; typedef FAdaptiveChebSymKernel<FReal,CellClass,ContainerClass,MatrixKernelClass,P> KernelClass; - //typedef FAdaptiveUnifKernel<CellClass,ContainerClass,MatrixKernelClass,P> KernelClass; + //typedef FAdaptiveUnifKernel<FReal,CellClass,ContainerClass,MatrixKernelClass,P> KernelClass; typedef FAdaptiveCell< CellClass, ContainerClass > CellWrapperClass; typedef FAdaptiveKernelWrapper< KernelClass, CellClass, ContainerClass > KernelWrapperClass; typedef FOctree< FReal, CellWrapperClass, ContainerClass , LeafClass > OctreeClass; @@ -108,7 +109,6 @@ int main(int argc, char ** argv){ ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// - typedef double FReal; const FReal boxWidth = 1.0; const FPoint<FReal> boxCenter(0.0, 0.0, 0.0); OctreeClass tree(NbLevels, SizeSubLevels, boxWidth, boxCenter); diff --git a/Tests/noDist/testSphericalBlasBlockProc.cpp b/Tests/noDist/testSphericalBlasBlockProc.cpp index 1c1b917d5..96a00b749 100644 --- a/Tests/noDist/testSphericalBlasBlockProc.cpp +++ b/Tests/noDist/testSphericalBlasBlockProc.cpp @@ -54,176 +54,176 @@ // Simply create particles and try the kernels int main(int argc, char ** argv){ FHelpDescribeAndExit(argc, argv, - "Test Spherical HArmonic kernel with blas.", - FParameterDefinitions::InputFile, FParameterDefinitions::OctreeHeight, - FParameterDefinitions::OctreeSubHeight, FParameterDefinitions::SHDevelopment, - FParameterDefinitions::NbThreads); + "Test Spherical HArmonic kernel with blas.", + FParameterDefinitions::InputFile, FParameterDefinitions::OctreeHeight, + FParameterDefinitions::OctreeSubHeight, FParameterDefinitions::SHDevelopment, + FParameterDefinitions::NbThreads); - typedef FSphericalCell CellClass; - typedef FP2PParticleContainer<FReal> ContainerClass; + typedef double FReal; + typedef FSphericalCell<FReal> CellClass; + typedef FP2PParticleContainer<FReal> ContainerClass; - typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; - typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; - typedef FSphericalBlockBlasKernel< CellClass, ContainerClass > KernelClass; + typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; + typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; + typedef FSphericalBlockBlasKernel< FReal, CellClass, ContainerClass > KernelClass; - typedef FFmmAlgorithmThreadProc<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; + typedef FFmmAlgorithmThreadProc<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; - ///////////////////////What we do///////////////////////////// - std::cout << ">> This executable has to be used to test Spherical algorithm.\n"; - ////////////////////////////////////////////////////////////// + ///////////////////////What we do///////////////////////////// + std::cout << ">> This executable has to be used to test Spherical algorithm.\n"; + ////////////////////////////////////////////////////////////// - FMpi app( argc, argv); + FMpi app( argc, argv); - const int DevP = FParameters::getValue(argc,argv,FParameterDefinitions::SHDevelopment.options, 8); - const int NbLevels = FParameters::getValue(argc,argv,FParameterDefinitions::OctreeHeight.options, 5); - const int SizeSubLevels = FParameters::getValue(argc,argv,FParameterDefinitions::OctreeSubHeight.options, 3); - FTic counter; - typedef double FReal; - const char* const defaultFilename = (sizeof(FReal) == sizeof(float))? - "../Data/test20k.bin.fma.single": - "../Data/test20k.bin.fma.double"; - const char* const filename = FParameters::getStr(argc,argv,FParameterDefinitions::InputFile.options, defaultFilename); - const int nbThreads = FParameters::getValue(argc,argv,FParameterDefinitions::NbThreads.options,8); - omp_set_num_threads(nbThreads); + const int DevP = FParameters::getValue(argc,argv,FParameterDefinitions::SHDevelopment.options, 8); + const int NbLevels = FParameters::getValue(argc,argv,FParameterDefinitions::OctreeHeight.options, 5); + const int SizeSubLevels = FParameters::getValue(argc,argv,FParameterDefinitions::OctreeSubHeight.options, 3); + FTic counter; + const char* const defaultFilename = (sizeof(FReal) == sizeof(float))? + "../Data/test20k.bin.fma.single": + "../Data/test20k.bin.fma.double"; + const char* const filename = FParameters::getStr(argc,argv,FParameterDefinitions::InputFile.options, defaultFilename); + const int nbThreads = FParameters::getValue(argc,argv,FParameterDefinitions::NbThreads.options,8); + omp_set_num_threads(nbThreads); - std::cout << "Opening : " << filename << "\n"; + std::cout << "Opening : " << filename << "\n"; - FMpiFmaGenericLoader<FReal> loader(filename, app.global()); - if(!loader.isOpen()){ - std::cout << "Loader Error, " << filename << " is missing\n"; - return 1; - } - - CellClass::Init(DevP,true); + FMpiFmaGenericLoader<FReal> loader(filename, app.global()); + if(!loader.isOpen()){ + std::cout << "Loader Error, " << filename << " is missing\n"; + return 1; + } + CellClass::Init(DevP,true); - OctreeClass tree(NbLevels, SizeSubLevels,loader.getBoxWidth(),loader.getCenterOfBox()); - // ----------------------------------------------------- + OctreeClass tree(NbLevels, SizeSubLevels,loader.getBoxWidth(),loader.getCenterOfBox()); - std::cout << "Creating & Inserting " << loader.getNumberOfParticles() << " particles ..." << std::endl; - std::cout << "\tHeight : " << NbLevels << " \t sub-height : " << SizeSubLevels << std::endl; - counter.tic(); + // ----------------------------------------------------- - if( app.global().processCount() != 1){ - ////////////////////////////////////////////////////////////////////////////////// - // Build tree from mpi loader - ////////////////////////////////////////////////////////////////////////////////// - std::cout << "Build Tree ..." << std::endl; + std::cout << "Creating & Inserting " << loader.getNumberOfParticles() << " particles ..." << std::endl; + std::cout << "\tHeight : " << NbLevels << " \t sub-height : " << SizeSubLevels << std::endl; counter.tic(); - struct TestParticle{ - FPoint<FReal> position; - FReal physicalValue; - const FPoint<FReal>& getPosition(){ - return position; - } - }; - - TestParticle* particles = new TestParticle[loader.getNumberOfParticles()]; - memset(particles, 0, sizeof(TestParticle) * loader.getNumberOfParticles()); - - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ - loader.fillParticle(&particles[idxPart].position,&particles[idxPart].physicalValue); + if( app.global().processCount() != 1){ + ////////////////////////////////////////////////////////////////////////////////// + // Build tree from mpi loader + ////////////////////////////////////////////////////////////////////////////////// + std::cout << "Build Tree ..." << std::endl; + counter.tic(); + + struct TestParticle{ + FPoint<FReal> position; + FReal physicalValue; + const FPoint<FReal>& getPosition(){ + return position; + } + }; + + TestParticle* particles = new TestParticle[loader.getNumberOfParticles()]; + memset(particles, 0, sizeof(TestParticle) * loader.getNumberOfParticles()); + + for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + loader.fillParticle(&particles[idxPart].position,&particles[idxPart].physicalValue); + } + + FVector<TestParticle> finalParticles; + FLeafBalance balancer; + // FMpiTreeBuilder< FReal,TestParticle >::ArrayToTree(app.global(), particles, loader.getNumberOfParticles(), + // tree.getBoxCenter(), + // tree.getBoxWidth(), + // tree.getHeight(), &finalParticles,&balancer); + FMpiTreeBuilder< FReal,TestParticle >::DistributeArrayToContainer(app.global(),particles, + loader.getMyNumberOfParticles(), + tree.getBoxCenter(), + tree.getBoxWidth(),tree.getHeight(), + &finalParticles, &balancer); + + ContainerClass parts; + parts.reserve(finalParticles.getSize()); + + //Convert ouput of DistributeArrayToContainer to a ContainerClass + for(int idxPart = 0; idxPart < finalParticles.getSize(); ++idxPart){ + + parts.push(finalParticles[idxPart].getPosition(),finalParticles[idxPart].physicalValue); + } + + + FTreeBuilder<FReal,OctreeClass,LeafClass>::BuildTreeFromArray(&tree,parts,true); + // for(int idx = 0 ; idx < finalParticles.getSize(); ++idx){ + // tree.insert(finalParticles[idx].position,finalParticles[idx].physicalValue); + + // } + + delete[] particles; + counter.tac(); + std::cout << "Done " << "(" << counter.elapsed() << "s)." << std::endl; + + ////////////////////////////////////////////////////////////////////////////////// } - - FVector<TestParticle> finalParticles; - FLeafBalance balancer; - // FMpiTreeBuilder< FReal,TestParticle >::ArrayToTree(app.global(), particles, loader.getNumberOfParticles(), - // tree.getBoxCenter(), - // tree.getBoxWidth(), - // tree.getHeight(), &finalParticles,&balancer); - FMpiTreeBuilder< FReal,TestParticle >::DistributeArrayToContainer(app.global(),particles, - loader.getMyNumberOfParticles(), - tree.getBoxCenter(), - tree.getBoxWidth(),tree.getHeight(), - &finalParticles, &balancer); - - ContainerClass parts; - parts.reserve(finalParticles.getSize()); - - //Convert ouput of DistributeArrayToContainer to a ContainerClass - for(int idxPart = 0; idxPart < finalParticles.getSize(); ++idxPart){ - - parts.push(finalParticles[idxPart].getPosition(),finalParticles[idxPart].physicalValue); + else{ + FPoint<FReal> position; + FReal physicalValue; + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + loader.fillParticle(&position,&physicalValue); + tree.insert(position, physicalValue); + } } - - FTreeBuilder<OctreeClass,LeafClass>::BuildTreeFromArray(&tree,parts,true); - // for(int idx = 0 ; idx < finalParticles.getSize(); ++idx){ - // tree.insert(finalParticles[idx].position,finalParticles[idx].physicalValue); - - // } - - delete[] particles; counter.tac(); - std::cout << "Done " << "(" << counter.elapsed() << "s)." << std::endl; - - ////////////////////////////////////////////////////////////////////////////////// - } - else{ - FPoint<FReal> position; - FReal physicalValue; - for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ - loader.fillParticle(&position,&physicalValue); - tree.insert(position, physicalValue); - } - } + std::cout << "Done " << "(@Creating and Inserting Particles = " << counter.elapsed() << "s)." << std::endl; - counter.tac(); - std::cout << "Done " << "(@Creating and Inserting Particles = " << counter.elapsed() << "s)." << std::endl; + // ----------------------------------------------------- + std::cout << "Create kernel..." << std::endl; - // ----------------------------------------------------- - std::cout << "Create kernel..." << std::endl; + KernelClass kernels(DevP, NbLevels,loader.getBoxWidth(), loader.getCenterOfBox()); - KernelClass kernels(DevP, NbLevels,loader.getBoxWidth(), loader.getCenterOfBox()); + std::cout << "Done " << " in " << counter.elapsed() << "s)." << std::endl; - std::cout << "Done " << " in " << counter.elapsed() << "s)." << std::endl; + // ----------------------------------------------------- - // ----------------------------------------------------- + std::cout << "Working on particles ..." << std::endl; - std::cout << "Working on particles ..." << std::endl; + FmmClass algo(app.global(),&tree,&kernels); - FmmClass algo(app.global(),&tree,&kernels); - - counter.tic(); - algo.execute(); - counter.tac(); + counter.tic(); + algo.execute(); + counter.tac(); - std::cout << "Done " << "(@Algorithm = " << counter.elapsed() << "s)." << std::endl; + std::cout << "Done " << "(@Algorithm = " << counter.elapsed() << "s)." << std::endl; - { // get sum forces&potential - FReal potential = 0; - FReal fx = 0.0, fy = 0.0, fz = 0.0; + { // get sum forces&potential + FReal potential = 0; + FReal fx = 0.0, fy = 0.0, fz = 0.0; - tree.forEachLeaf([&](LeafClass* leaf){ - const FReal*const potentials = leaf->getTargets()->getPotentials(); - const FReal*const forcesX = leaf->getTargets()->getForcesX(); - const FReal*const forcesY = leaf->getTargets()->getForcesY(); - const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + tree.forEachLeaf([&](LeafClass* leaf){ + const FReal*const potentials = leaf->getTargets()->getPotentials(); + const FReal*const forcesX = leaf->getTargets()->getForcesX(); + const FReal*const forcesY = leaf->getTargets()->getForcesY(); + const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); + const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - potential += potentials[idxPart]; - fx += forcesX[idxPart]; - fy += forcesY[idxPart]; - fz += forcesZ[idxPart]; - } - }); + for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + potential += potentials[idxPart]; + fx += forcesX[idxPart]; + fy += forcesY[idxPart]; + fz += forcesZ[idxPart]; + } + }); - std::cout << "My potential is " << potential << std::endl; + std::cout << "My potential is " << potential << std::endl; - potential = app.global().reduceSum(potential); - fx = app.global().reduceSum(fx); - fy = app.global().reduceSum(fy); - fz = app.global().reduceSum(fz); + potential = app.global().reduceSum(potential); + fx = app.global().reduceSum(fx); + fy = app.global().reduceSum(fy); + fz = app.global().reduceSum(fz); - if(app.global().processId() == 0){ - std::cout << "Foces Sum x = " << fx << " y = " << fy << " z = " << fz << std::endl; - std::cout << "Potential Sum = " << potential << std::endl; + if(app.global().processId() == 0){ + std::cout << "Foces Sum x = " << fx << " y = " << fy << " z = " << fz << std::endl; + std::cout << "Potential Sum = " << potential << std::endl; + } } - } - return 0; + return 0; } diff --git a/Tests/noDist/testSphericalBlasProc.cpp b/Tests/noDist/testSphericalBlasProc.cpp index 232856b8c..4a0c34e7a 100644 --- a/Tests/noDist/testSphericalBlasProc.cpp +++ b/Tests/noDist/testSphericalBlasProc.cpp @@ -58,12 +58,13 @@ int main(int argc, char ** argv){ FParameterDefinitions::OctreeSubHeight, FParameterDefinitions::SHDevelopment, FParameterDefinitions::NbThreads); - typedef FSphericalCell CellClass; + typedef double FReal; + typedef FSphericalCell<FReal> CellClass; typedef FP2PParticleContainer<FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; - typedef FSphericalBlasKernel< CellClass, ContainerClass > KernelClass; + typedef FSphericalBlasKernel<FReal, CellClass, ContainerClass > KernelClass; typedef FFmmAlgorithmThreadProc<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; @@ -78,7 +79,6 @@ int main(int argc, char ** argv){ const int NbLevels = FParameters::getValue(argc,argv,FParameterDefinitions::OctreeHeight.options, 5); const int SizeSubLevels = FParameters::getValue(argc,argv,FParameterDefinitions::OctreeSubHeight.options, 3); FTic counter; - typedef double FReal; const char* const defaultFilename = (sizeof(FReal) == sizeof(float))? "../Data/test20k.bin.fma.single": "../Data/test20k.bin.fma.double"; diff --git a/Tests/noDist/testSphericalDebug.cpp b/Tests/noDist/testSphericalDebug.cpp index 91151bb7e..d7ad0f04f 100644 --- a/Tests/noDist/testSphericalDebug.cpp +++ b/Tests/noDist/testSphericalDebug.cpp @@ -83,7 +83,7 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { Print("quarterDimLeaf:"); Print(quarterDimLeaf); - FSphericalCell::Init(DevP, isBlasKernel); + FSphericalCell<FReal>::Init(DevP, isBlasKernel); TestParticle* const particles = new TestParticle[nbParticles]; particles[0].position = FPoint<FReal>(quarterDimLeaf, quarterDimLeaf, quarterDimLeaf); @@ -262,10 +262,10 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { void TestSpherical(){ typedef double FReal; - typedef FSphericalCell CellClass; + typedef FSphericalCell<FReal> CellClass; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; - typedef FSphericalKernel< CellClass, ContainerClass > KernelClass; + typedef FSphericalKernel< FReal, CellClass, ContainerClass > KernelClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; @@ -276,7 +276,7 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { << " $$$$$$$$$ TestSpherical $$$$$$$$$$$$$$$$"<<std::endl << " $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<std::endl; - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass>(false); } @@ -284,17 +284,17 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { void TestRotation(){ typedef double FReal; - typedef FSphericalCell CellClass; + typedef FSphericalCell<FReal> CellClass; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; - typedef FSphericalRotationKernel< CellClass, ContainerClass > KernelClass; + typedef FSphericalRotationKernel< FReal, CellClass, ContainerClass > KernelClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; typedef FFmmAlgorithm<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass>(false); } @@ -303,17 +303,17 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { void TestSphericalBlas(){ typedef double FReal; - typedef FSphericalCell CellClass; + typedef FSphericalCell<FReal> CellClass; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; - typedef FSphericalBlasKernel< CellClass, ContainerClass > KernelClass; + typedef FSphericalBlasKernel<FReal, CellClass, ContainerClass > KernelClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; typedef FFmmAlgorithm<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass>(true); } @@ -321,10 +321,10 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { void TestSphericalBlockBlas(){ typedef double FReal; - typedef FSphericalCell CellClass; + typedef FSphericalCell<FReal> CellClass; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; - typedef FSphericalBlockBlasKernel< CellClass, ContainerClass > KernelClass; + typedef FSphericalBlockBlasKernel< FReal, CellClass, ContainerClass > KernelClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; @@ -335,7 +335,7 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { << " $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<std::endl << " $$$$$$$$$ TestSphericalBlockBlas $$$$$$$$$$$$$$$$"<<std::endl << " $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<std::endl; - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass>(true); } #endif diff --git a/Tests/noDist/testTreeBuilder.cpp b/Tests/noDist/testTreeBuilder.cpp index 5dfcde940..5deb3ac90 100644 --- a/Tests/noDist/testTreeBuilder.cpp +++ b/Tests/noDist/testTreeBuilder.cpp @@ -120,12 +120,12 @@ int main(int argc, char** argv){ static const int P = 9; - typedef FRotationCell<P> CellClass; + typedef FRotationCell<FReal,P> CellClass; typedef FP2PParticleContainer<FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; - //typedef FRotationKernel< CellClass, ContainerClass , P> KernelClass; + //typedef FRotationKernel< FReal, CellClass, ContainerClass , P> KernelClass; //typedef FFmmAlgorithmThread<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClassThread; @@ -210,7 +210,7 @@ int main(int argc, char** argv){ parts.push(arrayOfParts[idxPart].getPosition(),arrayOfParts[idxPart].physicalValue); } - FTreeBuilder<OctreeClass,LeafClass>::BuildTreeFromArray(&tree,parts,false); + FTreeBuilder<FReal,OctreeClass,LeafClass>::BuildTreeFromArray(&tree,parts,false); return 0; } diff --git a/Tests/noDist/testUnifMultiRhs.cpp b/Tests/noDist/testUnifMultiRhs.cpp index ed8a94a5e..67b3eddba 100644 --- a/Tests/noDist/testUnifMultiRhs.cpp +++ b/Tests/noDist/testUnifMultiRhs.cpp @@ -169,9 +169,9 @@ int main(int argc, char* argv[]) const unsigned int ORDER = 5; // typedefs - typedef FP2PParticleContainerIndexed<1,1,NVALS> ContainerClass; + typedef FP2PParticleContainerIndexed<FReal,1,1,NVALS> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; - typedef FUnifCell<ORDER,1,1,NVALS> CellClass; + typedef FUnifCell<FReal,ORDER,1,1,NVALS> CellClass; typedef FOctree<FReal, CellClass,ContainerClass,LeafClass> OctreeClass; typedef FUnifKernel<FReal,CellClass,ContainerClass,MatrixKernelClass,ORDER,NVALS> KernelClass; typedef FFmmAlgorithm<OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass; diff --git a/ToRemove/AdaptiveTree/FAdaptTools.hpp b/ToRemove/AdaptiveTree/FAdaptTools.hpp index 307979ce2..aea07ba0e 100644 --- a/ToRemove/AdaptiveTree/FAdaptTools.hpp +++ b/ToRemove/AdaptiveTree/FAdaptTools.hpp @@ -168,7 +168,7 @@ void adaptiveTreeBuildLists(OctreeClass & tree) { } }; ///////////////////////////////////////////////////////////////////////////////////////// -//! \fn setGlobalID(FOctree< FAdaptCell, FBasicParticleContainer<0> , FSimpleLeaf< FBasicParticleContainer<0>> > & tree) { +//! \fn setGlobalID(FOctree< FAdaptCell, FBasicParticleContainer<FReal,0,FReal> , FSimpleLeaf< FBasicParticleContainer<FReal,0,FReal>> > & tree) { ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/ToRemove/AdaptiveTree/FAdaptUnifKernel.hpp b/ToRemove/AdaptiveTree/FAdaptUnifKernel.hpp index b59125b79..61c9af07f 100644 --- a/ToRemove/AdaptiveTree/FAdaptUnifKernel.hpp +++ b/ToRemove/AdaptiveTree/FAdaptUnifKernel.hpp @@ -132,7 +132,7 @@ public: // // // set child info // FPoint<FReal> ChildRoots[nnodes], localChildRoots[nnodes]; -// FUnifTensor<ORDER>::setRoots(subCellCenter, subCellWidth, ChildRoots); +// FUnifTensor<FReal,ORDER>::setRoots(subCellCenter, subCellWidth, ChildRoots); // // // map global position of roots to local position in parent cell // const map_glob_loc map(poleCellCenter, poleCellWidth); @@ -148,7 +148,7 @@ public: // Set sub-child coords FReal globalChildCoords[3][ORDER]; - FUnifTensor<order>::setPolynomialsRoots(subCellCenter, subCellWidth, globalChildCoords); + FUnifTensor<FReal,order>::setPolynomialsRoots(subCellCenter, subCellWidth, globalChildCoords); // Map global position of sub-child nodes to [-1,1] FReal localChildCoords[3][ORDER]; @@ -222,7 +222,7 @@ public: // interpolation points of target (X) cell FPoint<FReal> X[nnodes]; - FUnifTensor<order>::setRoots(localCellCenter, localCellWidth, X); + FUnifTensor<FReal,order>::setRoots(localCellCenter, localCellWidth, X); // read positions const FReal*const positionsX = particles->getPositions()[0]; @@ -262,8 +262,8 @@ public: // interpolation points of source (Y) and target (X) cell FPoint<FReal> X[nnodes], Y[nnodes]; - FUnifTensor<order>::setRoots(poleCellCenter, poleCellWidth, Y); - FUnifTensor<order>::setRoots(localCellCenter, localCellWidth, X); + FUnifTensor<FReal,order>::setRoots(poleCellCenter, poleCellWidth, Y); + FUnifTensor<FReal,order>::setRoots(localCellCenter, localCellWidth, X); for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){ @@ -287,7 +287,7 @@ public: // interpolation points of source (Y) cell FPoint<FReal> Y[nnodes]; - FUnifTensor<order>::setRoots(poleCellCenter, poleCellWidth, Y); + FUnifTensor<FReal,order>::setRoots(poleCellCenter, poleCellWidth, Y); // read positions const FReal*const positionsX = particles->getPositions()[0]; @@ -336,7 +336,7 @@ public: // // // set child info // FPoint<FReal> ChildRoots[nnodes], localChildRoots[nnodes]; -// FUnifTensor<ORDER>::setRoots(subCellCenter, subCellWidth, ChildRoots); +// FUnifTensor<FReal,ORDER>::setRoots(subCellCenter, subCellWidth, ChildRoots); // // // map global position of roots to local position in parent cell // const map_glob_loc map(localCenter, localWidth); @@ -350,7 +350,7 @@ public: /// p^4 version // Set sub-child coords FReal globalChildCoords[3][ORDER]; - FUnifTensor<order>::setPolynomialsRoots(subCellCenter, subCellWidth, globalChildCoords); + FUnifTensor<FReal,order>::setPolynomialsRoots(subCellCenter, subCellWidth, globalChildCoords); // Map global position of sub-child nodes to [-1,1] FReal localChildCoords[3][ORDER]; diff --git a/ToRemove/AdaptiveTree/statAdaptiveOctree.cpp b/ToRemove/AdaptiveTree/statAdaptiveOctree.cpp index 8b383de69..27a4d3b7b 100644 --- a/ToRemove/AdaptiveTree/statAdaptiveOctree.cpp +++ b/ToRemove/AdaptiveTree/statAdaptiveOctree.cpp @@ -81,7 +81,7 @@ void usage() { } int main(int argc, char ** argv){ - typedef FBasicParticleContainer<0> ContainerClass; + typedef FBasicParticleContainer<FReal,0,FReal> ContainerClass; typedef FSimpleIndexedLeaf<FReal,ContainerClass> LeafClass; typedef FAdaptCell<FBasicCell,LeafClass> CellClass; typedef FOctree<FReal, CellClass, ContainerClass, LeafClass > OctreeClass; diff --git a/ToRemove/Olivier/ChebyshevDirectPeriodic.cpp b/ToRemove/Olivier/ChebyshevDirectPeriodic.cpp index f15006c42..916d3c8f9 100644 --- a/ToRemove/Olivier/ChebyshevDirectPeriodic.cpp +++ b/ToRemove/Olivier/ChebyshevDirectPeriodic.cpp @@ -174,7 +174,7 @@ class TestChebyshevDirect : public FUTester<TestChebyshevDirect> { energyD += particles[idx].potential*particles[idx].physicalValue ; } - // FFmaGenericWriter writer("dataDirect250-Per2.bfma") ; + // FFmaGenericWriter<FReal> writer("dataDirect250-Per2.bfma") ; // writer.writeHeader( loader.getCenterOfBox(),loader.getBoxWidth(), // loader.getNumberOfParticles(),*particles1) ; // writer.writeArrayOfParticles(particles1, loader.getNumberOfParticles()); @@ -281,7 +281,7 @@ class TestChebyshevDirect : public FUTester<TestChebyshevDirect> { typedef FChebCell<FReal,ORDER> CellClass; typedef FOctree<FReal, CellClass,ContainerClass,LeafClass> OctreeClass; typedef FChebKernel<FReal,CellClass,ContainerClass,MatrixKernelClass,ORDER> KernelClass; - typedef FFmmAlgorithmPeriodic<OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass; + typedef FFmmAlgorithmPeriodic<FReal,OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass; // run test std::cout <<" TEST 1 "<<std::endl; RunTest<CellClass,ContainerClass,KernelClass,MatrixKernelClass,LeafClass,OctreeClass,FmmClass>(); @@ -296,7 +296,7 @@ class TestChebyshevDirect : public FUTester<TestChebyshevDirect> { typedef FChebCell<FReal,ORDER> CellClass; typedef FOctree<FReal, CellClass,ContainerClass,LeafClass> OctreeClass; typedef FChebSymKernel<FReal,CellClass,ContainerClass,MatrixKernelClass,ORDER> KernelClass; - typedef FFmmAlgorithmPeriodic<OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass; + typedef FFmmAlgorithmPeriodic<FReal,OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass; // run test std::cout <<std::endl<<" TEST 2 "<<std::endl; RunTest<CellClass,ContainerClass,KernelClass,MatrixKernelClass,LeafClass,OctreeClass,FmmClass>(); diff --git a/ToRemove/Olivier/adaptiveOctree.cpp b/ToRemove/Olivier/adaptiveOctree.cpp index 5040ce068..602ab7cf3 100644 --- a/ToRemove/Olivier/adaptiveOctree.cpp +++ b/ToRemove/Olivier/adaptiveOctree.cpp @@ -80,7 +80,7 @@ void usage() { } int main(int argc, char ** argv){ - typedef FBasicParticleContainer<0> ContainerClass; + typedef FBasicParticleContainer<FReal,0,FReal> ContainerClass; typedef FSimpleIndexedLeaf<FReal,ContainerClass> LeafClass; typedef FAdaptCell<FBasicCell,LeafClass> CellClass; typedef FOctree<FReal, CellClass, ContainerClass, LeafClass > OctreeClass; diff --git a/ToRemove/Olivier/statAdapt.cpp b/ToRemove/Olivier/statAdapt.cpp index 2ccd3f49d..8fdd6ac1c 100644 --- a/ToRemove/Olivier/statAdapt.cpp +++ b/ToRemove/Olivier/statAdapt.cpp @@ -79,7 +79,7 @@ void usage() { } int main(int argc, char ** argv){ - typedef FBasicParticleContainer<0> ContainerClass; + typedef FBasicParticleContainer<FReal,0,FReal> ContainerClass; typedef FSimpleIndexedLeaf<FReal,ContainerClass> LeafClass; typedef FAdaptCell<FBasicCell,LeafClass> CellClass; typedef FOctree<FReal, CellClass, ContainerClass, LeafClass > OctreeClass; diff --git a/ToRemove/Olivier/testFMMEwald.cpp b/ToRemove/Olivier/testFMMEwald.cpp index 6c2646481..296bb6e58 100644 --- a/ToRemove/Olivier/testFMMEwald.cpp +++ b/ToRemove/Olivier/testFMMEwald.cpp @@ -79,13 +79,13 @@ int main(int argc, char ** argv){ typedef FChebSymKernel<FReal,CellClass,ContainerClass,MatrixKernelClass,ORDER> KernelClass; #else - typedef FSphericalCell CellClass; + typedef FSphericalCell<FReal> CellClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; - typedef FSphericalKernel< CellClass, ContainerClass > KernelClass; + typedef FSphericalKernel< FReal, CellClass, ContainerClass > KernelClass; const int DevP = FParameters::getValue(argc,argv,"-P", 9); #endif - typedef FFmmAlgorithmPeriodic<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; + typedef FFmmAlgorithmPeriodic<FReal,OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; typedef FFmmAlgorithm<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClassNoPer; ///////////////////////What we do///////////////////////////// if( FParameters::existParameter(argc, argv, "-help")){ diff --git a/ToRemove/Olivier/testSphericalKernel.cpp b/ToRemove/Olivier/testSphericalKernel.cpp index 1a2e2f1ed..aebd65f28 100644 --- a/ToRemove/Olivier/testSphericalKernel.cpp +++ b/ToRemove/Olivier/testSphericalKernel.cpp @@ -43,12 +43,12 @@ // Simply create particles and try the kernels int main(int argc, char ** argv){ - typedef FSphericalCell CellClass; + typedef FSphericalCell<FReal> CellClass; typedef FP2PParticleContainer<FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; - typedef FSphericalKernel< CellClass, ContainerClass > KernelClass; + typedef FSphericalKernel< FReal, CellClass, ContainerClass > KernelClass; typedef FFmmAlgorithm<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; // diff --git a/ToRemove/testDirectStored.cpp b/ToRemove/testDirectStored.cpp index 0bd71438f..7c4251cd6 100644 --- a/ToRemove/testDirectStored.cpp +++ b/ToRemove/testDirectStored.cpp @@ -126,7 +126,7 @@ int main(int argc, char* argv[]) printf("Elapsed Time for Direct Computation: \t %f\n",time.elapsed()); //Write results in output file - FFmaGenericWriter writer(fileresult) ; + FFmaGenericWriter<FReal> writer(fileresult) ; //Size of elements to be written diff --git a/ToRemove/testLoaderFMABinResult.cpp b/ToRemove/testLoaderFMABinResult.cpp index 185f70fd4..8b3247798 100644 --- a/ToRemove/testLoaderFMABinResult.cpp +++ b/ToRemove/testLoaderFMABinResult.cpp @@ -49,7 +49,7 @@ int main(int argc, char ** argv ){ typedef FBasicParticleContainer<1> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; - typedef FOctree< FBasicCell, ContainerClass , LeafClass > OctreeClass; + typedef FOctree<FReal, FBasicCell, ContainerClass , LeafClass > OctreeClass; ///////////////////////What we do///////////////////////////// std::cout << ">> This executable is useless to execute.\n"; std::cout << ">> It is only interesting to wath the code to understand\n"; diff --git a/ToRemove/utestChebyshevDirectPeriodic.cpp b/ToRemove/utestChebyshevDirectPeriodic.cpp index fd30f823e..0abfc30c4 100644 --- a/ToRemove/utestChebyshevDirectPeriodic.cpp +++ b/ToRemove/utestChebyshevDirectPeriodic.cpp @@ -258,7 +258,7 @@ class TestChebyshevDirect : public FUTester<TestChebyshevDirect> { typedef FChebCell<FReal,ORDER> CellClass; typedef FOctree<FReal, CellClass,ContainerClass,LeafClass> OctreeClass; typedef FChebKernel<FReal,CellClass,ContainerClass,MatrixKernelClass,ORDER> KernelClass; - typedef FFmmAlgorithmPeriodic<OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass; + typedef FFmmAlgorithmPeriodic<FReal,OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass; // run test std::cout <<" TEST 1 "<<std::endl; RunTest<CellClass,ContainerClass,KernelClass,MatrixKernelClass,LeafClass,OctreeClass,FmmClass>(); @@ -273,7 +273,7 @@ class TestChebyshevDirect : public FUTester<TestChebyshevDirect> { typedef FChebCell<FReal,ORDER> CellClass; typedef FOctree<FReal, CellClass,ContainerClass,LeafClass> OctreeClass; typedef FChebSymKernel<FReal,CellClass,ContainerClass,MatrixKernelClass,ORDER> KernelClass; - typedef FFmmAlgorithmPeriodic<OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass; + typedef FFmmAlgorithmPeriodic<FReal,OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass; // run test std::cout <<std::endl<<" TEST 2 "<<std::endl; RunTest<CellClass,ContainerClass,KernelClass,MatrixKernelClass,LeafClass,OctreeClass,FmmClass>(); diff --git a/ToRemove/utestSphericalDirect.cpp b/ToRemove/utestSphericalDirect.cpp index eeeae87f6..0a72e2c16 100644 --- a/ToRemove/utestSphericalDirect.cpp +++ b/ToRemove/utestSphericalDirect.cpp @@ -77,7 +77,7 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { loader.fillParticle(particles,nbParticles); // // Create octree - // FSphericalCell::Init(DevP); + // FSphericalCell<FReal>::Init(DevP); OctreeClass tree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox()); // Insert particle in the tree // @@ -198,10 +198,10 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { /** Classic */ void TestSpherical(){ - typedef FSphericalCell CellClass; + typedef FSphericalCell<FReal> CellClass; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; - typedef FSphericalKernel< CellClass, ContainerClass > KernelClass; + typedef FSphericalKernel< FReal, CellClass, ContainerClass > KernelClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; @@ -214,7 +214,7 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { /** Rotation */ void TestRotation(){ - typedef FSphericalCell CellClass; + typedef FSphericalCell<FReal> CellClass; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; typedef FSphericalRotationKernel< CellClass, ContainerClass > KernelClass; @@ -231,10 +231,10 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { #ifdef ScalFMM_USE_BLAS /** Blas */ void TestSphericalBlas(){ - typedef FSphericalCell CellClass; + typedef FSphericalCell<FReal> CellClass; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; - typedef FSphericalBlasKernel< CellClass, ContainerClass > KernelClass; + typedef FSphericalBlasKernel<FReal, CellClass, ContainerClass > KernelClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; @@ -247,10 +247,10 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { /** Block blas */ void TestSphericalBlockBlas(){ - typedef FSphericalCell CellClass; + typedef FSphericalCell<FReal> CellClass; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; - typedef FSphericalBlockBlasKernel< CellClass, ContainerClass > KernelClass; + typedef FSphericalBlockBlasKernel< FReal, CellClass, ContainerClass > KernelClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; diff --git a/UTests/utestAlgorithmBuilder.cpp b/UTests/utestAlgorithmBuilder.cpp index d0792502b..7b16ccc86 100644 --- a/UTests/utestAlgorithmBuilder.cpp +++ b/UTests/utestAlgorithmBuilder.cpp @@ -46,13 +46,13 @@ class TestBuilder : public FUTester<TestBuilder> { KernelClass kernel; { - FAlgorithmBuilder::SimulationProperties properties = FAlgorithmBuilder::BuildKernelSimulationProperties(height,center,dim,false); + FAlgorithmBuilder<FReal>::SimulationProperties properties = FAlgorithmBuilder<FReal>::BuildKernelSimulationProperties(height,center,dim,false); uassert(properties.centerOfBox.getX() == center.getX() && properties.centerOfBox.getY() == center.getY() && properties.centerOfBox.getZ() == center.getZ() ); uassert(properties.dimOfBox == dim); uassert(properties.height == height); - FAbstractAlgorithm*const algo = FAlgorithmBuilder::BuildAlgorithm<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass>(&tree, &kernel, 0, false); + FAbstractAlgorithm*const algo = FAlgorithmBuilder<FReal>::BuildAlgorithm<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass>(&tree, &kernel, 0, false); #ifndef ScalFMM_USE_MPI uassert(dynamic_cast<FFmmAlgorithm<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass>*>(algo) != nullptr || dynamic_cast<FFmmAlgorithmThread<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass>*>(algo) != nullptr); @@ -62,15 +62,15 @@ class TestBuilder : public FUTester<TestBuilder> { delete algo; } { - FAlgorithmBuilder::SimulationProperties properties = FAlgorithmBuilder::BuildKernelSimulationProperties(height,center,dim,true); + FAlgorithmBuilder<FReal>::SimulationProperties properties = FAlgorithmBuilder<FReal>::BuildKernelSimulationProperties(height,center,dim,true); uassert(properties.dimOfBox != dim); uassert(properties.height != height); - FAbstractAlgorithm*const algo = FAlgorithmBuilder::BuildAlgorithm<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass>(&tree, &kernel, 0, true); + FAbstractAlgorithm*const algo = FAlgorithmBuilder<FReal>::BuildAlgorithm<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass>(&tree, &kernel, 0, true); #ifndef ScalFMM_USE_MPI - uassert(dynamic_cast<FFmmAlgorithmPeriodic<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass>*>(algo) != nullptr ); + uassert(dynamic_cast<FFmmAlgorithmPeriodic<FReal,OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass>*>(algo) != nullptr ); #else - uassert(dynamic_cast<FFmmAlgorithmThreadProcPeriodic<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass>*>(algo) != nullptr); + uassert(dynamic_cast<FFmmAlgorithmThreadProcPeriodic<FReal, OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass>*>(algo) != nullptr); #endif delete algo; diff --git a/UTests/utestChebyshev.cpp b/UTests/utestChebyshev.cpp index bb8a9ae07..e73ff6fff 100644 --- a/UTests/utestChebyshev.cpp +++ b/UTests/utestChebyshev.cpp @@ -54,7 +54,7 @@ class TestChebyshevDirect : public FUKernelTester<TestChebyshevDirect> { typedef FChebKernel<FReal,CellClass,ContainerClass,MatrixKernelClass,ORDER> KernelClass; typedef FFmmAlgorithm<OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass; // run test - RunTest<CellClass,ContainerClass,KernelClass,MatrixKernelClass,LeafClass,OctreeClass,FmmClass>( + RunTest<FReal,CellClass,ContainerClass,KernelClass,MatrixKernelClass,LeafClass,OctreeClass,FmmClass>( [&](int NbLevels, FReal boxWidth, FPoint<FReal> centerOfBox, const MatrixKernelClass *const MatrixKernel){ return std::unique_ptr<KernelClass>(new KernelClass(NbLevels, boxWidth, centerOfBox, MatrixKernel)); }); @@ -72,7 +72,7 @@ class TestChebyshevDirect : public FUKernelTester<TestChebyshevDirect> { typedef FChebSymKernel<FReal,CellClass,ContainerClass,MatrixKernelClass,ORDER> KernelClass; typedef FFmmAlgorithm<OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass; // run test - RunTest<CellClass,ContainerClass,KernelClass,MatrixKernelClass,LeafClass,OctreeClass,FmmClass>( + RunTest<FReal,CellClass,ContainerClass,KernelClass,MatrixKernelClass,LeafClass,OctreeClass,FmmClass>( [&](int NbLevels, FReal boxWidth, FPoint<FReal> centerOfBox, const MatrixKernelClass *const MatrixKernel){ return std::unique_ptr<KernelClass>(new KernelClass(NbLevels, boxWidth, centerOfBox, MatrixKernel)); }); diff --git a/UTests/utestChebyshevAdaptative.cpp b/UTests/utestChebyshevAdaptative.cpp index 535109c84..d0df8b65b 100644 --- a/UTests/utestChebyshevAdaptative.cpp +++ b/UTests/utestChebyshevAdaptative.cpp @@ -64,7 +64,7 @@ class TestChebyshevDirect : public FUKernelTester<TestChebyshevDirect> { typedef FFmmAlgorithm<OctreeClass, CellWrapperClass, ContainerClass, KernelWrapperClass, LeafClass > FmmClass; // run test - RunTest<CellClass,ContainerClass,KernelWrapperClass,MatrixKernelClass,LeafClass,OctreeClass,FmmClass>( + RunTest<FReal,CellClass,ContainerClass,KernelWrapperClass,MatrixKernelClass,LeafClass,OctreeClass,FmmClass>( [&](int NbLevels, FReal boxWidth, FPoint<FReal> centerOfBox, const MatrixKernelClass *const MatrixKernel){ return std::unique_ptr<KernelWrapperClass>(new KernelWrapperClass(NbLevels, boxWidth, centerOfBox, MatrixKernel, 4, 4)); }); diff --git a/UTests/utestChebyshevDirectPeriodic.cpp b/UTests/utestChebyshevDirectPeriodic.cpp index d6318f270..937d7adf5 100644 --- a/UTests/utestChebyshevDirectPeriodic.cpp +++ b/UTests/utestChebyshevDirectPeriodic.cpp @@ -53,7 +53,7 @@ class TestChebyshevDirect : public FUTester<TestChebyshevDirect> { // The tests! /////////////////////////////////////////////////////////// - template <class CellClass, class ContainerClass, class KernelClass, class MatrixKernelClass, + template <class FReal, class CellClass, class ContainerClass, class KernelClass, class MatrixKernelClass, class LeafClass, class OctreeClass, class FmmClass> void RunTest() { // Warning in make test the exec dir it Build/UTests @@ -72,9 +72,8 @@ class TestChebyshevDirect : public FUTester<TestChebyshevDirect> { // Create octree OctreeClass tree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox()); - // interaction kernel evaluator - typedef double FReal; - const MatrixKernelClass MatrixKernel; + // interaction kernel evaluator + const MatrixKernelClass MatrixKernel; struct TestParticle{ FPoint<FReal> position; @@ -253,31 +252,33 @@ class TestChebyshevDirect : public FUTester<TestChebyshevDirect> { /** TestChebKernel */ void TestChebKernel(){ const unsigned int ORDER = 6; + typedef double FReal; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass> LeafClass; typedef FInterpMatrixKernelR<FReal> MatrixKernelClass; typedef FChebCell<FReal,ORDER> CellClass; typedef FOctree<FReal, CellClass,ContainerClass,LeafClass> OctreeClass; typedef FChebKernel<FReal,CellClass,ContainerClass,MatrixKernelClass,ORDER> KernelClass; - typedef FFmmAlgorithmPeriodic<OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass; + typedef FFmmAlgorithmPeriodic<FReal,OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass; // run test std::cout <<" TEST 1 "<<std::endl; - RunTest<CellClass,ContainerClass,KernelClass,MatrixKernelClass,LeafClass,OctreeClass,FmmClass>(); + RunTest<FReal,CellClass,ContainerClass,KernelClass,MatrixKernelClass,LeafClass,OctreeClass,FmmClass>(); } /** TestChebSymKernel */ void TestChebSymKernel(){ const unsigned int ORDER = 7; + typedef double FReal; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass> LeafClass; typedef FInterpMatrixKernelR<FReal> MatrixKernelClass; typedef FChebCell<FReal,ORDER> CellClass; typedef FOctree<FReal, CellClass,ContainerClass,LeafClass> OctreeClass; typedef FChebSymKernel<FReal,CellClass,ContainerClass,MatrixKernelClass,ORDER> KernelClass; - typedef FFmmAlgorithmPeriodic<OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass; + typedef FFmmAlgorithmPeriodic<FReal,OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass; // run test std::cout <<std::endl<<" TEST 2 "<<std::endl; - RunTest<CellClass,ContainerClass,KernelClass,MatrixKernelClass,LeafClass,OctreeClass,FmmClass>(); + RunTest<FReal,CellClass,ContainerClass,KernelClass,MatrixKernelClass,LeafClass,OctreeClass,FmmClass>(); } diff --git a/UTests/utestChebyshevMpi.cpp b/UTests/utestChebyshevMpi.cpp index c50f9c969..aa0484943 100644 --- a/UTests/utestChebyshevMpi.cpp +++ b/UTests/utestChebyshevMpi.cpp @@ -51,10 +51,9 @@ class TestChebyshevMpiDirect : public FUTesterMpi<TestChebyshevMpiDirect>{ - template <class CellClass, class ContainerClass, class KernelClass, class MatrixKernelClass, + template <class FReal, class CellClass, class ContainerClass, class KernelClass, class MatrixKernelClass, class LeafClass, class OctreeClass, class FmmClassProc> void RunTest(){ - typedef double FReal; const std::string parFile( (sizeof(FReal) == sizeof(float))? "Test/DirectFloatbfma": "UTest/DirectDouble.bfma"); @@ -282,6 +281,7 @@ class TestChebyshevMpiDirect : public FUTesterMpi<TestChebyshevMpiDirect>{ /** TestChebSymKernel */ void TestChebSymKernel(){ const unsigned int ORDER = 6; + typedef double FReal; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass> LeafClass; typedef FInterpMatrixKernelR<FReal> MatrixKernelClass; @@ -290,7 +290,7 @@ class TestChebyshevMpiDirect : public FUTesterMpi<TestChebyshevMpiDirect>{ typedef FChebSymKernel<FReal,CellClass,ContainerClass,MatrixKernelClass,ORDER> KernelClass; typedef FFmmAlgorithmThreadProc<OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClassProc; // run test - RunTest<CellClass,ContainerClass,KernelClass,MatrixKernelClass,LeafClass,OctreeClass,FmmClassProc>(); + RunTest<FReal,CellClass,ContainerClass,KernelClass,MatrixKernelClass,LeafClass,OctreeClass,FmmClassProc>(); } /////////////////////////////////////////////////////////// diff --git a/UTests/utestChebyshevThread.cpp b/UTests/utestChebyshevThread.cpp index 0fbdb3f3e..9f8aaf0e7 100644 --- a/UTests/utestChebyshevThread.cpp +++ b/UTests/utestChebyshevThread.cpp @@ -227,7 +227,7 @@ class TestChebyshevDirect : public FUTester<TestChebyshevDirect> { typedef FChebKernel<FReal,CellClass,ContainerClass,MatrixKernelClass,ORDER> KernelClass; typedef FFmmAlgorithmThread<OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass; // run test - RunTest<CellClass,ContainerClass,KernelClass,MatrixKernelClass,LeafClass,OctreeClass,FmmClass>(); + RunTest<FReal,CellClass,ContainerClass,KernelClass,MatrixKernelClass,LeafClass,OctreeClass,FmmClass>(); } /** TestChebSymKernel */ @@ -242,7 +242,7 @@ class TestChebyshevDirect : public FUTester<TestChebyshevDirect> { typedef FChebSymKernel<FReal,CellClass,ContainerClass,MatrixKernelClass,ORDER> KernelClass; typedef FFmmAlgorithmThread<OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass; // run test - RunTest<CellClass,ContainerClass,KernelClass,MatrixKernelClass,LeafClass,OctreeClass,FmmClass>(); + RunTest<FReal,CellClass,ContainerClass,KernelClass,MatrixKernelClass,LeafClass,OctreeClass,FmmClass>(); } diff --git a/UTests/utestInterpolationMultiRhs.cpp b/UTests/utestInterpolationMultiRhs.cpp index 72d586e0a..9123e4ca3 100644 --- a/UTests/utestInterpolationMultiRhs.cpp +++ b/UTests/utestInterpolationMultiRhs.cpp @@ -269,14 +269,14 @@ class TestInterpolationKernel : public FUTester<TestInterpolationKernel> { typedef FInterpMatrixKernelR<FReal> MatrixKernelClass; - typedef FP2PParticleContainerIndexed<1,1,NVals> ContainerClass; + typedef FP2PParticleContainerIndexed<FReal,1,1,NVals> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; - typedef FUnifCell<ORDER,1,1,NVals> CellClass; + typedef FUnifCell<FReal,ORDER,1,1,NVals> CellClass; typedef FOctree<FReal, CellClass,ContainerClass,LeafClass> OctreeClass; typedef FUnifKernel<FReal,CellClass,ContainerClass,MatrixKernelClass,ORDER,NVals> KernelClass; typedef FFmmAlgorithm<OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass; - RunTest<CellClass,ContainerClass,KernelClass,MatrixKernelClass,LeafClass,OctreeClass,FmmClass, NVals>(); + RunTest<FReal,CellClass,ContainerClass,KernelClass,MatrixKernelClass,LeafClass,OctreeClass,FmmClass, NVals>(); } /** TestChebSymKernel */ @@ -284,15 +284,15 @@ class TestInterpolationKernel : public FUTester<TestInterpolationKernel> { typedef double FReal; const int NVals = 3; const unsigned int ORDER = 6; - typedef FP2PParticleContainerIndexed<1,1,NVals> ContainerClass; + typedef FP2PParticleContainerIndexed<FReal,1,1,NVals> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass> LeafClass; typedef FInterpMatrixKernelR<FReal> MatrixKernelClass; - typedef FChebCell<ORDER, 1, 1, NVals> CellClass; + typedef FChebCell<FReal,ORDER, 1, 1, NVals> CellClass; typedef FOctree<FReal, CellClass,ContainerClass,LeafClass> OctreeClass; typedef FChebSymKernel<FReal,CellClass,ContainerClass,MatrixKernelClass,ORDER, NVals> KernelClass; typedef FFmmAlgorithm<OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass; // run test - RunTest<CellClass,ContainerClass,KernelClass,MatrixKernelClass,LeafClass,OctreeClass,FmmClass, NVals>(); + RunTest<FReal,CellClass,ContainerClass,KernelClass,MatrixKernelClass,LeafClass,OctreeClass,FmmClass, NVals>(); } /** TestChebKernel */ @@ -300,15 +300,15 @@ class TestInterpolationKernel : public FUTester<TestInterpolationKernel> { typedef double FReal; const int NVals = 3; const unsigned int ORDER = 6; - typedef FP2PParticleContainerIndexed<1,1,NVals> ContainerClass; + typedef FP2PParticleContainerIndexed<FReal,1,1,NVals> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass> LeafClass; typedef FInterpMatrixKernelR<FReal> MatrixKernelClass; - typedef FChebCell<ORDER, 1, 1, NVals> CellClass; + typedef FChebCell<FReal,ORDER, 1, 1, NVals> CellClass; typedef FOctree<FReal, CellClass,ContainerClass,LeafClass> OctreeClass; typedef FChebKernel<FReal,CellClass,ContainerClass,MatrixKernelClass,ORDER, NVals> KernelClass; typedef FFmmAlgorithm<OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass; // run test - RunTest<CellClass,ContainerClass,KernelClass,MatrixKernelClass,LeafClass,OctreeClass,FmmClass, NVals>(); + RunTest<FReal,CellClass,ContainerClass,KernelClass,MatrixKernelClass,LeafClass,OctreeClass,FmmClass, NVals>(); } /////////////////////////////////////////////////////////// diff --git a/UTests/utestLagrange.cpp b/UTests/utestLagrange.cpp index 68f82f468..a4615e029 100644 --- a/UTests/utestLagrange.cpp +++ b/UTests/utestLagrange.cpp @@ -223,7 +223,7 @@ class TestLagrange : public FUTester<TestLagrange> { typedef FUnifKernel<FReal,CellClass,ContainerClass,MatrixKernelClass,ORDER> KernelClass; typedef FFmmAlgorithm<OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass; // run test - RunTest<CellClass,ContainerClass,KernelClass,MatrixKernelClass,LeafClass,OctreeClass,FmmClass>(); + RunTest<FReal,CellClass,ContainerClass,KernelClass,MatrixKernelClass,LeafClass,OctreeClass,FmmClass>(); } /////////////////////////////////////////////////////////// diff --git a/UTests/utestLagrangeMpi.cpp b/UTests/utestLagrangeMpi.cpp index f6e4bf7b4..f67ea8cb3 100644 --- a/UTests/utestLagrangeMpi.cpp +++ b/UTests/utestLagrangeMpi.cpp @@ -290,7 +290,7 @@ class TestLagrangeMpiDirect : public FUTesterMpi<TestLagrangeMpiDirect>{ typedef FUnifKernel<FReal,CellClass,ContainerClass,MatrixKernelClass,ORDER> KernelClass; typedef FFmmAlgorithmThreadProc<OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClassProc; // run test - RunTest<CellClass,ContainerClass,KernelClass,MatrixKernelClass,LeafClass,OctreeClass,FmmClassProc>(); + RunTest<FReal,CellClass,ContainerClass,KernelClass,MatrixKernelClass,LeafClass,OctreeClass,FmmClassProc>(); } /////////////////////////////////////////////////////////// diff --git a/UTests/utestLagrangeThread.cpp b/UTests/utestLagrangeThread.cpp index 6788ac74c..bb2fb05d5 100644 --- a/UTests/utestLagrangeThread.cpp +++ b/UTests/utestLagrangeThread.cpp @@ -230,7 +230,7 @@ class TestLagrange : public FUTester<TestLagrange> { typedef FFmmAlgorithmThread<OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass; // run test - RunTest<CellClass,ContainerClass,KernelClass,MatrixKernelClass,LeafClass,OctreeClass,FmmClass>(); + RunTest<FReal,CellClass,ContainerClass,KernelClass,MatrixKernelClass,LeafClass,OctreeClass,FmmClass>(); } /////////////////////////////////////////////////////////// diff --git a/UTests/utestMpiTreeBuilder.cpp b/UTests/utestMpiTreeBuilder.cpp index 21d42620d..61d7a4ce1 100644 --- a/UTests/utestMpiTreeBuilder.cpp +++ b/UTests/utestMpiTreeBuilder.cpp @@ -123,9 +123,9 @@ class TestMpiTreeBuilder : public FUTesterMpi< class TestMpiTreeBuilder> { //Copy from the file to the array that will be sorted FSize nbOfParticles = loaderSeq.getNumberOfParticles(); printf("nbOfParticles : %lld \n",nbOfParticles); - struct TestParticle* arrayOfParticles = new TestParticle[nbOfParticles]; + struct TestParticle<FReal>* arrayOfParticles = new TestParticle<FReal>[nbOfParticles]; - memset(arrayOfParticles,0,sizeof(struct TestParticle)*nbOfParticles); + memset(arrayOfParticles,0,sizeof(struct TestParticle<FReal>)*nbOfParticles); for(FSize idxParts=0 ; idxParts<nbOfParticles ; ++idxParts){ @@ -144,8 +144,8 @@ class TestMpiTreeBuilder : public FUTesterMpi< class TestMpiTreeBuilder> { arrayOfParticles[idxParts].index = host.getMortonIndex(TreeHeight - 1); } //Save the original array - struct TestParticle * originalArray = new TestParticle[nbOfParticles]; - memcpy(originalArray,arrayOfParticles,sizeof(struct TestParticle)*nbOfParticles); + struct TestParticle<FReal> * originalArray = new TestParticle<FReal>[nbOfParticles]; + memcpy(originalArray,arrayOfParticles,sizeof(struct TestParticle<FReal>)*nbOfParticles); //Sort the array std::sort(arrayOfParticles,arrayOfParticles+nbOfParticles); @@ -173,16 +173,16 @@ class TestMpiTreeBuilder : public FUTesterMpi< class TestMpiTreeBuilder> { //Now, we sort again the particles with MPI QuickSort int idxStart = loader.getStart(); - FMpiTreeBuilder<TestParticle>::IndexedParticle * arrayToBeSorted = new FMpiTreeBuilder<TestParticle>::IndexedParticle[loader.getMyNumberOfParticles()]; + FMpiTreeBuilder<FReal,TestParticle<FReal>>::IndexedParticle * arrayToBeSorted = new FMpiTreeBuilder<FReal,TestParticle<FReal>>::IndexedParticle[loader.getMyNumberOfParticles()]; //Copy the TestParticles into an array of indexedParticle for(int i=0 ; i<loader.getMyNumberOfParticles() ; ++i){ arrayToBeSorted[i].particle = originalArray[i+idxStart]; arrayToBeSorted[i].index = arrayToBeSorted[i].particle.index; } - FMpiTreeBuilder<TestParticle>::IndexedParticle* outputArray = nullptr; - FQuickSortMpi<FMpiTreeBuilder<TestParticle>::IndexedParticle,MortonIndex,FSize>::QsMpi(arrayToBeSorted,loader.getMyNumberOfParticles(),&outputArray,&outputSize,app.global()); + FMpiTreeBuilder<FReal,TestParticle<FReal>>::IndexedParticle* outputArray = nullptr; + FQuickSortMpi<FMpiTreeBuilder<FReal,TestParticle<FReal>>::IndexedParticle,MortonIndex,FSize>::QsMpi(arrayToBeSorted,loader.getMyNumberOfParticles(),&outputArray,&outputSize,app.global()); - //FBitonicSort<FMpiTreeBuilder<TestParticle>::IndexedParticle,MortonIndex, FSize>::Sort(arrayToBeSorted,loader.getMyNumberOfParticles(),app.global()); + //FBitonicSort<FMpiTreeBuilder<FReal,TestParticle<FReal>>::IndexedParticle,MortonIndex, FSize>::Sort(arrayToBeSorted,loader.getMyNumberOfParticles(),app.global()); //Sum the outputSize of every body for knowing where to start inside the sorted array FSize starter = 0; //We use a prefix sum @@ -192,7 +192,7 @@ class TestMpiTreeBuilder : public FUTesterMpi< class TestMpiTreeBuilder> { //We sort the output array relatvely to line number in origin file FSize inc = 0; - FMpiTreeBuilder<TestParticle>::IndexedParticle * saveForSort = outputArray; + FMpiTreeBuilder<FReal,TestParticle<FReal>>::IndexedParticle * saveForSort = outputArray; int nbOfPartsInLeaf = 0; while(inc < outputSize){ while(outputArray[inc].index == saveForSort->index && inc < outputSize){ @@ -200,7 +200,7 @@ class TestMpiTreeBuilder : public FUTesterMpi< class TestMpiTreeBuilder> { nbOfPartsInLeaf++; } std::sort(saveForSort,saveForSort+nbOfPartsInLeaf, - [&](FMpiTreeBuilder<TestParticle>::IndexedParticle a,FMpiTreeBuilder<TestParticle>::IndexedParticle b) -> bool { + [&](FMpiTreeBuilder<FReal,TestParticle<FReal>>::IndexedParticle a,FMpiTreeBuilder<FReal,TestParticle<FReal>>::IndexedParticle b) -> bool { return (a.particle.indexInFile)<(b.particle.indexInFile); }); nbOfPartsInLeaf = 0; @@ -269,11 +269,11 @@ class TestMpiTreeBuilder : public FUTesterMpi< class TestMpiTreeBuilder> { bool resultMergeLeaves= true; //inputs needed - TestParticle * leavesArray = nullptr; + TestParticle<FReal> * leavesArray = nullptr; FSize * leavesIndices = nullptr; FSize leaveSize = 0; - FMpiTreeBuilder<TestParticle>::MergeSplitedLeaves(app.global(),outputArray,&outputSize,&leavesIndices,&leavesArray,&leaveSize); + FMpiTreeBuilder<FReal,TestParticle<FReal>>::MergeSplitedLeaves(app.global(),outputArray,&outputSize,&leavesIndices,&leavesArray,&leaveSize); //Compare again the results with the output of std::qsort @@ -297,11 +297,11 @@ class TestMpiTreeBuilder : public FUTesterMpi< class TestMpiTreeBuilder> { //Test the Equalize and Fill tree FLeafBalance balancer; - FVector<TestParticle> finalParticles; + FVector<TestParticle<FReal>> finalParticles; bool resultEqualize = true; - FMpiTreeBuilder<TestParticle>::EqualizeAndFillContainer(app.global(),&finalParticles,leavesIndices,leavesArray,leaveSize,outputSize,&balancer); + FMpiTreeBuilder<FReal,TestParticle<FReal>>::EqualizeAndFillContainer(app.global(),&finalParticles,leavesIndices,leavesArray,leaveSize,outputSize,&balancer); //Ok now count the Particles at the end of the Equalize int finalNbPart = finalParticles.getSize(); int finalStart = 0; diff --git a/UTests/utestOctree.cpp b/UTests/utestOctree.cpp index 142771ce1..f4ed3354c 100644 --- a/UTests/utestOctree.cpp +++ b/UTests/utestOctree.cpp @@ -39,7 +39,7 @@ class TestOctree : public FUTester<TestOctree> { typedef double FReal; typedef FBasicCell CellClass; - typedef FBasicParticleContainer<0> ContainerClass; + typedef FBasicParticleContainer<FReal,0,FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass , FBasicBlockAllocator<CellClass> > OctreeClass; diff --git a/UTests/utestRotation.cpp b/UTests/utestRotation.cpp index f72adba08..0e874ba07 100644 --- a/UTests/utestRotation.cpp +++ b/UTests/utestRotation.cpp @@ -223,17 +223,17 @@ class TestRotationDirect : public FUTester<TestRotationDirect> { template<int P> void TestRotation(){ typedef double FReal; - typedef FRotationCell<P> CellClass; + typedef FRotationCell<FReal,P> CellClass; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; - typedef FRotationKernel<CellClass, ContainerClass, P > KernelClass; + typedef FRotationKernel<FReal,CellClass, ContainerClass, P > KernelClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; typedef FFmmAlgorithm<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; - RunTest<CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass,P>(); + RunTest<FReal,CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass,P>(); } /////////////////////////////////////////////////////////// diff --git a/UTests/utestRotationDirectPeriodic.cpp b/UTests/utestRotationDirectPeriodic.cpp index 3b41b14a0..f00e2cb6a 100644 --- a/UTests/utestRotationDirectPeriodic.cpp +++ b/UTests/utestRotationDirectPeriodic.cpp @@ -36,15 +36,15 @@ class TestRotationDirectPeriodic : public FUTester<TestRotationDirectPeriodic> { void TestPeriodicFmm(){ typedef double FReal; static const int P = 14; - typedef FRotationCell<P> CellClass; + typedef FRotationCell<FReal,P> CellClass; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; - typedef FRotationKernel< CellClass, ContainerClass, P > KernelClass; + typedef FRotationKernel< FReal, CellClass, ContainerClass, P > KernelClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; - typedef FFmmAlgorithmPeriodic<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; + typedef FFmmAlgorithmPeriodic<FReal,OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; // Parameters const int NbLevels = 4; diff --git a/UTests/utestRotationDirectSeveralTime.cpp b/UTests/utestRotationDirectSeveralTime.cpp index 19e31057e..dc9cb4ead 100644 --- a/UTests/utestRotationDirectSeveralTime.cpp +++ b/UTests/utestRotationDirectSeveralTime.cpp @@ -198,17 +198,17 @@ class TestRotationDirectSeveralTime : public FUTester<TestRotationDirectSeveralT /** Rotation */ void TestRotation(){ typedef double FReal; - typedef FRotationCell<P> CellClass; + typedef FRotationCell<FReal,P> CellClass; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; - typedef FRotationKernel<CellClass, ContainerClass, P > KernelClass; + typedef FRotationKernel<FReal, CellClass, ContainerClass, P > KernelClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; typedef FFmmAlgorithm<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; - RunTest<CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass>(); + RunTest<FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass>(); } /////////////////////////////////////////////////////////// diff --git a/UTests/utestRotationDirectTsm.cpp b/UTests/utestRotationDirectTsm.cpp index d86a470d9..aeb6a0ee9 100644 --- a/UTests/utestRotationDirectTsm.cpp +++ b/UTests/utestRotationDirectTsm.cpp @@ -223,32 +223,32 @@ class TestRotationDirectTsm : public FUTester<TestRotationDirectTsm> { /** Rotation */ void TestRotation(){ typedef double FReal; - typedef FTypedRotationCell<P> CellClass; + typedef FTypedRotationCell<FReal,P> CellClass; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; - typedef FRotationKernel<CellClass, ContainerClass, P > KernelClass; + typedef FRotationKernel<FReal, CellClass, ContainerClass, P > KernelClass; - typedef FTypedLeaf<ContainerClass > LeafClass; + typedef FTypedLeaf<FReal,ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; typedef FFmmAlgorithmTsm<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; - RunTest<CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass>(); + RunTest<FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass>(); } void TestRotationThread(){ typedef double FReal; - typedef FTypedRotationCell<P> CellClass; + typedef FTypedRotationCell<FReal,P> CellClass; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; - typedef FRotationKernel<CellClass, ContainerClass, P > KernelClass; + typedef FRotationKernel<FReal, CellClass, ContainerClass, P > KernelClass; - typedef FTypedLeaf<ContainerClass > LeafClass; + typedef FTypedLeaf<FReal,ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; typedef FFmmAlgorithmThreadTsm<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; - RunTest<CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass>(); + RunTest<FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass>(); } /////////////////////////////////////////////////////////// diff --git a/UTests/utestRotationThread.cpp b/UTests/utestRotationThread.cpp index 61df9fbb2..624264639 100644 --- a/UTests/utestRotationThread.cpp +++ b/UTests/utestRotationThread.cpp @@ -194,17 +194,17 @@ class TestRotationDirect : public FUTester<TestRotationDirect> { /** Rotation */ void TestRotation(){ typedef double FReal; - typedef FRotationCell<P> CellClass; + typedef FRotationCell<FReal,P> CellClass; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; - typedef FRotationKernel<CellClass, ContainerClass, P > KernelClass; + typedef FRotationKernel<FReal, CellClass, ContainerClass, P > KernelClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; typedef FFmmAlgorithmThread<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; - RunTest<CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass>(); + RunTest<FReal,CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass>(); } /////////////////////////////////////////////////////////// diff --git a/UTests/utestSpherical.cpp b/UTests/utestSpherical.cpp index 0641e90b9..3425aa302 100644 --- a/UTests/utestSpherical.cpp +++ b/UTests/utestSpherical.cpp @@ -80,7 +80,7 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { // // Create octree // - FSphericalCell::Init(DevP); + FSphericalCell<FReal>::Init(DevP); OctreeClass tree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox()); // Insert particle in the tree // @@ -202,17 +202,17 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { /** Classic */ void TestSpherical(){ typedef double FReal; - typedef FSphericalCell CellClass; + typedef FSphericalCell<FReal> CellClass; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; - typedef FSphericalKernel< CellClass, ContainerClass > KernelClass; + typedef FSphericalKernel< FReal, CellClass, ContainerClass > KernelClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; typedef FFmmAlgorithm<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest<FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass>(false); } @@ -222,34 +222,34 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { /** Blas */ void TestSphericalBlas(){ typedef double FReal; - typedef FSphericalCell CellClass; + typedef FSphericalCell<FReal> CellClass; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; - typedef FSphericalBlasKernel< CellClass, ContainerClass > KernelClass; + typedef FSphericalBlasKernel<FReal, CellClass, ContainerClass > KernelClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; typedef FFmmAlgorithm<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest<FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass>(true); } /** Block blas */ void TestSphericalBlockBlas(){ typedef double FReal; - typedef FSphericalCell CellClass; + typedef FSphericalCell<FReal> CellClass; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; - typedef FSphericalBlockBlasKernel< CellClass, ContainerClass > KernelClass; + typedef FSphericalBlockBlasKernel< FReal, CellClass, ContainerClass > KernelClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; typedef FFmmAlgorithm<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest<FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass>(true); } #endif diff --git a/UTests/utestSphericalBlasAlgorithm.cpp b/UTests/utestSphericalBlasAlgorithm.cpp index dd7856805..b73ca3b5d 100644 --- a/UTests/utestSphericalBlasAlgorithm.cpp +++ b/UTests/utestSphericalBlasAlgorithm.cpp @@ -80,7 +80,7 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { // // Create octree // - FSphericalCell::Init(DevP); + FSphericalCell<FReal>::Init(DevP); OctreeClass tree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox()); // Insert particle in the tree // @@ -202,17 +202,17 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { /** Classic */ void TestSpherical(){ typedef double FReal; - typedef FSphericalCell CellClass; + typedef FSphericalCell<FReal> CellClass; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; - typedef FSphericalKernel< CellClass, ContainerClass > KernelClass; + typedef FSphericalKernel< FReal, CellClass, ContainerClass > KernelClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; typedef FFmmAlgorithm<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest<FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass>(false); } @@ -222,34 +222,34 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { /** Blas */ void TestSphericalBlas(){ typedef double FReal; - typedef FSphericalCell CellClass; + typedef FSphericalCell<FReal> CellClass; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; - typedef FSphericalBlasKernel< CellClass, ContainerClass > KernelClass; + typedef FSphericalBlasKernel<FReal, CellClass, ContainerClass > KernelClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; typedef FFmmAlgorithm<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest<FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass>(true); } /** Block blas */ void TestSphericalBlockBlas(){ typedef double FReal; - typedef FSphericalCell CellClass; + typedef FSphericalCell<FReal> CellClass; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; - typedef FSphericalBlockBlasKernel< CellClass, ContainerClass > KernelClass; + typedef FSphericalBlockBlasKernel< FReal, CellClass, ContainerClass > KernelClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; typedef FFmmAlgorithm<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest<FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass>(true); } #endif diff --git a/UTests/utestSphericalDirect.cpp b/UTests/utestSphericalDirect.cpp index 6b4faf3b1..a2d5a3596 100644 --- a/UTests/utestSphericalDirect.cpp +++ b/UTests/utestSphericalDirect.cpp @@ -83,7 +83,7 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { // // Create octree // - FSphericalCell::Init(DevP); + FSphericalCell<FReal>::Init(DevP); OctreeClass tree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox()); // Insert particle in the tree // @@ -210,10 +210,10 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { /** Classic */ void TestSpherical(){ typedef double FReal; - typedef FSphericalCell CellClass; + typedef FSphericalCell<FReal> CellClass; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; - typedef FSphericalKernel< CellClass, ContainerClass > KernelClass; + typedef FSphericalKernel< FReal, CellClass, ContainerClass > KernelClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; @@ -221,33 +221,33 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { typedef FFmmAlgorithm<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; printf("Spherical\n \n"); - // RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + // RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, // OctreeClass, FmmClass, 4>(false); - // RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + // RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, // OctreeClass, FmmClass, 6>(false); - // RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + // RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, // OctreeClass, FmmClass, 8>(false); - // RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + // RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, // OctreeClass, FmmClass, 10>(false); - // RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + // RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, // OctreeClass, FmmClass, 12>(false); - // RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + // RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, // OctreeClass, FmmClass, 14>(false); - // RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + // RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, // OctreeClass, FmmClass, 16>(false); - // RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + // RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, // OctreeClass, FmmClass, 18>(false); - // RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + // RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, // OctreeClass, FmmClass, 20>(true); - // RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + // RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, // OctreeClass, FmmClass, 22>(true); - // RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + // RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, // OctreeClass, FmmClass, 24>(true); - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass, 50>(true); - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass, 55>(true); - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass, 60>(true); @@ -259,10 +259,10 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { /** Blas */ void TestSphericalBlas(){ typedef double FReal; - typedef FSphericalCell CellClass; + typedef FSphericalCell<FReal> CellClass; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; - typedef FSphericalBlasKernel< CellClass, ContainerClass > KernelClass; + typedef FSphericalBlasKernel<FReal, CellClass, ContainerClass > KernelClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; @@ -270,37 +270,37 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { typedef FFmmAlgorithm<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; printf("Spherical BLAS\n \n"); - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass, 4>(true); - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass, 6>(true); - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass, 8>(true); - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass, 10>(true); - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass, 12>(true); - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass, 14>(true); - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass, 16>(true); - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass, 18>(true); - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass, 20>(true); - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass, 22>(true); - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass, 24>(true); } /** Block blas */ void TestSphericalBlockBlas(){ typedef double FReal; - typedef FSphericalCell CellClass; + typedef FSphericalCell<FReal> CellClass; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; - typedef FSphericalBlockBlasKernel< CellClass, ContainerClass > KernelClass; + typedef FSphericalBlockBlasKernel< FReal, CellClass, ContainerClass > KernelClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; @@ -309,35 +309,35 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { printf("Spherical BLOCK BLAS\n \n"); - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass, 4>(true); - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass, 6>(true); - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass, 8>(true); - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass, 10>(true); - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass, 12>(true); - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass, 14>(true); - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass, 16>(true); - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass, 18>(true); - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass, 20>(true); - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass, 22>(true); - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass, 24>(true); - RunTest< CellClass, ContainerClass, KernelClass, LeafClass, + RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, OctreeClass, FmmClass, 26>(true); -// RunTest< CellClass, ContainerClass, KernelClass, LeafClass, +// RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, // OctreeClass, FmmClass, 28>(true); -// RunTest< CellClass, ContainerClass, KernelClass, LeafClass, +// RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, // OctreeClass, FmmClass, 30>(true); -// RunTest< CellClass, ContainerClass, KernelClass, LeafClass, +// RunTest< FReal, CellClass, ContainerClass, KernelClass, LeafClass, // OctreeClass, FmmClass, 32>(true); } diff --git a/UTests/utestSphericalDirectPeriodic.cpp b/UTests/utestSphericalDirectPeriodic.cpp index 4d5ca9055..cac4b2c5c 100644 --- a/UTests/utestSphericalDirectPeriodic.cpp +++ b/UTests/utestSphericalDirectPeriodic.cpp @@ -37,15 +37,15 @@ class TestSphericalDirectPeriodic : public FUTester<TestSphericalDirectPeriodic> /** Here we test only the P2P */ void TestPeriodicFmm(){ typedef double FReal; - typedef FSphericalCell CellClass; + typedef FSphericalCell<FReal> CellClass; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; - typedef FSphericalKernel<CellClass, ContainerClass > KernelClass; + typedef FSphericalKernel<FReal, CellClass, ContainerClass > KernelClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; - typedef FFmmAlgorithmPeriodic<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; + typedef FFmmAlgorithmPeriodic<FReal,OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass; // Parameters const int NbLevels = 4; @@ -54,7 +54,7 @@ class TestSphericalDirectPeriodic : public FUTester<TestSphericalDirectPeriodic> const int DevP = 14; const int NbParticles = 100; - FSphericalCell::Init(DevP); + FSphericalCell<FReal>::Init(DevP); FRandomLoader<FReal> loader(NbParticles); OctreeClass tree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox()); diff --git a/UTests/utestSphericalWithPrevious.cpp b/UTests/utestSphericalWithPrevious.cpp index 05118dab9..ea8318f10 100644 --- a/UTests/utestSphericalWithPrevious.cpp +++ b/UTests/utestSphericalWithPrevious.cpp @@ -38,10 +38,10 @@ */ typedef double FReal; -typedef FSphericalCell CellClass; +typedef FSphericalCell<FReal> CellClass; typedef FP2PParticleContainerIndexed<FReal> ContainerClass; -typedef FSphericalKernel< CellClass, ContainerClass > KernelClass; +typedef FSphericalKernel< FReal, CellClass, ContainerClass > KernelClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; typedef FOctree<FReal, CellClass, ContainerClass , LeafClass > OctreeClass; @@ -91,7 +91,7 @@ class TestSphericalWithPrevious : public FUTester<TestSphericalWithPrevious> { // // Create octree // - FSphericalCell::Init(DevP); + FSphericalCell<FReal>::Init(DevP); // OctreeClass testTree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox()); // @@ -115,7 +115,7 @@ class TestSphericalWithPrevious : public FUTester<TestSphericalWithPrevious> { // Load previous result OctreeClass goodTree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox()); - FTreeIO::Load<OctreeClass, CellClass, LeafClass, ContainerClass >(DataFile.c_str(), goodTree); + FTreeIO<FReal>::Load<OctreeClass, CellClass, LeafClass, ContainerClass >(DataFile.c_str(), goodTree); // Compare the two simulations Print("Check the particles..."); diff --git a/Utils/noDist/testPrecisionAllKernel.cpp b/Utils/noDist/testPrecisionAllKernel.cpp index 2a4dd2013..fa334e30d 100644 --- a/Utils/noDist/testPrecisionAllKernel.cpp +++ b/Utils/noDist/testPrecisionAllKernel.cpp @@ -69,6 +69,7 @@ #include "Utils/FTemplate.hpp" +typedef double FReal; void usage() { std::cout << "Driver for all kernel (1/r kernel)" << std::endl; @@ -136,7 +137,7 @@ void checkResAndPrint(OctreeClass * tree, FmaRWParticle<FReal, 8,8> * const part // Simply create particles and try the CHEBYSHEV kernels struct ChebMainStruct{ - template <const unsigned int ORDER, class FReal> + template <const unsigned int ORDER> static void For(int argc, char* argv[],FSize nbParticles,int TreeHeight, int SubTreeHeight, FReal BoxWidth, FPoint<FReal>& CenterOfBox,FmaRWParticle<FReal, 8,8> * const particles, FReal energyD,FReal totPhysicalValue) @@ -175,7 +176,7 @@ struct ChebMainStruct{ std::cout <<"(FChebSymKernel @Algorithm = " << time.elapsed() << " s)." << std::endl; } // ----------------------------------------------------- { // Check that each particle has been summed with all other - checkResAndPrint<OctreeClass,LeafClass>(&tree,particles,energyD,std::string("Chebyshev.res"),ORDER); + checkResAndPrint<FReal,OctreeClass,LeafClass>(&tree,particles,energyD,std::string("Chebyshev.res"),ORDER); } } @@ -185,7 +186,7 @@ struct ChebMainStruct{ // Simply create particles and try the CHEBYSHEV kernels struct UnifMainStruct{ - template <const unsigned int ORDER, class FReal> + template <const unsigned int ORDER> static void For(int argc, char* argv[],FSize nbParticles,int TreeHeight, int SubTreeHeight, FReal BoxWidth, FPoint<FReal>& CenterOfBox,FmaRWParticle<FReal, 8,8> * const particles, FReal energyD,FReal totPhysicalValue) @@ -197,6 +198,7 @@ struct UnifMainStruct{ //Start of kernels there {//Lagrange + typedef FP2PParticleContainerIndexed<FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass> LeafClass; typedef FInterpMatrixKernelR<FReal> MatrixKernelClass; @@ -224,7 +226,7 @@ struct UnifMainStruct{ std::cout <<"(FUnifKernel @Algorithm = " << time.elapsed() << " s)." << std::endl; } // ----------------------------------------------------- { // Check that each particle has been summed with all other - checkResAndPrint<OctreeClass,LeafClass>(&tree,particles,energyD,std::string("Lagrange.res"),ORDER); + checkResAndPrint<FReal,OctreeClass,LeafClass>(&tree,particles,energyD,std::string("Lagrange.res"),ORDER); } } @@ -233,7 +235,7 @@ struct UnifMainStruct{ }; struct RotMainStruct{ - template <const unsigned int ORDER, class FReal> + template <const unsigned int ORDER> static void For(int argc, char* argv[],FSize nbParticles,int TreeHeight, int SubTreeHeight, FReal BoxWidth, FPoint<FReal>& CenterOfBox,FmaRWParticle<FReal, 8,8> * const particles, FReal energyD,FReal totPhysicalValue) @@ -245,12 +247,13 @@ struct RotMainStruct{ //Start of kernels there {//Rotation + typedef FP2PParticleContainerIndexed<FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass> LeafClass; - typedef FRotationCell<ORDER> CellClass; + typedef FRotationCell<FReal,ORDER> CellClass; typedef FOctree<FReal, CellClass,ContainerClass,LeafClass> OctreeClass; - typedef FRotationKernel<CellClass,ContainerClass,ORDER> KernelClass; + typedef FRotationKernel<FReal, CellClass,ContainerClass,ORDER> KernelClass; typedef FFmmAlgorithmThread<OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass; // init oct-tree OctreeClass tree(TreeHeight, SubTreeHeight, BoxWidth,CenterOfBox); @@ -269,7 +272,7 @@ struct RotMainStruct{ std::cout <<"(FRotationKernel @Algorithm = " << time.elapsed() << " s)." << std::endl; } // ----------------------------------------------------- { // Check that each particle has been summed with all other - checkResAndPrint<OctreeClass,LeafClass>(&tree,particles,energyD,std::string("Rotation.res"),ORDER); + checkResAndPrint<FReal,OctreeClass,LeafClass>(&tree,particles,energyD,std::string("Rotation.res"),ORDER); } } @@ -278,7 +281,7 @@ struct RotMainStruct{ }; struct TaylorMainStruct{ - template <const unsigned int ORDER, class FReal> + template <const unsigned int ORDER> static void For(int argc, char* argv[],FSize nbParticles,int TreeHeight, int SubTreeHeight, FReal BoxWidth, FPoint<FReal>& CenterOfBox,FmaRWParticle<FReal, 8,8> * const particles, FReal energyD,FReal totPhysicalValue) @@ -290,12 +293,13 @@ struct TaylorMainStruct{ //Start of kernels there {//Taylor + typedef FP2PParticleContainerIndexed<FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass> LeafClass; - typedef FTaylorCell<ORDER,1> CellClass; + typedef FTaylorCell<FReal,ORDER,1> CellClass; typedef FOctree<FReal, CellClass,ContainerClass,LeafClass> OctreeClass; - typedef FTaylorKernel<CellClass,ContainerClass,ORDER,1> KernelClass; + typedef FTaylorKernel<FReal,CellClass,ContainerClass,ORDER,1> KernelClass; typedef FFmmAlgorithmThread<OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass; // init oct-tree OctreeClass tree(TreeHeight, SubTreeHeight, BoxWidth,CenterOfBox); @@ -314,7 +318,7 @@ struct TaylorMainStruct{ std::cout <<"(FTaylorKernel @Algorithm = " << time.elapsed() << " s)." << std::endl; } // ----------------------------------------------------- { // Check that each particle has been summed with all other - checkResAndPrint<OctreeClass,LeafClass>(&tree,particles,energyD,std::string("Taylor.res"),ORDER); + checkResAndPrint<FReal,OctreeClass,LeafClass>(&tree,particles,energyD,std::string("Taylor.res"),ORDER); } } @@ -325,7 +329,7 @@ struct TaylorMainStruct{ // Simply create particles and try the SPHERICAL kernels struct SphericalBlasMainStruct{ - template <const unsigned int ORDER, class FReal> + template <const unsigned int ORDER> static void For(int argc, char* argv[],FSize nbParticles,int TreeHeight, int SubTreeHeight, FReal BoxWidth, FPoint<FReal>& CenterOfBox,FmaRWParticle<FReal, 8,8> * const particles, FReal energyD,FReal totPhysicalValue) @@ -337,12 +341,13 @@ struct SphericalBlasMainStruct{ //Start of kernels there {//Spherical + typedef FP2PParticleContainerIndexed<FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass> LeafClass; - typedef FSphericalCell CellClass; + typedef FSphericalCell<FReal> CellClass; typedef FOctree<FReal, CellClass,ContainerClass,LeafClass> OctreeClass; CellClass::Init(ORDER); - typedef FSphericalBlasKernel<CellClass,ContainerClass> KernelClass; + typedef FSphericalBlasKernel<FReal,CellClass,ContainerClass> KernelClass; typedef FFmmAlgorithmThread<OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass; // init oct-tree OctreeClass tree(TreeHeight, SubTreeHeight, BoxWidth,CenterOfBox); @@ -361,7 +366,7 @@ struct SphericalBlasMainStruct{ std::cout <<"(FSphericalBlasKernel @Algorithm = " << time.elapsed() << " s)." << std::endl; } // ----------------------------------------------------- { // Check that each particle has been summed with all other - checkResAndPrint<OctreeClass,LeafClass>(&tree,particles,energyD,std::string("Blas.res"),ORDER); + checkResAndPrint<FReal,OctreeClass,LeafClass>(&tree,particles,energyD,std::string("Blas.res"),ORDER); } } @@ -371,7 +376,7 @@ struct SphericalBlasMainStruct{ // Simply create particles and try the SPHERICAL kernels struct SphericalBlockBlasMainStruct{ - template <const unsigned int ORDER, class FReal> + template <const unsigned int ORDER> static void For(int argc, char* argv[],FSize nbParticles,int TreeHeight, int SubTreeHeight, FReal BoxWidth, FPoint<FReal>& CenterOfBox,FmaRWParticle<FReal, 8,8> * const particles, FReal energyD,FReal totPhysicalValue) @@ -383,12 +388,13 @@ struct SphericalBlockBlasMainStruct{ //Start of kernels there {//Spherical + typedef FP2PParticleContainerIndexed<FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass> LeafClass; - typedef FSphericalCell CellClass; + typedef FSphericalCell<FReal> CellClass; typedef FOctree<FReal, CellClass,ContainerClass,LeafClass> OctreeClass; CellClass::Init(ORDER); - typedef FSphericalBlockBlasKernel<CellClass,ContainerClass> KernelClass; + typedef FSphericalBlockBlasKernel<FReal,CellClass,ContainerClass> KernelClass; typedef FFmmAlgorithmThread<OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass; // init oct-tree OctreeClass tree(TreeHeight, SubTreeHeight, BoxWidth,CenterOfBox); @@ -407,7 +413,7 @@ struct SphericalBlockBlasMainStruct{ std::cout <<"(FSphericalBlockBlasKernel @Algorithm = " << time.elapsed() << " s)." << std::endl; } // ----------------------------------------------------- { // Check that each particle has been summed with all other - checkResAndPrint<OctreeClass,LeafClass>(&tree,particles,energyD,std::string("BlockBlas.res"),ORDER); + checkResAndPrint<FReal,OctreeClass,LeafClass>(&tree,particles,energyD,std::string("BlockBlas.res"),ORDER); } } @@ -428,7 +434,7 @@ int main(int argc, char** argv){ const unsigned int SubTreeHeight = FParameters::getValue(argc, argv, "-subdepth", 2); const unsigned int NbThreads = FParameters::getValue(argc, argv, "-t", omp_get_max_threads()); - typedef double FReal; + //Open files FFmaGenericLoader<FReal> loader(filename); -- GitLab