Commit 700461d1 authored by COULAUD Olivier's avatar COULAUD Olivier

Deprecated

parent 7e92296e
// ===================================================================================
// Copyright ScalFmm 2011 INRIA, Olivier Coulaud, Berenger Bramas
// olivier.coulaud@inria.fr, berenger.bramas@inria.fr
// This software is a computer program whose purpose is to compute the FMM.
//
// This software is governed by the CeCILL-C and LGPL licenses and
// abiding by the rules of distribution of free software.
//
// 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
// GNU General Public and CeCILL-C Licenses for more details.
// "http://www.cecill.info".
// "http://www.gnu.org/licenses".
// ===================================================================================
#ifndef FFMABINLOADERRESULT_HPP
#define FFMABINLOADERRESULT_HPP
#include "./FFmaGenericLoader.hpp"
/**
* @author Cyrille Piacibello (cyrille.piacibello@inria.fr)
* @class FFmaBinLoaderResult
*
* Please read the license
*
* @brief The aim of this class is to load particles and forces from a
* file, to compare with results from any Fmm Kernel.
*/
class FFmaBinLoaderResult : public FFmaGenericLoader {
protected:
typedef FFmaGenericLoader Parent;
size_t removeWarning;
public:
FFmaBinLoaderResult(const char * filename):
Parent::FFmaGenericLoader(filename,true)
{
}
void fillParticle(FPoint*const outParticlePosition, FReal*const outphysicalValue,
FReal* forceX, FReal* forceY, FReal* forceZ, FReal * const potential){
// FReal x,y,z,data,fx,fy,fz,pot;
//Same data as particle files
// removeWarning += fread(&x, sizeof(FReal), 1, file);
// removeWarning += fread(&y, sizeof(FReal), 1, file);
// removeWarning += fread(&z, sizeof(FReal), 1, file);
// removeWarning += fread(&data, sizeof(FReal), 1, file);
this->Parent::fillParticle(outParticlePosition,outphysicalValue);
// file->read((char*)(outParticlePositions), sizeof(FReal)*3);
// file->read((char*)(outPhysicalValue), sizeof(FReal));
//
file->read((char*)(forceX), sizeof(FReal)*3);
file->read((char*)(forceY), sizeof(FReal));
file->read((char*)(forceZ), sizeof(FReal)*3);
file->read((char*)(potential), sizeof(FReal));
//results data
// removeWarning += fread(&fx, sizeof(FReal), 1, file);
// removeWarning += fread(&fy, sizeof(FReal), 1, file);
// removeWarning += fread(&fz, sizeof(FReal), 1, file);
// removeWarning += fread(&pot, sizeof(FReal), 1, file);
// inParticlePosition->setPosition(x,y,z);
// (*physicalValue) = data;
// *forceX = fx;
// *forceY = fy;
// *forceZ = fz;
// *potential = pot;
}
};
#endif //FFMABINLOADERRESULT_HPP
// ===================================================================================
// Copyright ScalFmm 2011 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.
//
// This software is governed by the CeCILL-C and LGPL licenses and
// abiding by the rules of distribution of free software.
//
// 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
// GNU General Public and CeCILL-C Licenses for more details.
// "http://www.cecill.info".
// "http://www.gnu.org/licenses".
// ===================================================================================
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include "../../Src/Utils/FGlobal.hpp"
#include "../../Src/Utils/FParameters.hpp"
// This file can generate basic particles files to load with basic loader
// g++ testLoaderCreate.cpp -o testLoaderCreate.exe
int main(int argc, char ** argv){
///////////////////////What we do/////////////////////////////
std::cout << ">> This executable can create a basic particles files in custom format\n";
std::cout << ">> You can pass a filename in parameter else the program will use\n";
std::cout << ">> a default filename.\n";
std::cout << ">> The format of the file is : \n";
std::cout << ">> [number of particles] [boxe width] [boxe x center] [boxe y center] [boxe z center]\n";
std::cout << ">> [x] [y] [z]...\n";
//////////////////////////////////////////////////////////////
// Nb of particles
const FSize NbParticles = FParameters::getValue(argc,argv,"-nb", FSize(20000));
// Center of the box
const FReal XCenter = 0.5;
const FReal YCenter = 0.5;
const FReal ZCenter = 0.5;
// Box width
const FReal BoxWidth = 1.0;
// Output file please let .temp extension
const char* const Output = FParameters::getStr(argc,argv,"-f", "../Data/test20k.basic");
std::cout << "Creating : " << Output << "\n";
// Create file
std::ofstream myfile;
myfile.open (Output);
if(!myfile.is_open()){
std::cout << "Cannot create " << Output << "\n";
return 1;
}
std::cout << "Creating " << NbParticles << " particles at " << Output << "\n";
std::cout << "Working...\n";
// System properties
myfile << NbParticles << " " << BoxWidth << " " << XCenter << " " << YCenter << " " << ZCenter;
// Generate particles
for( long idx = 0 ; idx < NbParticles ; ++idx ){
const FReal px = ((FReal(drand48())) * BoxWidth) + XCenter - (BoxWidth/FReal(2.0));
const FReal py = ((FReal(drand48())) * BoxWidth) + YCenter - (BoxWidth/FReal(2.0));
const FReal pz = ((FReal(drand48())) * BoxWidth) + ZCenter - (BoxWidth/FReal(2.0));
myfile << " \n" << px << " " << py << " " << pz;
}
myfile.close();
std::cout << "Done\n";
return 0;
}
// ===================================================================================
// Copyright ScalFmm 2011 INRIA, Olivier Coulaud, Berenger Bramas, Matthias Messner
// olivier.coulaud@inria.fr, berenger.bramas@inria.fr
// This software is a computer program whose purpose is to compute the FMM.
//
// This software is governed by the CeCILL-C and LGPL licenses and
// abiding by the rules of distribution of free software.
//
// 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
// GNU General Public and CeCILL-C Licenses for more details.
// "http://www.cecill.info".
// "http://www.gnu.org/licenses".
// ===================================================================================
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include "../../Src/Utils/FParameters.hpp"
#include "../../Src/Utils/FTic.hpp"
#include "../../Src/Containers/FOctree.hpp"
#include "../../Src/Containers/FVector.hpp"
#include "../../Src/Utils/FAssert.hpp"
#include "../../Src/Utils/FPoint.hpp"
#include "../../Src/Components/FBasicCell.hpp"
#include "../../Src/Components/FSimpleLeaf.hpp"
#include "../../Src/Files/FFmaGenericLoader.hpp"
#include "../../Src/Components/FBasicParticleContainer.hpp"
/**
* In this file we show an example of FBasicLoader use
* Inserting 2000000 particles ...
* Done (5.77996).
* Deleting particles ...
* Done (0.171918).
*/
int main(int argc, char ** argv ){
typedef FBasicParticleContainer<1> ContainerClass;
typedef FSimpleLeaf< ContainerClass > LeafClass;
typedef FOctree< FBasicCell, ContainerClass , LeafClass > OctreeClass;
///////////////////////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";
std::cout << ">> how to use the FMA loader\n";
//////////////////////////////////////////////////////////////
// Use testLoaderCreate.exe to create this file
FTic counter;
const char* const filename = FParameters::getStr(argc,argv,"-f", "../Data/test20k.fma");
std::cout << "Opening : " << filename << "\n";
// open basic particles loader
FFmaGenericLoader loader(filename);
if(!loader.isOpen()){
std::cout << "Loader Error, " << filename << "is missing\n";
return 1;
}
{
// otree
OctreeClass tree(FParameters::getValue(argc,argv,"-depth", 5), FParameters::getValue(argc,argv,"-subdepth", 3),
loader.getBoxWidth(), loader.getCenterOfBox());
// -----------------------------------------------------
std::cout << "Inserting " << loader.getNumberOfParticles() << " particles ..." << std::endl;
counter.tic();
FPoint particlePosition;
FReal physicalValue = 0.0;
for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){
loader.fillParticle(&particlePosition,&physicalValue);
tree.insert(particlePosition,physicalValue);
}
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << ")." << std::endl;
// -----------------------------------------------------
std::cout << "Deleting particles ..." << std::endl;
counter.tic();
}
counter.tac();
std::cout << "Done " << "(" << counter.elapsed() << ")." << std::endl;
// -----------------------------------------------------
return 0;
}
// ===================================================================================
// Copyright ScalFmm 2011 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.
//
// This software is governed by the CeCILL-C and LGPL licenses and
// abiding by the rules of distribution of free software.
//
// 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
// GNU General Public and CeCILL-C Licenses for more details.
// "http://www.cecill.info".
// "http://www.gnu.org/licenses".
// ===================================================================================
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include "../../Src/Utils/FGlobal.hpp"
#include "../../Src/Utils/FParameters.hpp"
// This file can generate basic particles files in the FMA format
int main(int argc, char ** argv){
///////////////////////What we do/////////////////////////////
std::cout << ">> This executable can create a FMA particles files\n";
std::cout << ">> You can pass a filename in parameter else the program will use\n";
std::cout << ">> a default filename.\n";
std::cout << ">> The format of the file is : \n";
std::cout << ">> [number of particles] \n";
std::cout << ">> [boxe width] [boxe x center] [boxe y center] [boxe z center]\n";
std::cout << ">> [x] [y] [z] [physical value]...\n";
//////////////////////////////////////////////////////////////
// Nb of particles
const FSize NbParticles = FParameters::getValue(argc,argv,"-nb", FSize(20000));
const FReal physicalValue = FParameters::getValue(argc,argv,"-pv", FReal(0.1));
// Center of the box
const FReal XCenter = 0.5;
const FReal YCenter = 0.5;
const FReal ZCenter = 0.5;
// Box width
const FReal BoxWidth = 1.0/2;
// Output file please let .temp extension
const char* const defaultFilename = (sizeof(FReal) == sizeof(float))?
"../../Data/test20k.bin.fma.single":
"../../Data/test20k.bin.fma.double";
const char* const Output = FParameters::getStr(argc,argv,"-f", defaultFilename);
std::cout << "Creating : " << Output << "\n";
// Create file
FILE* const myfile = fopen(Output, "wb");
if(!myfile){
std::cout << "Cannot create " << Output << "\n";
return 1;
}
std::cout << "Generating " << NbParticles << " in " << Output << "\n";
std::cout << "Working...\n";
// System properties
const int sizeOfFreal = int(sizeof(FReal));
fwrite(&sizeOfFreal, sizeof(int), 1, myfile);
fwrite(&NbParticles, sizeof(FSize), 1, myfile);
fwrite(&BoxWidth, sizeof(FReal), 1, myfile);
fwrite(&XCenter, sizeof(FReal), 1, myfile);
fwrite(&YCenter, sizeof(FReal), 1, myfile);
fwrite(&ZCenter, sizeof(FReal), 1, myfile);
const FReal Limite = FReal(0.00001);
const FReal LimitedBoxWidth = BoxWidth - Limite * 2;
FReal data[4];
data[3] = physicalValue;
// Generate particles
for( FSize idx = 0 ; idx < NbParticles ; ++idx ){
data[0] = ((FReal(drand48())) * LimitedBoxWidth * 2) + XCenter - BoxWidth + Limite;
data[1] = ((FReal(drand48())) * LimitedBoxWidth * 2) + YCenter - BoxWidth + Limite;
data[2] = ((FReal(drand48())) * LimitedBoxWidth * 2) + ZCenter - BoxWidth + Limite;
fwrite(&data, sizeof(FReal), 4, myfile);
}
fclose(myfile);
std::cout << "Done\n";
return 0;
}
// ===================================================================================
// Copyright ScalFmm 2011 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.
//
// This software is governed by the CeCILL-C and LGPL licenses and
// abiding by the rules of distribution of free software.
//
// 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
// GNU General Public and CeCILL-C Licenses for more details.
// "http://www.cecill.info".
// "http://www.gnu.org/licenses".
// ===================================================================================
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include "../../Src/Utils/FGlobal.hpp"
#include "../../Src/Utils/FMath.hpp"
#include "../../Src/Utils/FParameters.hpp"
// This file can generate basic particles files in the FMA format
int main(int argc, char ** argv){
///////////////////////What we do/////////////////////////////
std::cout << ">> This executable can create a FMA particles files\n";
std::cout << ">> You can pass a filename in parameter else the program will use\n";
std::cout << ">> a default filename.\n";
std::cout << ">> The format of the file is : \n";
std::cout << ">> [number of particles] \n";
std::cout << ">> [boxe width] [boxe x center] [boxe y center] [boxe z center]\n";
std::cout << ">> [x] [y] [z] [physical value]...\n";
//////////////////////////////////////////////////////////////
// Nb of particles
const FSize NbParticles = FParameters::getValue(argc,argv,"-nb", FSize(20000));
const FReal physicalValue = FParameters::getValue(argc,argv,"-pv", FReal(0.1));
// Center of the box
const FReal XCenter = 0.5;
const FReal YCenter = 0.5;
const FReal ZCenter = 0.5;
// Box width
const FReal BoxWidth = 1.0/2;
// Output file please let .temp extension
const char* const Output = FParameters::getStr(argc,argv,"-f", "../Data/stest20k.bin.fma");
std::cout << "Creating : " << Output << "\n";
// Create file
FILE* const myfile = fopen(Output, "wb");
if(!myfile){
std::cout << "Cannot create " << Output << "\n";
return 1;
}
std::cout << "Generating " << NbParticles << " in " << Output << "\n";
std::cout << "Working...\n";
// System properties
const int sizeOfFreal = int(sizeof(FReal));
fwrite(&sizeOfFreal, sizeof(int), 1, myfile);
fwrite(&NbParticles, sizeof(FSize), 1, myfile);
fwrite(&BoxWidth, sizeof(FReal), 1, myfile);
fwrite(&XCenter, sizeof(FReal), 1, myfile);
fwrite(&YCenter, sizeof(FReal), 1, myfile);
fwrite(&ZCenter, sizeof(FReal), 1, myfile);
FReal data[4];
data[3] = physicalValue;
if( FParameters::findParameter(argc,argv,"-double") == FParameters::NotFound ){
const FReal rayon = FReal(0.4);
const FReal thresh = FReal(0.15);
const FReal threshDiv2 = thresh/2;
// Generate particles
for( long idx = 0 ; idx < NbParticles ; ++idx ){
const FReal theta = (FReal(drand48())) * FMath::FPi;
const FReal omega = (FReal(drand48())) * FMath::FPi * FReal(2);
data[0] = rayon * FMath::Cos(omega) * FMath::Sin(theta) + XCenter + thresh * (FReal(drand48())) - threshDiv2;
data[1] = rayon * FMath::Sin(omega) * FMath::Sin(theta) + YCenter + thresh * (FReal(drand48())) - threshDiv2;
data[2] = rayon * FMath::Cos(theta) + ZCenter + thresh * (FReal(drand48())) - threshDiv2;
fwrite(&data, sizeof(FReal), 4, myfile);
}
}
else{
const FReal rayon = FReal(0.2);
const FReal thresh = FReal(0.03);
const FReal threshDiv2 = thresh/2;
const FReal offset = FReal(0.25);
// Generate particles
for( long idx = 0 ; idx < NbParticles/2 ; ++idx ){
const FReal theta = (FReal(drand48())) * FMath::FPi;
const FReal omega = (FReal(drand48())) * FMath::FPi * FReal(2);
data[0] = rayon * FMath::Cos(omega) * FMath::Sin(theta) + XCenter - offset + thresh * (FReal(drand48())) - threshDiv2;
data[1] = rayon * FMath::Sin(omega) * FMath::Sin(theta) + YCenter - offset + thresh * (FReal(drand48())) - threshDiv2;
data[2] = rayon * FMath::Cos(theta) + ZCenter - offset + thresh * (FReal(drand48())) - threshDiv2;
fwrite(&data, sizeof(FReal), 4, myfile);
}
for( long idx = 0 ; idx < NbParticles/2 ; ++idx ){
const FReal theta = (FReal(drand48())) * FMath::FPi;
const FReal omega = (FReal(drand48())) * FMath::FPi * FReal(2);
data[0] = rayon * FMath::Cos(omega) * FMath::Sin(theta) + XCenter + offset + thresh * (FReal(drand48())) - threshDiv2;
data[1] = rayon * FMath::Sin(omega) * FMath::Sin(theta) + YCenter + offset + thresh * (FReal(drand48())) - threshDiv2;
data[2] = rayon * FMath::Cos(theta) + ZCenter + offset + thresh * (FReal(drand48())) - threshDiv2;
fwrite(&data, sizeof(FReal), 4, myfile);
}
}
fclose(myfile);
std::cout << "Done\n";
return 0;
}
// ===================================================================================
// Copyright ScalFmm 2011 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.
//
// This software is governed by the CeCILL-C and LGPL licenses and
// abiding by the rules of distribution of free software.
//
// 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
// GNU General Public and CeCILL-C Licenses for more details.
// "http://www.cecill.info".
// "http://www.gnu.org/licenses".
// ===================================================================================
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include "../../Src/Utils/FGlobal.hpp"
#include "../../Src/Utils/FParameters.hpp"
// This file can generate basic particles files in the FMA format
int main(int argc, char ** argv){
///////////////////////What we do/////////////////////////////
std::cout << ">> This executable can create a FMA particles files\n";
std::cout << ">> You can pass a filename in parameter else the program will use\n";
std::cout << ">> a default filename.\n";
std::cout << ">> The format of the file is : \n";
std::cout << ">> [number of particles] \n";
std::cout << ">> [boxe width] [boxe x center] [boxe y center] [boxe z center]\n";
std::cout << ">> [x] [y] [z] [physical value]...\n";
//////////////////////////////////////////////////////////////
// Nb of particles
const long NbParticles = FParameters::getValue(argc,argv,"-nb", long(20000));
const FReal physicalValue = FParameters::getValue(argc,argv,"-pv", FReal(0.1));
// Box width
const FReal BoxWidth = FParameters::getValue(argc,argv,"-width", FReal(1.0/2.0));
// Center of the box
const FReal XCenter = BoxWidth;
const FReal YCenter = BoxWidth;
const FReal ZCenter = BoxWidth;
// Output file please let .temp extension
const char* const Output = FParameters::getStr(argc,argv,"-f", "../Data/test20k.fma");
std::cout << "Creating : " << Output << "\n";
// Create file
std::ofstream myfile;
myfile.open (Output);
if(!myfile.is_open()){
std::cout << "Cannot create " << Output << "\n";
return 1;
}
std::cout << "Generating " << NbParticles << " in " << Output << "\n";
std::cout << "Working...\n";
// System properties
myfile << NbParticles << "\n";
myfile << BoxWidth << "\t" << XCenter << "\t" << YCenter << "\t" << ZCenter;
const FReal Limite = FReal(0.00001);
const FReal LimitedBoxWidth = BoxWidth - Limite * 2;
// Generate particles
for( long idx = 0 ; idx < NbParticles ; ++idx ){
const FReal px = ((FReal(drand48())) * LimitedBoxWidth * 2) + XCenter - BoxWidth + Limite;
const FReal py = ((FReal(drand48())) * LimitedBoxWidth * 2) + YCenter - BoxWidth + Limite;
const FReal pz = ((FReal(drand48())) * LimitedBoxWidth * 2) + ZCenter - BoxWidth + Limite;
myfile << "\n" << px << "\t" << py << "\t" << pz << "\t" << physicalValue;
}
myfile.close();
std::cout << "Done\n";
return 0;
}
// ===================================================================================
// Copyright ScalFmm 2011 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.
//
// This software is governed by the CeCILL-C and LGPL licenses and
// abiding by the rules of distribution of free software.
//
// 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
// GNU General Public and CeCILL-C Licenses for more details.
// "http://www.cecill.info".
// "http://www.gnu.org/licenses".
// ===================================================================================
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <cmath>
#include "../../Src/Utils/FGlobal.hpp"
#include "../../Src/Utils/FMath.hpp"
#include "../../Src/Utils/FParameters.hpp"