diff --git a/include/openmc/constants.h b/include/openmc/constants.h index b8c5c8548..c77817a14 100644 --- a/include/openmc/constants.h +++ b/include/openmc/constants.h @@ -11,9 +11,9 @@ namespace openmc { -typedef std::vector > double_2dvec; -typedef std::vector > > double_3dvec; -typedef std::vector > > > double_4dvec; +using double_2dvec = std::vector>; +using double_3dvec = std::vector>>; +using double_4dvec = std::vector>>>; // ============================================================================ // VERSIONING NUMBERS diff --git a/include/openmc/hdf5_interface.h b/include/openmc/hdf5_interface.h index 3ab2014c1..b791c8d72 100644 --- a/include/openmc/hdf5_interface.h +++ b/include/openmc/hdf5_interface.h @@ -70,9 +70,6 @@ void read_nd_vector(hid_t obj_id, const char* name, xt::xtensor& result, bool must_have = false); -void -read_nd_vector(hid_t obj_id, const char* name, xt::xtensor& result, - bool must_have = false); std::vector attribute_shape(hid_t obj_id, const char* name); std::vector dataset_names(hid_t group_id); diff --git a/include/openmc/mgxs.h b/include/openmc/mgxs.h index cd312ea17..e80355bee 100644 --- a/include/openmc/mgxs.h +++ b/include/openmc/mgxs.h @@ -159,7 +159,7 @@ class Mgxs { //! @param dg delayed group index; use nullptr if irrelevant. //! @return Requested cross section value. double - get_xs(const int xstype, const int gin, int* gout, double* mu, int* dg); + get_xs(int xstype, int gin, int* gout, double* mu, int* dg); //! \brief Samples the fission neutron energy and if prompt or delayed. //! @@ -167,7 +167,7 @@ class Mgxs { //! @param dg Sampled delayed group index. //! @param gout Sampled outgoing energy group. void - sample_fission_energy(const int gin, int& dg, int& gout); + sample_fission_energy(int gin, int& dg, int& gout); //! \brief Samples the outgoing energy and angle from a scatter event. //! @@ -176,7 +176,7 @@ class Mgxs { //! @param mu Sampled cosine of the change-in-angle. //! @param wgt Weight of the particle to be adjusted. void - sample_scatter(const int gin, int& gout, double& mu, double& wgt); + sample_scatter(int gin, int& gout, double& mu, double& wgt); //! \brief Calculates cross section quantities needed for tracking. //! @@ -187,14 +187,14 @@ class Mgxs { //! @param abs_xs Resultant absorption cross section. //! @param nu_fiss_xs Resultant nu-fission cross section. void - calculate_xs(const int gin, const double sqrtkT, const double uvw[3], + calculate_xs(int gin, double sqrtkT, const double uvw[3], double& total_xs, double& abs_xs, double& nu_fiss_xs); //! \brief Sets the temperature index in cache given a temperature //! //! @param sqrtkT Temperature of the material. void - set_temperature_index(const double sqrtkT); + set_temperature_index(double sqrtkT); //! \brief Sets the angle index in cache given a direction //! diff --git a/include/openmc/xsdata.h b/include/openmc/xsdata.h index 0bdeaf818..fa75b10aa 100644 --- a/include/openmc/xsdata.h +++ b/include/openmc/xsdata.h @@ -94,7 +94,7 @@ class XsData { // [angle][incoming group][outgoing group][delayed group] xt::xtensor chi_delayed; // scatter has the following dimensions: [angle] - std::vector > scatter; + std::vector> scatter; XsData() = default; diff --git a/src/hdf5_interface.cpp b/src/hdf5_interface.cpp index 52fae8228..514cf6966 100644 --- a/src/hdf5_interface.cpp +++ b/src/hdf5_interface.cpp @@ -673,36 +673,6 @@ read_nd_vector(hid_t obj_id, const char* name, xt::xtensor& result, } } -void -read_nd_vector(hid_t obj_id, const char* name, xt::xtensor& result, - bool must_have) -{ - if (object_exists(obj_id, name)) { - int dim1 = result.shape()[0]; - int dim2 = result.shape()[1]; - int dim3 = result.shape()[2]; - int dim4 = result.shape()[3]; - int dim5 = result.shape()[4]; - double temp_arr[dim1 * dim2 * dim3 * dim4 * dim5]; - read_double(obj_id, name, temp_arr, true); - - int temp_idx = 0; - for (int i = 0; i < dim1; i++) { - for (int j = 0; j < dim2; j++) { - for (int k = 0; k < dim3; k++) { - for (int l = 0; l < dim4; l++) { - for (int m = 0; m < dim5; m++) { - result(i, j, k, l, m) = temp_arr[temp_idx++]; - } - } - } - } - } - } else if (must_have) { - fatal_error(std::string("Must provide " + std::string(name) + "!")); - } -} - void read_tally_results(hid_t group_id, hsize_t n_filter, hsize_t n_score, double* results) diff --git a/src/mgxs.cpp b/src/mgxs.cpp index b9e22780a..12c73fab4 100644 --- a/src/mgxs.cpp +++ b/src/mgxs.cpp @@ -423,7 +423,7 @@ Mgxs::combine(const std::vector& micros, const std::vector& scala //============================================================================== double -Mgxs::get_xs(const int xstype, const int gin, int* gout, double* mu, int* dg) +Mgxs::get_xs(int xstype, int gin, int* gout, double* mu, int* dg) { // This method assumes that the temperature and angle indices are set #ifdef _OPENMP @@ -535,7 +535,7 @@ Mgxs::get_xs(const int xstype, const int gin, int* gout, double* mu, int* dg) //============================================================================== void -Mgxs::sample_fission_energy(const int gin, int& dg, int& gout) +Mgxs::sample_fission_energy(int gin, int& dg, int& gout) { // This method assumes that the temperature and angle indices are set #ifdef _OPENMP @@ -599,7 +599,7 @@ Mgxs::sample_fission_energy(const int gin, int& dg, int& gout) //============================================================================== void -Mgxs::sample_scatter(const int gin, int& gout, double& mu, double& wgt) +Mgxs::sample_scatter(int gin, int& gout, double& mu, double& wgt) { // This method assumes that the temperature and angle indices are set // Sample the data @@ -614,7 +614,7 @@ Mgxs::sample_scatter(const int gin, int& gout, double& mu, double& wgt) //============================================================================== void -Mgxs::calculate_xs(const int gin, const double sqrtkT, const double uvw[3], +Mgxs::calculate_xs(int gin, double sqrtkT, const double uvw[3], double& total_xs, double& abs_xs, double& nu_fiss_xs) { // Set our indices @@ -649,7 +649,7 @@ Mgxs::equiv(const Mgxs& that) //============================================================================== void -Mgxs::set_temperature_index(const double sqrtkT) +Mgxs::set_temperature_index(double sqrtkT) { // See if we need to find the new index #ifdef _OPENMP diff --git a/src/xsdata.cpp b/src/xsdata.cpp index 56783a672..8abc1edfd 100644 --- a/src/xsdata.cpp +++ b/src/xsdata.cpp @@ -132,7 +132,7 @@ XsData::fission_vector_beta_from_hdf5(hid_t xsdata_grp, size_t n_ang, read_nd_vector(xsdata_grp, "chi", temp_chi, true); // Normalize chi by summing over the outgoing groups for each incoming angle - temp_chi = temp_chi / xt::view(xt::sum(temp_chi, {1}), xt::all(), xt::newaxis()); + temp_chi /= xt::view(xt::sum(temp_chi, {1}), xt::all(), xt::newaxis()); // Now every incoming group in prompt_chi and delayed_chi is the normalized // chi we just made @@ -186,16 +186,15 @@ XsData::fission_vector_no_beta_from_hdf5(hid_t xsdata_grp, size_t n_ang, read_nd_vector(xsdata_grp, "chi-prompt", temp_chi_p, true); // Normalize chi by summing over the outgoing groups for each incoming angle - temp_chi_p = temp_chi_p / xt::view(xt::sum(temp_chi_p, {1}), xt::all(), - xt::newaxis()); + temp_chi_p /= xt::view(xt::sum(temp_chi_p, {1}), xt::all(), xt::newaxis()); // Get chi-delayed xt::xtensor temp_chi_d({n_ang, delayed_groups, energy_groups}, 0.); read_nd_vector(xsdata_grp, "chi-delayed", temp_chi_d, true); // Normalize chi by summing over the outgoing groups for each incoming angle - temp_chi_d = temp_chi_d / xt::view(xt::sum(temp_chi_d, {2}), xt::all(), - xt::all(), xt::newaxis()); + temp_chi_d /= xt::view(xt::sum(temp_chi_d, {2}), + xt::all(), xt::all(), xt::newaxis()); // Now assign the prompt and delayed chis by replicating for each incoming group chi_prompt = xt::view(temp_chi_p, xt::all(), xt::newaxis(), xt::all()); @@ -203,8 +202,10 @@ XsData::fission_vector_no_beta_from_hdf5(hid_t xsdata_grp, size_t n_ang, xt::all()); // Get prompt and delayed nu-fission directly - read_nd_vector(xsdata_grp, "prompt-nu-fission", prompt_nu_fission, true); - read_nd_vector(xsdata_grp, "delayed-nu-fission", delayed_nu_fission, true); + read_nd_vector(xsdata_grp, "prompt-nu-fission", prompt_nu_fission, + true); + read_nd_vector(xsdata_grp, "delayed-nu-fission", + delayed_nu_fission, true); } void @@ -219,7 +220,7 @@ XsData::fission_vector_no_delayed_from_hdf5(hid_t xsdata_grp, size_t n_ang, read_nd_vector(xsdata_grp, "chi", temp_chi, true); // Normalize chi by summing over the outgoing groups for each incoming angle - temp_chi = temp_chi / xt::view(xt::sum(temp_chi, {1}), xt::all(), xt::newaxis()); + temp_chi /= xt::view(xt::sum(temp_chi, {1}), xt::all(), xt::newaxis()); // Now every incoming group in self.chi is the normalized chi we just made chi_prompt = xt::view(temp_chi, xt::all(), xt::newaxis(), xt::all()); @@ -299,11 +300,11 @@ XsData::fission_matrix_beta_from_hdf5(hid_t xsdata_grp, size_t n_ang, } //Normalize both chis - chi_prompt = chi_prompt / xt::view(xt::sum(chi_prompt, {2}), xt::all(), - xt::all(), xt::newaxis()); + chi_prompt /= xt::view(xt::sum(chi_prompt, {2}), + xt::all(), xt::all(), xt::newaxis()); - chi_delayed = chi_delayed / xt::view(xt::sum(chi_delayed, {3}), xt::all(), - xt::all(), xt::all(), xt::newaxis()); + chi_delayed /= xt::view(xt::sum(chi_delayed, {3}), + xt::all(), xt::all(), xt::all(), xt::newaxis()); } void