testLoaderFMATsm.cpp 4.07 KB
Newer Older
1
// ===================================================================================
2 3 4 5
// Copyright ScalFmm 2016 INRIA, Olivier Coulaud, Bérenger Bramas,
// Matthias Messner olivier.coulaud@inria.fr, berenger.bramas@inria.fr
// This software is a computer program whose purpose is to compute the
// FMM.
6
//
7
// This software is governed by the CeCILL-C and LGPL licenses and
8
// abiding by the rules of distribution of free software.
9 10 11
// An extension to the license is given to allow static linking of scalfmm
// inside a proprietary application (no matter its license).
// See the main license file for more details.
12
//
13 14 15
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 17 18
// GNU General Public and CeCILL-C Licenses for more details.
// "http://www.cecill.info".
// "http://www.gnu.org/licenses".
19
// ===================================================================================
20 21 22

#include <iostream>

23 24
#include <cstdio>
#include <cstdlib>
25 26
#include <time.h>

27
#include "../../Src/Utils/FTic.hpp"
28

29 30
#include "../../Src/Containers/FOctree.hpp"
#include "../../Src/Containers/FVector.hpp"
31

32
#include "../../Src/Utils/FAssert.hpp"
33
#include "../../Src/Utils/FPoint.hpp"
34

35
#include "../../Src/Components/FBasicCell.hpp"
36

37
#include "../../Src/Components/FTypedLeaf.hpp"
38

39
#include "../../Src/Files/FFmaTsmLoader.hpp"
40

41
#include "../../Src/Components/FBasicParticleContainer.hpp"
42

43
#include "../../Src/Utils/FParameters.hpp"
44

45
#include "../../Src/Utils/FParameterNames.hpp"
46

47

48
int main(int argc, char ** argv ){
49 50 51
    FHelpDescribeAndExit(argc, argv, "Load a file and put the particles in a tree with the TSM (target source model)",
                         FParameterDefinitions::InputFile, FParameterDefinitions::OctreeHeight);

52
    typedef double FReal;
53 54 55
    typedef FBasicParticleContainer<FReal,1,FReal>     ContainerClass;
    typedef FTypedLeaf< FReal, ContainerClass >                     LeafClass;
    typedef FOctree< FReal, FBasicCell, ContainerClass , LeafClass >  OctreeClass;
56 57 58
    ///////////////////////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";
59
    std::cout << ">> how to use the Tsm loader\n";
60 61
    //////////////////////////////////////////////////////////////

62 63
    // Use testLoaderCreate.exe to create this file
    FTic counter;
64
    const char* const filename = FParameters::getStr(argc,argv,FParameterDefinitions::InputFile.options, "../Data/test20k.tsm.fma");
65
    std::cout << "Opening : " << filename << "\n";
66

67
    // open basic particles loader
68
    FFmaTsmLoader<FReal> loader(filename);
69
    if(!loader.isOpen()){
70 71 72
        std::cout << "Loader Error, " << filename << "is missing\n";
        return 1;
    }
73 74
    {
        // otree
75
        OctreeClass tree(FParameters::getValue(argc,argv,FParameterDefinitions::OctreeHeight.options, 5), FParameters::getValue(argc,argv,FParameterDefinitions::OctreeSubHeight.options, 3),
76
                         loader.getBoxWidth(),loader.getCenterOfBox());
77 78 79 80

        // -----------------------------------------------------
        std::cout << "Inserting " << loader.getNumberOfParticles() << " particles ..." << std::endl;
        counter.tic();
81

82
        FPoint<FReal> particlePosition;
83
        FReal physicalValue = 0.0;
84
        FParticleType particleType;
85
        for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){
86 87
            loader.fillParticle(&particlePosition,&physicalValue, &particleType);
            tree.insert(particlePosition, particleType, physicalValue);
88
        }
89

90 91 92 93 94 95
        counter.tac();
        std::cout << "Done  " << "(" << counter.elapsed() << ")." << std::endl;

        // -----------------------------------------------------
        std::cout << "Deleting particles ..." << std::endl;
        counter.tic();
96 97 98 99 100 101 102 103 104
    }
    counter.tac();
    std::cout << "Done  " << "(" << counter.elapsed() << ")." << std::endl;
    // -----------------------------------------------------

    return 0;
}


105