Commit 06576e2d authored by jclamber's avatar jclamber
Browse files

daily update

git-svn-id: http://svn.oamp.fr/repos/uns_projects/trunk@97 f264a43e-d52d-4b82-913b-c2bd5215a18a
parent 1d1ece7e
......@@ -40,23 +40,27 @@ CRectify::CRectify()
}
bool CRectify::rectify(const int _nbody,const float _time,
float * _pos, float * _vel,float * _mass, float * _weight, const bool _rectify,
float * _pos, float * _vel,float * _mass, float * _rho,
const bool _use_rho, const bool _rectify,
std::string _cod_file,std::string _rect_file, const float _threshold)
{
nbody= _nbody;
pos = _pos;
vel = _vel;
mass = _mass;
rho = _weight;
time = _time;
init();
nbody= _nbody;
pos = _pos;
vel = _vel;
mass = _mass;
rho = _rho;
time = _time;
threshold = _threshold;
cod_file = _cod_file;
rect_file = _rect_file;
threshold = _threshold;
cod_file = _cod_file;
rect_file = _rect_file;
rect = _rectify;
rect = _rectify;
use_rho = _use_rho;
process();
process2();
}
......@@ -93,18 +97,63 @@ void CRectify::init()
density=NULL;
nbody=0;
}
void CRectify::process2()
{
if (cod_file.length()!=0 &&!CSnaptools::isFileExist(cod_file)) {
std::cerr << "Requested codfile["<<codf<<"] does not exist, abort\n";
std::exit(1);
}
if (density) delete density;
if (use_rho) {
processRho();
}
findCenter();
findMoment();
snapTransform();
}
void CRectify::process()
{
if (density) delete density;
findCenter();
findMoment();
snapTransform();
}
void CRectify::findCenter()
{
if (cod_file.length()!=0) { // read cod from file
bool ok=CSnaptools::getTimeDataFile(cod_file,time,6,cod);
if (! ok ) {
std::cerr << "From file ["<<cod_file<<"] unable to find corresponding time ["<<time<<"]"
<< "aborting program....\n";
std::exit(1);
}
} else {
if (use_rho) {
CSnaptools::moveToCod<float>(vmass.size(),&vpos[0],&vvel[0],&vmass[0],&vrho[0],cod,false); // compute cod don't move
}
else {
std::cerr << "WE should be here.....FILE" << __FILE__<<" Line : "
<<__LINE__<< "\n";
std::exit(1);
}
}
for (int i=0; i<6; i++) {
codf[i] = (float) cod[i];
}
}
void CRectify::processRho()
{
if (!rho) {
// Instantiate a density object
density = new CDensity(nbody,&pos[0],&mass[0]);
......@@ -158,10 +207,10 @@ void CRectify::findCenter()
}
std::cerr << "Nbody = "<< nbody << " sel=" << ii << "\n";
// compute COD without shifting
CSnaptools::moveToCod<float>(vmass.size(),&vpos[0],&vvel[0],&vmass[0],&vrho[0],cod,false); // compute cod don't move
for (int i=0; i<6; i++) {
codf[i] = (float) cod[i];
if (cod_file.length()==0) { // we must compute COD
}
}
void CRectify::findMoment()
{
......
......@@ -56,20 +56,24 @@ public:
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, const bool rectify=false,
float * pos, float * vel,float * mass, float * weight,
const bool _use_rho, const bool rectify=false,
std::string cod_file="",std::string rect_file="", const float threshold=0.0);
void process();
void process2();
private:
uns::CunsIn * unsin;
jclut::CDensity * density;
float time, * pos, * vel, * mass, * rho;
float threshold;
std::string cod_file, rect_file;
bool rect;
bool rect, use_rho;
int nbody;
std::vector<CDataIndex> rho_di;
void init();
void processRho();
void findCenter();
void findMoment();
void snapTransform();
......
......@@ -59,20 +59,17 @@ int main(int argc, char ** argv )
std::string outname (getparam ((char *) "out" ));
std::string codf (getparam ((char *) "codfile" ));
std::string rectf (getparam ((char *) "rectf" ));
bool rho (getbparam((char *) "rho" ));
bool use_rho (getbparam((char *) "rho" ));
std::string select_c (getparam ((char *) "select" ));
std::string select_t (getparam ((char *) "times" ));
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";
bool okcodf=CSnaptools::getTimeDataFile(codf,5.,6,cod);
std::cerr << "ok ocdf=" << okcodf <<"\n";
for (int i=0;i<6;i++)
std::cerr << " " << cod[i];
std::cerr << "\n";
......@@ -104,6 +101,7 @@ int main(int argc, char ** argv )
// get RHO if exist
ok=uns->snapshot->getData("rho",&cnbody,&rho);
// get HSML if exist
ok=uns->snapshot->getData("hsml",&cnbody,&hsml);
......
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