Skip to content

Commit

Permalink
Rewrite: MCCProcess::readCrossSectionFile
Browse files Browse the repository at this point in the history
More robust and earlier error checking.
  • Loading branch information
ax3l committed Nov 12, 2021
1 parent d515ad6 commit e936cc0
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions Source/Particles/Collision/MCCProcess.cpp
Expand Up @@ -97,17 +97,15 @@ MCCProcess::readCrossSectionFile (
amrex::Gpu::HostVector<amrex::Real>& sigmas )
{
std::ifstream infile(cross_section_file);
if(!infile) amrex::Abort("Failed to open readCrossSectionFile file");
infile.exceptions(std::ios_base::failbit | std::ios_base::badbit);
if(!infile.is_open()) amrex::Abort("Failed to open cross-section data file");

double energy, sigma;
while (infile >> energy >> sigma) {
energies.push_back(energy);
sigmas.push_back(sigma);
}
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(energies.size() > 1,
"Failed to read cross-section data from file."
);
if (infile.bad()) amrex::Abort("Failed to read cross-section data from file.");
infile.close();
}

void
Expand Down

0 comments on commit e936cc0

Please sign in to comment.