From d046dd5532791b46a8f86c99d182c5666f2d1137 Mon Sep 17 00:00:00 2001 From: Pierre Blanchard Date: Tue, 15 Jul 2014 14:21:21 +0200 Subject: [PATCH] Modified interpolation based kernels such that matrix kernel is passed to ctor. --- Examples/ChebyshevInterpolationFMM.cpp | 3 +- Src/Kernels/Chebyshev/FAbstractChebKernel.hpp | 16 +----- Src/Kernels/Chebyshev/FChebKernel.hpp | 24 +++++---- Src/Kernels/Chebyshev/FChebM2LHandler.hpp | 29 +++++------ Src/Kernels/Chebyshev/FChebSymKernel.hpp | 25 +++++---- Src/Kernels/Chebyshev/FChebSymM2LHandler.hpp | 2 +- .../Chebyshev/FChebTensorialKernel.hpp | 21 ++++---- .../Chebyshev/FChebTensorialM2LHandler.hpp | 2 - .../Interpolation/FInterpMatrixKernel.hpp | 52 ++++++++++++++----- Src/Kernels/Uniform/FAbstractUnifKernel.hpp | 12 +---- Src/Kernels/Uniform/FUnifKernel.hpp | 15 ++++-- Src/Kernels/Uniform/FUnifTensorialKernel.hpp | 21 ++++---- Tests/Kernels/testChebTensorialAlgorithm.cpp | 26 +++++----- Tests/Kernels/testUnifAlgorithm.cpp | 2 +- Tests/Kernels/testUnifAlgorithmProc.cpp | 9 ++-- Tests/Kernels/testUnifTensorialAlgorithm.cpp | 10 ++-- Tests/noDist/testChebAlgorithm.cpp | 2 +- Tests/noDist/testChebAlgorithmProc.cpp | 9 ++-- Tests/noDist/testCompareKernels.cpp | 6 +-- UTests/FUKernelTester.hpp | 9 ++-- UTests/utestChebyshev.cpp | 12 ++--- UTests/utestChebyshevDirectPeriodic.cpp | 2 +- UTests/utestChebyshevMpi.cpp | 5 +- UTests/utestChebyshevMultiRhs.cpp | 4 +- UTests/utestChebyshevThread.cpp | 12 +++-- UTests/utestLagrange.cpp | 12 +++-- UTests/utestLagrangeMpi.cpp | 5 +- UTests/utestLagrangeThread.cpp | 11 ++-- 28 files changed, 206 insertions(+), 152 deletions(-) diff --git a/Examples/ChebyshevInterpolationFMM.cpp b/Examples/ChebyshevInterpolationFMM.cpp index 70aaf4b8..d2b7f063 100755 --- a/Examples/ChebyshevInterpolationFMM.cpp +++ b/Examples/ChebyshevInterpolationFMM.cpp @@ -122,6 +122,7 @@ int main(int argc, char* argv[]) typedef FOctree OctreeClass; // typedef FInterpMatrixKernelR MatrixKernelClass; + const MatrixKernelClass MatrixKernel; typedef FChebSymKernel KernelClass; // #ifdef _OPENMP @@ -161,7 +162,7 @@ int main(int argc, char* argv[]) time.tic(); // - KernelClass kernels(TreeHeight, loader.getBoxWidth(), loader.getCenterOfBox()); + KernelClass kernels(TreeHeight, loader.getBoxWidth(), loader.getCenterOfBox(),&MatrixKernel); // FmmClass algorithm(&tree, &kernels); // diff --git a/Src/Kernels/Chebyshev/FAbstractChebKernel.hpp b/Src/Kernels/Chebyshev/FAbstractChebKernel.hpp index 776cf0dd..7fe03414 100755 --- a/Src/Kernels/Chebyshev/FAbstractChebKernel.hpp +++ b/Src/Kernels/Chebyshev/FAbstractChebKernel.hpp @@ -49,8 +49,6 @@ protected: /// 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 @@ -61,9 +59,6 @@ protected: const FReal BoxWidthLeaf; /// Extension of the box width ( same for all level! ) const FReal BoxWidthExtension; - - /// Parameter to pass to matrix kernel (material specific or anything) - const FReal MatParam; /** * Compute center of leaf cell from its tree coordinate. @@ -86,18 +81,15 @@ public: FAbstractChebKernel(const int inTreeHeight, const FReal inBoxWidth, const FPoint& inBoxCenter, - const FReal inBoxWidthExtension = 0.0, - const FReal inMatParam = 0.0) + const FReal inBoxWidthExtension = 0.0) : Interpolator(new InterpolatorClass(inTreeHeight, inBoxWidth, inBoxWidthExtension)), - MatrixKernel(new MatrixKernelClass(inMatParam)), TreeHeight(inTreeHeight), BoxCorner(inBoxCenter - inBoxWidth / FReal(2.)), BoxWidth(inBoxWidth), BoxWidthLeaf(BoxWidth / FReal(FMath::pow(2, inTreeHeight - 1))), - BoxWidthExtension(inBoxWidthExtension), - MatParam(inMatParam) + BoxWidthExtension(inBoxWidthExtension) { /* empty */ } @@ -109,10 +101,6 @@ public: const InterpolatorClass * getPtrToInterpolator() const { return Interpolator.getPtr(); } - MatrixKernelClass * getPtrMatrixKernel() - {return MatrixKernel; } - - virtual void P2M(CellClass* const LeafCell, const ContainerClass* const SourceParticles) = 0; diff --git a/Src/Kernels/Chebyshev/FChebKernel.hpp b/Src/Kernels/Chebyshev/FChebKernel.hpp index 17c7adc8..6dbd3184 100755 --- a/Src/Kernels/Chebyshev/FChebKernel.hpp +++ b/Src/Kernels/Chebyshev/FChebKernel.hpp @@ -51,6 +51,9 @@ class FChebKernel typedef FAbstractChebKernel< CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS> AbstractBaseClass; + /// Needed for P2P and M2L operators + const MatrixKernelClass *const MatrixKernel; + /// Needed for M2L operator FSmartPointer< M2LHandlerClass,FSmartPointerMemory> M2LHandler; @@ -60,20 +63,21 @@ public: * precomputed and compressed M2L operators from a binary file (an * runtime_error is thrown if the required file is not valid). */ - FChebKernel(const int inTreeHeight, const FReal inBoxWidth, const FPoint& inBoxCenter, - const FReal Epsilon) - : FAbstractChebKernel< CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS>(inTreeHeight, - inBoxWidth, - inBoxCenter), - M2LHandler(new M2LHandlerClass(Epsilon)) + FChebKernel(const int inTreeHeight, const FReal inBoxWidth, const FPoint& inBoxCenter, const MatrixKernelClass *const inMatrixKernel, + const FReal Epsilon) + : FAbstractChebKernel< CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS>(inTreeHeight, + inBoxWidth, + inBoxCenter), + MatrixKernel(inMatrixKernel), + M2LHandler(new M2LHandlerClass(MatrixKernel,Epsilon)) { // read precomputed compressed m2l operators from binary file //M2LHandler->ReadFromBinaryFileAndSet(); M2LHandler->ComputeAndCompressAndSet(); } - FChebKernel(const int inTreeHeight, const FReal inBoxWidth, const FPoint& inBoxCenter) - : FChebKernel(inTreeHeight, inBoxWidth,inBoxCenter,FMath::pow(10.0,static_cast(-ORDER))) + FChebKernel(const int inTreeHeight, const FReal inBoxWidth, const FPoint& inBoxCenter, const MatrixKernelClass *const inMatrixKernel) + : FChebKernel(inTreeHeight, inBoxWidth,inBoxCenter,inMatrixKernel,FMath::pow(10.0,static_cast(-ORDER))) { } @@ -212,14 +216,14 @@ public: ContainerClass* const NeighborSourceParticles[27], const int /* size */) { - DirectInteractionComputer::P2P(TargetParticles,NeighborSourceParticles,AbstractBaseClass::MatrixKernel.getPtr()); + DirectInteractionComputer::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::P2PRemote(inTargets,inNeighbors,27,AbstractBaseClass::MatrixKernel.getPtr()); + DirectInteractionComputer::P2PRemote(inTargets,inNeighbors,27,MatrixKernel); } }; diff --git a/Src/Kernels/Chebyshev/FChebM2LHandler.hpp b/Src/Kernels/Chebyshev/FChebM2LHandler.hpp index 782ef596..ff2fa37f 100755 --- a/Src/Kernels/Chebyshev/FChebM2LHandler.hpp +++ b/Src/Kernels/Chebyshev/FChebM2LHandler.hpp @@ -70,7 +70,7 @@ class FChebM2LHandler : FNoCopyable nnodes = TensorTraits::nnodes, ninteractions = 316}; // 7^3 - 3^3 (max num cells in far-field) - const MatrixKernelClass MatrixKernel; + const MatrixKernelClass *const MatrixKernel; FReal *U, *C, *B; const FReal epsilon; //getScaleFactor(CellWidth)); FBlas::gemva(rank, rank, scale, C + idx*rank*rank, const_cast(Y), X); } void applyC(const unsigned int idx, FReal CellWidth, const FReal *const Y, FReal *const X) const { - const FReal scale(MatrixKernel.getScaleFactor(CellWidth)); + const FReal scale(MatrixKernel->getScaleFactor(CellWidth)); FBlas::gemva(rank, rank, scale, C + idx*rank*rank, const_cast(Y), X); } void applyC(FReal CellWidth, const FReal *const Y, FReal *const X) const { - const FReal scale(MatrixKernel.getScaleFactor(CellWidth)); + const FReal scale(MatrixKernel->getScaleFactor(CellWidth)); FBlas::gemva(rank, rank * 343, scale, C, const_cast(Y), X); } @@ -229,7 +229,8 @@ public: template unsigned int -FChebM2LHandler::ComputeAndCompress(const FReal epsilon, +FChebM2LHandler::ComputeAndCompress(const MatrixKernelClass *const MatrixKernel, + const FReal epsilon, FReal* &U, FReal* &C, FReal* &B) @@ -241,8 +242,6 @@ FChebM2LHandler::ComputeAndCompress(const FReal epsilo FPoint X[nnodes], Y[nnodes]; // set roots of target cell (X) FChebTensor::setRoots(FPoint(0.,0.,0.), FReal(2.), X); - // init matrix kernel - const MatrixKernelClass MatrixKernel; // allocate memory and compute 316 m2l operators FReal *_U, *_C, *_B; @@ -260,7 +259,7 @@ FChebM2LHandler::ComputeAndCompress(const FReal epsilo for (unsigned int n=0; nevaluate(X[m], Y[n]); // increment interaction counter counter++; } @@ -330,14 +329,14 @@ FChebM2LHandler::ComputeAndCompress(const FReal epsilo template void -FChebM2LHandler::ComputeAndCompressAndStoreInBinaryFile(const FReal epsilon) +FChebM2LHandler::ComputeAndCompressAndStoreInBinaryFile(const MatrixKernelClass *const MatrixKernel, const FReal epsilon) { // measure time FTic time; time.tic(); // start computing process FReal *U, *C, *B; U = C = B = nullptr; - const unsigned int rank = ComputeAndCompress(epsilon, U, C, B); + const unsigned int rank = ComputeAndCompress(MatrixKernel, epsilon, U, C, B); // store into binary file const std::string filename(getFileName(epsilon)); std::ofstream stream(filename.c_str(), diff --git a/Src/Kernels/Chebyshev/FChebSymKernel.hpp b/Src/Kernels/Chebyshev/FChebSymKernel.hpp index 93ed3e06..df339485 100755 --- a/Src/Kernels/Chebyshev/FChebSymKernel.hpp +++ b/Src/Kernels/Chebyshev/FChebSymKernel.hpp @@ -56,6 +56,9 @@ class FChebSymKernel typedef SymmetryHandler SymmetryHandlerClass; enum {nnodes = AbstractBaseClass::nnodes}; + /// Needed for P2P and M2L operators + const MatrixKernelClass *const MatrixKernel; + /// Needed for handling all symmetries const FSmartPointer SymHandler; @@ -105,11 +108,13 @@ public: * runtime_error is thrown if the required file is not valid). */ FChebSymKernel(const int inTreeHeight, - const FReal inBoxWidth, - const FPoint& inBoxCenter, - const FReal Epsilon) + const FReal inBoxWidth, + const FPoint& inBoxCenter, + const MatrixKernelClass *const inMatrixKernel, + const FReal Epsilon) : AbstractBaseClass(inTreeHeight, inBoxWidth, inBoxCenter), - SymHandler(new SymmetryHandlerClass(AbstractBaseClass::MatrixKernel.getPtr(), Epsilon, inBoxWidth, inTreeHeight)), + MatrixKernel(inMatrixKernel), + SymHandler(new SymmetryHandlerClass(MatrixKernel, Epsilon, inBoxWidth, inTreeHeight)), Loc(nullptr), Mul(nullptr), countExp(nullptr) { this->allocateMemoryForPermutedExpansions(); @@ -126,8 +131,9 @@ public: * runtime_error is thrown if the required file is not valid). */ FChebSymKernel(const int inTreeHeight, - const FReal inBoxWidth, - const FPoint& inBoxCenter) :FChebSymKernel(inTreeHeight,inBoxWidth, inBoxCenter,FMath::pow(10.0,static_cast(-ORDER))) + const FReal inBoxWidth, + const FPoint& inBoxCenter, + const MatrixKernelClass *const inMatrixKernel) :FChebSymKernel(inTreeHeight,inBoxWidth, inBoxCenter,inMatrixKernel,FMath::pow(10.0,static_cast(-ORDER))) {} @@ -135,6 +141,7 @@ public: /** Copy constructor */ FChebSymKernel(const FChebSymKernel& other) : AbstractBaseClass(other), + MatrixKernel(other.MatrixKernel), SymHandler(other.SymHandler), Loc(nullptr), Mul(nullptr), countExp(nullptr) { @@ -264,7 +271,7 @@ public: // multiply (mat-mat-mul) FReal Compressed [nnodes * 24]; - const FReal scale = AbstractBaseClass::MatrixKernel->getScaleFactor(AbstractBaseClass::BoxWidth, TreeLevel); + const FReal scale = MatrixKernel->getScaleFactor(AbstractBaseClass::BoxWidth, TreeLevel); for (unsigned int pidx=0; pidx<343; ++pidx) { const unsigned int count = countExp[pidx]; if (count) { @@ -462,14 +469,14 @@ public: ContainerClass* const NeighborSourceParticles[27], const int /* size */) { - DirectInteractionComputer::P2P(TargetParticles,NeighborSourceParticles,AbstractBaseClass::MatrixKernel.getPtr()); + DirectInteractionComputer::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::P2PRemote(inTargets,inNeighbors,27,AbstractBaseClass::MatrixKernel.getPtr()); + DirectInteractionComputer::P2PRemote(inTargets,inNeighbors,27,MatrixKernel); } }; diff --git a/Src/Kernels/Chebyshev/FChebSymM2LHandler.hpp b/Src/Kernels/Chebyshev/FChebSymM2LHandler.hpp index b2422582..28e6e324 100755 --- a/Src/Kernels/Chebyshev/FChebSymM2LHandler.hpp +++ b/Src/Kernels/Chebyshev/FChebSymM2LHandler.hpp @@ -303,7 +303,7 @@ static void precompute(const MatrixKernelClass *const MatrixKernel, const FReal FChebTensor::setRootOfWeights(weights); // now the entry-computer is responsible for weighting the matrix entries - EntryComputer Computer(nnodes, X, nnodes, Y, weights); + EntryComputer Computer(MatrixKernel, nnodes, X, nnodes, Y, weights); // start timer time.tic(); diff --git a/Src/Kernels/Chebyshev/FChebTensorialKernel.hpp b/Src/Kernels/Chebyshev/FChebTensorialKernel.hpp index 4966e084..dcf24d47 100755 --- a/Src/Kernels/Chebyshev/FChebTensorialKernel.hpp +++ b/Src/Kernels/Chebyshev/FChebTensorialKernel.hpp @@ -59,6 +59,9 @@ protected://PB: for OptiDis typedef FAbstractChebKernel< CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS> AbstractBaseClass; + /// Needed for P2P and M2L operators + const MatrixKernelClass *const MatrixKernel; + /// Needed for M2L operator FSmartPointer< M2LHandlerClass,FSmartPointerMemory> M2LHandler; @@ -71,11 +74,12 @@ public: FChebTensorialKernel(const int inTreeHeight, const FReal inBoxWidth, const FPoint& inBoxCenter, + const MatrixKernelClass *const inMatrixKernel, const FReal inBoxWidthExtension, - const FReal Epsilon, - const double inMatParam = 0.0) - : FAbstractChebKernel< CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS>(inTreeHeight,inBoxWidth,inBoxCenter,inBoxWidthExtension,inMatParam), - M2LHandler(new M2LHandlerClass(AbstractBaseClass::MatrixKernel.getPtr(), + const FReal Epsilon) + : FAbstractChebKernel< CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS>(inTreeHeight,inBoxWidth,inBoxCenter,inBoxWidthExtension), + MatrixKernel(inMatrixKernel), + M2LHandler(new M2LHandlerClass(MatrixKernel, inTreeHeight, inBoxWidth, inBoxWidthExtension, @@ -143,7 +147,7 @@ public: // scale factor for homogeneous case const FReal CellWidth(AbstractBaseClass::BoxWidth / FReal(FMath::pow(2, TreeLevel))); const FReal ExtendedCellWidth(CellWidth + AbstractBaseClass::BoxWidthExtension); - const FReal scale(AbstractBaseClass::MatrixKernel.getPtr()->getScaleFactor(ExtendedCellWidth)); + const FReal scale(MatrixKernel->getScaleFactor(ExtendedCellWidth)); for(int idxV = 0 ; idxV < NVALS ; ++idxV){ for (int idxLhs=0; idxLhs < nLhs; ++idxLhs){ @@ -158,8 +162,7 @@ public: const int idxMul = idxV*nRhs + idxRhs; // get index in matrix kernel - const unsigned int d - = AbstractBaseClass::MatrixKernel.getPtr()->getPosition(idxLhs); + const unsigned int d = MatrixKernel->getPosition(idxLhs); for (int idx=0; idx<343; ++idx){ if (SourceCells[idx]){ @@ -237,14 +240,14 @@ public: ContainerClass* const NeighborSourceParticles[27], const int /* size */) { - DirectInteractionComputer::P2P(TargetParticles,NeighborSourceParticles,AbstractBaseClass::MatrixKernel.getPtr()); + DirectInteractionComputer::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::P2PRemote(inTargets,inNeighbors,27,AbstractBaseClass::MatrixKernel.getPtr()); + DirectInteractionComputer::P2PRemote(inTargets,inNeighbors,27,MatrixKernel); } }; diff --git a/Src/Kernels/Chebyshev/FChebTensorialM2LHandler.hpp b/Src/Kernels/Chebyshev/FChebTensorialM2LHandler.hpp index 40614bfd..d65a7c59 100755 --- a/Src/Kernels/Chebyshev/FChebTensorialM2LHandler.hpp +++ b/Src/Kernels/Chebyshev/FChebTensorialM2LHandler.hpp @@ -82,8 +82,6 @@ class FChebTensorialM2LHandler : FNoCopyabl ninteractions = 316,// 7^3 - 3^3 (max num cells in far-field) ncmp = MatrixKernelClass::NCMP}; -// const MatrixKernelClass MatrixKernel; - // FReal *U, *C, *B; FReal *U, *B; FReal** C; diff --git a/Src/Kernels/Interpolation/FInterpMatrixKernel.hpp b/Src/Kernels/Interpolation/FInterpMatrixKernel.hpp index 16a15dee..52a19d7e 100755 --- a/Src/Kernels/Interpolation/FInterpMatrixKernel.hpp +++ b/Src/Kernels/Interpolation/FInterpMatrixKernel.hpp @@ -80,7 +80,11 @@ struct FInterpMatrixKernelR : FInterpAbstractMatrixKernel static const unsigned int NRHS = 1; //< dim of mult exp static const unsigned int NLHS = 1; //< dim of loc exp - FInterpMatrixKernelR(const FReal = 0.0, const unsigned int = 0) {} + FInterpMatrixKernelR() {} + + // copy ctor + FInterpMatrixKernelR(const FInterpMatrixKernelR& other) + {} // returns position in reduced storage int getPosition(const unsigned int) const @@ -142,9 +146,14 @@ struct FInterpMatrixKernelRH :FInterpMatrixKernelR{ static const unsigned int NLHS = 1; //< dim of loc exp FReal LX,LY,LZ ; - FInterpMatrixKernelRH(const FReal = 0.0, const unsigned int = 0) : LX(1.0),LY(1.0),LZ(1.0) + FInterpMatrixKernelRH() : LX(1.0),LY(1.0),LZ(1.0) { } + // copy ctor + FInterpMatrixKernelRH(const FInterpMatrixKernelRH& other) + : LX(other.LX), LY(other.LY), LZ(other.LZ) + {} + // evaluate interaction FReal evaluate(const FPoint& x, const FPoint& y) const { @@ -207,7 +216,11 @@ struct FInterpMatrixKernelRR : FInterpAbstractMatrixKernel static const unsigned int NRHS = 1; //< dim of mult exp static const unsigned int NLHS = 1; //< dim of loc exp - FInterpMatrixKernelRR(const FReal = 0.0, const unsigned int = 0) {} + FInterpMatrixKernelRR() {} + + // copy ctor + FInterpMatrixKernelRR(const FInterpMatrixKernelRR& other) + {} // returns position in reduced storage int getPosition(const unsigned int) const @@ -272,7 +285,11 @@ struct FInterpMatrixKernelLJ : FInterpAbstractMatrixKernel static const unsigned int NRHS = 1; //< dim of mult exp static const unsigned int NLHS = 1; //< dim of loc exp - FInterpMatrixKernelLJ(const FReal = 0.0, const unsigned int = 0) {} + FInterpMatrixKernelLJ() {} + + // copy ctor + FInterpMatrixKernelLJ(const FInterpMatrixKernelLJ& other) + {} // returns position in reduced storage int getPosition(const unsigned int) const @@ -388,6 +405,11 @@ struct FInterpMatrixKernel_R_IJ : FInterpAbstractMatrixKernel : _i(indexTab[d]), _j(indexTab[d+NCMP]), _CoreWidth2(CoreWidth*CoreWidth) {} + // copy ctor + FInterpMatrixKernel_R_IJ(const FInterpMatrixKernel_R_IJ& other) + : _i(other._i), _j(other._j), _CoreWidth2(other._CoreWidth2) + {} + // returns position in reduced storage from position in full 3x3 matrix unsigned int getPosition(const unsigned int n) const {return applyTab[n];} @@ -487,6 +509,11 @@ struct FInterpMatrixKernel_R_IJK : FInterpAbstractMatrixKernel : _i(indexTab[d]), _j(indexTab[d+NCMP]), _k(indexTab[d+2*NCMP]), _CoreWidth2(CoreWidth*CoreWidth) {} + // copy ctor + FInterpMatrixKernel_R_IJK(const FInterpMatrixKernel_R_IJK& other) + : _i(other._i), _j(other._j), _k(other._k), _CoreWidth2(other._CoreWidth2) + {} + // returns position in reduced storage from position in full 3x3x3 matrix unsigned int getPosition(const unsigned int n) const {return applyTab[n];} @@ -598,10 +625,10 @@ struct FInterpMatrixKernel_R_IJK : FInterpAbstractMatrixKernel number of rows and cols and on the coordinates x and y and the type of the generating matrix-kernel function. */ -template +template class EntryComputer { - const MatrixKernel Kernel; + const MatrixKernelClass *const MatrixKernel; const unsigned int nx, ny; const FPoint *const px, *const py; @@ -609,12 +636,11 @@ class EntryComputer const FReal *const weights; public: - explicit EntryComputer(const unsigned int _nx, const FPoint *const _px, + explicit EntryComputer(const MatrixKernelClass *const inMatrixKernel, + const unsigned int _nx, const FPoint *const _px, const unsigned int _ny, const FPoint *const _py, - const FReal *const _weights = NULL, - const unsigned int idxK = 0, - const FReal matparam = 0.0) - : Kernel(matparam,idxK), nx(_nx), ny(_ny), px(_px), py(_py), weights(_weights) {} + const FReal *const _weights = NULL) + : MatrixKernel(inMatrixKernel), nx(_nx), ny(_ny), px(_px), py(_py), weights(_weights) {} void operator()(const unsigned int xbeg, const unsigned int xend, const unsigned int ybeg, const unsigned int yend, @@ -624,11 +650,11 @@ public: if (weights) { for (unsigned int j=ybeg; jevaluate(px[i], py[j]); } else { for (unsigned int j=ybeg; jevaluate(px[i], py[j]); } /* diff --git a/Src/Kernels/Uniform/FAbstractUnifKernel.hpp b/Src/Kernels/Uniform/FAbstractUnifKernel.hpp index 90c84775..d9529a32 100644 --- a/Src/Kernels/Uniform/FAbstractUnifKernel.hpp +++ b/Src/Kernels/Uniform/FAbstractUnifKernel.hpp @@ -49,8 +49,6 @@ protected: /// 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 @@ -62,9 +60,6 @@ protected: /// Extension of the box width ( same for all level! ) const FReal BoxWidthExtension; - /// Parameter to pass to matrix kernel (material specific or anything) - const double MatParam; - /** * Compute center of leaf cell from its tree coordinate. * @param[in] Coordinate tree coordinate @@ -86,18 +81,15 @@ public: FAbstractUnifKernel(const int inTreeHeight, const FReal inBoxWidth, const FPoint& inBoxCenter, - const FReal inBoxWidthExtension = 0.0, - const double inMatParam = 0.0) + const FReal inBoxWidthExtension = 0.0) : Interpolator(new InterpolatorClass(inTreeHeight, inBoxWidth, inBoxWidthExtension)), - MatrixKernel(new MatrixKernelClass(inMatParam)), TreeHeight(inTreeHeight), BoxCorner(inBoxCenter - inBoxWidth / FReal(2.)), BoxWidth(inBoxWidth), BoxWidthLeaf(BoxWidth / FReal(FMath::pow(2, inTreeHeight - 1))), - BoxWidthExtension(inBoxWidthExtension), - MatParam(inMatParam) + BoxWidthExtension(inBoxWidthExtension) { /* empty */ } diff --git a/Src/Kernels/Uniform/FUnifKernel.hpp b/Src/Kernels/Uniform/FUnifKernel.hpp index 1fcfad13..6c2324af 100644 --- a/Src/Kernels/Uniform/FUnifKernel.hpp +++ b/Src/Kernels/Uniform/FUnifKernel.hpp @@ -51,6 +51,9 @@ class FUnifKernel typedef FAbstractUnifKernel< CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS> AbstractBaseClass; + /// Needed for P2P and M2L operators + const MatrixKernelClass *const MatrixKernel; + /// Needed for M2L operator const M2LHandlerClass M2LHandler; @@ -63,9 +66,11 @@ public: */ FUnifKernel(const int inTreeHeight, const FReal inBoxWidth, - const FPoint& inBoxCenter) + const FPoint& inBoxCenter, + const MatrixKernelClass *const inMatrixKernel) : FAbstractUnifKernel< CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS>(inTreeHeight,inBoxWidth,inBoxCenter), - M2LHandler(AbstractBaseClass::MatrixKernel.getPtr(), + MatrixKernel(inMatrixKernel), + M2LHandler(MatrixKernel, inTreeHeight, inBoxWidth) { } @@ -131,7 +136,7 @@ public: const int TreeLevel) { const FReal CellWidth(AbstractBaseClass::BoxWidth / FReal(FMath::pow(2, TreeLevel))); - const FReal scale(AbstractBaseClass::MatrixKernel.getPtr()->getScaleFactor(CellWidth)); + const FReal scale(MatrixKernel->getScaleFactor(CellWidth)); for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){ FComplexe *const TransformedLocalExpansion = TargetCell->getTransformedLocal(idxRhs); @@ -208,7 +213,7 @@ public: ContainerClass* const NeighborSourceParticles[27], const int /* size */) { - DirectInteractionComputer::P2P(TargetParticles,NeighborSourceParticles,AbstractBaseClass::MatrixKernel.getPtr()); + DirectInteractionComputer::P2P(TargetParticles,NeighborSourceParticles,MatrixKernel); } @@ -216,7 +221,7 @@ public: ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict /*inSources*/, ContainerClass* const inNeighbors[27], const int /*inSize*/) { - DirectInteractionComputer::P2PRemote(inTargets,inNeighbors,27,AbstractBaseClass::MatrixKernel.getPtr()); + DirectInteractionComputer::P2PRemote(inTargets,inNeighbors,27,MatrixKernel); } }; diff --git a/Src/Kernels/Uniform/FUnifTensorialKernel.hpp b/Src/Kernels/Uniform/FUnifTensorialKernel.hpp index 52edf182..05a5c289 100644 --- a/Src/Kernels/Uniform/FUnifTensorialKernel.hpp +++ b/Src/Kernels/Uniform/FUnifTensorialKernel.hpp @@ -75,6 +75,9 @@ protected://PB: for OptiDis typedef FAbstractUnifKernel< CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS> AbstractBaseClass; + /// Needed for P2P and M2L operators + const MatrixKernelClass *const MatrixKernel; + /// Needed for M2L operator const M2LHandlerClass M2LHandler; @@ -87,10 +90,11 @@ public: FUnifTensorialKernel(const int inTreeHeight, const FReal inBoxWidth, const FPoint& inBoxCenter, - const FReal inBoxWidthExtension, - const double inMatParam = 0.0) - : FAbstractUnifKernel< CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS>(inTreeHeight,inBoxWidth,inBoxCenter,inBoxWidthExtension,inMatParam), - M2LHandler(AbstractBaseClass::MatrixKernel.getPtr(), + const MatrixKernelClass *const inMatrixKernel, + const FReal inBoxWidthExtension) + : FAbstractUnifKernel< CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS>(inTreeHeight,inBoxWidth,inBoxCenter,inBoxWidthExtension), + MatrixKernel(inMatrixKernel), + M2LHandler(MatrixKernel, inTreeHeight, inBoxWidth, inBoxWidthExtension) @@ -157,7 +161,7 @@ public: { const FReal CellWidth(AbstractBaseClass::BoxWidth / FReal(FMath::pow(2, TreeLevel))); const FReal ExtendedCellWidth(CellWidth + AbstractBaseClass::BoxWidthExtension); - const FReal scale(AbstractBaseClass::MatrixKernel.getPtr()->getScaleFactor(ExtendedCellWidth)); + const FReal scale(MatrixKernel->getScaleFactor(ExtendedCellWidth)); for(int idxV = 0 ; idxV < NVALS ; ++idxV){ for (int idxLhs=0; idxLhs < nLhs; ++idxLhs){ @@ -175,8 +179,7 @@ public: const int idxMul = idxV*nRhs + idxRhs; // get index in matrix kernel - const unsigned int d - = AbstractBaseClass::MatrixKernel.getPtr()->getPosition(idxLhs); + const unsigned int d = MatrixKernel->getPosition(idxLhs); for (int idx=0; idx<343; ++idx){ if (SourceCells[idx]){ @@ -248,14 +251,14 @@ public: ContainerClass* const NeighborSourceParticles[27], const int /* size */) { - DirectInteractionComputer::P2P(TargetParticles,NeighborSourceParticles,AbstractBaseClass::MatrixKernel.getPtr()); + DirectInteractionComputer::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::P2PRemote(inTargets,inNeighbors,27,AbstractBaseClass::MatrixKernel.getPtr()); + DirectInteractionComputer::P2PRemote(inTargets,inNeighbors,27,MatrixKernel); } }; diff --git a/Tests/Kernels/testChebTensorialAlgorithm.cpp b/Tests/Kernels/testChebTensorialAlgorithm.cpp index 0c928dd3..01f762c3 100644 --- a/Tests/Kernels/testChebTensorialAlgorithm.cpp +++ b/Tests/Kernels/testChebTensorialAlgorithm.cpp @@ -78,7 +78,7 @@ int main(int argc, char* argv[]) const unsigned int NLHS = MatrixKernelClass::NLHS; const double CoreWidth = 0.1; - const MatrixKernelClass DirectMatrixKernel(CoreWidth); + const MatrixKernelClass MatrixKernel(CoreWidth); std::cout<< "Interaction kernel: "; if(MK_ID == ONE_OVER_R) std::cout<< "1/R"; else if(MK_ID == R_IJ) @@ -143,16 +143,16 @@ int main(int argc, char* argv[]) particles[idxOther].position.getZ(), particles[idxOther].physicalValue, particles[idxOther].forces[0], particles[idxOther].forces[1], particles[idxOther].forces[2], particles[idxOther].potential, - &DirectMatrixKernel); - else if(MK_ID == ONE_OVER_R) - FP2P::MutualParticles(particles[idxTarget].position.getX(), particles[idxTarget].position.getY(), - particles[idxTarget].position.getZ(), particles[idxTarget].physicalValue[0], - particles[idxTarget].forces[0], particles[idxTarget].forces[1], - particles[idxTarget].forces[2], particles[idxTarget].potential, - particles[idxOther].position.getX(), particles[idxOther].position.getY(), - particles[idxOther].position.getZ(), particles[idxOther].physicalValue[0], - particles[idxOther].forces[0], particles[idxOther].forces[1], - particles[idxOther].forces[2], particles[idxOther].potential); + &MatrixKernel); +// else if(MK_ID == ONE_OVER_R) +// FP2P::MutualParticles(particles[idxTarget].position.getX(), particles[idxTarget].position.getY(), +// particles[idxTarget].position.getZ(), particles[idxTarget].physicalValue[0], +// particles[idxTarget].forces[0], particles[idxTarget].forces[1], +// particles[idxTarget].forces[2], particles[idxTarget].potential, +// particles[idxOther].position.getX(), particles[idxOther].position.getY(), +// particles[idxOther].position.getZ(), particles[idxOther].physicalValue[0], +// particles[idxOther].forces[0], particles[idxOther].forces[1], +// particles[idxOther].forces[2], particles[idxOther].potential,&MatrixKernel); else if(MK_ID == R_IJK) FP2P::MutualParticlesRIJK(particles[idxTarget].position.getX(), particles[idxTarget].position.getY(), particles[idxTarget].position.getZ(), particles[idxTarget].physicalValue, @@ -162,7 +162,7 @@ int main(int argc, char* argv[]) particles[idxOther].position.getZ(), particles[idxOther].physicalValue, particles[idxOther].forces[0], particles[idxOther].forces[1], particles[idxOther].forces[2], particles[idxOther].potential, - &DirectMatrixKernel); + &MatrixKernel); else std::runtime_error("Provide a valid matrix kernel!"); } @@ -240,7 +240,7 @@ int main(int argc, char* argv[]) { // ----------------------------------------------------- std::cout << "\nChebyshev FMM (ORDER="<< ORDER << ") ... " << std::endl; time.tic(); - KernelClass kernels(TreeHeight, loader.getBoxWidth(), loader.getCenterOfBox(), BoxWidthExtension, epsilon, CoreWidth); + KernelClass kernels(TreeHeight, loader.getBoxWidth(), loader.getCenterOfBox(), &MatrixKernel, BoxWidthExtension, epsilon); FmmClass algorithm(&tree, &kernels); algorithm.execute(); time.tac(); diff --git a/Tests/Kernels/testUnifAlgorithm.cpp b/Tests/Kernels/testUnifAlgorithm.cpp index 599e0ef7..6dd14266 100644 --- a/Tests/Kernels/testUnifAlgorithm.cpp +++ b/Tests/Kernels/testUnifAlgorithm.cpp @@ -166,7 +166,7 @@ int main(int argc, char* argv[]) { // ----------------------------------------------------- std::cout << "\nLagrange/Uniform grid FMM (ORDER="<< ORDER << ") ... " << std::endl; time.tic(); - KernelClass kernels(TreeHeight, loader.getBoxWidth(), loader.getCenterOfBox()); + KernelClass kernels(TreeHeight, loader.getBoxWidth(), loader.getCenterOfBox(),&MatrixKernel); FmmClass algorithm(&tree, &kernels); algorithm.execute(); time.tac(); diff --git a/Tests/Kernels/testUnifAlgorithmProc.cpp b/Tests/Kernels/testUnifAlgorithmProc.cpp index aa4451ad..7525f934 100644 --- a/Tests/Kernels/testUnifAlgorithmProc.cpp +++ b/Tests/Kernels/testUnifAlgorithmProc.cpp @@ -87,9 +87,12 @@ int main(int argc, char* argv[]) #endif std::cout << "Opening : " <::uassert; // The run function is performing the test for the given configuration - template - void RunTest(std::function(int NbLevels, FReal boxWidth, FPoint centerOfBox)> GetKernelFunc) { + void RunTest(std::function(int NbLevels, FReal boxWidth, FPoint centerOfBox, const MatrixKernelClass *const MatrixKernel)> GetKernelFunc) { // // Load particles // @@ -85,11 +85,14 @@ public: tree.insert(particles[idxPart].getPosition() , idxPart, particles[idxPart].getPhysicalValue() ); } // + // Create Matrix Kernel + const MatrixKernelClass MatrixKernel; // FUKernelTester is only designed to work with 1/R, i.e. matrix kernel ctor takes no argument. + // ///////////////////////////////////////////////////////////////////////////////////////////////// // Run FMM computation ///////////////////////////////////////////////////////////////////////////////////////////////// Print("Fmm..."); - std::unique_ptr kernels(GetKernelFunc(NbLevels, loader.getBoxWidth(), loader.getCenterOfBox())); + std::unique_ptr kernels(GetKernelFunc(NbLevels, loader.getBoxWidth(), loader.getCenterOfBox(),&MatrixKernel)); FmmClass algo(&tree,kernels.get()); algo.execute(); // diff --git a/UTests/utestChebyshev.cpp b/UTests/utestChebyshev.cpp index 1fd76ade..7a5bcbea 100755 --- a/UTests/utestChebyshev.cpp +++ b/UTests/utestChebyshev.cpp @@ -53,9 +53,9 @@ class TestChebyshevDirect : public FUKernelTester { typedef FChebKernel KernelClass; typedef FFmmAlgorithm FmmClass; // run test - RunTest( - [&](int NbLevels, FReal boxWidth, FPoint centerOfBox){ - return std::unique_ptr(new KernelClass(NbLevels, boxWidth, centerOfBox)); + RunTest( + [&](int NbLevels, FReal boxWidth, FPoint centerOfBox, const MatrixKernelClass *const MatrixKernel){ + return std::unique_ptr(new KernelClass(NbLevels, boxWidth, centerOfBox, MatrixKernel)); }); } @@ -70,9 +70,9 @@ class TestChebyshevDirect : public FUKernelTester { typedef FChebSymKernel KernelClass; typedef FFmmAlgorithm FmmClass; // run test - RunTest( - [&](int NbLevels, FReal boxWidth, FPoint centerOfBox){ - return std::unique_ptr(new KernelClass(NbLevels, boxWidth, centerOfBox)); + RunTest( + [&](int NbLevels, FReal boxWidth, FPoint centerOfBox, const MatrixKernelClass *const MatrixKernel){ + return std::unique_ptr(new KernelClass(NbLevels, boxWidth, centerOfBox, MatrixKernel)); }); } diff --git a/UTests/utestChebyshevDirectPeriodic.cpp b/UTests/utestChebyshevDirectPeriodic.cpp index 170fa84c..f7b461cc 100755 --- a/UTests/utestChebyshevDirectPeriodic.cpp +++ b/UTests/utestChebyshevDirectPeriodic.cpp @@ -104,7 +104,7 @@ class TestChebyshevDirect : public FUTester { ///////////////////////////////////////////////////////////////////////////////////////////////// Print("Fmm..."); FmmClass algo(&tree,PeriodicDeep ); - KernelClass kernels(algo.extendedTreeHeight(), algo.extendedBoxWidth(), algo.extendedBoxCenter()); + KernelClass kernels(algo.extendedTreeHeight(), algo.extendedBoxWidth(), algo.extendedBoxCenter(),&MatrixKernel); algo.setKernel(&kernels); algo.execute(); ///////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/UTests/utestChebyshevMpi.cpp b/UTests/utestChebyshevMpi.cpp index 45735a5b..ec8ceed4 100644 --- a/UTests/utestChebyshevMpi.cpp +++ b/UTests/utestChebyshevMpi.cpp @@ -67,6 +67,9 @@ class TestChebyshevMpiDirect : public FUTesterMpi{ const int nbLevels = 4; const int sizeOfSubLevel = 2; + // Create Matrix Kernel + const MatrixKernelClass MatrixKernel; // FUKernelTester is only designed to work with 1/R, i.e. matrix kernel ctor takes no argument. + // Create octree struct TestParticle : public FmaRWParticle<8,8>{ @@ -107,7 +110,7 @@ class TestChebyshevMpiDirect : public FUTesterMpi{ } - KernelClass* kernels= new KernelClass(nbLevels, loader.getBoxWidth(), loader.getCenterOfBox()); + KernelClass* kernels= new KernelClass(nbLevels, loader.getBoxWidth(), loader.getCenterOfBox(),&MatrixKernel); FmmClassProc algorithm(app.global(),&tree, kernels); algorithm.execute(); diff --git a/UTests/utestChebyshevMultiRhs.cpp b/UTests/utestChebyshevMultiRhs.cpp index d2f52657..731e0dc9 100644 --- a/UTests/utestChebyshevMultiRhs.cpp +++ b/UTests/utestChebyshevMultiRhs.cpp @@ -83,6 +83,8 @@ class TestChebyshevDirect : public FUTester { const int NbLevels = 4; const int SizeSubLevels = 2; + // Create Matrix Kernel + const MatrixKernelClass MatrixKernel; // FUKernelTester is only designed to work with 1/R, i.e. matrix kernel ctor takes no argument. // FSize nbParticles = loader.getNumberOfParticles() ; FmaRWParticle<8,8>* const particles = new FmaRWParticle<8,8>[nbParticles]; @@ -116,7 +118,7 @@ class TestChebyshevDirect : public FUTester { // Run FMM Print("Fmm..."); - KernelClass kernels(NbLevels, loader.getBoxWidth(), loader.getCenterOfBox()); + KernelClass kernels(NbLevels, loader.getBoxWidth(), loader.getCenterOfBox(),&MatrixKernel); FmmClass algo(&tree,&kernels); algo.execute(); // diff --git a/UTests/utestChebyshevThread.cpp b/UTests/utestChebyshevThread.cpp index 1c929b71..124965c7 100755 --- a/UTests/utestChebyshevThread.cpp +++ b/UTests/utestChebyshevThread.cpp @@ -81,16 +81,20 @@ class TestChebyshevDirect : public FUTester { const int NbLevels = 4; const int SizeSubLevels = 2; - // Create octree + // Create Matrix Kernel + const MatrixKernelClass MatrixKernel; // FUKernelTester is only designed to work with 1/R, i.e. matrix kernel ctor takes no argument. + // Load particles FSize nbParticles = loader.getNumberOfParticles() ; FmaRWParticle<8,8>* const particles = new FmaRWParticle<8,8>[nbParticles]; loader.fillParticle(particles,nbParticles); - // + + // Create octree + OctreeClass tree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox()); + // // Insert particle in the tree // - OctreeClass tree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox()); for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ tree.insert(particles[idxPart].getPosition() , idxPart, particles[idxPart].getPhysicalValue() ); } @@ -99,7 +103,7 @@ class TestChebyshevDirect : public FUTester { // Run FMM computation ///////////////////////////////////////////////////////////////////////////////////////////////// Print("Fmm..."); - KernelClass kernels(NbLevels, loader.getBoxWidth(), loader.getCenterOfBox()); + KernelClass kernels(NbLevels, loader.getBoxWidth(), loader.getCenterOfBox(),&MatrixKernel); FmmClass algo(&tree,&kernels); algo.execute(); //0 diff --git a/UTests/utestLagrange.cpp b/UTests/utestLagrange.cpp index 93d42880..d83d9513 100755 --- a/UTests/utestLagrange.cpp +++ b/UTests/utestLagrange.cpp @@ -73,16 +73,20 @@ class TestLagrange : public FUTester { const int NbLevels = 4; const int SizeSubLevels = 2; - // Create octree + // Create Matrix Kernel + const MatrixKernelClass MatrixKernel; // FUKernelTester is only designed to work with 1/R, i.e. matrix kernel ctor takes no argument. + // Load particles FSize nbParticles = loader.getNumberOfParticles() ; FmaRWParticle<8,8>* const particles = new FmaRWParticle<8,8>[nbParticles]; loader.fillParticle(particles,nbParticles); - // + + // Create octree + OctreeClass tree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox()); + // // Insert particle in the tree // - OctreeClass tree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox()); for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ tree.insert(particles[idxPart].getPosition(), idxPart, particles[idxPart].getPhysicalValue() ); } @@ -91,7 +95,7 @@ class TestLagrange : public FUTester { // Run FMM computation ///////////////////////////////////////////////////////////////////////////////////////////////// Print("Fmm..."); - KernelClass kernels(NbLevels, loader.getBoxWidth(), loader.getCenterOfBox()); + KernelClass kernels(NbLevels, loader.getBoxWidth(), loader.getCenterOfBox(),&MatrixKernel); FmmClass algo(&tree,&kernels); algo.execute(); //0 diff --git a/UTests/utestLagrangeMpi.cpp b/UTests/utestLagrangeMpi.cpp index 569f237e..931412bb 100644 --- a/UTests/utestLagrangeMpi.cpp +++ b/UTests/utestLagrangeMpi.cpp @@ -66,6 +66,9 @@ class TestLagrangeMpiDirect : public FUTesterMpi{ const int nbLevels = 4; const int sizeOfSubLevel = 2; + // Create Matrix Kernel + const MatrixKernelClass MatrixKernel; // FUKernelTester is only designed to work with 1/R, i.e. matrix kernel ctor takes no argument. + // Create octree struct TestParticle : public FmaRWParticle<8,8>{ @@ -106,7 +109,7 @@ class TestLagrangeMpiDirect : public FUTesterMpi{ } - KernelClass* kernels= new KernelClass(nbLevels, loader.getBoxWidth(), loader.getCenterOfBox()); + KernelClass* kernels= new KernelClass(nbLevels, loader.getBoxWidth(), loader.getCenterOfBox(),&MatrixKernel); FmmClassProc algorithm(app.global(),&tree, kernels); algorithm.execute(); diff --git a/UTests/utestLagrangeThread.cpp b/UTests/utestLagrangeThread.cpp index 45fe8bb4..c5ee30da 100755 --- a/UTests/utestLagrangeThread.cpp +++ b/UTests/utestLagrangeThread.cpp @@ -81,16 +81,19 @@ class TestLagrange : public FUTester { const int NbLevels = 4; const int SizeSubLevels = 2; - // Create octree + // Create Matrix Kernel + const MatrixKernelClass MatrixKernel; // FUKernelTester is only designed to work with 1/R, i.e. matrix kernel ctor takes no argument. FSize nbParticles = loader.getNumberOfParticles() ; FmaRWParticle<8,8>* const particles = new FmaRWParticle<8,8>[nbParticles]; loader.fillParticle(particles,nbParticles); - // + + // Create octree + OctreeClass tree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox()); + // // Insert particle in the tree // - OctreeClass tree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox()); for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ tree.insert(particles[idxPart].getPosition() , idxPart, particles[idxPart].getPhysicalValue() ); } @@ -99,7 +102,7 @@ class TestLagrange : public FUTester { // Run FMM computation ///////////////////////////////////////////////////////////////////////////////////////////////// Print("Fmm..."); - KernelClass kernels(NbLevels, loader.getBoxWidth(), loader.getCenterOfBox()); + KernelClass kernels(NbLevels, loader.getBoxWidth(), loader.getCenterOfBox(),&MatrixKernel); FmmClass algo(&tree,&kernels); algo.execute(); //0 -- GitLab