From 33701cb25f19764925c996b50af3a43e6f1963c4 Mon Sep 17 00:00:00 2001 From: piacibel Date: Wed, 8 Jan 2014 14:37:23 +0100 Subject: [PATCH] Change to kernel constructor prototype for Chebyshev and Uniform. Changes propagated to all Test and UTest files (I hope) --- Src/Kernels/Chebyshev/FAbstractChebKernel.hpp | 140 +++++++++--------- Src/Kernels/Chebyshev/FChebFlopsSymKernel.hpp | 6 +- Src/Kernels/Chebyshev/FChebKernel.hpp | 12 +- Src/Kernels/Chebyshev/FChebSymKernel.hpp | 8 +- Src/Kernels/Uniform/FAbstractUnifKernel.hpp | 4 +- Src/Kernels/Uniform/FUnifKernel.hpp | 8 +- Tests/Kernels/testChebAlgorithm.cpp | 2 +- Tests/Kernels/testChebAlgorithmProc.cpp | 2 +- Tests/Kernels/testCompareKernels.cpp | 2 +- Tests/Kernels/testFlopsChebAlgorithm.cpp | 2 +- Tests/Kernels/testNewCompareKernels.cpp | 6 +- Tests/Kernels/testSphericalEwalAlgorithm.cpp | 4 +- Tests/Kernels/testUnifAlgorithm.cpp | 2 +- Tests/Kernels/testUnifAlgorithmProc.cpp | 2 +- Tests/Utils/testFFTW.cpp | 4 +- UTests/utestChebyshevDirect.cpp | 2 +- UTests/utestChebyshevDirectPeriodic.cpp | 4 +- UTests/utestChebyshevMultiRhs.cpp | 2 +- 18 files changed, 106 insertions(+), 106 deletions(-) diff --git a/Src/Kernels/Chebyshev/FAbstractChebKernel.hpp b/Src/Kernels/Chebyshev/FAbstractChebKernel.hpp index ecf9ba5d..40352b82 100755 --- a/Src/Kernels/Chebyshev/FAbstractChebKernel.hpp +++ b/Src/Kernels/Chebyshev/FAbstractChebKernel.hpp @@ -45,95 +45,95 @@ class FAbstractChebKernel : public FAbstractKernels< CellClass, ContainerClass> { protected: enum {nnodes = TensorTraits::nnodes}; - typedef FChebInterpolator InterpolatorClass; - - /// Needed for P2M, M2M, L2L and L2P operators - const FSmartPointer Interpolator; - /// Needed for P2P operator - const FSmartPointer MatrixKernel; - /// Height of the entire oct-tree - const unsigned int TreeHeight; - /// Corner of oct-tree box - const FPoint BoxCorner; - /// Width of oct-tree box - const FReal BoxWidth; - /// Width of a leaf cell box - const FReal BoxWidthLeaf; - - /** - * Compute center of leaf cell from its tree coordinate. - * @param[in] Coordinate tree coordinate - * @return center of leaf cell - */ - const FPoint getLeafCellCenter(const FTreeCoordinate& Coordinate) const - { - return FPoint(BoxCorner.getX() + (FReal(Coordinate.getX()) + FReal(.5)) * BoxWidthLeaf, - BoxCorner.getY() + (FReal(Coordinate.getY()) + FReal(.5)) * BoxWidthLeaf, - BoxCorner.getZ() + (FReal(Coordinate.getZ()) + FReal(.5)) * BoxWidthLeaf); - } + typedef FChebInterpolator InterpolatorClass; + + /// Needed for P2M, M2M, L2L and L2P operators + const FSmartPointer Interpolator; + /// Needed for P2P operator + const FSmartPointer MatrixKernel; + /// Height of the entire oct-tree + const unsigned int TreeHeight; + /// Corner of oct-tree box + const FPoint BoxCorner; + /// Width of oct-tree box + const FReal BoxWidth; + /// Width of a leaf cell box + const FReal BoxWidthLeaf; + + /** + * Compute center of leaf cell from its tree coordinate. + * @param[in] Coordinate tree coordinate + * @return center of leaf cell + */ + const FPoint getLeafCellCenter(const FTreeCoordinate& Coordinate) const + { + return FPoint(BoxCorner.getX() + (FReal(Coordinate.getX()) + FReal(.5)) * BoxWidthLeaf, + BoxCorner.getY() + (FReal(Coordinate.getY()) + FReal(.5)) * BoxWidthLeaf, + BoxCorner.getZ() + (FReal(Coordinate.getZ()) + FReal(.5)) * BoxWidthLeaf); + } public: - /** - * The constructor initializes all constant attributes and it reads the - * precomputed and compressed M2L operators from a binary file (an - * runtime_error is thrown if the required file is not valid). - */ - FAbstractChebKernel(const int inTreeHeight, - const FPoint& inBoxCenter, - const FReal inBoxWidth) - : Interpolator(new InterpolatorClass()), - MatrixKernel(new MatrixKernelClass()), - TreeHeight(inTreeHeight), - BoxCorner(inBoxCenter - inBoxWidth / FReal(2.)), - BoxWidth(inBoxWidth), - BoxWidthLeaf(BoxWidth / FReal(FMath::pow(2, inTreeHeight - 1))) - { - /* empty */ - } + /** + * The constructor initializes all constant attributes and it reads the + * precomputed and compressed M2L operators from a binary file (an + * runtime_error is thrown if the required file is not valid). + */ + FAbstractChebKernel(const int inTreeHeight, + const FReal inBoxWidth, + const FPoint& inBoxCenter) + : Interpolator(new InterpolatorClass()), + MatrixKernel(new MatrixKernelClass()), + TreeHeight(inTreeHeight), + BoxCorner(inBoxCenter - inBoxWidth / FReal(2.)), + BoxWidth(inBoxWidth), + BoxWidthLeaf(BoxWidth / FReal(FMath::pow(2, inTreeHeight - 1))) + { + /* empty */ + } - virtual ~FAbstractChebKernel(){ - // should not be used - } + virtual ~FAbstractChebKernel(){ + // should not be used + } - const InterpolatorClass *const getPtrToInterpolator() const - { return Interpolator.getPtr(); } + const InterpolatorClass *const getPtrToInterpolator() const + { return Interpolator.getPtr(); } - virtual void P2M(CellClass* const LeafCell, - const ContainerClass* const SourceParticles) = 0; + virtual void P2M(CellClass* const LeafCell, + const ContainerClass* const SourceParticles) = 0; - virtual void M2M(CellClass* const FRestrict ParentCell, - const CellClass*const FRestrict *const FRestrict ChildCells, - const int TreeLevel) = 0; + virtual void M2M(CellClass* const FRestrict ParentCell, + const CellClass*const FRestrict *const FRestrict ChildCells, + const int TreeLevel) = 0; - virtual void M2L(CellClass* const FRestrict TargetCell, - const CellClass* SourceCells[343], - const int NumSourceCells, - const int TreeLevel) = 0; + virtual void M2L(CellClass* const FRestrict TargetCell, + const CellClass* SourceCells[343], + const int NumSourceCells, + const int TreeLevel) = 0; - virtual void L2L(const CellClass* const FRestrict ParentCell, - CellClass* FRestrict *const FRestrict ChildCells, - const int TreeLevel) = 0; + virtual void L2L(const CellClass* const FRestrict ParentCell, + CellClass* FRestrict *const FRestrict ChildCells, + const int TreeLevel) = 0; - virtual void L2P(const CellClass* const LeafCell, - ContainerClass* const TargetParticles) = 0; + virtual void L2P(const CellClass* const LeafCell, + ContainerClass* const TargetParticles) = 0; - virtual void P2P(const FTreeCoordinate& /* LeafCellCoordinate */, // needed for periodic boundary conditions - ContainerClass* const FRestrict TargetParticles, - const ContainerClass* const FRestrict /*SourceParticles*/, - ContainerClass* const NeighborSourceParticles[27], - const int /* size */) = 0; + virtual void P2P(const FTreeCoordinate& /* LeafCellCoordinate */, // needed for periodic boundary conditions + ContainerClass* const FRestrict TargetParticles, + const ContainerClass* const FRestrict /*SourceParticles*/, + ContainerClass* const NeighborSourceParticles[27], + const int /* size */) = 0; - virtual void P2PRemote(const FTreeCoordinate& /*inPosition*/, - ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict /*inSources*/, - ContainerClass* const inNeighbors[27], const int /*inSize*/) = 0; + virtual void P2PRemote(const FTreeCoordinate& /*inPosition*/, + ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict /*inSources*/, + ContainerClass* const inNeighbors[27], const int /*inSize*/) = 0; }; diff --git a/Src/Kernels/Chebyshev/FChebFlopsSymKernel.hpp b/Src/Kernels/Chebyshev/FChebFlopsSymKernel.hpp index 58dc8d54..87873f0a 100755 --- a/Src/Kernels/Chebyshev/FChebFlopsSymKernel.hpp +++ b/Src/Kernels/Chebyshev/FChebFlopsSymKernel.hpp @@ -105,9 +105,9 @@ public: * runtime_error is thrown if the required file is not valid). */ FChebFlopsSymKernel(const int _inTreeHeight, - const FPoint& inBoxCenter, - const FReal inBoxWidth, - const FReal Epsilon) + const FReal inBoxWidth, + const FPoint& inBoxCenter, + const FReal Epsilon) : MatrixKernel(new MatrixKernelClass()), SymHandler(new SymmetryHandler(MatrixKernel.getPtr(), Epsilon)), inTreeHeight(_inTreeHeight), flopsP2M(0), flopsM2M(0), flopsM2L(0), flopsL2L(0), flopsL2P(0), flopsP2P(0), diff --git a/Src/Kernels/Chebyshev/FChebKernel.hpp b/Src/Kernels/Chebyshev/FChebKernel.hpp index 2c169262..dc99a1d9 100755 --- a/Src/Kernels/Chebyshev/FChebKernel.hpp +++ b/Src/Kernels/Chebyshev/FChebKernel.hpp @@ -61,13 +61,13 @@ public: * runtime_error is thrown if the required file is not valid). */ FChebKernel(const int inTreeHeight, - const FPoint& inBoxCenter, - const FReal inBoxWidth, - const FReal Epsilon) + const FReal inBoxWidth, + const FPoint& inBoxCenter, + const FReal Epsilon) : FAbstractChebKernel< CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS>(inTreeHeight, - inBoxCenter, - inBoxWidth), - M2LHandler(new M2LHandlerClass(Epsilon)) + inBoxWidth, + inBoxCenter), + M2LHandler(new M2LHandlerClass(Epsilon)) { // read precomputed compressed m2l operators from binary file //M2LHandler->ReadFromBinaryFileAndSet(); diff --git a/Src/Kernels/Chebyshev/FChebSymKernel.hpp b/Src/Kernels/Chebyshev/FChebSymKernel.hpp index 9143c569..3fc6bc3c 100755 --- a/Src/Kernels/Chebyshev/FChebSymKernel.hpp +++ b/Src/Kernels/Chebyshev/FChebSymKernel.hpp @@ -107,10 +107,10 @@ public: * runtime_error is thrown if the required file is not valid). */ FChebSymKernel(const int inTreeHeight, - const FPoint& inBoxCenter, - const FReal inBoxWidth, - const FReal Epsilon) - : AbstractBaseClass(inTreeHeight, inBoxCenter, inBoxWidth), + const FReal inBoxWidth, + const FPoint& inBoxCenter, + const FReal Epsilon) + : AbstractBaseClass(inTreeHeight, inBoxWidth, inBoxCenter), SymHandler(new SymmetryHandlerClass(AbstractBaseClass::MatrixKernel.getPtr(), Epsilon, inBoxWidth, inTreeHeight)), Loc(NULL), Mul(NULL), countExp(NULL) { diff --git a/Src/Kernels/Uniform/FAbstractUnifKernel.hpp b/Src/Kernels/Uniform/FAbstractUnifKernel.hpp index 18bcf624..6edde821 100644 --- a/Src/Kernels/Uniform/FAbstractUnifKernel.hpp +++ b/Src/Kernels/Uniform/FAbstractUnifKernel.hpp @@ -79,8 +79,8 @@ public: * runtime_error is thrown if the required file is not valid). */ FAbstractUnifKernel(const int inTreeHeight, - const FPoint& inBoxCenter, - const FReal inBoxWidth) + const FReal inBoxWidth, + const FPoint& inBoxCenter) : Interpolator(new InterpolatorClass()), MatrixKernel(new MatrixKernelClass()), TreeHeight(inTreeHeight), diff --git a/Src/Kernels/Uniform/FUnifKernel.hpp b/Src/Kernels/Uniform/FUnifKernel.hpp index 4bd37ed9..a017baaf 100644 --- a/Src/Kernels/Uniform/FUnifKernel.hpp +++ b/Src/Kernels/Uniform/FUnifKernel.hpp @@ -61,11 +61,11 @@ public: * runtime_error is thrown if the required file is not valid). */ FUnifKernel(const int inTreeHeight, - const FPoint& inBoxCenter, - const FReal inBoxWidth) + const FReal inBoxWidth, + const FPoint& inBoxCenter) : FAbstractUnifKernel< CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS>(inTreeHeight, - inBoxCenter, - inBoxWidth), + inBoxWidth, + inBoxCenter), M2LHandler(new M2LHandlerClass()) { // read precomputed compressed m2l operators from binary file diff --git a/Tests/Kernels/testChebAlgorithm.cpp b/Tests/Kernels/testChebAlgorithm.cpp index e9e5a26d..31238e19 100755 --- a/Tests/Kernels/testChebAlgorithm.cpp +++ b/Tests/Kernels/testChebAlgorithm.cpp @@ -158,7 +158,7 @@ int main(int argc, char* argv[]) { // ----------------------------------------------------- std::cout << "\nChebyshev FMM (ORDER="<< ORDER << ",EPS="<< epsilon <<") ... " << std::endl; time.tic(); - KernelClass kernels(TreeHeight, loader.getCenterOfBox(), loader.getBoxWidth(), epsilon); + KernelClass kernels(TreeHeight, loader.getBoxWidth(), loader.getCenterOfBox(), epsilon); FmmClass algorithm(&tree, &kernels); algorithm.execute(); time.tac(); diff --git a/Tests/Kernels/testChebAlgorithmProc.cpp b/Tests/Kernels/testChebAlgorithmProc.cpp index fa201414..bbb1b7a1 100644 --- a/Tests/Kernels/testChebAlgorithmProc.cpp +++ b/Tests/Kernels/testChebAlgorithmProc.cpp @@ -134,7 +134,7 @@ int main(int argc, char* argv[]) { // ----------------------------------------------------- std::cout << "\nChebyshev FMM (ORDER="<< ORDER << ",EPS="<< epsilon <<") ... " << std::endl; time.tic(); - KernelClass kernels(TreeHeight, loader.getCenterOfBox(), loader.getBoxWidth(), epsilon); + KernelClass kernels(TreeHeight, loader.getBoxWidth(), loader.getCenterOfBox(), epsilon); FmmClass algorithm(app.global(),&tree, &kernels); algorithm.execute(); time.tac(); diff --git a/Tests/Kernels/testCompareKernels.cpp b/Tests/Kernels/testCompareKernels.cpp index 7e2dd3e1..fff64349 100755 --- a/Tests/Kernels/testCompareKernels.cpp +++ b/Tests/Kernels/testCompareKernels.cpp @@ -153,7 +153,7 @@ int main(int argc, char* argv[]) { // ----------------------------------------------------- std::cout << "\nChebyshev FMM ... " << std::endl; time.tic(); - KernelClass kernels(TreeHeight, loader.getCenterOfBox(), loader.getBoxWidth(), epsilon); + KernelClass kernels(TreeHeight, loader.getBoxWidth(), loader.getCenterOfBox(), epsilon); FmmClass algorithm(&tree, &kernels); algorithm.execute(); time.tac(); diff --git a/Tests/Kernels/testFlopsChebAlgorithm.cpp b/Tests/Kernels/testFlopsChebAlgorithm.cpp index 3ff510e4..99738128 100755 --- a/Tests/Kernels/testFlopsChebAlgorithm.cpp +++ b/Tests/Kernels/testFlopsChebAlgorithm.cpp @@ -97,7 +97,7 @@ int main(int argc, char* argv[]) // ----------------------------------------------------- std::cout << "\nChebyshev FMM ... " << std::endl; - KernelClass kernels(TreeHeight, loader.getCenterOfBox(), loader.getBoxWidth(), epsilon); + KernelClass kernels(TreeHeight, loader.getBoxWidth(),loader.getCenterOfBox(), epsilon); FmmClass algorithm(&tree,&kernels); time.tic(); algorithm.execute(); diff --git a/Tests/Kernels/testNewCompareKernels.cpp b/Tests/Kernels/testNewCompareKernels.cpp index 1a0ef699..fb9231d9 100644 --- a/Tests/Kernels/testNewCompareKernels.cpp +++ b/Tests/Kernels/testNewCompareKernels.cpp @@ -152,7 +152,7 @@ int main(int argc, char* argv[]) typedef FOctree OctreeClass; typedef FChebSymKernel KernelClass; - // typedef FChebKernel KernelClass; + // typedef FChebKernDel KernelClass; typedef FFmmAlgorithm FmmClass; @@ -178,7 +178,7 @@ int main(int argc, char* argv[]) { // ----------------------------------------------------- std::cout << "\nChebyshev FMM ... " << std::endl; time.tic(); - KernelClass kernels(TreeHeight, loader.getCenterOfBox(), loader.getBoxWidth(), epsilon); + KernelClass kernels(TreeHeight, loader.getBoxWidth(), loader.getCenterOfBox(), epsilon); FmmClass algorithm(&tree, &kernels); algorithm.execute(); time.tac(); @@ -333,7 +333,7 @@ int main(int argc, char* argv[]) { // ----------------------------------------------------- std::cout << "\nLagrange FMM ... " << std::endl; time.tic(); - KernelClass kernels(TreeHeight, loader.getCenterOfBox(), loader.getBoxWidth()); + KernelClass kernels(TreeHeight, loader.getBoxWidth(), loader.getCenterOfBox()); FmmClass algorithm(&tree, &kernels); algorithm.execute(); time.tac(); diff --git a/Tests/Kernels/testSphericalEwalAlgorithm.cpp b/Tests/Kernels/testSphericalEwalAlgorithm.cpp index e7f38850..546c0882 100755 --- a/Tests/Kernels/testSphericalEwalAlgorithm.cpp +++ b/Tests/Kernels/testSphericalEwalAlgorithm.cpp @@ -158,7 +158,7 @@ int main(int argc, char ** argv){ #ifndef ScalFMM_USE_BLAS KernelClass kernels( DevP, NbLevels, loader.getBoxWidth(), loader.getCenterOfBox()); #else - KernelClass kernels( NbLevels, loader.getCenterOfBox(), loader.getBoxWidth(),epsilon); + KernelClass kernels( NbLevels, loader.getBoxWidth(), loader.getCenterOfBox(), epsilon); #endif FmmClassNoPer algo(&tree,&kernels); algo.execute(); @@ -170,7 +170,7 @@ int main(int argc, char ** argv){ KernelClass kernels( DevP, algo.extendedTreeHeight(), algo.extendedBoxWidth(),algo.extendedBoxCenter()); // KernelClass kernels( DevP, algo.extendedTreeHeight(), algo.extendedBoxWidth(),algo.extendedBoxCenter()); #else - KernelClass kernels(algo.extendedTreeHeight(), algo.extendedBoxCenter(), algo.extendedBoxWidth(),epsilon); + KernelClass kernels(algo.extendedTreeHeight(), algo.extendedBoxWidth(),algo.extendedBoxCenter(), epsilon); #endif algo.setKernel(&kernels); algo.execute(); diff --git a/Tests/Kernels/testUnifAlgorithm.cpp b/Tests/Kernels/testUnifAlgorithm.cpp index 983e7b24..9336e0f2 100644 --- a/Tests/Kernels/testUnifAlgorithm.cpp +++ b/Tests/Kernels/testUnifAlgorithm.cpp @@ -156,7 +156,7 @@ int main(int argc, char* argv[]) { // ----------------------------------------------------- std::cout << "\nLagrange/Uniform grid FMM (ORDER="<< ORDER << ") ... " << std::endl; time.tic(); - KernelClass kernels(TreeHeight, loader.getCenterOfBox(), loader.getBoxWidth()); + KernelClass kernels(TreeHeight, loader.getBoxWidth(), loader.getCenterOfBox()); FmmClass algorithm(&tree, &kernels); algorithm.execute(); time.tac(); diff --git a/Tests/Kernels/testUnifAlgorithmProc.cpp b/Tests/Kernels/testUnifAlgorithmProc.cpp index 1bfd95d6..30cc8905 100644 --- a/Tests/Kernels/testUnifAlgorithmProc.cpp +++ b/Tests/Kernels/testUnifAlgorithmProc.cpp @@ -133,7 +133,7 @@ int main(int argc, char* argv[]) { // ----------------------------------------------------- std::cout << "\nChebyshev FMM (ORDER="<< ORDER << ",EPS="<< epsilon <<") ... " << std::endl; time.tic(); - KernelClass kernels(TreeHeight, loader.getCenterOfBox(), loader.getBoxWidth()); + KernelClass kernels(TreeHeight, loader.getBoxWidth(), loader.getCenterOfBox()); FmmClass algorithm(app.global(),&tree, &kernels); algorithm.execute(); time.tac(); diff --git a/Tests/Utils/testFFTW.cpp b/Tests/Utils/testFFTW.cpp index 60ec8a90..bd275bfc 100644 --- a/Tests/Utils/testFFTW.cpp +++ b/Tests/Utils/testFFTW.cpp @@ -22,10 +22,10 @@ #include // include for libfftw3 -//#include +#include // include for mkl_fftw3 -#include +//#include #include "../../Src/Utils/FGlobal.hpp" #include "../../Src/Utils/FComplexe.hpp" diff --git a/UTests/utestChebyshevDirect.cpp b/UTests/utestChebyshevDirect.cpp index 0d87c0d5..a3f87f03 100755 --- a/UTests/utestChebyshevDirect.cpp +++ b/UTests/utestChebyshevDirect.cpp @@ -105,7 +105,7 @@ class TestChebyshevDirect : public FUTester { // Run FMM Print("Fmm..."); - KernelClass kernels(NbLevels, loader.getCenterOfBox(), loader.getBoxWidth(), epsilon); + KernelClass kernels(NbLevels, loader.getBoxWidth(), loader.getCenterOfBox(), epsilon); FmmClass algo(&tree,&kernels); algo.execute(); diff --git a/UTests/utestChebyshevDirectPeriodic.cpp b/UTests/utestChebyshevDirectPeriodic.cpp index 944db451..8b9eb627 100755 --- a/UTests/utestChebyshevDirectPeriodic.cpp +++ b/UTests/utestChebyshevDirectPeriodic.cpp @@ -96,8 +96,8 @@ class TestChebyshevDirect : public FUTester { // Run FMM Print("Fmm..."); FmmClass algo(&tree,PeriodicDeep ); - KernelClass kernels(algo.extendedTreeHeight(), algo.extendedBoxCenter(), - algo.extendedBoxWidth(), epsilon); + KernelClass kernels(algo.extendedTreeHeight(), algo.extendedBoxWidth(), + algo.extendedBoxCenter(), epsilon); algo.setKernel(&kernels); algo.execute(); diff --git a/UTests/utestChebyshevMultiRhs.cpp b/UTests/utestChebyshevMultiRhs.cpp index b2634d28..7baa2e8e 100644 --- a/UTests/utestChebyshevMultiRhs.cpp +++ b/UTests/utestChebyshevMultiRhs.cpp @@ -105,7 +105,7 @@ class TestChebyshevDirect : public FUTester { // Run FMM Print("Fmm..."); - KernelClass kernels(NbLevels, loader.getCenterOfBox(), loader.getBoxWidth(), epsilon); + KernelClass kernels(NbLevels, loader.getBoxWidth(), loader.getCenterOfBox(), epsilon); FmmClass algo(&tree,&kernels); algo.execute(); -- GitLab