utestChebyshev.cpp 4.27 KB
Newer Older
1
// See LICENCE file at project root
2 3 4 5 6

// ==== CMAKE =====
// @FUSE_BLAS
// ================

7
#include "FUKernelTester.hpp"
8

BRAMAS Berenger's avatar
BRAMAS Berenger committed
9
#include "Components/FSimpleLeaf.hpp"
10

BRAMAS Berenger's avatar
BRAMAS Berenger committed
11 12
#include "Kernels/Chebyshev/FChebCell.hpp"
#include "Kernels/Interpolation/FInterpMatrixKernel.hpp"
13
#include "Kernels/Chebyshev/FChebDenseKernel.hpp"
BRAMAS Berenger's avatar
BRAMAS Berenger committed
14 15
#include "Kernels/Chebyshev/FChebKernel.hpp"
#include "Kernels/Chebyshev/FChebSymKernel.hpp"
16

BRAMAS Berenger's avatar
BRAMAS Berenger committed
17
#include "Kernels/P2P/FP2PParticleContainerIndexed.hpp"
18 19
/*
  In this test we compare the Chebyschev fmm results and the direct results.
20
*/
21 22 23 24

/** the test class
 *
 */
25
class TestChebyshevDirect : public FUKernelTester<TestChebyshevDirect> {
26

27 28 29 30 31
  ///////////////////////////////////////////////////////////
  // Set the tests!
  ///////////////////////////////////////////////////////////


32 33
  /** TestChebDenseKernel */
  void TestChebDenseKernel(){
34 35 36 37 38 39 40
    typedef double FReal;
    const unsigned int ORDER = 6;
    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;
41
    typedef FChebDenseKernel<FReal,CellClass,ContainerClass,MatrixKernelClass,ORDER> KernelClass;
42 43
    typedef FFmmAlgorithm<OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass;
    // run test
44
    RunTest<FReal,CellClass,ContainerClass,KernelClass,MatrixKernelClass,LeafClass,OctreeClass,FmmClass>(
45 46 47
                           [&](int NbLevels, FReal boxWidth, FPoint<FReal> centerOfBox, const MatrixKernelClass *const MatrixKernel){
                             return std::unique_ptr<KernelClass>(new KernelClass(NbLevels, boxWidth, centerOfBox, MatrixKernel));
                           });
48
  }
49

50
  /** TestChebKernel */
51
  void TestChebKernel(){
52 53 54 55 56 57 58
    typedef double FReal;
    const unsigned int ORDER = 6;
    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;
59
    typedef FChebKernel<FReal,CellClass,ContainerClass,MatrixKernelClass,ORDER> KernelClass;
60 61 62 63 64 65 66
    typedef FFmmAlgorithm<OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass;
    // run test
    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));
													 });
  }
67 68 69 70 71 72 73 74 75 76 77 78 79

  /** TestChebSymKernel */
  void TestChebSymKernel(){
    typedef double FReal;
    const unsigned int ORDER = 6;
    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 FFmmAlgorithm<OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass;
    // run test
80
    RunTest<FReal,CellClass,ContainerClass,KernelClass,MatrixKernelClass,LeafClass,OctreeClass,FmmClass>(
81 82 83 84
													 [&](int NbLevels, FReal boxWidth, FPoint<FReal> centerOfBox, const MatrixKernelClass *const MatrixKernel){
													   return std::unique_ptr<KernelClass>(new KernelClass(NbLevels, boxWidth, centerOfBox, MatrixKernel));
													 });
  }
85 86 87



88 89 90
  ///////////////////////////////////////////////////////////
  // Set the tests!
  ///////////////////////////////////////////////////////////
91

92 93
  /** set test */
  void SetTests(){
94 95 96
    AddTest(&TestChebyshevDirect::TestChebDenseKernel,"Test Chebyshev Kernel without compression.");
    AddTest(&TestChebyshevDirect::TestChebKernel,"Test Chebyshev Kernel with 1 large compression.");
    AddTest(&TestChebyshevDirect::TestChebSymKernel,"Test Chebyshev Kernel with 16 small SVDs and symmetries.");
97
  }
98 99 100 101 102 103 104 105 106
};


// You must do this
TestClass(TestChebyshevDirect)