Commit 602685c9 authored by jclamber's avatar jclamber
Browse files

push fix

git-svn-id: http://svn.oamp.fr/repos/uns_projects/trunk@95 f264a43e-d52d-4b82-913b-c2bd5215a18a
parent bf561bcc
......@@ -54,6 +54,10 @@ public:
bool rectify(std::string component,float theshold=70.0, std::string cod_file="");
bool rectify(int nbody,float * pos, float * vel,float * mass, float * rho,
float threshold=70.0, std::string cod_file="");
bool rectify(const int nbody,const float time,
float * pos, float * vel,float * mass, float * weight,
std::string cod_file="",std::string rect_file="", float threshold=0.0);
void process();
private:
uns::CunsIn * unsin;
......
......@@ -22,8 +22,26 @@ using namespace jclut;
//
// ----------------------------------------------------------------------------
// getCodFromFile
bool getTimeDataFile(std::string input_file,const float time,std::vector<double> data,double offset, bool verbose)
// isFileExist
bool CSnaptools::isFileExist(std::string test_file)
{
bool ok=false;
std::ifstream fd; // file descriptor
fd.open(test_file.c_str(), std::ios::in); // open file
if (fd.is_open()) {
ok=true;
fd.close();
}
else ok = false;
return ok;
}
//
// ----------------------------------------------------------------------------
// getTimeDataFile
bool CSnaptools::getTimeDataFile(std::string input_file,const float time,const int n,double data[],const double offset,const bool verbose)
{
bool ok=false;
std::ifstream fd; // file descriptor
......@@ -44,15 +62,16 @@ bool getTimeDataFile(std::string input_file,const float time,std::vector<double>
if (r_time-offset <= time && time <= r_time+offset) { // found good time
stop = true;
ok = true;
for (int i=0; i<6; i++) { // read cod
double value;
ss >> value;
for (int i=0; i<n; i++) { // read cod
ss >> data[i];
}
}
}
}
}
if (fd.is_open()) {
fd.close();
}
return ok;
}
......
......@@ -28,7 +28,8 @@ namespace jclut {
template <class T> static void moveToCod(const int nbody,T * pos, T * Vel, T * mass, T * rho, double cod[6], bool move, bool verbose=false);
template <class T> static void moveToCom(const int nbody,T * pos, T * mass, bool verbose=false);
static bool getTimeDataFile(std::string _file,const float time,std::vector<double> data,double offset=0.0000001, bool verbose=false);
static bool getTimeDataFile(std::string _file,const float time,const int n,double data[],const double offset=0.0000001,const bool verbose=false);
static bool isFileExist(std::string);
static std::string basename(const std::string);
static std::string dirname(const std::string);
static std::string parseString(std::string & next_string, const std::string sep=",");
......
......@@ -23,6 +23,9 @@
// Include file
#include "uns.h"
#include "crectify.h"
#include "csnaptools.h"
using namespace jclut;
// ------------------------------------------------------------
// Nemo variable
const char * defv[] = {
......@@ -62,7 +65,17 @@ int main(int argc, char ** argv )
float threshold(getdparam ((char *) "threshold"));
bool verbose = getbparam((char *) "verbose" );
if (! CSnaptools::isFileExist(codf)) {
std::cerr << "codfile["<<codf<<"] does not exist, abort\n";
std::exit(1);
}
std::cerr << "codfile["<<codf<<"] length="<< codf.length()<<"\n";
double cod[6];
bool ok=CSnaptools::getTimeDataFile(codf,5.,6,cod);
std::cerr << "ok=" << ok <<"\n";
for (int i=0;i<6;i++)
std::cerr << " " << cod[i];
std::cerr << "\n";
std::exit(1);
// -----------------------------------------------
......
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