changes from double to float to check if
error is indeed cancellation error
This commit is contained in:
@@ -15,6 +15,7 @@ class Hdf5Writer {
|
|||||||
void write(const blitz::Array<double, 3>& data, std::string path);
|
void write(const blitz::Array<double, 3>& data, std::string path);
|
||||||
void write(const blitz::Array<double, 4>& data, std::string path);
|
void write(const blitz::Array<double, 4>& data, std::string path);
|
||||||
void write(const blitz::Array<double, 5>& data, std::string path);
|
void write(const blitz::Array<double, 5>& data, std::string path);
|
||||||
|
void write(const blitz::Array<float, 5>& data, std::string path);
|
||||||
void write(const blitz::Array<long int, 4>& data, std::string path);
|
void write(const blitz::Array<long int, 4>& data, std::string path);
|
||||||
void write(const blitz::Array<long int, 5>& data, std::string path);
|
void write(const blitz::Array<long int, 5>& data, std::string path);
|
||||||
void write(const blitz::TinyVector<double, 3>& data, std::string path);
|
void write(const blitz::TinyVector<double, 3>& data, std::string path);
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ class CpuSynchronizer {
|
|||||||
*/
|
*/
|
||||||
void sumToAll(blitz::Array<double, 4>& array,
|
void sumToAll(blitz::Array<double, 4>& array,
|
||||||
blitz::Array<double, 4>& last_sync_array);
|
blitz::Array<double, 4>& last_sync_array);
|
||||||
|
void sumToAll(blitz::Array<float, 5>& array,
|
||||||
|
blitz::Array<float, 5>& last_sync_array);
|
||||||
void sumToAll(blitz::Array<double, 5>& array,
|
void sumToAll(blitz::Array<double, 5>& array,
|
||||||
blitz::Array<double, 5>& last_sync_array);
|
blitz::Array<double, 5>& last_sync_array);
|
||||||
void sumToAll(blitz::Array<double, 3>& array,
|
void sumToAll(blitz::Array<double, 3>& array,
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class DynamicDensityField : public DensityField {
|
|||||||
|
|
||||||
blitz::Array<double, 3> densityArray();
|
blitz::Array<double, 3> densityArray();
|
||||||
blitz::Array<double, 4> spectrumArray();
|
blitz::Array<double, 4> spectrumArray();
|
||||||
blitz::Array<double, 5> timeInBinArray() const;
|
blitz::Array<float, 5> timeInBinArray() const;
|
||||||
// blitz::Array<long int, 5> deletedParticlesArray() const;
|
// blitz::Array<long int, 5> deletedParticlesArray() const;
|
||||||
blitz::Array<double, 3> binVolumeArray() const;
|
blitz::Array<double, 3> binVolumeArray() const;
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ class DynamicDensityField : public DensityField {
|
|||||||
|
|
||||||
// return an array of the time in bin at the Coordinate position and the energy
|
// return an array of the time in bin at the Coordinate position and the energy
|
||||||
// energy_eV (only pitch angle direction left); over and underflow bin are removed
|
// energy_eV (only pitch angle direction left); over and underflow bin are removed
|
||||||
blitz::Array<double, 1> sliceTimeInBinArray(const Coordinate& position,
|
blitz::Array<float, 1> sliceTimeInBinArray(const Coordinate& position,
|
||||||
double energy_eV) const;
|
double energy_eV) const;
|
||||||
|
|
||||||
const EnergyBinning* energyBinning() const;
|
const EnergyBinning* energyBinning() const;
|
||||||
@@ -94,10 +94,10 @@ class DynamicDensityField : public DensityField {
|
|||||||
// time in bin now contains the physical particle number per bin
|
// time in bin now contains the physical particle number per bin
|
||||||
// (not renamed, since that would require many, many changes due to
|
// (not renamed, since that would require many, many changes due to
|
||||||
// renaming of the functions)
|
// renaming of the functions)
|
||||||
blitz::Array<double, 5> time_in_bin_s_;
|
blitz::Array<float, 5> time_in_bin_s_;
|
||||||
// blitz::Array<long int, 5> deleted_particles_;
|
// blitz::Array<long int, 5> deleted_particles_;
|
||||||
|
|
||||||
blitz::Array<double, 5> sync_time_in_bin_s_;
|
blitz::Array<float, 5> sync_time_in_bin_s_;
|
||||||
// blitz::Array<long int, 5> sync_deleted_particles_;
|
// blitz::Array<long int, 5> sync_deleted_particles_;
|
||||||
|
|
||||||
blitz::Array<double, 4> density_per_m3_;
|
blitz::Array<double, 4> density_per_m3_;
|
||||||
|
|||||||
@@ -197,6 +197,38 @@ void Hdf5Writer::write(const blitz::Array<double, 5>& data, std::string path) {
|
|||||||
H5Fclose(file);
|
H5Fclose(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Hdf5Writer::write(const blitz::Array<float, 5>& data, std::string path) {
|
||||||
|
hid_t file = H5Fopen(absolute_filename_.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
|
||||||
|
|
||||||
|
blitz::TinyVector<int, 5> size = data.extent();
|
||||||
|
blitz::TinyVector<int, 5> start(0, 0, 0, 0, 0);
|
||||||
|
|
||||||
|
hid_t filespace =
|
||||||
|
H5Screate_simple(5, blitz::TinyVector<hsize_t, 5>(size).data(), NULL);
|
||||||
|
|
||||||
|
hid_t lcpl = H5Pcreate(H5P_LINK_CREATE);
|
||||||
|
H5Pset_create_intermediate_group(lcpl, 1);
|
||||||
|
|
||||||
|
// turn of error report by hdf5 because of check H5Dopen2
|
||||||
|
H5Eset_auto(H5E_DEFAULT, NULL, NULL);
|
||||||
|
hid_t dataset;
|
||||||
|
dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
|
||||||
|
if (dataset < 0) {
|
||||||
|
dataset = H5Dcreate2(file, path.c_str(), H5T_NATIVE_FLOAT, filespace, lcpl,
|
||||||
|
H5P_DEFAULT, H5P_DEFAULT);
|
||||||
|
}
|
||||||
|
// turn error report back onby hdf5 because of check H5Dopen2
|
||||||
|
H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
|
||||||
|
|
||||||
|
H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, filespace, H5P_DEFAULT,
|
||||||
|
data.data());
|
||||||
|
|
||||||
|
H5Dclose(dataset);
|
||||||
|
H5Pclose(lcpl);
|
||||||
|
H5Sclose(filespace);
|
||||||
|
H5Fclose(file);
|
||||||
|
}
|
||||||
|
|
||||||
void Hdf5Writer::write(const blitz::Array<long int, 4>& data,
|
void Hdf5Writer::write(const blitz::Array<long int, 4>& data,
|
||||||
std::string path) {
|
std::string path) {
|
||||||
hid_t file = H5Fopen(absolute_filename_.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
|
hid_t file = H5Fopen(absolute_filename_.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
|
||||||
|
|||||||
@@ -27,6 +27,16 @@ void CpuSynchronizer::sumToAll(blitz::Array<double, 5>& array,
|
|||||||
last_sync_array += delta;
|
last_sync_array += delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CpuSynchronizer::sumToAll(blitz::Array<float, 5>& array,
|
||||||
|
blitz::Array<float, 5>& last_sync_array) {
|
||||||
|
int size = array.size();
|
||||||
|
blitz::Array<float, 5> delta(array.extent());
|
||||||
|
delta = array - last_sync_array;
|
||||||
|
MPI_Allreduce(MPI_IN_PLACE, delta.data(), size, MPI_FLOAT,
|
||||||
|
MPI_SUM, MPI_COMM_WORLD);
|
||||||
|
last_sync_array += delta;
|
||||||
|
}
|
||||||
|
|
||||||
void CpuSynchronizer::sumToAll(blitz::Array<long int, 4>& array,
|
void CpuSynchronizer::sumToAll(blitz::Array<long int, 4>& array,
|
||||||
blitz::Array<long int, 4>& last_sync_array) {
|
blitz::Array<long int, 4>& last_sync_array) {
|
||||||
int size = array.size();
|
int size = array.size();
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ DynamicDensityField::DynamicDensityField(
|
|||||||
energy_binning_(energy_binning),
|
energy_binning_(energy_binning),
|
||||||
pitch_angle_binning_(pitch_angle_binning),
|
pitch_angle_binning_(pitch_angle_binning),
|
||||||
timer_(timer),
|
timer_(timer),
|
||||||
time_in_bin_s_(initiate5DArray<double>(
|
time_in_bin_s_(initiate5DArray<float>(
|
||||||
blitz::Range(position_binning.radial_binning.binIndexMin(),
|
blitz::Range(position_binning.radial_binning.binIndexMin(),
|
||||||
position_binning.radial_binning.binIndexMax()),
|
position_binning.radial_binning.binIndexMax()),
|
||||||
blitz::Range(position_binning.azimuth_binning.binIndexMin(),
|
blitz::Range(position_binning.azimuth_binning.binIndexMin(),
|
||||||
@@ -72,7 +72,7 @@ DynamicDensityField::DynamicDensityField(
|
|||||||
pitch_angle_binning.binIndexMax()),
|
pitch_angle_binning.binIndexMax()),
|
||||||
blitz::Range(energy_binning.binIndexMin(),
|
blitz::Range(energy_binning.binIndexMin(),
|
||||||
energy_binning.binIndexMax()))),
|
energy_binning.binIndexMax()))),
|
||||||
sync_time_in_bin_s_(initiate5DArray<double>(
|
sync_time_in_bin_s_(initiate5DArray<float>(
|
||||||
blitz::Range(position_binning.radial_binning.binIndexMin(),
|
blitz::Range(position_binning.radial_binning.binIndexMin(),
|
||||||
position_binning.radial_binning.binIndexMax()),
|
position_binning.radial_binning.binIndexMax()),
|
||||||
blitz::Range(position_binning.azimuth_binning.binIndexMin(),
|
blitz::Range(position_binning.azimuth_binning.binIndexMin(),
|
||||||
@@ -209,7 +209,7 @@ void DynamicDensityField::logMovement(const Coordinate& position,
|
|||||||
const int pitch_angle_bin = pitch_angle_binning_.bin(pitch_angle);
|
const int pitch_angle_bin = pitch_angle_binning_.bin(pitch_angle);
|
||||||
|
|
||||||
time_in_bin_s_(position_bin(0), position_bin(1), position_bin(2),
|
time_in_bin_s_(position_bin(0), position_bin(1), position_bin(2),
|
||||||
pitch_angle_bin, energy_bin) += weight;
|
pitch_angle_bin, energy_bin) += static_cast<float>(weight);
|
||||||
}
|
}
|
||||||
|
|
||||||
// void DynamicDensityField::logDeletion(const Coordinate& position,
|
// void DynamicDensityField::logDeletion(const Coordinate& position,
|
||||||
@@ -251,7 +251,7 @@ blitz::Array<double, 4> DynamicDensityField::spectrumArray() {
|
|||||||
return density_per_m3_;
|
return density_per_m3_;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 5> DynamicDensityField::timeInBinArray() const {
|
blitz::Array<float, 5> DynamicDensityField::timeInBinArray() const {
|
||||||
return time_in_bin_s_;
|
return time_in_bin_s_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,7 +327,7 @@ blitz::Array<double, 1> DynamicDensityField::
|
|||||||
energy_binning_.binIndexMax()-1)).copy();
|
energy_binning_.binIndexMax()-1)).copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 1> DynamicDensityField::
|
blitz::Array<float, 1> DynamicDensityField::
|
||||||
sliceTimeInBinArray(const Coordinate& position, double energy_eV) const {
|
sliceTimeInBinArray(const Coordinate& position, double energy_eV) const {
|
||||||
blitz::TinyVector<int, 3> position_bin =
|
blitz::TinyVector<int, 3> position_bin =
|
||||||
position_binning_.bin(position.cylinderEntries());
|
position_binning_.bin(position.cylinderEntries());
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ CartesianVector VelocityDistributionFromDensityField::rollVelocity(
|
|||||||
|
|
||||||
// draw pitch angle from DynamicDensityField
|
// draw pitch angle from DynamicDensityField
|
||||||
|
|
||||||
blitz::Array<double, 1> pitchAngleValues = density_field_->
|
blitz::Array<float, 1> pitchAngleValues = density_field_->
|
||||||
sliceTimeInBinArray(position, energy_eV);
|
sliceTimeInBinArray(position, energy_eV);
|
||||||
|
|
||||||
std::piecewise_constant_distribution<double> pitchAngle_dist(
|
std::piecewise_constant_distribution<double> pitchAngle_dist(
|
||||||
@@ -113,7 +113,7 @@ CartesianVector VelocityDistributionFromDensityField::rollVelocity(
|
|||||||
|
|
||||||
// draw pitch angle from DynamicDensityField
|
// draw pitch angle from DynamicDensityField
|
||||||
|
|
||||||
blitz::Array<double, 1> pitchAngleValues = density_field_->
|
blitz::Array<float, 1> pitchAngleValues = density_field_->
|
||||||
sliceTimeInBinArray(position, energy_eV);
|
sliceTimeInBinArray(position, energy_eV);
|
||||||
|
|
||||||
std::piecewise_constant_distribution<double> pitchAngle_dist(
|
std::piecewise_constant_distribution<double> pitchAngle_dist(
|
||||||
|
|||||||
Reference in New Issue
Block a user