Moved serial mode to target mcelecron_serial.
Implemented parallelization with mpi.
This commit is contained in:
@@ -18,34 +18,15 @@ Pop4_Container::Pop4_Container(int num_z_bins, int num_r_bins, int num_phi_bins,
|
||||
phi_scale = Lin_Scale(0, 2*pi, num_phi_bins);
|
||||
E_scale = Log_Scale(scale_start, scale_end, num_E_bins);
|
||||
|
||||
data = new double ***[num_z_bins];
|
||||
for (int i = 0; i < num_z_bins; i++) {
|
||||
data[i] = new double **[num_r_bins];
|
||||
for(int j = 0; j < num_r_bins; j++) {
|
||||
data[i][j] = new double *[num_phi_bins];
|
||||
for (int k = 0; k < num_phi_bins; k++) {
|
||||
data[i][j][k] = new double [num_E_bins];
|
||||
for (int l = 0; l< num_E_bins; l++) {
|
||||
data[i][j][k][l] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
phi_offset = num_E_bins;
|
||||
r_offset = phi_offset * num_phi_bins;
|
||||
z_offset = r_offset*num_r_bins;
|
||||
total_data_size = num_z_bins*z_offset;
|
||||
|
||||
data = new double[total_data_size];
|
||||
}
|
||||
|
||||
Pop4_Container::~Pop4_Container() {
|
||||
int num_z_bins = z_scale.get_number_bins();
|
||||
int num_r_bins = r_scale.get_number_bins();
|
||||
int num_phi_bins = phi_scale.get_number_bins();
|
||||
for (int i = 0; i < num_z_bins; i++) {
|
||||
for(int j = 0; j < num_r_bins; j++) {
|
||||
for (int k = 0; k < num_phi_bins; k++) {
|
||||
delete[] data[i][j][k];
|
||||
}
|
||||
delete[] data[i][j];
|
||||
}
|
||||
delete[] data[i];
|
||||
}
|
||||
delete[] data;
|
||||
}
|
||||
|
||||
@@ -54,23 +35,14 @@ Pop4_Container::Pop4_Container(const Pop4_Container& other) {
|
||||
r_scale = other.r_scale;
|
||||
phi_scale = other.phi_scale;
|
||||
E_scale = other.E_scale;
|
||||
int num_z_bins = z_scale.get_number_bins();
|
||||
int num_r_bins = r_scale.get_number_bins();
|
||||
int num_phi_bins = phi_scale.get_number_bins();
|
||||
int num_E_bins = E_scale.get_number_bins();
|
||||
|
||||
data = new double ***[num_z_bins];
|
||||
for (int i = 0; i < num_z_bins; i++) {
|
||||
data[i] = new double **[num_r_bins];
|
||||
for(int j = 0; j < num_r_bins; j++) {
|
||||
data[i][j] = new double *[num_phi_bins];
|
||||
for (int k = 0; k < num_phi_bins; k++) {
|
||||
data[i][j][k] = new double [num_E_bins];
|
||||
for (int l = 0; l < num_E_bins; l++) {
|
||||
data[i][j][k][l] = other.data[i][j][k][l];
|
||||
}
|
||||
}
|
||||
}
|
||||
z_offset = other.z_offset;
|
||||
r_offset = other.r_offset;
|
||||
phi_offset = other.phi_offset;
|
||||
total_data_size = other.total_data_size;
|
||||
|
||||
for (int i=0; i<total_data_size; i++) {
|
||||
data[i] = other.data[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,17 +52,21 @@ Pop4_Container& Pop4_Container::operator=(const Pop4_Container& other) {
|
||||
swap(r_scale, tmp.r_scale);
|
||||
swap(phi_scale, tmp.phi_scale);
|
||||
swap(E_scale, tmp.E_scale);
|
||||
swap(z_offset, tmp.z_offset);
|
||||
swap(r_offset, tmp.r_offset);
|
||||
swap(phi_offset, tmp.phi_offset);
|
||||
swap(total_data_size, tmp.total_data_size);
|
||||
swap(data, tmp.data);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Pop4_Container::increase_value(const double &value, const vec3 &loc_m, const double &E_eV) {
|
||||
int zbin = z_scale.calc_index(calc_z_m(loc_m));
|
||||
int rbin = r_scale.calc_index(calc_r_m(loc_m));
|
||||
int phibin = phi_scale.calc_index(calc_phi(loc_m));
|
||||
int z_bin = z_scale.calc_index(calc_z_m(loc_m));
|
||||
int r_bin = r_scale.calc_index(calc_r_m(loc_m));
|
||||
int phi_bin = phi_scale.calc_index(calc_phi(loc_m));
|
||||
int E_bin = E_scale.calc_index(E_eV);
|
||||
|
||||
data[zbin][rbin][phibin][E_bin] += value;
|
||||
data[calc_data_bin(z_bin, r_bin, phi_bin, E_bin)] += value;
|
||||
}
|
||||
|
||||
void Pop4_Container::increase_value(const double &value, const vec3 &loc1_m, const vec3 &loc2_m, const double &E_eV) {
|
||||
@@ -103,27 +79,46 @@ void Pop4_Container::increase_value(const double &value, const vec3 &loc1_m, con
|
||||
int max_z_index = z_scale.calc_index(z_max_m);
|
||||
// No r/phi movement, else need to calculate more exactly
|
||||
double r = calc_r_m(loc1_m);
|
||||
int rbin = r_scale.calc_index(calc_r_m(r));
|
||||
int r_bin = r_scale.calc_index(calc_r_m(r));
|
||||
double phi = calc_phi(loc1_m);
|
||||
int phibin = phi_scale.calc_index(phi);
|
||||
int phi_bin = phi_scale.calc_index(phi);
|
||||
int E_bin = E_scale.calc_index(E_eV);
|
||||
|
||||
for (int i = min_z_index; i<=max_z_index; i++) {
|
||||
data[i][rbin][phibin][E_bin] += value;
|
||||
for (int z_bin = min_z_index; z_bin<=max_z_index; z_bin++) {
|
||||
data[calc_data_bin(z_bin, r_bin, phi_bin, E_bin)] += value;
|
||||
}
|
||||
}
|
||||
|
||||
double Pop4_Container::get_value(const vec3 &loc_m, const double &E_eV) {
|
||||
int zbin = z_scale.calc_index(calc_z_m(loc_m));
|
||||
int rbin = r_scale.calc_index(calc_r_m(loc_m));
|
||||
int phibin = phi_scale.calc_index(calc_phi(loc_m));
|
||||
int z_bin = z_scale.calc_index(calc_z_m(loc_m));
|
||||
int r_bin = r_scale.calc_index(calc_r_m(loc_m));
|
||||
int phi_bin = phi_scale.calc_index(calc_phi(loc_m));
|
||||
int E_bin = E_scale.calc_index(E_eV);
|
||||
return data[zbin][rbin][phibin][E_bin];
|
||||
return data[calc_data_bin(z_bin, r_bin, phi_bin, E_bin)];
|
||||
}
|
||||
|
||||
double *Pop4_Container::get_E_bins (const vec3 &loc_m) {
|
||||
int z_bin = z_scale.calc_index(loc_m[0]);
|
||||
int r_bin = r_scale.calc_index(loc_m[1]);
|
||||
int phi_bin = phi_scale.calc_index(loc_m[2]);
|
||||
return data[z_bin][r_bin][phi_bin];
|
||||
double Pop4_Container::get_value_sum(const vec3 &loc_m) {
|
||||
int z_bin = z_scale.calc_index(calc_z_m(loc_m));
|
||||
int r_bin = r_scale.calc_index(calc_r_m(loc_m));
|
||||
int phi_bin = phi_scale.calc_index(calc_phi(loc_m));
|
||||
int data_bin_start = calc_data_bin(z_bin, r_bin, phi_bin, 0);
|
||||
int data_bin_end = calc_data_bin(z_bin, r_bin, phi_bin, E_scale.get_number_bins());
|
||||
double sum = 0;
|
||||
for (int data_bin=data_bin_start; data_bin<data_bin_end; data_bin++) {
|
||||
sum += data[data_bin];
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
||||
loc_bins Pop4_Container::get_loc_bins(const vec3 &loc_m) {
|
||||
loc_bins res;
|
||||
res.z_bin = z_scale.calc_index(calc_z_m(loc_m));
|
||||
res.r_bin = r_scale.calc_index(calc_r_m(loc_m));
|
||||
res.phi_bin = phi_scale.calc_index(calc_phi(loc_m));
|
||||
return res;
|
||||
}
|
||||
|
||||
int Pop4_Container::calc_data_bin(int z_bin, int r_bin, int phi_bin, int E_bin) {
|
||||
return z_offset*z_bin + r_offset*r_bin + phi_offset*phi_bin + E_bin;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user