ScalFmm  1.4
Main Examples

In the scalfmm directory, you can locate several folders. The sources folder called Src, the examples/tests folder Tests, the unit tests folders UTests, the Addons folder which contains one sub-folder per addon, the doc directory where you can find some documentation and the data folder which contains particles files or any other data needed per the simulation examples.

Here we focus mainly on the Tests and UTests folders, and we encourage users to look directly in the code file to see how things are made.

How to use

The parameters system

Most of the examples need some user parameters or let the user shows some values. This is done with the FParameters class. You can open an example and find the parameters directives, like in the Tests/Utils/testStatsTree.cpp:

const int NbLevels = FParameters::getValue(argc,argv,"-depth", 5);
const int SizeSubLevels = FParameters::getValue(argc,argv,"-subdepth", 3);
const char* const filename = FParameters::getStr(argc,argv,"-f", "../Data/test20k.fma");

This means that in the console, you can tape:

./Tests/Release/testStatsTree -depth [an height] -subdepth [a sub height] -f [a file to load]

A Concrete example : Spherical Harmonics FMM

In this part we will run a simulation with Spherical Harmonics and rotation optimization: ./Examples/Release/RotationFMM .

Create a particles file

In the test file we can read:

std::string filename = FParameters::getStr(argc, argv,"-fin", "../Data/test20k.fma");
FFmaGenericLoader loader(filename);

It means, that the test file is reading FMA file (see FMA format) which can be changed but here we still use this format. We can pass a file in parameter with the -fin option. So let first create with generateDistributions 2.000.000 particles in a unit cube and store the particle in a file with the FMA format:

./Exemple/Release/generateDistributions -N 2000000 -unitcube -filename my2kkpartfile.fma

Which create a file called my2kkpartfile.fma.

Running the Simulation

With the Spherical harmonic expansion kernel we can choose the P=4 accuracy parameter for this kernel. RotationFMM

./Examples/Release/RotationFMM -f my2kkpartfile.fma -depth 5 -subdepth 3


Here some drivers.


Examples from Tests

From Tests/Utils

From Tests/Kernels

Examples from UTests

In this folder you will find the unit tests. There are some related to data structures (like vector or list) and some others related to real FMM.

  • FUTester.hpp : this is the main class for unit test.
  • utestParameters.cpp : this tests the FParameters class which allow a quick access to application command line parameter.
  • utestQuicksort.cpp : this tests the quick sort in sequential and shared memory.
  • utestRotationDirect.cpp : this tests the rotation FMM.
  • utestBoolArray.cpp : this tests the boolean array which is a data structure that enable bit bool value.
  • utestRotationDirectPeriodic.cpp : this tests the rotation kernel with periodicity.
  • utestBuffer.cpp : this tests the buffer used in the serialization of data in the MPI FMM.
  • utestSphericalDirect.cpp : this tests the Spherical Harmonic kernel.
  • utestChebyshevDirect.cpp : this tests the Chebyshev kernel.
  • utestSphericalDirectPeriodic.cpp : this tests the Chebyshev kernel with periodicity.
  • utestChebyshevDirectPeriodic.cpp : this tests the Spherical Harmonic kernel with periodicity.
  • utestSphericalWithPrevious.cpp : this tests the Spherical Harmonic kernel with a previous run.
  • utestList.cpp : this tests our home made linked list.
  • utestTest.cpp : this tests the unit test main class (this is just an example of how to use).
  • utestMorton.cpp : this tests the Morton indexing tools.
  • utestVector.cpp : this tests our home made vector.
  • utestOctree.cpp : this tests the octree validation.

Create your own application using ScalFMM

In you compile ScalFMM and enabled the Tests (by passing a parameter to CMake or by using ccmake) any cpp file that will put into the Tests/ directories will be compiled and linked to ScalFMM. Therefore it can be a quick way to create and test with scalfmm without creating your own project and thinking about the compilation and link stages. Put your file in the test directories, enable the Tests in the cmake, be sure that the CMake is generated (type cmake.. again in the build dir), and then make your_cpp_file_without_extension