This function is called on every nth iteration. It counts the number of particle updates which have been performed.
41 std::map<size_t, std::array<double, 3>> avg_velocity_per_bin_index_x;
42 std::map<size_t, std::array<double, 3>> avg_velocity_per_bin_index_y;
43 std::map<size_t, std::array<double, 3>> avg_velocity_per_bin_index_z;
45 std::map<size_t, size_t> samples_per_bin_index_x;
46 std::map<size_t, size_t> samples_per_bin_index_y;
47 std::map<size_t, size_t> samples_per_bin_index_z;
50 auto& velocity = particle.getV();
51 auto& position = particle.getX();
54 if (position[0] <
box.first[0] || position[0] >
box.second[0] || position[1] <
box.first[1] || position[1] >
box.second[1] ||
55 position[2] <
box.first[2] || position[2] >
box.second[2]) {
59 size_t bin_index_x = std::floor((position[0] -
box.first[0]) /
bin_width[0]);
60 size_t bin_index_y = std::floor((position[1] -
box.first[1]) /
bin_width[1]);
61 size_t bin_index_z = std::floor((position[2] -
box.first[2]) /
bin_width[2]);
63 avg_velocity_per_bin_index_x[bin_index_x] =
64 (1.0 / (samples_per_bin_index_x[bin_index_x] + 1)) *
65 (samples_per_bin_index_x[bin_index_x] * avg_velocity_per_bin_index_x[bin_index_x] + velocity);
67 avg_velocity_per_bin_index_y[bin_index_y] =
68 (1.0 / (samples_per_bin_index_y[bin_index_y] + 1)) *
69 (samples_per_bin_index_y[bin_index_y] * avg_velocity_per_bin_index_y[bin_index_y] + velocity);
71 avg_velocity_per_bin_index_z[bin_index_z] =
72 (1.0 / (samples_per_bin_index_z[bin_index_z] + 1)) *
73 (samples_per_bin_index_z[bin_index_z] * avg_velocity_per_bin_index_z[bin_index_z] + velocity);
75 samples_per_bin_index_x[bin_index_x]++;
76 samples_per_bin_index_y[bin_index_y]++;
77 samples_per_bin_index_z[bin_index_z]++;
80 for (
auto& [bin_index, avg_velocity] : avg_velocity_per_bin_index_x) {
81 csv_writer_x->writeRow({iteration, bin_index, avg_velocity[0], avg_velocity[1], avg_velocity[2]});
84 for (
auto& [bin_index, avg_velocity] : avg_velocity_per_bin_index_y) {
85 csv_writer_y->writeRow({iteration, bin_index, avg_velocity[0], avg_velocity[1], avg_velocity[2]});
88 for (
auto& [bin_index, avg_velocity] : avg_velocity_per_bin_index_z) {
89 csv_writer_z->writeRow({iteration, bin_index, avg_velocity[0], avg_velocity[1], avg_velocity[2]});
std::unique_ptr< ParticleContainer > particle_container
Reference to the ParticleContainer on whose content the simulation is performed.