Commit a450abe1 authored by jclamber's avatar jclamber

add Ramses 2D support

git-svn-id: http://svn.oamp.fr/repos/unsio/trunk@214 ce2cc22f-6084-46ce-a062-084b172ee5dc
parent f6da3a0d
......@@ -294,49 +294,30 @@ int CAmr::loadData(uns::CParticles * particles,
(ilevel>=lmin) &&
((px+dx2)>=xmin) &&
((py+dx2)>=ymin) &&
((pz+dx2)>=zmin) &&
((ndim<3) || ((pz+dx2)>=zmin)) &&
((px-dx2)<=xmax) &&
((py-dx2)<=ymax) &&
((pz-dx2)<=zmax) );
((ndim<3) || ((pz-dx2)<=zmax)));
if (ok_cell) {
if (!count_only) {
#if 0
int idx=index[nbody];
if (idx!=-1) { // it's a valide particle
pos[3*cpt+0] = px;
pos[3*cpt+1] = py;
pos[3*cpt+2] = pz;
rneib[cpt] = dx;
rho[cpt] = var[0*ngrida*twotondim+ind*ngrida+i];
#if 1
temp[cpt]= std::max(0.0,var[4*ngrida*twotondim+ind*ngrida+i]/rho[cpt]);
//temp[cpt]= var[4*ngrida*twotondim+ind*ngrida+i]/rho[cpt];
#else
float p=var[4*ngrida*twotondim+ind*ngrida+i]; // pressure
float alpha=0.28; // fraction of He in mass
float mu=4./(8.-5.*alpha);
float mh=1.67e-24; // proton mass in g
float kb=1.38e-16; // Boltzmann constant in erg.K-1
temp[cpt]= mu*mh/kb*p/rho[cpt]*1.e14; // Temperature en K
//temp[cpt] /= (11604.5/1000.); // Temperature en Kev
temp[cpt]=std::max((float)0.0,temp[cpt]);
#endif
cpt++;
}
#else
bool take=false;
if (req_bits&POS_BIT) {
particles->pos.push_back(px*header.boxlen); // x
particles->pos.push_back(py*header.boxlen); // y
particles->pos.push_back(pz*header.boxlen); // z
if (ndim>2)
particles->pos.push_back(pz*header.boxlen); // z
else
particles->pos.push_back(0.0); // z
particles->load_bits |= POS_BIT;
take=true;
}
if (req_bits&VEL_BIT) {
particles->vel.push_back(var[1*ngrida*twotondim+ind*ngrida+i]); // vx
particles->vel.push_back(var[2*ngrida*twotondim+ind*ngrida+i]); // vy
particles->vel.push_back(var[3*ngrida*twotondim+ind*ngrida+i]); // vz
if (ndim>2)
particles->vel.push_back(var[3*ngrida*twotondim+ind*ngrida+i]); // vz
else
particles->vel.push_back(0.0); // vz
particles->load_bits |= VEL_BIT;
take=true;
}
......@@ -381,7 +362,6 @@ int CAmr::loadData(uns::CParticles * particles,
}
particles->ntot++; // one more total particles
// this variable count all particles
#endif
}
nbody++;
}
......
......@@ -99,6 +99,9 @@ int CPart::loadData(uns::CParticles * particles,
readHeader();
double * tmp[7];//=new double[npart];
for (int i=0;i<7;i++) {
tmp[i] = NULL;
}
part.skipBlock(3);
// read positions
......@@ -148,10 +151,11 @@ int CPart::loadData(uns::CParticles * particles,
(agetmp[k]!=0.&& (comp_bits&STARS_BIT))) { // its' stars
if ((tmp[0][k]>=xmin && tmp[0][k]<=xmax) &&
(tmp[1][k]>=ymin && tmp[1][k]<=ymax) &&
(tmp[2][k]>=zmin && tmp[2][k]<=zmax)) {
((ndim<3)||(tmp[2][k]>=zmin && tmp[2][k]<=zmax))
) {
bool take=false;
for (int l=0;l<3;l++) {
for (int l=0;l<ndim;l++) {
if (req_bits&POS_BIT) {
particles->pos.push_back(tmp[l][k]);
particles->load_bits |= POS_BIT;
......@@ -163,6 +167,14 @@ int CPart::loadData(uns::CParticles * particles,
take=true;
}
}
if (ndim<3) { // for 2D only
if (req_bits&POS_BIT) {
particles->pos.push_back(0.0);
}
if (req_bits&VEL_BIT) {
particles->vel.push_back(0.0);
}
}
if (req_bits&MASS_BIT) {
particles->mass.push_back(tmp[6][k]);
particles->load_bits |= MASS_BIT;
......@@ -219,9 +231,10 @@ int CPart::loadData(uns::CParticles * particles,
for (int k=0; k<npart; k++) {
if ((tmp[0][k]>=xmin && tmp[0][k]<=xmax) &&
(tmp[1][k]>=ymin && tmp[1][k]<=ymax) &&
(tmp[2][k]>=zmin && tmp[2][k]<=zmax)) {
((ndim<3)||(tmp[2][k]>=zmin && tmp[2][k]<=zmax))
) {
bool take=false;
for (int l=0;l<3;l++) {
for (int l=0;l<ndim;l++) {
if (req_bits&POS_BIT) {
particles->pos.push_back(tmp[l][k]);
take=true;
......@@ -231,6 +244,14 @@ int CPart::loadData(uns::CParticles * particles,
take=true;
}
}
if (ndim<3) { // for 2D only
if (req_bits&POS_BIT) {
particles->pos.push_back(0.0);
}
if (req_bits&VEL_BIT) {
particles->vel.push_back(0.0);
}
}
if (req_bits&MASS_BIT) {
particles->mass.push_back(tmp[6][k]);
take=true;
......@@ -259,7 +280,9 @@ int CPart::loadData(uns::CParticles * particles,
}
// garbage collecting
for (int i=0; i<7; i++)
delete [] tmp[i];
if (tmp[i]) {
delete [] tmp[i];
}
part.close(); // close current file
} // for ...
return 1;
......
......@@ -22,7 +22,7 @@
namespace uns {
const std::string VERSION="1.0.1"; // UNSIO version
const std::string VERSION="1.1.0"; // UNSIO version
inline std::string getVersion() { return uns::VERSION; }
......
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