Skip to content

Conversation

@pajkosmi
Copy link
Contributor

Proposed changes

Proper read in of tabulated EOS data to initialize CCSN executable.

Upgrade instructions

Code review checklist

  • The code is documented and the documentation renders correctly. Run
    make doc to generate the documentation locally into BUILD_DIR/docs/html.
    Then open index.html.
  • The code follows the stylistic and code quality guidelines listed in the
    code review guide.
  • The PR lists upgrade instructions and is labeled bugfix or
    new feature if appropriate.

Further comments

@pajkosmi pajkosmi force-pushed the tab_eos_ccsn branch 3 times, most recently from 73a26dd to 1a46646 Compare June 11, 2025 21:26
@pajkosmi pajkosmi requested a review from nilsdeppe June 11, 2025 23:08
Copy link
Member

@nilsdeppe nilsdeppe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can squash immediately

Comment on lines 161 to 166
for (size_t i = 0; i < num_radial_points_; i++) {
if (radius_[i] > target_radius) {
radius_index = i - 1;
break;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do this with a binary search, I think. https://en.cppreference.com/w/cpp/algorithm/lower_bound.html and then use https://en.cppreference.com/w/cpp/iterator/distance.html

const auto radius_index = static_cast<size_t>(std::distance(radius_.begin(),
    std::lower_bound(radius.begin(), radius.end(), target_radius));

Comment on lines 298 to 300
const double& central_angular_velocity,
const double& diff_rot_parameter,
const double& max_dens_ratio_interp,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For basic types (double, float, int, etc.) taking by value is better because a pointer (which is what a reference is) is 8 bytes while a double is 8 bytes, but with the pointer you have to resolve the pointer. Not a huge deal here, but in perf critical regions this can make a big difference.

Copy link
Contributor Author

@pajkosmi pajkosmi Jun 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clang tidy was giving me trouble on these lines, saying they should be references; do you suggest taking by value and overriding it with //NOLINT?

edit: disregard above

Comment on lines +550 to +554
const auto rest_mass_density = get<hydro::Tags::RestMassDensity<DataType>>(
variables(vars, x, tmpl::list<hydro::Tags::RestMassDensity<DataType>>{}));
const auto temperature = get<hydro::Tags::Temperature<DataType>>(
variables(vars, x, tmpl::list<hydro::Tags::Temperature<DataType>>{}));
const auto electron_fraction =
get<hydro::Tags::ElectronFraction<DataType>>(variables(
vars, x, tmpl::list<hydro::Tags::ElectronFraction<DataType>>{}));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use const auto& here. const auto does a copy instead of a reference.

Comment on lines 531 to +535
const auto rest_mass_density = get<hydro::Tags::RestMassDensity<DataType>>(
variables(vars, x, tmpl::list<hydro::Tags::RestMassDensity<DataType>>{}));
const auto electron_fraction =
get<hydro::Tags::ElectronFraction<DataType>>(variables(
vars, x, tmpl::list<hydro::Tags::ElectronFraction<DataType>>{}));
const auto temperature = get<hydro::Tags::Temperature<DataType>>(
variables(vars, x, tmpl::list<hydro::Tags::Temperature<DataType>>{}));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use const auto& here. const auto does a copy instead of a reference.

Comment on lines +568 to +573
const auto rest_mass_density = get<hydro::Tags::RestMassDensity<DataType>>(
variables(vars, x, tmpl::list<hydro::Tags::RestMassDensity<DataType>>{}));
const auto specific_internal_energy =
get<hydro::Tags::SpecificInternalEnergy<DataType>>(variables(
vars, x,
tmpl::list<hydro::Tags::SpecificInternalEnergy<DataType>>{}));
const auto pressure = get<hydro::Tags::Pressure<DataType>>(
variables(vars, x, tmpl::list<hydro::Tags::Pressure<DataType>>{}));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use const auto& here. const auto does a copy instead of a reference.

Comment on lines 12 to 22
#include "IO/Connectivity.hpp"
#include "IO/H5/AccessType.hpp"
#include "IO/H5/CheckH5.hpp"
#include "IO/H5/EosTable.hpp"
#include "IO/H5/File.hpp"
#include "IO/H5/Header.hpp"
#include "IO/H5/Helpers.hpp"
#include "IO/H5/OpenGroup.hpp"
#include "IO/H5/SourceArchive.hpp"
#include "IO/H5/Version.hpp"
#include "IO/H5/Wrappers.hpp"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need any of these includes in the hpp because the cpp file reads in the data, but the class doesn't store the h5 file, it stores the contents. Phrased differently, the hpp doesn't use any of the h5 stuff, so it's only needed in the cpp. Putting it in the cpp will help keep compile times down. In the cpp you only need

#include "IO/H5/AccessType.hpp"
#include "IO/H5/EosTable.hpp"
#include "IO/H5/File.hpp"

@nilsdeppe nilsdeppe marked this pull request as ready for review June 13, 2025 16:57
@nilsdeppe nilsdeppe merged commit e912056 into sxs-collaboration:develop Jun 13, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants