From e67ed9907792ea06b595b517db1549b43731aa38 Mon Sep 17 00:00:00 2001 From: "Paul P.H. Wilson" Date: Thu, 11 Jun 2020 09:23:29 -0500 Subject: [PATCH 01/24] Addressed PullRequest comments for UWUW code --- src/uwuw/name_concatenator.hpp | 4 ++-- src/uwuw/uwuw.cpp | 2 +- src/uwuw/uwuw_preprocessor.cpp | 27 +++++++++------------------ 3 files changed, 12 insertions(+), 21 deletions(-) diff --git a/src/uwuw/name_concatenator.hpp b/src/uwuw/name_concatenator.hpp index 800c92367f..988e8001dd 100644 --- a/src/uwuw/name_concatenator.hpp +++ b/src/uwuw/name_concatenator.hpp @@ -5,10 +5,10 @@ class name_concatenator { public: /// constructor - name_concatenator(); + name_concatenator() {}; /// destructor - ~name_concatenator(); + ~name_concatenator() {}; /// returns the a unique name std::string make_name_8bytes(std::string name); diff --git a/src/uwuw/uwuw.cpp b/src/uwuw/uwuw.cpp index 8de6f10dde..47de03726b 100644 --- a/src/uwuw/uwuw.cpp +++ b/src/uwuw/uwuw.cpp @@ -65,7 +65,7 @@ std::string UWUW::get_full_filepath(std::string filename) { } // see if file exists -bool UWUW::check_file_exists(std::string filename) { +bool UWUW::check_file_exists(const std::string& filename) { // from http://stackoverflow.com/questions/12774207/ // fastest-way-to-check-if-a-file-exist-using-standard-c-c11-c std::ifstream infile(filename.c_str()); diff --git a/src/uwuw/uwuw_preprocessor.cpp b/src/uwuw/uwuw_preprocessor.cpp index 708b73a52f..7bdc216c10 100644 --- a/src/uwuw/uwuw_preprocessor.cpp +++ b/src/uwuw/uwuw_preprocessor.cpp @@ -96,11 +96,10 @@ pyne::Material uwuw_preprocessor::create_new_material(pyne::Material material, s std::string material_name; // make a new name - if (density != "") { - material_name = "mat:" + material.metadata["name"].asString() + "/rho:" + density; + material_name = "mat:" + material.metadata["name"].asString(); + if (density != "") { + material_name = material_name + "/rho:" + density; new_mat.density = atof(density.c_str()); - } else { - material_name = "mat:" + material.metadata["name"].asString(); } if (verbose) { @@ -178,7 +177,7 @@ void uwuw_preprocessor::process_tallies() { std::vector::iterator it; // first volumes - for (int i = 1 ; i <= DAG->num_entities(3); i++) { + for (size_t i = 1 ; i <= DAG->num_entities(3); i++) { // get the tally properties std::string prop = dmd->get_volume_property("tally", i, true); std::vector tally_props = dmd->unpack_string(prop, "|"); @@ -191,7 +190,7 @@ void uwuw_preprocessor::process_tallies() { } } // now surfaces - for (int i = 1 ; i <= DAG->num_entities(2); i++) { + for (size_t i = 1 ; i <= DAG->num_entities(2); i++) { // get the tally properties std::string prop = dmd->get_surface_property("tally", i, true); std::vector tally_props = dmd->unpack_string(prop, "|"); @@ -245,7 +244,7 @@ void uwuw_preprocessor::check_material_props(std::vector material_p if (verbose || fatal) { std::cout << "More than one material for volume with id " << cellid << std::endl; std::cout << cellid << " has the following material assignments" << std::endl; - for (int j = 0 ; j < material_props.size() ; j++) { + for (size_t j = 0 ; j < material_props.size() ; j++) { std::cout << material_props[j] << std::endl; } std::cout << "Please check your material assignments " << cellid << std::endl; @@ -271,7 +270,7 @@ void uwuw_preprocessor::check_material_props(std::vector material_p if (verbose || fatal) { std::cout << "More than one density specified for " << cellid << std::endl; std::cout << cellid << " has the following density assignments" << std::endl; - for (int j = 0 ; j < density_props.size() ; j++) { + for (size_t j = 0 ; j < density_props.size() ; j++) { std::cout << density_props[j] << std::endl; } std::cout << "Please check your density assignments " << cellid << std::endl; @@ -303,10 +302,10 @@ void uwuw_preprocessor::print_summary() { } // used for printing & debugging only -void uwuw_preprocessor::property_vector(std::vector props) { +void uwuw_preprocessor::property_vector(const std::vector& props) { if (props.size() == 0) return; - for (int i = 0 ; i < props.size() ; i++) { + for (size_t i = 0 ; i < props.size() ; i++) { if (i == 0) { std::cout << "| " << props[i] << " "; continue; @@ -436,14 +435,6 @@ void uwuw_preprocessor::check_tally_props(std::string particle_name, } -// constructor -name_concatenator::name_concatenator() { -} - -// destructor -name_concatenator::~name_concatenator() { -} - // make the fluka name from the string std::string name_concatenator::make_name_8bytes(std::string name) { // fluka name needs to be 8 chars long uppercase and unique From 9dd0260ad8dacd0bbd9d028c85c9df1287e5adac Mon Sep 17 00:00:00 2001 From: "Paul P.H. Wilson" Date: Thu, 11 Jun 2020 09:24:51 -0500 Subject: [PATCH 02/24] Add VSCode workspace files to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 3f1c939e7c..4afabfaf9d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ #* # vscode settings .vscode +.code-workspace # Ignore built documentation gh-build From 8a27d2d0f7115a1c9e1dbf47c7e8c319c8911671 Mon Sep 17 00:00:00 2001 From: "Paul P.H. Wilson" Date: Thu, 11 Jun 2020 09:38:11 -0500 Subject: [PATCH 03/24] Add another fix to UWUW --- src/uwuw/uwuw.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/uwuw/uwuw.cpp b/src/uwuw/uwuw.cpp index 47de03726b..0da5694372 100644 --- a/src/uwuw/uwuw.cpp +++ b/src/uwuw/uwuw.cpp @@ -150,8 +150,7 @@ int UWUW::get_length_of_table(std::string filename, std::string datapath) { // Initilize to dataspace, to find the indices we are looping over hid_t arr_space = H5Dget_space(ds); - hsize_t arr_dims[1]; - int arr_ndim = H5Sget_simple_extent_dims(arr_space, arr_dims, NULL); + H5Sget_simple_extent_dims(arr_space, arr_dims, NULL); status = H5Eclear(H5E_DEFAULT); From 517a8bb09c5b6084f0aa417f45d729a898250ab4 Mon Sep 17 00:00:00 2001 From: "Paul P.H. Wilson" Date: Thu, 11 Jun 2020 09:48:14 -0500 Subject: [PATCH 04/24] Apply PullRequest changes for Tally code --- src/tally/KDEMeshTally.cpp | 10 +++++----- src/tally/TrackLengthMeshTally.cpp | 13 ++++++------- src/tally/tests/test_KDEKernel.cpp | 6 +++--- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/tally/KDEMeshTally.cpp b/src/tally/KDEMeshTally.cpp index 31c332bedf..ed741e2e79 100644 --- a/src/tally/KDEMeshTally.cpp +++ b/src/tally/KDEMeshTally.cpp @@ -188,9 +188,9 @@ void KDEMeshTally::write_data(double num_histories) { if (data->has_total_energy_bin()) num_ebins--; - double tally_vect[num_ebins]; - double error_vect[num_ebins]; - + std::vector tally_vect(num_ebins); + std::vector error_vect(num_ebins); + for (unsigned int j = 0; j < num_ebins; ++ j) { std::pair tally_data = data->get_data(point_index, j); double tally = tally_data.first; @@ -210,9 +210,9 @@ void KDEMeshTally::write_data(double num_histories) { error_vect[j] = rel_error; } // set tally and error tag values for this entity - rval = mbi->tag_set_data(tally_tag, &point, 1, tally_vect); + rval = mbi->tag_set_data(tally_tag, &point, 1, tally_vect.data()); MB_CHK_SET_ERR_RET(rval, "Failed to set the tally_tag data"); - rval = mbi->tag_set_data(error_tag, &point, 1, error_vect); + rval = mbi->tag_set_data(error_tag, &point, 1, error_vect.data()); MB_CHK_SET_ERR_RET(rval, "Failed to set the error_tag data"); } diff --git a/src/tally/TrackLengthMeshTally.cpp b/src/tally/TrackLengthMeshTally.cpp index 3e43a65aab..d2493a0db5 100644 --- a/src/tally/TrackLengthMeshTally.cpp +++ b/src/tally/TrackLengthMeshTally.cpp @@ -261,9 +261,9 @@ void TrackLengthMeshTally::write_data(double num_histories) { if (data->has_total_energy_bin()) num_ebins--; - double tally_vect[num_ebins]; - double error_vect[num_ebins]; - + std::vector tally_vect(num_ebins); + std::vector error_vect(num_ebins); + for (unsigned j = 0; j < num_ebins ; ++j) { std::pair tally_data = data->get_data(tet_index, j); double tally = tally_data.first; @@ -282,9 +282,9 @@ void TrackLengthMeshTally::write_data(double num_histories) { error_vect[j] = rel_err; } - rval = mb->tag_set_data(tally_tag, &t, 1, tally_vect); + rval = mb->tag_set_data(tally_tag, &t, 1, tally_vect.data()); MB_CHK_SET_ERR_RET(rval, "Failed to set tally_tag " + std::to_string(rval) + " " + std::to_string(t)); - rval = mb->tag_set_data(error_tag, &t, 1, error_vect); + rval = mb->tag_set_data(error_tag, &t, 1, error_vect.data() ); MB_CHK_SET_ERR_RET(rval, "Failed to set error_tag " + std::to_string(rval) + " " + std::to_string(t)); @@ -630,8 +630,7 @@ void TrackLengthMeshTally::sort_intersection_data(std::vector& intersect // function to compute the track lengths void TrackLengthMeshTally::compute_tracklengths(const TallyEvent& event, unsigned int ebin, double weight, - const std::vector& intersections, - const std::vector& triangles) { + const std::vector& intersections) { double track_length; // track_length to add to the tet CartVect hit_p; //position on the triangular face of the hit std::vector hit_point; // array of all hit points diff --git a/src/tally/tests/test_KDEKernel.cpp b/src/tally/tests/test_KDEKernel.cpp index 66a0e2dee7..b973d2c0e6 100644 --- a/src/tally/tests/test_KDEKernel.cpp +++ b/src/tally/tests/test_KDEKernel.cpp @@ -24,9 +24,9 @@ class MockEpanechnikovKernel : public KDEKernel { } // not implemented - std::string get_kernel_name() const {} - int get_order() const {} - int get_min_quadrature(unsigned int i) const {} + std::string get_kernel_name() const { return std::string(); } + int get_order() const { return 0; } + int get_min_quadrature(unsigned int i) const { return 0; } // integrates the ith moment function double integrate_moment(double a, double b, unsigned int i) const { From 69ad9939b675fba2ab280e3a4adac14b6178c02b Mon Sep 17 00:00:00 2001 From: "Paul P.H. Wilson" Date: Thu, 11 Jun 2020 10:00:31 -0500 Subject: [PATCH 05/24] Add news file --- news/PR-0680.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 news/PR-0680.rst diff --git a/news/PR-0680.rst b/news/PR-0680.rst new file mode 100644 index 0000000000..7669dcd0a0 --- /dev/null +++ b/news/PR-0680.rst @@ -0,0 +1,13 @@ +**Added:** None + +**Changed:** +* a few small fixes prompted by PullRequest review #660 +* only changed files in `uwuw` and `tally` + +**Deprecated:** None + +**Removed:** None + +**Fixed:** None + +**Security:** None From cb791801cb6f6600e970f4cae5e6a068180561af Mon Sep 17 00:00:00 2001 From: "Paul P.H. Wilson" Date: Thu, 11 Jun 2020 10:45:47 -0500 Subject: [PATCH 06/24] Added changes to overlap_check files as well --- news/PR-0680.rst | 2 +- src/overlap_check/ProgressBar.cpp | 12 +++--------- src/overlap_check/ProgressBar.hpp | 14 ++++++++++---- src/overlap_check/app/overlap_check.cpp | 4 +++- src/overlap_check/overlap.cpp | 6 +++--- src/overlap_check/test/overlap_check_test.cpp | 8 ++++---- src/overlap_check/test/overlap_check_test.hpp | 6 +++--- 7 files changed, 27 insertions(+), 25 deletions(-) diff --git a/news/PR-0680.rst b/news/PR-0680.rst index 7669dcd0a0..32636b56f7 100644 --- a/news/PR-0680.rst +++ b/news/PR-0680.rst @@ -2,7 +2,7 @@ **Changed:** * a few small fixes prompted by PullRequest review #660 -* only changed files in `uwuw` and `tally` +* only changed files in `uwuw`, `tally`, and `overlap_check` **Deprecated:** None diff --git a/src/overlap_check/ProgressBar.cpp b/src/overlap_check/ProgressBar.cpp index 1d68ce1140..53f659f0b1 100644 --- a/src/overlap_check/ProgressBar.cpp +++ b/src/overlap_check/ProgressBar.cpp @@ -2,6 +2,7 @@ #include "ProgressBar.hpp" +#include #include #include #include @@ -12,15 +13,6 @@ #define BAR_WIDTH 72 -ProgressBar::ProgressBar() { - // initialize bar - set_value(0.0); -} - -ProgressBar::~ProgressBar() { - std::cout << "\n"; -} - bool ProgressBar::is_terminal() { #ifdef _POSIX_VERSION return isatty(STDOUT_FILENO) != 0; @@ -62,7 +54,9 @@ void ProgressBar::set_value(double val) { // write the bar to screen std::cout << '\r' << bar.str() << std::flush; + need_final_newline = true; if (val >= 100.0) { std::cout << "\n"; + need_final_newline = false; } } diff --git a/src/overlap_check/ProgressBar.hpp b/src/overlap_check/ProgressBar.hpp index 3ca25c4ece..62c75b6f05 100644 --- a/src/overlap_check/ProgressBar.hpp +++ b/src/overlap_check/ProgressBar.hpp @@ -2,16 +2,21 @@ #ifndef DAGMC_PROGRESSBAR_H #define DAGMC_PROGRESSBAR_H -#include - class ProgressBar { public: // constructor - ProgressBar(); + ProgressBar() { + // initialize bar + set_value(0.0); + }; // destructor - ~ProgressBar(); + ~ProgressBar() { + if (need_final_newline) { + std::cout << "\n"; + } + }; void set_value(double val); @@ -19,6 +24,7 @@ class ProgressBar { private: int current {0}; + bool need_final_newline {false}; }; #endif // HEADER GUARD diff --git a/src/overlap_check/app/overlap_check.cpp b/src/overlap_check/app/overlap_check.cpp index e530a46c00..4f74a4b54c 100644 --- a/src/overlap_check/app/overlap_check.cpp +++ b/src/overlap_check/app/overlap_check.cpp @@ -19,7 +19,9 @@ int main(int argc, char* argv[]) { std::string filename; int points_per_tri_edge {0}; - int n_threads {0}; + #ifdef _OPENMP + int n_threads {0}; + #endif po.addRequiredArg("dag_file", "Path to DAGMC file to check", &filename); diff --git a/src/overlap_check/overlap.cpp b/src/overlap_check/overlap.cpp index 2bda51dc33..2e1e27ab37 100644 --- a/src/overlap_check/overlap.cpp +++ b/src/overlap_check/overlap.cpp @@ -104,11 +104,11 @@ check_instance_for_overlaps(std::shared_ptr MBI, #pragma omp parallel shared(overlap_map, num_checked) { #pragma omp for schedule(auto) - for (int i = 0; i < all_verts.size(); i++) { + for (size_t i = 0; i < all_verts.size(); i++) { EntityHandle vert = all_verts[i]; CartVect loc; - rval = MBI->get_coords(&vert, 1, loc.array()); + MBI->get_coords(&vert, 1, loc.array()); rval = check_location_for_overlap(GQT, all_vols, loc, dir, overlap_map); MB_CHK_SET_ERR_CONT(rval, "Failed to check location " << loc << " for an overlap"); @@ -129,7 +129,7 @@ check_instance_for_overlaps(std::shared_ptr MBI, // (curve edges are likely in here too, // but it isn't hurting anything to check more locations) #pragma omp for schedule(auto) - for (int i = 0; i < all_edges.size() ; i++) { + for (size_t i = 0; i < all_edges.size() ; i++) { EntityHandle edge = all_edges[i]; Range edge_verts; diff --git a/src/overlap_check/test/overlap_check_test.cpp b/src/overlap_check/test/overlap_check_test.cpp index e68421b89f..8afe692939 100644 --- a/src/overlap_check/test/overlap_check_test.cpp +++ b/src/overlap_check/test/overlap_check_test.cpp @@ -27,7 +27,7 @@ void OverlapTest::TearDown() { }; class OverlappingVolumesTest : public OverlapTest { - virtual void SetFilename() { filename = "overlap.h5m"; } + virtual void SetFilename() override { filename = "overlap.h5m"; } }; TEST_F(OverlappingVolumesTest, test1) { @@ -43,7 +43,7 @@ TEST_F(OverlappingVolumesTest, test1) { } class NonOverlappingVolumesTest : public OverlapTest { - virtual void SetFilename() { filename = "no_overlap.h5m"; } + virtual void SetFilename() override { filename = "no_overlap.h5m"; } }; TEST_F(NonOverlappingVolumesTest, test2) { @@ -62,7 +62,7 @@ TEST_F(NonOverlappingVolumesTest, test2) { } class NonOverlappingImprintedVolumesTest : public OverlapTest { - virtual void SetFilename() { filename = "no_overlap_imp.h5m"; } + virtual void SetFilename() override { filename = "no_overlap_imp.h5m"; } }; TEST_F(NonOverlappingImprintedVolumesTest, test3) { @@ -81,7 +81,7 @@ TEST_F(NonOverlappingImprintedVolumesTest, test3) { } class EnclosedVolumeTest : public OverlapTest { - virtual void SetFilename() { filename = "enclosed.h5m"; } + virtual void SetFilename() override { filename = "enclosed.h5m"; } }; TEST_F(EnclosedVolumeTest, test1) { diff --git a/src/overlap_check/test/overlap_check_test.hpp b/src/overlap_check/test/overlap_check_test.hpp index f93a616cdc..80c4e4c217 100644 --- a/src/overlap_check/test/overlap_check_test.hpp +++ b/src/overlap_check/test/overlap_check_test.hpp @@ -5,9 +5,9 @@ using namespace moab; class OverlapTest : public::testing::Test { protected: - virtual void SetUp(); - virtual void TearDown(); - virtual void SetFilename() {}; + virtual void SetUp() override; + virtual void TearDown() override; + virtual void SetFilename() override {}; std::string filename; From 9ed620ca38fbeae2dad0c4003112ff2eeb54579d Mon Sep 17 00:00:00 2001 From: "Paul P.H. Wilson" Date: Thu, 11 Jun 2020 10:54:32 -0500 Subject: [PATCH 07/24] Add changes for build_obb as well --- news/PR-0680.rst | 6 +++++- src/build_obb/build_obb.cpp | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/news/PR-0680.rst b/news/PR-0680.rst index 32636b56f7..80b0134b7f 100644 --- a/news/PR-0680.rst +++ b/news/PR-0680.rst @@ -2,7 +2,11 @@ **Changed:** * a few small fixes prompted by PullRequest review #660 -* only changed files in `uwuw`, `tally`, and `overlap_check` +* only changed files in + * `uwuw` + * `tally` + * `overlap_check` + * `build_obb` **Deprecated:** None diff --git a/src/build_obb/build_obb.cpp b/src/build_obb/build_obb.cpp index 5f9a990010..3a2c223cdd 100644 --- a/src/build_obb/build_obb.cpp +++ b/src/build_obb/build_obb.cpp @@ -25,7 +25,12 @@ int main(int argc, char* argv[]) { // sets the output filename if none specified if (out_file == "") { int pos = dag_file.find(".h5m"); - out_file = dag_file.substr(0, pos) + "_obb.h5m"; + if (pos != -1) { + out_file = dag_file.substr(0, pos); + } else { + out_file = dag_file; + } + out_file = out_file + "_obb.h5m"; std::cout << "Setting default outfile to be " << out_file << std::endl; } From f0824277d9f52a27d4f086ea1b2516a44d6f078d Mon Sep 17 00:00:00 2001 From: "Paul P.H. Wilson" Date: Thu, 11 Jun 2020 10:57:39 -0500 Subject: [PATCH 08/24] Last change - adding changes in misc/tests --- misc/tests/test_uwuw_preproc_model.py | 5 ++--- news/PR-0680.rst | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/misc/tests/test_uwuw_preproc_model.py b/misc/tests/test_uwuw_preproc_model.py index 406e73c344..a74fa3acf3 100644 --- a/misc/tests/test_uwuw_preproc_model.py +++ b/misc/tests/test_uwuw_preproc_model.py @@ -28,9 +28,8 @@ def test_model_material(): # group_list is the final list of group names found on the CAD h5m file for k in pseudo_list: if ("mat:" in k): - index = k.index('\n') - k = k[0:index] - group_list.append(k.rstrip("\n")) + idx = k.index('\n') + group_list.append(k[0:idx].rstrip("\n")) # tag_list is the list of group names obtained by running get_tag_values # function tag_list = gtag.get_tag_values(filename, output_filename) diff --git a/news/PR-0680.rst b/news/PR-0680.rst index 80b0134b7f..458dbe8a54 100644 --- a/news/PR-0680.rst +++ b/news/PR-0680.rst @@ -7,6 +7,7 @@ * `tally` * `overlap_check` * `build_obb` + * `misc/tests` **Deprecated:** None From 973b4763eca645af4a614038550b5b8263ad57db Mon Sep 17 00:00:00 2001 From: "Paul P.H. Wilson" Date: Thu, 11 Jun 2020 11:28:37 -0500 Subject: [PATCH 09/24] small change to be more platform independent --- src/overlap_check/ProgressBar.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/overlap_check/ProgressBar.hpp b/src/overlap_check/ProgressBar.hpp index 62c75b6f05..19862b3ec6 100644 --- a/src/overlap_check/ProgressBar.hpp +++ b/src/overlap_check/ProgressBar.hpp @@ -14,7 +14,7 @@ class ProgressBar { // destructor ~ProgressBar() { if (need_final_newline) { - std::cout << "\n"; + std::cout << std::endl; } }; From d38c4eb27d95bbf309478d65983991e3e9a3ed2d Mon Sep 17 00:00:00 2001 From: "Paul P.H. Wilson" Date: Thu, 11 Jun 2020 11:33:05 -0500 Subject: [PATCH 10/24] astyle changes --- src/overlap_check/ProgressBar.hpp | 2 +- src/overlap_check/app/overlap_check.cpp | 6 ++--- src/tally/KDEMeshTally.cpp | 2 +- src/tally/TrackLengthMeshTally.cpp | 4 +-- src/tally/tests/test_KDENeighborhood.cpp | 34 ++++++++++++------------ src/uwuw/uwuw_preprocessor.cpp | 4 +-- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/overlap_check/ProgressBar.hpp b/src/overlap_check/ProgressBar.hpp index 19862b3ec6..4791dd59a9 100644 --- a/src/overlap_check/ProgressBar.hpp +++ b/src/overlap_check/ProgressBar.hpp @@ -6,7 +6,7 @@ class ProgressBar { public: // constructor - ProgressBar() { + ProgressBar() { // initialize bar set_value(0.0); }; diff --git a/src/overlap_check/app/overlap_check.cpp b/src/overlap_check/app/overlap_check.cpp index 4f74a4b54c..0d30ea2170 100644 --- a/src/overlap_check/app/overlap_check.cpp +++ b/src/overlap_check/app/overlap_check.cpp @@ -19,9 +19,9 @@ int main(int argc, char* argv[]) { std::string filename; int points_per_tri_edge {0}; - #ifdef _OPENMP - int n_threads {0}; - #endif +#ifdef _OPENMP + int n_threads {0}; +#endif po.addRequiredArg("dag_file", "Path to DAGMC file to check", &filename); diff --git a/src/tally/KDEMeshTally.cpp b/src/tally/KDEMeshTally.cpp index ed741e2e79..52bbe27fa1 100644 --- a/src/tally/KDEMeshTally.cpp +++ b/src/tally/KDEMeshTally.cpp @@ -190,7 +190,7 @@ void KDEMeshTally::write_data(double num_histories) { std::vector tally_vect(num_ebins); std::vector error_vect(num_ebins); - + for (unsigned int j = 0; j < num_ebins; ++ j) { std::pair tally_data = data->get_data(point_index, j); double tally = tally_data.first; diff --git a/src/tally/TrackLengthMeshTally.cpp b/src/tally/TrackLengthMeshTally.cpp index d2493a0db5..1e95409741 100644 --- a/src/tally/TrackLengthMeshTally.cpp +++ b/src/tally/TrackLengthMeshTally.cpp @@ -263,7 +263,7 @@ void TrackLengthMeshTally::write_data(double num_histories) { std::vector tally_vect(num_ebins); std::vector error_vect(num_ebins); - + for (unsigned j = 0; j < num_ebins ; ++j) { std::pair tally_data = data->get_data(tet_index, j); double tally = tally_data.first; @@ -284,7 +284,7 @@ void TrackLengthMeshTally::write_data(double num_histories) { rval = mb->tag_set_data(tally_tag, &t, 1, tally_vect.data()); MB_CHK_SET_ERR_RET(rval, "Failed to set tally_tag " + std::to_string(rval) + " " + std::to_string(t)); - rval = mb->tag_set_data(error_tag, &t, 1, error_vect.data() ); + rval = mb->tag_set_data(error_tag, &t, 1, error_vect.data()); MB_CHK_SET_ERR_RET(rval, "Failed to set error_tag " + std::to_string(rval) + " " + std::to_string(t)); diff --git a/src/tally/tests/test_KDENeighborhood.cpp b/src/tally/tests/test_KDENeighborhood.cpp index 395b338442..7a1eb4a29f 100644 --- a/src/tally/tests/test_KDENeighborhood.cpp +++ b/src/tally/tests/test_KDENeighborhood.cpp @@ -327,14 +327,14 @@ TEST_F(IsCalculationPointTest, ValidCornerPoints) { moab::Range corner_points; double corner_coords[] = { -0.1, -0.2, -0.3, - 0.1, 0.2, 0.3, + 0.1, 0.2, 0.3, -0.1, -0.2, 0.3, -0.1, 0.2, -0.3, - 0.1, -0.2, 0.3, + 0.1, -0.2, 0.3, -0.1, 0.2, 0.3, - 0.1, -0.2, 0.3, - 0.1, 0.2, -0.3 - }; + 0.1, -0.2, 0.3, + 0.1, 0.2, -0.3 + }; // add new corner points to the MOAB instance and convert Range to set rval = mbi->create_vertices(corner_coords, 8, corner_points); @@ -371,13 +371,13 @@ TEST_F(IsCalculationPointTest, ValidEdgePoints) { double edge_coords[] = { -0.1, -0.2, 0.1667, -0.1, -0.05, -0.3, - 0.0, -0.2, -0.3, - 0.1, 0.2, -0.01, - 0.1, 0.13, 0.3, + 0.0, -0.2, -0.3, + 0.1, 0.2, -0.01, + 0.1, 0.13, 0.3, -0.09, 0.2, 0.3, - 0.07, -0.2, 0.3, - 0.1, 0.0, -0.3 - }; + 0.07, -0.2, 0.3, + 0.1, 0.0, -0.3 + }; // add new edge points to the MOAB instance and convert Range to set rval = mbi->create_vertices(edge_coords, 8, edge_points); @@ -453,16 +453,16 @@ TEST_F(IsCalculationPointTest, InvalidPoints) { double invalid_coords[] = { -0.1, -0.2, 0.5, -0.1, -0.3, -0.3, - 0.2, -0.2, -0.3, - 0.1, 0.2, -0.7, - 0.1, 0.9, 0.3, + 0.2, -0.2, -0.3, + 0.1, 0.2, -0.7, + 0.1, 0.9, 0.3, -0.1, 5.1, -2.9, - 1.7, 0.0, 10.4, + 1.7, 0.0, 10.4, -0.5, -0.8, 0.3, - 0.6, -0.9, 1.5, + 0.6, -0.9, 1.5, -0.7, 0.4, -0.5, -0.1, -0.3, -0.3 - }; + }; // add new invalid points to the MOAB instance and convert Range to set rval = mbi->create_vertices(invalid_coords, 11, invalid_points); diff --git a/src/uwuw/uwuw_preprocessor.cpp b/src/uwuw/uwuw_preprocessor.cpp index 7bdc216c10..456c10acba 100644 --- a/src/uwuw/uwuw_preprocessor.cpp +++ b/src/uwuw/uwuw_preprocessor.cpp @@ -96,8 +96,8 @@ pyne::Material uwuw_preprocessor::create_new_material(pyne::Material material, s std::string material_name; // make a new name - material_name = "mat:" + material.metadata["name"].asString(); - if (density != "") { + material_name = "mat:" + material.metadata["name"].asString(); + if (density != "") { material_name = material_name + "/rho:" + density; new_mat.density = atof(density.c_str()); } From e7b0cba3bf47e2817697f2e9ab7001976ef7ff16 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Thu, 11 Jun 2020 11:41:58 -0500 Subject: [PATCH 11/24] formatting test_KDENeighborhood.cpp with astyle --- src/tally/tests/test_KDENeighborhood.cpp | 34 ++++++++++++------------ 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/tally/tests/test_KDENeighborhood.cpp b/src/tally/tests/test_KDENeighborhood.cpp index 7a1eb4a29f..395b338442 100644 --- a/src/tally/tests/test_KDENeighborhood.cpp +++ b/src/tally/tests/test_KDENeighborhood.cpp @@ -327,14 +327,14 @@ TEST_F(IsCalculationPointTest, ValidCornerPoints) { moab::Range corner_points; double corner_coords[] = { -0.1, -0.2, -0.3, - 0.1, 0.2, 0.3, + 0.1, 0.2, 0.3, -0.1, -0.2, 0.3, -0.1, 0.2, -0.3, - 0.1, -0.2, 0.3, + 0.1, -0.2, 0.3, -0.1, 0.2, 0.3, - 0.1, -0.2, 0.3, - 0.1, 0.2, -0.3 - }; + 0.1, -0.2, 0.3, + 0.1, 0.2, -0.3 + }; // add new corner points to the MOAB instance and convert Range to set rval = mbi->create_vertices(corner_coords, 8, corner_points); @@ -371,13 +371,13 @@ TEST_F(IsCalculationPointTest, ValidEdgePoints) { double edge_coords[] = { -0.1, -0.2, 0.1667, -0.1, -0.05, -0.3, - 0.0, -0.2, -0.3, - 0.1, 0.2, -0.01, - 0.1, 0.13, 0.3, + 0.0, -0.2, -0.3, + 0.1, 0.2, -0.01, + 0.1, 0.13, 0.3, -0.09, 0.2, 0.3, - 0.07, -0.2, 0.3, - 0.1, 0.0, -0.3 - }; + 0.07, -0.2, 0.3, + 0.1, 0.0, -0.3 + }; // add new edge points to the MOAB instance and convert Range to set rval = mbi->create_vertices(edge_coords, 8, edge_points); @@ -453,16 +453,16 @@ TEST_F(IsCalculationPointTest, InvalidPoints) { double invalid_coords[] = { -0.1, -0.2, 0.5, -0.1, -0.3, -0.3, - 0.2, -0.2, -0.3, - 0.1, 0.2, -0.7, - 0.1, 0.9, 0.3, + 0.2, -0.2, -0.3, + 0.1, 0.2, -0.7, + 0.1, 0.9, 0.3, -0.1, 5.1, -2.9, - 1.7, 0.0, 10.4, + 1.7, 0.0, 10.4, -0.5, -0.8, 0.3, - 0.6, -0.9, 1.5, + 0.6, -0.9, 1.5, -0.7, 0.4, -0.5, -0.1, -0.3, -0.3 - }; + }; // add new invalid points to the MOAB instance and convert Range to set rval = mbi->create_vertices(invalid_coords, 11, invalid_points); From 21bd7c3311bd0fdca110a2eda463290565fda2d3 Mon Sep 17 00:00:00 2001 From: "Paul P.H. Wilson" Date: Thu, 11 Jun 2020 12:29:40 -0500 Subject: [PATCH 12/24] Match headers to changes in implementation --- src/tally/TrackLengthMeshTally.hpp | 3 +-- src/uwuw/uwuw.hpp | 2 +- src/uwuw/uwuw_preprocessor.hpp | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/tally/TrackLengthMeshTally.hpp b/src/tally/TrackLengthMeshTally.hpp index b607fb5045..dd22536ec1 100644 --- a/src/tally/TrackLengthMeshTally.hpp +++ b/src/tally/TrackLengthMeshTally.hpp @@ -239,8 +239,7 @@ class TrackLengthMeshTally : public MeshTally { */ void compute_tracklengths(const TallyEvent& event, unsigned int ebin, double weight, - const std::vector& intersections, - const std::vector& triangles); + const std::vector& intersections); }; diff --git a/src/uwuw/uwuw.hpp b/src/uwuw/uwuw.hpp index 793fa6bfdb..6917003aa1 100644 --- a/src/uwuw/uwuw.hpp +++ b/src/uwuw/uwuw.hpp @@ -103,7 +103,7 @@ class UWUW { // turns the filename string into the full file path std::string get_full_filepath(std::string filename); // make sure the file, filename exists - bool check_file_exists(std::string filename); + bool check_file_exists(const std::string& filename); /** * \brief loads the pyne materials in map of name vs Material diff --git a/src/uwuw/uwuw_preprocessor.hpp b/src/uwuw/uwuw_preprocessor.hpp index f9afbeb4fc..d20f35d67e 100644 --- a/src/uwuw/uwuw_preprocessor.hpp +++ b/src/uwuw/uwuw_preprocessor.hpp @@ -209,7 +209,7 @@ class uwuw_preprocessor { */ pyne::Material create_new_material(pyne::Material material, std::string density); - void property_vector(std::vector props); + void property_vector(const std::vector& props); // public class members public: From 803a297028907afee339ee29bd58eb0784a4690b Mon Sep 17 00:00:00 2001 From: "Paul P.H. Wilson" Date: Thu, 11 Jun 2020 12:30:15 -0500 Subject: [PATCH 13/24] Make the change to gitingore useful --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 4afabfaf9d..45565f7a8f 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ #* # vscode settings .vscode -.code-workspace +*.code-workspace # Ignore built documentation gh-build From 1e3361f3927e7c2aadec5ff9c2926bef53a21c00 Mon Sep 17 00:00:00 2001 From: "Paul P.H. Wilson" Date: Thu, 11 Jun 2020 12:51:02 -0500 Subject: [PATCH 14/24] Make function call match new signature... --- src/tally/TrackLengthMeshTally.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tally/TrackLengthMeshTally.cpp b/src/tally/TrackLengthMeshTally.cpp index 1e95409741..2877181e8e 100644 --- a/src/tally/TrackLengthMeshTally.cpp +++ b/src/tally/TrackLengthMeshTally.cpp @@ -209,7 +209,7 @@ void TrackLengthMeshTally::compute_score(const TallyEvent& event) { sort_intersection_data(intersections, triangles); // compute the tracklengths - compute_tracklengths(event, ebin, weight, intersections, triangles); + compute_tracklengths(event, ebin, weight, intersections); return; } From 1b3b32240302ed0eac7efc7d39347fb73fefd8d0 Mon Sep 17 00:00:00 2001 From: "Paul P.H. Wilson" Date: Thu, 11 Jun 2020 13:05:38 -0500 Subject: [PATCH 15/24] Return destructor to impl to avoid extra includes --- src/overlap_check/ProgressBar.cpp | 6 ++++++ src/overlap_check/ProgressBar.hpp | 6 +----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/overlap_check/ProgressBar.cpp b/src/overlap_check/ProgressBar.cpp index 53f659f0b1..d7ff2c914c 100644 --- a/src/overlap_check/ProgressBar.cpp +++ b/src/overlap_check/ProgressBar.cpp @@ -13,6 +13,12 @@ #define BAR_WIDTH 72 +void ProgressBar::~ProgressBar() { + if (need_final_newline) { + std::cout << std::endl; + } + } + bool ProgressBar::is_terminal() { #ifdef _POSIX_VERSION return isatty(STDOUT_FILENO) != 0; diff --git a/src/overlap_check/ProgressBar.hpp b/src/overlap_check/ProgressBar.hpp index 4791dd59a9..1713684fd9 100644 --- a/src/overlap_check/ProgressBar.hpp +++ b/src/overlap_check/ProgressBar.hpp @@ -12,11 +12,7 @@ class ProgressBar { }; // destructor - ~ProgressBar() { - if (need_final_newline) { - std::cout << std::endl; - } - }; + ~ProgressBar(); void set_value(double val); From 9518129ebc73cf9fde6ad26b051d503c849e96c3 Mon Sep 17 00:00:00 2001 From: "Paul P.H. Wilson" Date: Thu, 11 Jun 2020 13:05:46 -0500 Subject: [PATCH 16/24] remove extra override --- src/overlap_check/test/overlap_check_test.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/overlap_check/test/overlap_check_test.hpp b/src/overlap_check/test/overlap_check_test.hpp index 80c4e4c217..01409fd454 100644 --- a/src/overlap_check/test/overlap_check_test.hpp +++ b/src/overlap_check/test/overlap_check_test.hpp @@ -7,7 +7,7 @@ class OverlapTest : public::testing::Test { protected: virtual void SetUp() override; virtual void TearDown() override; - virtual void SetFilename() override {}; + virtual void SetFilename() {}; std::string filename; From b44714aad5f4ab2e849209766e8da42e95908e10 Mon Sep 17 00:00:00 2001 From: "Paul P.H. Wilson" Date: Thu, 11 Jun 2020 13:10:58 -0500 Subject: [PATCH 17/24] style fix! --- src/overlap_check/ProgressBar.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/overlap_check/ProgressBar.cpp b/src/overlap_check/ProgressBar.cpp index d7ff2c914c..bc0fe14562 100644 --- a/src/overlap_check/ProgressBar.cpp +++ b/src/overlap_check/ProgressBar.cpp @@ -13,11 +13,11 @@ #define BAR_WIDTH 72 -void ProgressBar::~ProgressBar() { - if (need_final_newline) { - std::cout << std::endl; - } +void ProgressBar::~ProgressBar() { + if (need_final_newline) { + std::cout << std::endl; } +} bool ProgressBar::is_terminal() { #ifdef _POSIX_VERSION From c8424c0351108c5f7047c1fd8de5d2a48e2a705a Mon Sep 17 00:00:00 2001 From: "Paul P.H. Wilson" Date: Thu, 11 Jun 2020 13:24:28 -0500 Subject: [PATCH 18/24] syntax error --- src/overlap_check/ProgressBar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/overlap_check/ProgressBar.cpp b/src/overlap_check/ProgressBar.cpp index bc0fe14562..df5c273df7 100644 --- a/src/overlap_check/ProgressBar.cpp +++ b/src/overlap_check/ProgressBar.cpp @@ -13,7 +13,7 @@ #define BAR_WIDTH 72 -void ProgressBar::~ProgressBar() { +ProgressBar::~ProgressBar() { if (need_final_newline) { std::cout << std::endl; } From 28f8e85a3730f666044abd85262c2679f843d276 Mon Sep 17 00:00:00 2001 From: "Paul P.H. Wilson" Date: Thu, 11 Jun 2020 13:36:05 -0500 Subject: [PATCH 19/24] removed an extra line - restored --- src/uwuw/uwuw.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/uwuw/uwuw.cpp b/src/uwuw/uwuw.cpp index 0da5694372..9edfd28909 100644 --- a/src/uwuw/uwuw.cpp +++ b/src/uwuw/uwuw.cpp @@ -150,6 +150,7 @@ int UWUW::get_length_of_table(std::string filename, std::string datapath) { // Initilize to dataspace, to find the indices we are looping over hid_t arr_space = H5Dget_space(ds); + hsize_t arr_dims[1]; H5Sget_simple_extent_dims(arr_space, arr_dims, NULL); status = H5Eclear(H5E_DEFAULT); From e7686dbe2894270f34543f9bdf98a5b7455634e3 Mon Sep 17 00:00:00 2001 From: Paul Wilson Date: Mon, 15 Jun 2020 12:42:29 -0500 Subject: [PATCH 20/24] Update src/build_obb/build_obb.cpp Co-authored-by: Patrick Shriwise --- src/build_obb/build_obb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/build_obb/build_obb.cpp b/src/build_obb/build_obb.cpp index 3a2c223cdd..61fe5f3a62 100644 --- a/src/build_obb/build_obb.cpp +++ b/src/build_obb/build_obb.cpp @@ -25,7 +25,7 @@ int main(int argc, char* argv[]) { // sets the output filename if none specified if (out_file == "") { int pos = dag_file.find(".h5m"); - if (pos != -1) { + if (pos != std::string::npos) { out_file = dag_file.substr(0, pos); } else { out_file = dag_file; From 2ffc9ab35ef2449a3fd331e0669bb1ee07dfa15e Mon Sep 17 00:00:00 2001 From: Paul Wilson Date: Mon, 15 Jun 2020 12:42:44 -0500 Subject: [PATCH 21/24] Apply suggestions from code review Co-authored-by: Patrick Shriwise --- src/uwuw/name_concatenator.hpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/uwuw/name_concatenator.hpp b/src/uwuw/name_concatenator.hpp index 988e8001dd..edfdd1c223 100644 --- a/src/uwuw/name_concatenator.hpp +++ b/src/uwuw/name_concatenator.hpp @@ -5,10 +5,10 @@ class name_concatenator { public: /// constructor - name_concatenator() {}; + name_concatenator() = default; /// destructor - ~name_concatenator() {}; + ~name_concatenator() = default; /// returns the a unique name std::string make_name_8bytes(std::string name); @@ -44,4 +44,3 @@ class name_concatenator { private: std::set used_b8_names; ///< the collection of names used so far }; - From 14295feed58c81737949fcbc39d881bd069cd96e Mon Sep 17 00:00:00 2001 From: "Paul P.H. Wilson" Date: Mon, 15 Jun 2020 12:53:45 -0500 Subject: [PATCH 22/24] fix docstring after code change --- src/tally/TrackLengthMeshTally.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/tally/TrackLengthMeshTally.hpp b/src/tally/TrackLengthMeshTally.hpp index dd22536ec1..4792f8701e 100644 --- a/src/tally/TrackLengthMeshTally.hpp +++ b/src/tally/TrackLengthMeshTally.hpp @@ -234,7 +234,6 @@ class TrackLengthMeshTally : public MeshTally { * \param[in] ebin the energy bin index corresponding to the energy * \param[in] weight the multiplier value for the score to be tallied * \param[in] vector intersections list of all the intersections - * \param[in] vector triangles list of the triangle entity handles that correspond to the intersections * \return void */ void compute_tracklengths(const TallyEvent& event, From 238c4ac38ca77377097e469c4a52b7ec856518d2 Mon Sep 17 00:00:00 2001 From: "Paul P.H. Wilson" Date: Mon, 15 Jun 2020 12:54:18 -0500 Subject: [PATCH 23/24] combine declaration with immediate assignment --- src/uwuw/uwuw_preprocessor.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/uwuw/uwuw_preprocessor.cpp b/src/uwuw/uwuw_preprocessor.cpp index 456c10acba..06884d6067 100644 --- a/src/uwuw/uwuw_preprocessor.cpp +++ b/src/uwuw/uwuw_preprocessor.cpp @@ -94,9 +94,8 @@ pyne::Material uwuw_preprocessor::create_new_material(pyne::Material material, s // use the name concatenator to make the fluka name std::string fluka_name = ncr->make_name_8bytes(material.metadata["name"].asString()); - std::string material_name; // make a new name - material_name = "mat:" + material.metadata["name"].asString(); + std::string material_name = "mat:" + material.metadata["name"].asString(); if (density != "") { material_name = material_name + "/rho:" + density; new_mat.density = atof(density.c_str()); From a81ae533f7206cbc3eecf5655a2529c0994c6654 Mon Sep 17 00:00:00 2001 From: "Paul P.H. Wilson" Date: Mon, 15 Jun 2020 13:52:26 -0500 Subject: [PATCH 24/24] Assume final new line flag only changes one way and once --- src/overlap_check/ProgressBar.cpp | 2 +- src/overlap_check/ProgressBar.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/overlap_check/ProgressBar.cpp b/src/overlap_check/ProgressBar.cpp index df5c273df7..724f08f6ed 100644 --- a/src/overlap_check/ProgressBar.cpp +++ b/src/overlap_check/ProgressBar.cpp @@ -60,7 +60,7 @@ void ProgressBar::set_value(double val) { // write the bar to screen std::cout << '\r' << bar.str() << std::flush; - need_final_newline = true; + if (val >= 100.0) { std::cout << "\n"; need_final_newline = false; diff --git a/src/overlap_check/ProgressBar.hpp b/src/overlap_check/ProgressBar.hpp index 1713684fd9..b3d258cf5a 100644 --- a/src/overlap_check/ProgressBar.hpp +++ b/src/overlap_check/ProgressBar.hpp @@ -20,7 +20,7 @@ class ProgressBar { private: int current {0}; - bool need_final_newline {false}; + bool need_final_newline {true}; }; #endif // HEADER GUARD