FScalfmmApiInit.cpp 1.93 KB
Newer Older
1 2 3 4 5 6
/** It should be compiled with C export */
extern "C" {
#include "CScalfmmApi.h"
}

#include "FInterEngine.hpp"
7
#include "FUserKernelEngine.hpp"
8

9
extern "C" scalfmm_handle scalfmm_init(/*int TreeHeight,double BoxWidth,double* BoxCenter, */scalfmm_kernel_type KernelType){
10 11 12 13
    ScalFmmCoreHandle * handle = new ScalFmmCoreHandle();

    switch(KernelType){
    case 0:
14
        handle->engine = new FUserKernelEngine(/*TreeHeight, BoxWidth, BoxCenter, */KernelType);
15 16 17 18 19 20 21 22 23 24
        break;

    case 1:
        //TODO typedefs
        typedef FP2PParticleContainerIndexed<>                                 ContainerClass;
        typedef FChebCell<7>                                                         ChebCell;

        typedef FInterpMatrixKernelR                                        MatrixKernelClass;
        typedef FChebSymKernel<ChebCell,ContainerClass,MatrixKernelClass,7>        ChebKernel;

25
        handle->engine = new FInterEngine<ChebCell,ChebKernel>(/*TreeHeight,BoxWidth,BoxCenter, */KernelType);
26 27 28 29 30 31 32 33 34
        break;
    case 2:
        //TODO typedefs
        typedef FP2PParticleContainerIndexed<>                                 ContainerClass;
        typedef FUnifCell<7>                                                         UnifCell;

        typedef FInterpMatrixKernelR                                        MatrixKernelClass;
        typedef FUnifKernel<UnifCell,ContainerClass,MatrixKernelClass,7>           UnifKernel;

35
        handle->engine = new FInterEngine<UnifCell,UnifKernel>(/*TreeHeight,BoxWidth,BoxCenter, */KernelType);
36 37 38 39 40 41 42 43 44 45
        break;

    default:
        std::cout<< "Kernel type unsupported" << std::endl;
        exit(0);
        break;
    }
    return handle;
}

46 47 48 49 50
extern "C" void scalfmm_dealloc_handle(scalfmm_handle handle, Callback_free_cell userDeallocator){
    ((ScalFmmCoreHandle *) handle)->engine->intern_dealloc_handle(userDeallocator);
    delete ((ScalFmmCoreHandle *) handle)->engine ;
    delete (ScalFmmCoreHandle *) handle;
}