<commit_before>#ifdef PARTICLES

#include <unistd.h>
#include <algorithm>
#include <iostream>
#include "../grid3D.h"
#include "../io.h"
#include "particles_3D.h"

#ifdef MPI_CHOLLA
#include "../mpi_routines.h"
#endif



Real Get_and_Remove_Real( part_int_t indx, real_vector_t &vec ){
  Real value = vec[indx];
  vec[indx] = vec.back();
  vec.pop_back();
  return value;
}

void Remove_Real( part_int_t indx, real_vector_t &vec ){
  vec[indx] = vec.back();
  vec.pop_back();
}

Real Get_and_Remove_partID( part_int_t indx, int_vector_t &vec ){
  Real value = (Real) vec[indx];
  vec[indx] = vec.back();
  vec.pop_back();
  return value;
}

void Remove_ID( part_int_t indx, int_vector_t &vec ){
  vec[indx] = vec.back();
  vec.pop_back();
}

part_int_t Real_to_part_int( Real inVal ){
  part_int_t outVal = (part_int_t) inVal;
  if ( (inVal - outVal) > 0.1 ) outVal += 1;
  if ( fabs(outVal - inVal) > 0.5 ) outVal -= 1;
  return outVal;
}

void Grid3D::Transfer_Particles_Boundaries( struct parameters P ){
  
  
  //Transfer Particles Boundaries
  Particles.TRANSFER_PARTICLES_BOUNDARIES = true;
  #ifdef CPU_TIME
  Timer.Start_Timer();
  #endif
  Set_Boundary_Conditions(P);
  #ifdef CPU_TIME
  Timer.End_and_Record_Time( 8 );
  #endif
  Particles.TRANSFER_PARTICLES_BOUNDARIES = false;
  
  // Count Total Particles
  part_int_t N_paricles_total;
  N_paricles_total = ReducePartIntSum( Particles.n_local );
  chprintf( " Total Particles: %ld\n", N_paricles_total );
}

#ifdef MPI_CHOLLA

void Grid3D::Finish_Particles_Transfer( void ){

  Particles.Remove_Transfered_Particles();

}


void Particles_3D::Remove_Transfered_Particles( void ){
  
  
  part_int_t n_delete = 0;
  n_delete += out_indxs_vec_x0.size();
  n_delete += out_indxs_vec_x1.size();
  n_delete += out_indxs_vec_y0.size();
  n_delete += out_indxs_vec_y1.size();
  n_delete += out_indxs_vec_z0.size();
  n_delete += out_indxs_vec_z1.size();<commit_msg>print Warning when particles lost<commit_after>#ifdef PARTICLES

#include <unistd.h>
#include <algorithm>
#include <iostream>
#include "../grid3D.h"
#include "../io.h"
#include "particles_3D.h"

#ifdef MPI_CHOLLA
#include "../mpi_routines.h"
#endif



Real Get_and_Remove_Real( part_int_t indx, real_vector_t &vec ){
  Real value = vec[indx];
  vec[indx] = vec.back();
  vec.pop_back();
  return value;
}

void Remove_Real( part_int_t indx, real_vector_t &vec ){
  vec[indx] = vec.back();
  vec.pop_back();
}

Real Get_and_Remove_partID( part_int_t indx, int_vector_t &vec ){
  Real value = (Real) vec[indx];
  vec[indx] = vec.back();
  vec.pop_back();
  return value;
}

void Remove_ID( part_int_t indx, int_vector_t &vec ){
  vec[indx] = vec.back();
  vec.pop_back();
}

part_int_t Real_to_part_int( Real inVal ){
  part_int_t outVal = (part_int_t) inVal;
  if ( (inVal - outVal) > 0.1 ) outVal += 1;
  if ( fabs(outVal - inVal) > 0.5 ) outVal -= 1;
  return outVal;
}

void Grid3D::Transfer_Particles_Boundaries( struct parameters P ){
  
  
  //Transfer Particles Boundaries
  Particles.TRANSFER_PARTICLES_BOUNDARIES = true;
  #ifdef CPU_TIME
  Timer.Start_Timer();
  #endif
  Set_Boundary_Conditions(P);
  #ifdef CPU_TIME
  Timer.End_and_Record_Time( 8 );
  #endif
  Particles.TRANSFER_PARTICLES_BOUNDARIES = false;
  
  // Count Total Particles
  part_int_t N_paricles_total;
  N_paricles_total = ReducePartIntSum( Particles.n_local );
  chprintf( " Total Particles: %ld\n", N_paricles_total );
  
  if ( N_paricles_total != Particles.n_total_initial ) chprintf( " WARNING: Lost Particles: %d \n", Particles.n_total_initial - N_paricles_total );
}

#ifdef MPI_CHOLLA

void Grid3D::Finish_Particles_Transfer( void ){

  Particles.Remove_Transfered_Particles();

}


void Particles_3D::Remove_Transfered_Particles( void ){
  
  
  part_int_t n_delete = 0;
  n_delete += out_indxs_vec_x0.size();
  n_delete += out_indxs_vec_x1.size();
  n_delete += out_indxs_vec_y0.size();
  n_delete += out_indxs_vec_y1.size();
  n_delete += out_indxs_vec_z0.size();
  n_delete += out_indxs_vec_z1.size();
{'fraction_non_alphanumeric': 0.12876712328767123, 'fraction_numerical': 0.009464508094645082, 'mean_word_length': 4.585535465924895, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6424374', 'n_tokens_mistral': 1658, 'n_tokens_neox': 1624, 'n_words': 308}