Skip to content

Commit

Permalink
refs #6667 Modified getNeutronAtom without exceptions to be really
Browse files Browse the repository at this point in the history
without exceptions

As it is impossible to start Mantid in Debug mode as it throws thousand exceptions which are then catched, analyzed, reported and one has to wait for 1 min to start trivial program
  • Loading branch information
abuts committed Jun 24, 2013
1 parent ee8b3ad commit dc6ef63
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ namespace Mantid

MANTID_KERNEL_DLL std::ostream& operator<<(std::ostream& out, const NeutronAtom &atom);
MANTID_KERNEL_DLL NeutronAtom getNeutronAtom(const uint16_t z_number, const uint16_t a_number = 0);
MANTID_KERNEL_DLL const NeutronAtom getNeutronNoExceptions(const uint16_t z_number, const uint16_t a_number);

} //Namespace PhysicalConstants
} //Namespace Mantid
Expand Down
17 changes: 2 additions & 15 deletions Code/Mantid/Framework/Kernel/src/Atom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,14 @@ namespace PhysicalConstants

using std::string;

/// Get the corresponding neutronic atom
const NeutronAtom getNeutronNoExceptions(const uint16_t z, const uint16_t a)
{
try
{
return getNeutronAtom(z, a);
}
catch (std::runtime_error & )
{
return NeutronAtom(z, a,
NAN, NAN, NAN, NAN,
NAN, NAN, NAN, NAN); // set to junk value
}
}


Atom::Atom(const std::string& symbol, const uint16_t z, const uint16_t a,
const double abundance, const double mass, const double density) :
symbol(symbol), z_number(z), a_number(a), abundance(abundance),
mass(mass), mass_density(density),
number_density(density * N_A * 1.e-24/ mass), // Convert from cm^-3 to Angstroms^-3
neutron(getNeutronNoExceptions(z, a))
neutron(getNeutronNoExceptions(z, a)) /// Get the corresponding neutronic atom
{
}

Expand Down
15 changes: 15 additions & 0 deletions Code/Mantid/Framework/Kernel/src/NeutronAtom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,21 @@ NeutronAtom getNeutronAtom(const uint16_t z_number, const uint16_t a_number)

return *result;
}
const NeutronAtom getNeutronNoExceptions(const uint16_t z_number, const uint16_t a_number)
{

NeutronAtom temp(z_number, a_number,
NAN, NAN, NAN, NAN, NAN, NAN); // set to junk value

NeutronAtom *result = std::lower_bound(&(ATOMS[0]), &(ATOMS[NUM_ATOMS]), temp, compareAtoms);
if (result == &(ATOMS[NUM_ATOMS]) || result->z_number != z_number
|| result->a_number != a_number)
{
return temp;
}
else
return *result;
}

} // namespace PhysicalConstants
} // namespace Mantid
Expand Down

0 comments on commit dc6ef63

Please sign in to comment.