mirror of
https://github.com/cosmo-sims/monofonIC.git
synced 2024-09-19 17:03:45 +02:00
added ID offset for baryon particles to avoid duplicate IDs
This commit is contained in:
parent
b0b67086fd
commit
0abe891f86
2 changed files with 7 additions and 4 deletions
|
@ -37,7 +37,7 @@ const std::vector<vec3<real_t>> second_lattice_shift =
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename field_t>
|
template<typename field_t>
|
||||||
void initialize_lattice( container& particles, lattice lattice_type, const bool b64reals, const bool b64ids, const field_t& field ){
|
void initialize_lattice( container& particles, lattice lattice_type, const bool b64reals, const bool b64ids, const size_t IDoffset, const field_t& field ){
|
||||||
// number of modes present in the field
|
// number of modes present in the field
|
||||||
const size_t num_p_in_load = field.local_size();
|
const size_t num_p_in_load = field.local_size();
|
||||||
// unless SC lattice is used, particle number is a multiple of the number of modes (=num_p_in_load):
|
// unless SC lattice is used, particle number is a multiple of the number of modes (=num_p_in_load):
|
||||||
|
@ -50,9 +50,9 @@ void initialize_lattice( container& particles, lattice lattice_type, const bool
|
||||||
for( size_t k=0; k<field.size(2); ++k,++ipcount){
|
for( size_t k=0; k<field.size(2); ++k,++ipcount){
|
||||||
for( size_t iload=0; iload<overload; ++iload ){
|
for( size_t iload=0; iload<overload; ++iload ){
|
||||||
if( b64ids ){
|
if( b64ids ){
|
||||||
particles.set_id64( ipcount+iload*num_p_in_load, overload*field.get_cell_idx_1d(i,j,k)+iload );
|
particles.set_id64( ipcount+iload*num_p_in_load, IDoffset + overload*field.get_cell_idx_1d(i,j,k)+iload );
|
||||||
}else{
|
}else{
|
||||||
particles.set_id32( ipcount+iload*num_p_in_load, overload*field.get_cell_idx_1d(i,j,k)+iload );
|
particles.set_id32( ipcount+iload*num_p_in_load, IDoffset + overload*field.get_cell_idx_1d(i,j,k)+iload );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -540,11 +540,14 @@ int Run( ConfigFile& the_config )
|
||||||
bool shifted_lattice = (this_species == cosmo_species::baryon &&
|
bool shifted_lattice = (this_species == cosmo_species::baryon &&
|
||||||
the_output_plugin->write_species_as(this_species) == output_type::particles) ? true : false;
|
the_output_plugin->write_species_as(this_species) == output_type::particles) ? true : false;
|
||||||
|
|
||||||
|
// somewhat arbitrarily, start baryon particle IDs from 2**31 if we have 32bit and from 2**56 if we have 64 bits
|
||||||
|
size_t IDoffset = (this_species == cosmo_species::baryon)? ((the_output_plugin->has_64bit_ids())? 1ul<<56 : 1ul<<31): 0 ;
|
||||||
|
|
||||||
// if output plugin wants particles, then we need to store them, along with their IDs
|
// if output plugin wants particles, then we need to store them, along with their IDs
|
||||||
if( the_output_plugin->write_species_as( this_species ) == output_type::particles )
|
if( the_output_plugin->write_species_as( this_species ) == output_type::particles )
|
||||||
{
|
{
|
||||||
// allocate particle structure and generate particle IDs
|
// allocate particle structure and generate particle IDs
|
||||||
particle::initialize_lattice( particles, lattice_type, the_output_plugin->has_64bit_reals(), the_output_plugin->has_64bit_ids(), tmp );
|
particle::initialize_lattice( particles, lattice_type, the_output_plugin->has_64bit_reals(), the_output_plugin->has_64bit_ids(), IDoffset, tmp );
|
||||||
}
|
}
|
||||||
|
|
||||||
// write out positions
|
// write out positions
|
||||||
|
|
Loading…
Reference in a new issue