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

Merge branch 'master' of bitbucket.org:ohahn/monofonic into newbaryonlattice

This commit is contained in:
Oliver Hahn 2022-11-10 18:27:05 +01:00
commit ee391f2575
3 changed files with 20 additions and 21 deletions

View file

@ -20,6 +20,7 @@
#include <complex>
#include <map>
#include <memory>
#if defined(USE_MPI)
#include <mpi.h>

View file

@ -30,7 +30,7 @@ public:
//! empty constructor
vec3_t()
: x(data_[0]),y(data_[1]),z(data_[2]){}
: data_{{T(0),T(0),T(0)}},x(data_[0]),y(data_[1]),z(data_[2]){}
//! copy constructor
vec3_t( const vec3_t<T> &v)

View file

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