Commit 093bde30 authored by berenger-bramas's avatar berenger-bramas

Improve and comment the utest.

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/scalfmm/scalfmm/trunk@319 2616d619-271b-44dc-8df4-d4a8f33a7222
parent 1be7b9ff
No preview for this file type
......@@ -205,7 +205,7 @@ public:
for( int indexLevel = this->subOctreeHeight - 1 ; indexLevel >= 0 ; --indexLevel ){
for( int indexCells = mostLeft ; indexCells <= mostRight ; ++indexCells ){
if(this->cells[indexLevel][indexCells]){
//delete this->cells[indexLevel][indexCells];
delete this->cells[indexLevel][indexCells];
}
}
......
......@@ -82,7 +82,7 @@ public:
* Default destructor, simply close the file
*/
virtual ~FFmaBinLoader(){
fclose(file);
if(file) fclose(file);
}
/**
......
......@@ -79,7 +79,7 @@ public:
* Default destructor, simply close the file
*/
virtual ~FHLoader(){
fclose(file);
if(file) fclose(file);
}
/**
......
......@@ -195,7 +195,7 @@ public:
int maxParticlesInLeaf = 0;
file.read((char*)&maxParticlesInLeaf, sizeof(int));
ParticleClass* const particles = new ParticleClass[maxParticlesInLeaf];
ParticleClass* const particles = reinterpret_cast<ParticleClass*>(new char[maxParticlesInLeaf * sizeof(ParticleClass)]);
for(int idxLeaf = 0 ; idxLeaf < nbLeaf ; ++idxLeaf){
int particlesInLeaf = 0;
......@@ -206,7 +206,7 @@ public:
}
}
//delete[] particles;
delete[] reinterpret_cast<char*>(particles);
}
// Start from leal level - 1
......
// [--License--]
#include "../Src/Containers/FOctree.hpp"
#include "../Src/Containers/FVector.hpp"
......@@ -18,6 +16,11 @@
#include "FUTester.hpp"
/*
This test compare a previous FMM result with a simulation.
*/
typedef FmbParticle ParticleClass;
typedef FComputeCell CellClass;
typedef FVector<ParticleClass> ContainerClass;
......@@ -38,12 +41,15 @@ class TestFmb : public FUTester<TestFmb> {
const int DevP = 12;
FComputeCell::Init(DevP);
// Load the particles file
FFmaBinLoader<ParticleClass> loader("../Data/utestFmb.bin.fma");
if(!loader.isOpen()){
Print("Cannot open particles file.");
assert(false);
return;
}
// Create octree
OctreeClass testTree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox());
{
ParticleClass particleToFill;
......@@ -53,18 +59,20 @@ class TestFmb : public FUTester<TestFmb> {
}
}
// Run simulation
KernelClass kernels(DevP,NbLevels,loader.getBoxWidth());
FmmClass algo(&testTree,&kernels);
algo.execute();
//FTreeIO::Save<OctreeClass, CellClass, ParticleClass, FTreeIO::Copier<CellClass, ParticleClass> >("../Data/utestFmb.data", testTree);
// If needed save the result
FTreeIO::Save<OctreeClass, CellClass, ParticleClass, FTreeIO::Copier<CellClass, ParticleClass> >("../Data/utestFmb.data", testTree);
// Load previous result
OctreeClass goodTree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox());
FTreeIO::Load<OctreeClass, CellClass, ParticleClass, FTreeIO::Copier<CellClass, ParticleClass> >("../Data/utestFmb.data", goodTree);
// Compare the two simulations
Print("Check the particles...");
{ // Check that each particle has been summed with all other
typename OctreeClass::Iterator testOctreeIterator(&testTree);
typename OctreeClass::Iterator goodOctreeIterator(&goodTree);
......
......@@ -52,9 +52,11 @@ class TestFmbDirect : public FUTester<TestFmbDirect> {
void TestDirect(){
FFmaBinLoader<ParticleClass> loader("../Data/utestFmbDirect.bin.fma");
// Load particles
FFmaBinLoader<ParticleClass> loader("../../Data/utestFmbDirect.bin.fma");
if(!loader.isOpen()){
Print("Cannot open particles file.");
assert(false);
return;
}
Print("Number of particles:");
......@@ -64,9 +66,9 @@ class TestFmbDirect : public FUTester<TestFmbDirect> {
const int SizeSubLevels = 2;
const int DevP = 12;
FComputeCell::Init(DevP);
OctreeClass tree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox());
// Create octree
OctreeClass tree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox());
ParticleClass* const particles = new ParticleClass[loader.getNumberOfParticles()];
for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){
loader.fillParticle(particles[idxPart]);
......@@ -75,13 +77,14 @@ class TestFmbDirect : public FUTester<TestFmbDirect> {
}
// Run FMM
Print("Fmm...");
//KernelClass kernels(NbLevels,loader.getBoxWidth());
KernelClass kernels(DevP,NbLevels,loader.getBoxWidth());
FmmClass algo(&tree,&kernels);
algo.execute();
// Run direct computation
Print("Direct...");
for(int idxTarget = 0 ; idxTarget < loader.getNumberOfParticles() ; ++idxTarget){
for(int idxOther = idxTarget + 1 ; idxOther < loader.getNumberOfParticles() ; ++idxOther){
......@@ -90,10 +93,10 @@ class TestFmbDirect : public FUTester<TestFmbDirect> {
}
}
// Compare
Print("Compute Diff...");
FReal potentialDiff = 0;
FReal fx = 0, fy = 0, fz = 0;
{ // Check that each particle has been summed with all other
typename OctreeClass::Iterator octreeIterator(&tree);
octreeIterator.gotoBottomLeft();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment