From 52354128f14289012c8eded6b1109ae610f57ea8 Mon Sep 17 00:00:00 2001 From: Kalin Kiesling Date: Fri, 27 Mar 2020 10:27:17 -0500 Subject: [PATCH 1/6] removed unused commented lines --- src/mcnp/mcnp5/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mcnp/mcnp5/CMakeLists.txt b/src/mcnp/mcnp5/CMakeLists.txt index ca13c7d2ea..af9213ce5f 100644 --- a/src/mcnp/mcnp5/CMakeLists.txt +++ b/src/mcnp/mcnp5/CMakeLists.txt @@ -52,7 +52,6 @@ set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-O1 -g") # C compiler flags if (CMAKE_C_COMPILER_ID STREQUAL "Intel") - #set(CMAKE_C_FLAGS "${CMAKE_Fortran_FLAGS} -mcmodel=medium") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pc64") else () set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64") @@ -63,7 +62,6 @@ if (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -no-vec") set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -heap-arrays 1024") set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -traceback") - #set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -mcmodel=medium") set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -pc64") set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -r8") else () From 3f8f85c7a0bf4d6a31562566f4e3d88cdaa45eec Mon Sep 17 00:00:00 2001 From: Kalin Kiesling Date: Fri, 27 Mar 2020 10:36:12 -0500 Subject: [PATCH 2/6] changed to std::cerr when it's an error --- src/mcnp/mcnp_funcs.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/mcnp/mcnp_funcs.cpp b/src/mcnp/mcnp_funcs.cpp index 2544fc2633..89be82fadd 100644 --- a/src/mcnp/mcnp_funcs.cpp +++ b/src/mcnp/mcnp_funcs.cpp @@ -201,10 +201,10 @@ void write_cell_cards(std::ostringstream& lcadfile, const char* mcnp_version_maj if (mat_num.find("Graveyard") == std::string::npos && mat_num.find("Vacuum") == std::string::npos) { if (!DMD->try_to_make_int(mat_num)) { - std::cout << "Failed to cast material number to an integer" << std::endl; - std::cout << "volume with ID " << cellid << " has material assignment" << std::endl; - std::cout << mat_num << " which appears to be a name rather than an integer" << std::endl; - std::cout << "Did you forget to run uwuw_preproc?" << std::endl; + std::cerr << "Failed to cast material number to an integer" << std::endl; + std::cerr << "volume with ID " << cellid << " has material assignment" << std::endl; + std::cerr << mat_num << " which appears to be a name rather than an integer" << std::endl; + std::cerr << "Did you forget to run uwuw_preproc?" << std::endl; exit(EXIT_FAILURE); } } @@ -220,8 +220,8 @@ void write_cell_cards(std::ostringstream& lcadfile, const char* mcnp_version_maj // if we not vacuum or graveyard if (mat_name.find("Vacuum") == std::string::npos && mat_name.find("Graveyard") == std::string::npos) { if (workflow_data->material_library.count(mat_name) == 0) { - std::cout << "Material with name " << mat_name << " not found " << std::endl; - std::cout << "In the material library" << std::endl; + std::cerr << "Material with name " << mat_name << " not found " << std::endl; + std::cerr << "In the material library" << std::endl; exit(EXIT_FAILURE); } @@ -251,7 +251,7 @@ void write_cell_cards(std::ostringstream& lcadfile, const char* mcnp_version_maj } else if (mcnp_version_major[0] == '6') { mcnp_name = pyne::particle::mcnp6(particle_name); } else { - std::cout << "Unknown MCNP verison: " << mcnp_version_major << std::endl; + std::cerr << "Unknown MCNP verison: " << mcnp_version_major << std::endl; exit(EXIT_FAILURE); } double imp = 1.0; From a67913d25629d9e6b245d459bd0c3b9f4bc1284c Mon Sep 17 00:00:00 2001 From: Kalin Kiesling Date: Fri, 27 Mar 2020 10:45:21 -0500 Subject: [PATCH 3/6] converted graveyard and vacuum strings to variables --- src/mcnp/mcnp_funcs.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/mcnp/mcnp_funcs.cpp b/src/mcnp/mcnp_funcs.cpp index 89be82fadd..2196367434 100644 --- a/src/mcnp/mcnp_funcs.cpp +++ b/src/mcnp/mcnp_funcs.cpp @@ -46,6 +46,9 @@ static bool visited_surface = false; static bool use_dist_limit = false; static double dist_limit; // needs to be thread-local +static std::string graveyard_str = "Graveyard"; +static std::string vacuum_str = "Vacuum"; + void dagmcinit_(char* cfile, int* clen, // geom char* ftol, int* ftlen, // faceting tolerance @@ -198,8 +201,8 @@ void write_cell_cards(std::ostringstream& lcadfile, const char* mcnp_version_maj // that material numbers are assigned mat_num = DMD->volume_material_data_eh[entity]; // if we cant make an int from the mat_num - if (mat_num.find("Graveyard") == std::string::npos && - mat_num.find("Vacuum") == std::string::npos) { + if (mat_num.find(graveyard_str) == std::string::npos && + mat_num.find(vacuum_str) == std::string::npos) { if (!DMD->try_to_make_int(mat_num)) { std::cerr << "Failed to cast material number to an integer" << std::endl; std::cerr << "volume with ID " << cellid << " has material assignment" << std::endl; @@ -211,14 +214,14 @@ void write_cell_cards(std::ostringstream& lcadfile, const char* mcnp_version_maj density = DMD->volume_density_data_eh[entity]; // if we have a vacuum problem - if (mat_num == "Graveyard" || mat_num == "Vacuum") { + if (mat_num == graveyard_str || mat_num == vacuum_str) { mat_num = "0"; density = ""; } } else { std::string mat_name = DMD->volume_material_property_data_eh[entity]; // if we not vacuum or graveyard - if (mat_name.find("Vacuum") == std::string::npos && mat_name.find("Graveyard") == std::string::npos) { + if (mat_name.find(vacuum_str) == std::string::npos && mat_name.find(graveyard_str) == std::string::npos) { if (workflow_data->material_library.count(mat_name) == 0) { std::cerr << "Material with name " << mat_name << " not found " << std::endl; std::cerr << "In the material library" << std::endl; @@ -256,10 +259,10 @@ void write_cell_cards(std::ostringstream& lcadfile, const char* mcnp_version_maj } double imp = 1.0; // if we find graveyard always have importance 0.0 - if (mat_name.find("Graveyard") != std::string::npos) { + if (mat_name.find(graveyard_str) != std::string::npos) { imp = 0.0; // no splitting can happenin vacuum set to 1 - } else if (mat_name.find("Vacuum") != std::string::npos) { + } else if (mat_name.find(vacuum_str) != std::string::npos) { imp = 1.0; // otherwise as the map says } else { @@ -269,7 +272,7 @@ void write_cell_cards(std::ostringstream& lcadfile, const char* mcnp_version_maj } // its possible no importances were assigned if (set.size() == 0) { - if (mat_name.find("Graveyard") == std::string::npos) { + if (mat_name.find(graveyard_str) == std::string::npos) { importances = "imp:n=1"; } else { importances = "imp:n=0"; @@ -277,7 +280,7 @@ void write_cell_cards(std::ostringstream& lcadfile, const char* mcnp_version_maj } // add descriptive comments for special volumes - if (mat_name.find("Graveyard") != std::string::npos) { + if (mat_name.find(graveyard_str) != std::string::npos) { importances += " $ graveyard"; } else if (DAG->is_implicit_complement(entity)) { importances += " $ implicit complement"; From e41d2ee250560c9ccbab79fe5d9cf372e9315633 Mon Sep 17 00:00:00 2001 From: Kalin Kiesling Date: Fri, 27 Mar 2020 16:16:45 -0500 Subject: [PATCH 4/6] news file --- news/PR-0665.rst | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 news/PR-0665.rst diff --git a/news/PR-0665.rst b/news/PR-0665.rst new file mode 100644 index 0000000000..71c4684840 --- /dev/null +++ b/news/PR-0665.rst @@ -0,0 +1,16 @@ +**Added:** None + +**Changed:** None +- Applied changes from PullRequest-Agent to MCNP related files: + - using std::err for errors + - update to C++11 standards for converting ints/doubles to strings + - removed unnecessary comments + - moved Graveyard and Vacuum strings to variables + +**Deprecated:** None + +**Removed:** None + +**Fixed:** None + +**Security:** None From dc2e6c2f8dc80b9c6f6726af464ca9bd02f782ec Mon Sep 17 00:00:00 2001 From: Kalin Kiesling Date: Mon, 30 Mar 2020 21:42:24 -0500 Subject: [PATCH 5/6] using std::to_string for ints --- src/mcnp/mcnp_funcs.cpp | 13 ++----------- src/mcnp/mcnp_funcs.h | 3 --- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/src/mcnp/mcnp_funcs.cpp b/src/mcnp/mcnp_funcs.cpp index 2196367434..88feed27f8 100644 --- a/src/mcnp/mcnp_funcs.cpp +++ b/src/mcnp/mcnp_funcs.cpp @@ -230,7 +230,7 @@ void write_cell_cards(std::ostringstream& lcadfile, const char* mcnp_version_maj pyne::Material material = workflow_data->material_library[mat_name]; int matnumber = material.metadata["mat_number"].asInt(); - mat_num = _to_string(matnumber); + mat_num = std::to_string(matnumber); density = "-" + _to_string(material.density); } else { mat_num = "0"; @@ -310,7 +310,7 @@ void write_surface_cards(std::ostringstream& lcadfile) { surface_property = "+"; else surface_property = ""; - lcadfile << surface_property << _to_string(surfid) << std::endl; + lcadfile << surface_property << std::to_string(surfid) << std::endl; } return; } @@ -790,15 +790,6 @@ void dagmc_teardown_() { delete DAG; } -// these functions should be replaced when we adopt C++11 -// int to string -std::string _to_string(int var) { - std::ostringstream outstr; - outstr << var; - std::string ret_string = outstr.str(); - return ret_string; -} - // double to string std::string _to_string(double var) { std::ostringstream outstr; diff --git a/src/mcnp/mcnp_funcs.h b/src/mcnp/mcnp_funcs.h index 09a2bf1d8c..bc79f824b8 100644 --- a/src/mcnp/mcnp_funcs.h +++ b/src/mcnp/mcnp_funcs.h @@ -147,9 +147,6 @@ void write_surface_cards(std::ostringstream& lcad_string); void write_material_data(std::ostringstream& lcad_string); void write_tally_data(std::ostringstream& lcad_string); -// until we adopt C++11 - makes life easy -// convenience functions for c++ int to string -std::string _to_string(int val); // convenience functions for c++ double to string std::string _to_string(double val); From 3d79f25b5982358c6fa38a8591961e9f4f3c5753 Mon Sep 17 00:00:00 2001 From: Kalin Kiesling Date: Mon, 30 Mar 2020 21:43:42 -0500 Subject: [PATCH 6/6] more accurate news file --- news/PR-0665.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/news/PR-0665.rst b/news/PR-0665.rst index 71c4684840..3d512ecaf4 100644 --- a/news/PR-0665.rst +++ b/news/PR-0665.rst @@ -3,7 +3,7 @@ **Changed:** None - Applied changes from PullRequest-Agent to MCNP related files: - using std::err for errors - - update to C++11 standards for converting ints/doubles to strings + - update to C++11 standards for converting ints to strings - removed unnecessary comments - moved Graveyard and Vacuum strings to variables