Commit 21c1e9d4 authored by berenger-bramas's avatar berenger-bramas
Browse files

Use the user parameters to set the tree height for 2 tests.

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/scalfmm/scalfmm/trunk@131 2616d619-271b-44dc-8df4-d4a8f33a7222
parent e6d50d8f
......@@ -18,7 +18,7 @@ namespace FParameters{
* <code> const int argInt = userParemetersAt<int>(1,-1); </code>
*/
template <class VariableType>
static const VariableType StrToOther(const char* const str, const VariableType& defaultValue = VariableType()){
const VariableType StrToOther(const char* const str, const VariableType& defaultValue = VariableType()){
std::istringstream iss(str,std::istringstream::in);
VariableType value;
iss >> value;
......@@ -57,7 +57,7 @@ namespace FParameters{
/** To find a parameters from user format char parameters
*
*/
int findParameter(const char* const inName, const int argc, const char* const * const argv, const bool caseSensible = false){
int findParameter(const int argc, const char* const * const argv, const char* const inName, const bool caseSensible = false){
for(int idxArg = 0; idxArg < argc ; ++idxArg){
if(areStrEquals(inName, argv[idxArg], caseSensible)){
return idxArg;
......@@ -65,6 +65,21 @@ namespace FParameters{
}
return -1;
}
/** To get a value like :
* getValue(argc,argv, "Toto", 0, false);
* will return 55 if the command contains : -Toto 55
* else 0
*/
template <class VariableType>
const VariableType getValue(const int argc, const char* const * const argv, const char* const inName, const VariableType& defaultValue = VariableType(), const bool caseSensible = false){
const int position = findParameter(argc,argv,inName,caseSensible);
if(position == -1 || position == argc - 1){
return defaultValue;
}
return StrToOther(argv[position+1],defaultValue);
}
}
......
......@@ -6,6 +6,7 @@
#include <stdlib.h>
#include "../Src/Utils/FTic.hpp"
#include "../Src/Utils/FParameters.hpp"
#include "../Src/Containers/FOctree.hpp"
#include "../Src/Containers/FVector.hpp"
......@@ -61,8 +62,8 @@ int main(int argc, char ** argv){
std::cout << ">> This executable has to be used to test fmb algorithm.\n";
//////////////////////////////////////////////////////////////
const int NbLevels = 9;//10;
const int SizeSubLevels = 3;//3
const int NbLevels = FParameters::getValue(argc,argv,"-h", 9);
const int SizeSubLevels = FParameters::getValue(argc,argv,"-sh", 3);
FTic counter;
const char* const defaultFilename = "testLoaderFMA.fma"; //../../Data/ "testLoaderFMA.fma" "testFMAlgorithm.fma" Sphere.fma
const char* filename;
......@@ -91,6 +92,7 @@ int main(int argc, char ** argv){
// -----------------------------------------------------
std::cout << "Creating & Inserting " << loader.getNumberOfParticles() << " particles ..." << std::endl;
std::cout << "\tHeight : " << NbLevels << " \t sub-height : " << SizeSubLevels << std::endl;
counter.tic();
{
......
......@@ -8,6 +8,7 @@
#include "../Src/Utils/FTic.hpp"
#include "../Src/Utils/FMpi.hpp"
#include "../Src/Utils/FAbstractSendable.hpp"
#include "../Src/Utils/FParameters.hpp"
#include "../Src/Containers/FOctree.hpp"
#include "../Src/Containers/FVector.hpp"
......@@ -257,8 +258,8 @@ int main(int argc, char ** argv){
FMpi app( argc, argv);
const int NbLevels = 9;//10;
const int SizeSubLevels = 3;//3
const int NbLevels = FParameters::getValue(argc,argv,"-h", 9);
const int SizeSubLevels = FParameters::getValue(argc,argv,"-sh", 3);
FTic counter;
const char* const defaultFilename = "testLoaderFMA.fma"; //../../Data/ "testLoaderFMA.fma" "testFMAlgorithm.fma" Sphere.fma
const char* filename;
......@@ -290,6 +291,7 @@ int main(int argc, char ** argv){
// -----------------------------------------------------
std::cout << "Creating & Inserting " << loader.getNumberOfParticles() << " particles ..." << std::endl;
std::cout << "\tHeight : " << NbLevels << " \t sub-height : " << SizeSubLevels << std::endl;
counter.tic();
{
......
......@@ -58,17 +58,17 @@ class TestParameters : public FUTester<TestParameters> {
"tu.tU"
};
assert(FParameters::findParameter("tOto",argc,argv,false) == 0);
assert(FParameters::findParameter("titi",argc,argv,false) == 1);
assert(FParameters::findParameter("tAtA",argc,argv,false) == 2);
assert(FParameters::findParameter("tu.tu",argc,argv,false) == 3);
assert(FParameters::findParameter(argc,argv,"tOto",false) == 0);
assert(FParameters::findParameter(argc,argv,"titi",false) == 1);
assert(FParameters::findParameter(argc,argv,"tAtA",false) == 2);
assert(FParameters::findParameter(argc,argv,"tu.tu",false) == 3);
for(int idx = 0 ; idx < argc ; ++idx){
assert(FParameters::findParameter(argv[idx],argc,argv,true) == idx);
assert(FParameters::findParameter(argc,argv,argv[idx],true) == idx);
}
assert(FParameters::findParameter("tu.tu",argc,argv,true) == -1);
assert(FParameters::findParameter("TOTO",argc,argv,true) == -1);
assert(FParameters::findParameter(argc,argv,"tu.tu",true) == -1);
assert(FParameters::findParameter(argc,argv,"TOTO",true) == -1);
}
void StrToOther(){
......
Supports Markdown
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