1
0
Fork 0
mirror of https://github.com/cosmo-sims/monofonIC.git synced 2024-09-19 17:03:45 +02:00

add missing HACC/GenericIO fields

This commit is contained in:
Michael Buehlmann 2022-04-28 13:13:51 -05:00
parent 762bef3aa2
commit fbf6690458

View file

@ -16,6 +16,7 @@ protected:
std::vector<float> vx, vy, vz; std::vector<float> vx, vy, vz;
std::vector<float> mass, hh, uu; std::vector<float> mass, hh, uu;
std::vector<float> mu, phi, rho; std::vector<float> mu, phi, rho;
std::vector<float> zmet, yhe;
std::vector<uint16_t> mask; std::vector<uint16_t> mask;
public: public:
@ -85,12 +86,16 @@ public:
vy.reserve(vy.size() + npart); vy.reserve(vy.size() + npart);
vz.reserve(vz.size() + npart); vz.reserve(vz.size() + npart);
ids.reserve(ids.size() + npart); ids.reserve(ids.size() + npart);
mask.reserve(mask.size() + npart);
// phi doesn't need to be initialized, just needs to be present in data
phi.resize(phi.size() + npart, 0.0f);
auto _pos = reinterpret_cast<const float*>(pc.get_pos32_ptr()); auto _pos = reinterpret_cast<const float*>(pc.get_pos32_ptr());
auto _vel = reinterpret_cast<const float*>(pc.get_vel32_ptr()); auto _vel = reinterpret_cast<const float*>(pc.get_vel32_ptr());
auto _ids = reinterpret_cast<const uint64_t*>(pc.get_ids64_ptr()); auto _ids = reinterpret_cast<const uint64_t*>(pc.get_ids64_ptr());
auto _mass = reinterpret_cast<const float*>(pc.get_mass32_ptr()); auto _mass = reinterpret_cast<const float*>(pc.get_mass32_ptr());
for(size_t i=0; i<npart; ++i) { for(size_t i=0; i<npart; ++i) {
xx.push_back(fmod(_pos[3*i + 0]+lunit_, lunit_)); xx.push_back(fmod(_pos[3*i + 0]+lunit_, lunit_));
yy.push_back(fmod(_pos[3*i + 1]+lunit_, lunit_)); yy.push_back(fmod(_pos[3*i + 1]+lunit_, lunit_));
@ -98,16 +103,15 @@ public:
vx.push_back(_vel[3*i + 0]); vx.push_back(_vel[3*i + 0]);
vy.push_back(_vel[3*i + 1]); vy.push_back(_vel[3*i + 1]);
vz.push_back(_vel[3*i + 2]); vz.push_back(_vel[3*i + 2]);
mask.push_back(s == cosmo_species::baryon ? 1<<2 : 0);
} }
// phi doesn't need to be initialized, just needs to be present in data
phi.resize(phi.size() + npart);
std::copy(_ids, _ids+npart, std::back_inserter(ids)); std::copy(_ids, _ids+npart, std::back_inserter(ids));
if(hacc_hydro_) { if(hacc_hydro_) {
size_t prev_size = mass.size(); size_t prev_size = mass.size();
size_t new_size = prev_size + npart; size_t new_size = prev_size + npart;
if(pc.bhas_individual_masses_) { if(pc.bhas_individual_masses_) {
std::copy(_mass, _mass+npart, std::back_inserter(mass)); std::copy(_mass, _mass+npart, std::back_inserter(mass));
} else { } else {
@ -115,20 +119,12 @@ public:
std::fill(mass.begin() + prev_size, mass.end(), particle_mass); std::fill(mass.begin() + prev_size, mass.end(), particle_mass);
} }
mask.resize(new_size); hh.resize(new_size, hh_value_);
std::fill(mask.begin() + prev_size, mask.end(), s == cosmo_species::baryon ? 1<<2 : 0); uu.resize(new_size, s == cosmo_species::baryon ? uu_value_ : 0.0f);
rho.resize(new_size, rho_value_);
hh.resize(new_size); mu.resize(new_size, s == cosmo_species::baryon ? mu_value_ : 0.0f);
std::fill(hh.begin() + prev_size, hh.end(), hh_value_); zmet.resize(new_size, 0.0f);
yhe.resize(new_size, 0.0f);
uu.resize(new_size);
std::fill(uu.begin() + prev_size, uu.end(), s == cosmo_species::baryon ? uu_value_ : 0.0f);
rho.resize(new_size);
std::fill(rho.begin() + prev_size, rho.end(), rho_value_);
mu.resize(new_size);
std::fill(mu.begin() + prev_size, mu.end(), s == cosmo_species::baryon ? mu_value_ : 0.0f);
} }
} }
@ -145,13 +141,15 @@ public:
writer.addVariable("vz", vz); writer.addVariable("vz", vz);
writer.addVariable("id", ids); writer.addVariable("id", ids);
writer.addVariable("phi", phi); writer.addVariable("phi", phi);
writer.addVariable("mask", mask);
if(hacc_hydro_) { if(hacc_hydro_) {
writer.addVariable("mass", mass); writer.addVariable("mass", mass);
writer.addVariable("mask", mask);
writer.addVariable("hh", hh); writer.addVariable("hh", hh);
writer.addVariable("uu", uu); writer.addVariable("uu", uu);
writer.addVariable("rho", rho); writer.addVariable("rho", rho);
writer.addVariable("mu", mu); writer.addVariable("mu", mu);
writer.addVariable("zmet", zmet);
writer.addVariable("yhe", yhe);
} }
writer.write(); writer.write();
MPI_Barrier(MPI_COMM_WORLD); MPI_Barrier(MPI_COMM_WORLD);