From 7160d8629ac7984cc07f3786aeb041e85d15b4d5 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Wed, 20 Apr 2022 08:46:42 -0500 Subject: [PATCH 01/34] Switching to exact match for vacuum and graveyard checks. --- src/dagmc/dagmcmetadata.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dagmc/dagmcmetadata.cpp b/src/dagmc/dagmcmetadata.cpp index b2753cf2f..a9bad5cbc 100644 --- a/src/dagmc/dagmcmetadata.cpp +++ b/src/dagmc/dagmcmetadata.cpp @@ -209,11 +209,11 @@ void dagmcMetaData::parse_material_data() { // set the material value volume_material_property_data_eh[eh] = grp_name; - + std::cout << "Group name -- " << grp_name << std::endl; bool is_graveyard = - to_lower(grp_name).find(to_lower(graveyard_str)) != std::string::npos; + to_lower(grp_name) == "mat:" + to_lower(graveyard_str); bool is_vacuum = - to_lower(grp_name).find(to_lower(vacuum_str)) != std::string::npos; + to_lower(grp_name) == "mat:" + to_lower(vacuum_str); // not graveyard or vacuum or implicit compliment if (!is_graveyard && !is_vacuum && !DAG->is_implicit_complement(eh)) { @@ -379,7 +379,7 @@ void dagmcMetaData::parse_boundary_data() { exit(EXIT_FAILURE); } // 2d entities have been tagged with the boundary condition property - // ie. both surfaces and its members triangles, + // ie. both surfaces and its member triangles std::string bc_string = to_lower(boundary_assignment[0]); From f2bd3d074f747cfb5b6eb19e4f7ed9f02cd53e18 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Wed, 20 Apr 2022 08:46:56 -0500 Subject: [PATCH 02/34] Removing extra print in uwuw test --- src/uwuw/tests/uwuw_unit_tests.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/uwuw/tests/uwuw_unit_tests.cpp b/src/uwuw/tests/uwuw_unit_tests.cpp index da876e9c9..d45a4c501 100644 --- a/src/uwuw/tests/uwuw_unit_tests.cpp +++ b/src/uwuw/tests/uwuw_unit_tests.cpp @@ -146,7 +146,6 @@ TEST_F(UWUWTest, mat_write) { mat.metadata["mat_number"] = 1; // check openmc material write std::string openmc_rep = mat.openmc(); - std::cout << openmc_rep << std::endl; std::stringstream expected_rep; expected_rep << " \n"; expected_rep << " \n"; From ee6c0d8cfe3984b4d43f50ed613aff3abaa11832 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Wed, 20 Apr 2022 14:14:31 -0500 Subject: [PATCH 03/34] Using new member variables for comprision and assignment --- src/dagmc/dagmcmetadata.cpp | 8 ++++---- src/dagmc/dagmcmetadata.hpp | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/dagmc/dagmcmetadata.cpp b/src/dagmc/dagmcmetadata.cpp index a9bad5cbc..581d14e76 100644 --- a/src/dagmc/dagmcmetadata.cpp +++ b/src/dagmc/dagmcmetadata.cpp @@ -211,9 +211,9 @@ void dagmcMetaData::parse_material_data() { volume_material_property_data_eh[eh] = grp_name; std::cout << "Group name -- " << grp_name << std::endl; bool is_graveyard = - to_lower(grp_name) == "mat:" + to_lower(graveyard_str); + to_lower(grp_name) == to_lower(graveyard_mat_str); bool is_vacuum = - to_lower(grp_name) == "mat:" + to_lower(vacuum_str); + to_lower(grp_name) == to_lower(vacuum_mat_str); // not graveyard or vacuum or implicit compliment if (!is_graveyard && !is_vacuum && !DAG->is_implicit_complement(eh)) { @@ -221,12 +221,12 @@ void dagmcMetaData::parse_material_data() { } // found graveyard else if (is_graveyard) { - volume_material_property_data_eh[eh] = "mat:Graveyard"; + volume_material_property_data_eh[eh] = graveyard_mat_str; volume_material_data_eh[eh] = graveyard_str; } // vacuum else if (is_vacuum) { - volume_material_property_data_eh[eh] = "mat:Vacuum"; + volume_material_property_data_eh[eh] = vacuum_mat_str; volume_material_data_eh[eh] = vacuum_str; } // implicit complement diff --git a/src/dagmc/dagmcmetadata.hpp b/src/dagmc/dagmcmetadata.hpp index 90de31cf4..bd05a8770 100644 --- a/src/dagmc/dagmcmetadata.hpp +++ b/src/dagmc/dagmcmetadata.hpp @@ -353,6 +353,8 @@ class dagmcMetaData { // Some constant keyword values const std::string graveyard_str{"Graveyard"}; const std::string vacuum_str{"Vacuum"}; + const std::string vacuum_mat_str{"mat:Vacuum"}; + const std::string graveyard_mat_str{"mat:Graveyard"}; const std::string reflecting_str{"Reflecting"}; const std::string white_str{"White"}; const std::string periodic_str{"Periodic"}; From 338bdcce34d23d6f49b8310b17559c2b2f46a22b Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Wed, 20 Apr 2022 15:00:37 -0500 Subject: [PATCH 04/34] Adding accessors for material strings and using in mcnp_funcs --- src/dagmc/dagmcmetadata.cpp | 28 ++++++++++++++-------------- src/dagmc/dagmcmetadata.hpp | 9 +++++++++ src/mcnp/mcnp_funcs.cpp | 21 +++++++++------------ 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/src/dagmc/dagmcmetadata.cpp b/src/dagmc/dagmcmetadata.cpp index 581d14e76..b23f5fc26 100644 --- a/src/dagmc/dagmcmetadata.cpp +++ b/src/dagmc/dagmcmetadata.cpp @@ -211,9 +211,9 @@ void dagmcMetaData::parse_material_data() { volume_material_property_data_eh[eh] = grp_name; std::cout << "Group name -- " << grp_name << std::endl; bool is_graveyard = - to_lower(grp_name) == to_lower(graveyard_mat_str); + to_lower(grp_name) == to_lower(graveyard_mat_str()); bool is_vacuum = - to_lower(grp_name) == to_lower(vacuum_mat_str); + to_lower(grp_name) == to_lower(vacuum_mat_str()); // not graveyard or vacuum or implicit compliment if (!is_graveyard && !is_vacuum && !DAG->is_implicit_complement(eh)) { @@ -221,13 +221,13 @@ void dagmcMetaData::parse_material_data() { } // found graveyard else if (is_graveyard) { - volume_material_property_data_eh[eh] = graveyard_mat_str; - volume_material_data_eh[eh] = graveyard_str; + volume_material_property_data_eh[eh] = graveyard_mat_str(); + volume_material_data_eh[eh] = graveyard_str(); } // vacuum else if (is_vacuum) { - volume_material_property_data_eh[eh] = vacuum_mat_str; - volume_material_data_eh[eh] = vacuum_str; + volume_material_property_data_eh[eh] = vacuum_mat_str(); + volume_material_data_eh[eh] = vacuum_str(); } // implicit complement else if (DAG->is_implicit_complement(eh)) { @@ -383,14 +383,14 @@ void dagmcMetaData::parse_boundary_data() { std::string bc_string = to_lower(boundary_assignment[0]); - if (bc_string.find(to_lower(reflecting_str)) != std::string::npos) - surface_boundary_data_eh[eh] = reflecting_str; - if (bc_string.find(to_lower(white_str)) != std::string::npos) - surface_boundary_data_eh[eh] = white_str; - if (bc_string.find(to_lower(periodic_str)) != std::string::npos) - surface_boundary_data_eh[eh] = periodic_str; - if (bc_string.find(to_lower(vacuum_str)) != std::string::npos) - surface_boundary_data_eh[eh] = vacuum_str; + if (bc_string.find(to_lower(reflecting_str())) != std::string::npos) + surface_boundary_data_eh[eh] = reflecting_str(); + if (bc_string.find(to_lower(white_str())) != std::string::npos) + surface_boundary_data_eh[eh] = white_str(); + if (bc_string.find(to_lower(periodic_str())) != std::string::npos) + surface_boundary_data_eh[eh] = periodic_str(); + if (bc_string.find(to_lower(vacuum_str())) != std::string::npos) + surface_boundary_data_eh[eh] = vacuum_str(); } } diff --git a/src/dagmc/dagmcmetadata.hpp b/src/dagmc/dagmcmetadata.hpp index bd05a8770..a30404b3e 100644 --- a/src/dagmc/dagmcmetadata.hpp +++ b/src/dagmc/dagmcmetadata.hpp @@ -316,6 +316,15 @@ class dagmcMetaData { */ std::map> importance_map; + // Some constant keyword values + const std::string& graveyard_str() const { return graveyard_str_; } + const std::string& vacuum_str() const { return vacuum_str_; } + const std::string& vacuum_mat_str() const { return vacuum_mat_str_; } + const std::string& graveyard_mat_str() const { return graveyard_mat_str_; } + const std::string& reflecting_str() const { return reflecting_str_; } + const std::string& white_str() const { return white_str_; } + const std::string& periodic_str() const { return periodic_str_; } + // private member variables private: /** diff --git a/src/mcnp/mcnp_funcs.cpp b/src/mcnp/mcnp_funcs.cpp index 579b5a7f8..56eb131fb 100644 --- a/src/mcnp/mcnp_funcs.cpp +++ b/src/mcnp/mcnp_funcs.cpp @@ -46,9 +46,6 @@ 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 int* parallel_file_mode, // parallel read mode @@ -203,8 +200,8 @@ void write_cell_cards(std::ostringstream& lcadfile, // 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_str) == std::string::npos && - mat_num.find(vacuum_str) == std::string::npos) { + if (mat_num != DMD->graveyard_mat_str() && + mat_num != DMD->vacuum_mat_str()) { if (!DMD->try_to_make_int(mat_num)) { std::cerr << "Failed to cast material number to an integer" << std::endl; @@ -220,15 +217,15 @@ void write_cell_cards(std::ostringstream& lcadfile, density = DMD->volume_density_data_eh[entity]; // if we have a vacuum problem - if (mat_num == graveyard_str || mat_num == vacuum_str) { + if (mat_num == DMD->graveyard_str() || mat_num == DMD->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_str) == std::string::npos && - mat_name.find(graveyard_str) == std::string::npos) { + if (mat_name != DMD->vacuum_mat_str() && + mat_name != DMD->graveyard_mat_str()) { if (workflow_data->material_library.count(mat_name) == 0) { std::cerr << "Material with name " << mat_name << " not found " << std::endl; @@ -269,10 +266,10 @@ void write_cell_cards(std::ostringstream& lcadfile, } double imp = 1.0; // if we find graveyard always have importance 0.0 - if (mat_name.find(graveyard_str) != std::string::npos) { + if (mat_name == DMD->graveyard_mat_str()) { imp = 0.0; // no splitting can happenin vacuum set to 1 - } else if (mat_name.find(vacuum_str) != std::string::npos) { + } else if (mat_name == DMD->vacuum_mat_str()) { imp = 1.0; // otherwise as the map says } else { @@ -282,7 +279,7 @@ void write_cell_cards(std::ostringstream& lcadfile, } // its possible no importances were assigned if (set.size() == 0) { - if (mat_name.find(graveyard_str) == std::string::npos) { + if (mat_name != DMD->graveyard_mat_str()) { importances = "imp:n=1"; } else { importances = "imp:n=0"; @@ -290,7 +287,7 @@ void write_cell_cards(std::ostringstream& lcadfile, } // add descriptive comments for special volumes - if (mat_name.find(graveyard_str) != std::string::npos) { + if (mat_name == DMD->graveyard_mat_str()) { importances += " $ graveyard"; } else if (DAG->is_implicit_complement(entity)) { importances += " $ implicit complement"; From 2737338232d4a2aba9de07c786c7f3b3d794eae9 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Wed, 11 Dec 2024 15:30:20 +0100 Subject: [PATCH 05/34] turning cout into a logged message --- src/dagmc/dagmcmetadata.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dagmc/dagmcmetadata.cpp b/src/dagmc/dagmcmetadata.cpp index b23f5fc26..bd5bb7acf 100644 --- a/src/dagmc/dagmcmetadata.cpp +++ b/src/dagmc/dagmcmetadata.cpp @@ -209,7 +209,7 @@ void dagmcMetaData::parse_material_data() { // set the material value volume_material_property_data_eh[eh] = grp_name; - std::cout << "Group name -- " << grp_name << std::endl; + logger.message("Group name -- " + grp_name); bool is_graveyard = to_lower(grp_name) == to_lower(graveyard_mat_str()); bool is_vacuum = From c8b43cd6ad88294a5342d0bd8e0a57f5ed2b8706 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Wed, 11 Dec 2024 15:34:11 +0100 Subject: [PATCH 06/34] Add changelog --- doc/CHANGELOG.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/CHANGELOG.rst b/doc/CHANGELOG.rst index 71e4daae4..2480d32ef 100644 --- a/doc/CHANGELOG.rst +++ b/doc/CHANGELOG.rst @@ -26,6 +26,7 @@ v3.2.4 * Updated documentation to build dependencies (#963) * Pause support for Windows (#966) * Localize invocation of git submodule for PyNE (#968) + * Fixed the name of the Graveyard and the Vaccuum to mat:Graveyard and mat:Vacuum (and lower case) (#971) v3.2.3 ==================== From af403338a9da74e679c212e49bd95a946030b072 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Wed, 11 Dec 2024 17:38:36 +0100 Subject: [PATCH 07/34] bug fix --- src/dagmc/dagmcmetadata.cpp | 2 +- src/dagmc/dagmcmetadata.hpp | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/dagmc/dagmcmetadata.cpp b/src/dagmc/dagmcmetadata.cpp index bd5bb7acf..4d13cbd97 100644 --- a/src/dagmc/dagmcmetadata.cpp +++ b/src/dagmc/dagmcmetadata.cpp @@ -234,7 +234,7 @@ void dagmcMetaData::parse_material_data() { if (implicit_complement_material == "") { logger.message("Implicit Complement assumed to be Vacuum"); volume_material_property_data_eh[eh] = "mat:Vacuum"; - volume_material_data_eh[eh] = vacuum_str; + volume_material_data_eh[eh] = vacuum_str(); } else { volume_material_property_data_eh[eh] = "mat:" + implicit_complement_material; diff --git a/src/dagmc/dagmcmetadata.hpp b/src/dagmc/dagmcmetadata.hpp index a30404b3e..d3a940f3f 100644 --- a/src/dagmc/dagmcmetadata.hpp +++ b/src/dagmc/dagmcmetadata.hpp @@ -360,13 +360,13 @@ class dagmcMetaData { std::map keyword_synonyms; // Some constant keyword values - const std::string graveyard_str{"Graveyard"}; - const std::string vacuum_str{"Vacuum"}; - const std::string vacuum_mat_str{"mat:Vacuum"}; - const std::string graveyard_mat_str{"mat:Graveyard"}; - const std::string reflecting_str{"Reflecting"}; - const std::string white_str{"White"}; - const std::string periodic_str{"Periodic"}; + const std::string graveyard_str_{"Graveyard"}; + const std::string vacuum_str_{"Vacuum"}; + const std::string vacuum_mat_str_{"mat:Vacuum"}; + const std::string graveyard_mat_str_{"mat:Graveyard"}; + const std::string reflecting_str_{"Reflecting"}; + const std::string white_str_{"White"}; + const std::string periodic_str_{"Periodic"}; DagMC_Logger logger; }; From f9da36755ee459f98aaf1874610d2a1c223d6baf Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Wed, 11 Dec 2024 17:42:25 +0100 Subject: [PATCH 08/34] formating --- src/dagmc/dagmcmetadata.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/dagmc/dagmcmetadata.cpp b/src/dagmc/dagmcmetadata.cpp index 4d13cbd97..081328d60 100644 --- a/src/dagmc/dagmcmetadata.cpp +++ b/src/dagmc/dagmcmetadata.cpp @@ -210,10 +210,8 @@ void dagmcMetaData::parse_material_data() { // set the material value volume_material_property_data_eh[eh] = grp_name; logger.message("Group name -- " + grp_name); - bool is_graveyard = - to_lower(grp_name) == to_lower(graveyard_mat_str()); - bool is_vacuum = - to_lower(grp_name) == to_lower(vacuum_mat_str()); + bool is_graveyard = to_lower(grp_name) == to_lower(graveyard_mat_str()); + bool is_vacuum = to_lower(grp_name) == to_lower(vacuum_mat_str()); // not graveyard or vacuum or implicit compliment if (!is_graveyard && !is_vacuum && !DAG->is_implicit_complement(eh)) { From c717d7643540ac2070c62e4cfaa4c223ee483258 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Wed, 11 Dec 2024 17:55:13 +0100 Subject: [PATCH 09/34] fixing mcnp bug --- src/mcnp/mcnp_funcs.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mcnp/mcnp_funcs.cpp b/src/mcnp/mcnp_funcs.cpp index 56eb131fb..49df23223 100644 --- a/src/mcnp/mcnp_funcs.cpp +++ b/src/mcnp/mcnp_funcs.cpp @@ -200,8 +200,8 @@ void write_cell_cards(std::ostringstream& lcadfile, // 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 != DMD->graveyard_mat_str() && - mat_num != DMD->vacuum_mat_str()) { + if (to_lower(mat_num) != to_lower(DMD->graveyard_mat_str()) && + to_lower(mat_num) != to_lower(DMD->vacuum_mat_str())) { if (!DMD->try_to_make_int(mat_num)) { std::cerr << "Failed to cast material number to an integer" << std::endl; From 816fbd6147ba3c3bb37863b776f9ee39aa8eaa19 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Wed, 11 Dec 2024 18:00:08 +0100 Subject: [PATCH 10/34] fixing mcnp bug --- src/mcnp/mcnp_funcs.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mcnp/mcnp_funcs.cpp b/src/mcnp/mcnp_funcs.cpp index 49df23223..f4af323df 100644 --- a/src/mcnp/mcnp_funcs.cpp +++ b/src/mcnp/mcnp_funcs.cpp @@ -200,8 +200,8 @@ void write_cell_cards(std::ostringstream& lcadfile, // that material numbers are assigned mat_num = DMD->volume_material_data_eh[entity]; // if we cant make an int from the mat_num - if (to_lower(mat_num) != to_lower(DMD->graveyard_mat_str()) && - to_lower(mat_num) != to_lower(DMD->vacuum_mat_str())) { + if (dagmcMetaData::to_lower(mat_num) != dagmcMetaData::to_lower(DMD->graveyard_mat_str()) && + dagmcMetaData::to_lower(mat_num) != dagmcMetaData::to_lower(DMD->vacuum_mat_str())) { if (!DMD->try_to_make_int(mat_num)) { std::cerr << "Failed to cast material number to an integer" << std::endl; From 9372bbe386d3fff7a2f0f4b3eff8b848d544d9ce Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Wed, 11 Dec 2024 18:04:22 +0100 Subject: [PATCH 11/34] fixing mcnp bug --- src/mcnp/mcnp_funcs.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mcnp/mcnp_funcs.cpp b/src/mcnp/mcnp_funcs.cpp index f4af323df..0e6900bbb 100644 --- a/src/mcnp/mcnp_funcs.cpp +++ b/src/mcnp/mcnp_funcs.cpp @@ -2,6 +2,8 @@ #include "DagMC.hpp" #include "dagmcmetadata.hpp" +#include "util.hpp" + using moab::DagMC; #include @@ -200,8 +202,8 @@ void write_cell_cards(std::ostringstream& lcadfile, // that material numbers are assigned mat_num = DMD->volume_material_data_eh[entity]; // if we cant make an int from the mat_num - if (dagmcMetaData::to_lower(mat_num) != dagmcMetaData::to_lower(DMD->graveyard_mat_str()) && - dagmcMetaData::to_lower(mat_num) != dagmcMetaData::to_lower(DMD->vacuum_mat_str())) { + if (dagmc_utils::lowercase_str(mat_num) != dagmc_utils::lowercase_str(DMD->graveyard_mat_str()) && + dagmc_utils::lowercase_str(mat_num) != dagmc_utils::lowercase_str(DMD->vacuum_mat_str())) { if (!DMD->try_to_make_int(mat_num)) { std::cerr << "Failed to cast material number to an integer" << std::endl; From d20fa0d9283daa93927fea90f8201f6b77417b03 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Wed, 11 Dec 2024 18:06:45 +0100 Subject: [PATCH 12/34] dagmc_util not dagmc_utils --- src/mcnp/mcnp_funcs.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mcnp/mcnp_funcs.cpp b/src/mcnp/mcnp_funcs.cpp index 0e6900bbb..2dfcba22b 100644 --- a/src/mcnp/mcnp_funcs.cpp +++ b/src/mcnp/mcnp_funcs.cpp @@ -202,8 +202,8 @@ void write_cell_cards(std::ostringstream& lcadfile, // that material numbers are assigned mat_num = DMD->volume_material_data_eh[entity]; // if we cant make an int from the mat_num - if (dagmc_utils::lowercase_str(mat_num) != dagmc_utils::lowercase_str(DMD->graveyard_mat_str()) && - dagmc_utils::lowercase_str(mat_num) != dagmc_utils::lowercase_str(DMD->vacuum_mat_str())) { + if (dagmc_util::lowercase_str(mat_num) != dagmc_util::lowercase_str(DMD->graveyard_mat_str()) && + dagmc_util::lowercase_str(mat_num) != dagmc_util::lowercase_str(DMD->vacuum_mat_str())) { if (!DMD->try_to_make_int(mat_num)) { std::cerr << "Failed to cast material number to an integer" << std::endl; From 8f3a0c99fb2712dc61b5c7b00f665d55137b0fb6 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Wed, 11 Dec 2024 18:08:01 +0100 Subject: [PATCH 13/34] formating --- src/mcnp/mcnp_funcs.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/mcnp/mcnp_funcs.cpp b/src/mcnp/mcnp_funcs.cpp index 2dfcba22b..4b15a5eba 100644 --- a/src/mcnp/mcnp_funcs.cpp +++ b/src/mcnp/mcnp_funcs.cpp @@ -202,8 +202,13 @@ void write_cell_cards(std::ostringstream& lcadfile, // that material numbers are assigned mat_num = DMD->volume_material_data_eh[entity]; // if we cant make an int from the mat_num - if (dagmc_util::lowercase_str(mat_num) != dagmc_util::lowercase_str(DMD->graveyard_mat_str()) && - dagmc_util::lowercase_str(mat_num) != dagmc_util::lowercase_str(DMD->vacuum_mat_str())) { + if (dagmc_util::lowercase_str(mat_num) != + dagmc_util::lowercase_str(DMD->graveyard_mat_str()) && + dagmc_util::lowercase_str(mat_num) != + dagmc_util::lowercase_str(DMD->vacuum_mat_str())) { + if (!DMD->try_to_make_int(mat_num)) { + std::cerr << "Failed to cast material number to an integer" + << std::endl; if (!DMD->try_to_make_int(mat_num)) { std::cerr << "Failed to cast material number to an integer" << std::endl; From 292cb9c6709e82a5044a631aba82f6bbcb40f320 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Wed, 11 Dec 2024 18:09:45 +0100 Subject: [PATCH 14/34] using DMD to_lower --- src/mcnp/mcnp_funcs.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/mcnp/mcnp_funcs.cpp b/src/mcnp/mcnp_funcs.cpp index 4b15a5eba..3a6393aa1 100644 --- a/src/mcnp/mcnp_funcs.cpp +++ b/src/mcnp/mcnp_funcs.cpp @@ -1,7 +1,6 @@ #include "mcnp_funcs.h" #include "DagMC.hpp" -#include "dagmcmetadata.hpp" #include "util.hpp" using moab::DagMC; @@ -202,10 +201,10 @@ void write_cell_cards(std::ostringstream& lcadfile, // that material numbers are assigned mat_num = DMD->volume_material_data_eh[entity]; // if we cant make an int from the mat_num - if (dagmc_util::lowercase_str(mat_num) != - dagmc_util::lowercase_str(DMD->graveyard_mat_str()) && - dagmc_util::lowercase_str(mat_num) != - dagmc_util::lowercase_str(DMD->vacuum_mat_str())) { + if (DMD->to_lower(mat_num) != + DMD->to_lower(DMD->graveyard_mat_str()) && + DMD->to_lower(mat_num) != + DMD->to_lower(DMD->vacuum_mat_str())) { if (!DMD->try_to_make_int(mat_num)) { std::cerr << "Failed to cast material number to an integer" << std::endl; From 29bee83da7462a5e3297be10308c251ccdbe791a Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Wed, 11 Dec 2024 18:11:25 +0100 Subject: [PATCH 15/34] fix --- src/mcnp/mcnp_funcs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mcnp/mcnp_funcs.cpp b/src/mcnp/mcnp_funcs.cpp index 3a6393aa1..8035b9158 100644 --- a/src/mcnp/mcnp_funcs.cpp +++ b/src/mcnp/mcnp_funcs.cpp @@ -204,7 +204,7 @@ void write_cell_cards(std::ostringstream& lcadfile, if (DMD->to_lower(mat_num) != DMD->to_lower(DMD->graveyard_mat_str()) && DMD->to_lower(mat_num) != - DMD->to_lower(DMD->vacuum_mat_str())) { + DMD->to_lower(DMD->vacuum_mat_str()) { if (!DMD->try_to_make_int(mat_num)) { std::cerr << "Failed to cast material number to an integer" << std::endl; From 4f73e41caa451e5e373f3cd5c911b8e1ad064036 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Wed, 11 Dec 2024 18:14:57 +0100 Subject: [PATCH 16/34] fix --- src/mcnp/mcnp_funcs.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/mcnp/mcnp_funcs.cpp b/src/mcnp/mcnp_funcs.cpp index 8035b9158..ee8171faf 100644 --- a/src/mcnp/mcnp_funcs.cpp +++ b/src/mcnp/mcnp_funcs.cpp @@ -201,10 +201,8 @@ void write_cell_cards(std::ostringstream& lcadfile, // that material numbers are assigned mat_num = DMD->volume_material_data_eh[entity]; // if we cant make an int from the mat_num - if (DMD->to_lower(mat_num) != - DMD->to_lower(DMD->graveyard_mat_str()) && - DMD->to_lower(mat_num) != - DMD->to_lower(DMD->vacuum_mat_str()) { + if (DMD->to_lower(mat_num) != DMD->to_lower(DMD->graveyard_mat_str()) && + DMD->to_lower(mat_num) != DMD->to_lower(DMD->vacuum_mat_str())) { if (!DMD->try_to_make_int(mat_num)) { std::cerr << "Failed to cast material number to an integer" << std::endl; From 10211b02a5cc54fbe9b285edc5c4bd9102eb7e0d Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Wed, 11 Dec 2024 18:17:11 +0100 Subject: [PATCH 17/34] fix typo --- src/mcnp/mcnp_funcs.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/mcnp/mcnp_funcs.cpp b/src/mcnp/mcnp_funcs.cpp index ee8171faf..ec2ca19a7 100644 --- a/src/mcnp/mcnp_funcs.cpp +++ b/src/mcnp/mcnp_funcs.cpp @@ -201,11 +201,8 @@ void write_cell_cards(std::ostringstream& lcadfile, // that material numbers are assigned mat_num = DMD->volume_material_data_eh[entity]; // if we cant make an int from the mat_num - if (DMD->to_lower(mat_num) != DMD->to_lower(DMD->graveyard_mat_str()) && + if (DMD->to_lower(mat_num) != DMD->to_lower(DMD->graveyard_mat_str()) && DMD->to_lower(mat_num) != DMD->to_lower(DMD->vacuum_mat_str())) { - if (!DMD->try_to_make_int(mat_num)) { - std::cerr << "Failed to cast material number to an integer" - << std::endl; if (!DMD->try_to_make_int(mat_num)) { std::cerr << "Failed to cast material number to an integer" << std::endl; From a031643f2abb5f3075658bf33a713c37b6f8e4e0 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Wed, 11 Dec 2024 18:18:56 +0100 Subject: [PATCH 18/34] propagating change --- src/mcnp/mcnp_funcs.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mcnp/mcnp_funcs.cpp b/src/mcnp/mcnp_funcs.cpp index ec2ca19a7..27d4ca993 100644 --- a/src/mcnp/mcnp_funcs.cpp +++ b/src/mcnp/mcnp_funcs.cpp @@ -225,8 +225,8 @@ void write_cell_cards(std::ostringstream& lcadfile, } else { std::string mat_name = DMD->volume_material_property_data_eh[entity]; // if we not vacuum or graveyard - if (mat_name != DMD->vacuum_mat_str() && - mat_name != DMD->graveyard_mat_str()) { + if (DMD->to_lower(mat_num) != DMD->to_lower(DMD->graveyard_mat_str()) && + DMD->to_lower(mat_num) != DMD->to_lower(DMD->vacuum_mat_str())) { if (workflow_data->material_library.count(mat_name) == 0) { std::cerr << "Material with name " << mat_name << " not found " << std::endl; @@ -267,10 +267,10 @@ void write_cell_cards(std::ostringstream& lcadfile, } double imp = 1.0; // if we find graveyard always have importance 0.0 - if (mat_name == DMD->graveyard_mat_str()) { + if (DMD->to_lower(mat_num) == DMD->to_lower(DMD->graveyard_mat_str()) { imp = 0.0; // no splitting can happenin vacuum set to 1 - } else if (mat_name == DMD->vacuum_mat_str()) { + } else if (DMD->to_lower(mat_num) != DMD->to_lower(DMD->vacuum_mat_str())) { imp = 1.0; // otherwise as the map says } else { From 32de4d819131730eda4733719bbb84e638d96f41 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Wed, 11 Dec 2024 18:21:41 +0100 Subject: [PATCH 19/34] propagating change --- src/mcnp/mcnp_funcs.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mcnp/mcnp_funcs.cpp b/src/mcnp/mcnp_funcs.cpp index 27d4ca993..85b08626c 100644 --- a/src/mcnp/mcnp_funcs.cpp +++ b/src/mcnp/mcnp_funcs.cpp @@ -267,10 +267,10 @@ void write_cell_cards(std::ostringstream& lcadfile, } double imp = 1.0; // if we find graveyard always have importance 0.0 - if (DMD->to_lower(mat_num) == DMD->to_lower(DMD->graveyard_mat_str()) { + if (DMD->to_lower(mat_nanme) == DMD->to_lower(DMD->graveyard_mat_str()) { imp = 0.0; // no splitting can happenin vacuum set to 1 - } else if (DMD->to_lower(mat_num) != DMD->to_lower(DMD->vacuum_mat_str())) { + } else if (DMD->to_lower(mat_nanme) == DMD->to_lower(DMD->vacuum_mat_str())) { imp = 1.0; // otherwise as the map says } else { @@ -280,7 +280,7 @@ void write_cell_cards(std::ostringstream& lcadfile, } // its possible no importances were assigned if (set.size() == 0) { - if (mat_name != DMD->graveyard_mat_str()) { + if (DMD->to_lower(mat_nanme) != DMD->to_lower(DMD->graveyard_mat_str()) { importances = "imp:n=1"; } else { importances = "imp:n=0"; @@ -288,7 +288,7 @@ void write_cell_cards(std::ostringstream& lcadfile, } // add descriptive comments for special volumes - if (mat_name == DMD->graveyard_mat_str()) { + if (DMD->to_lower(mat_nanme) == DMD->to_lower(DMD->graveyard_mat_str()) { importances += " $ graveyard"; } else if (DAG->is_implicit_complement(entity)) { importances += " $ implicit complement"; From 0b356d1f508c6452c64a29a408e6226905dc3704 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Wed, 11 Dec 2024 18:23:12 +0100 Subject: [PATCH 20/34] removed the wrong import --- src/mcnp/mcnp_funcs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mcnp/mcnp_funcs.cpp b/src/mcnp/mcnp_funcs.cpp index 85b08626c..1001c6e78 100644 --- a/src/mcnp/mcnp_funcs.cpp +++ b/src/mcnp/mcnp_funcs.cpp @@ -1,7 +1,7 @@ #include "mcnp_funcs.h" #include "DagMC.hpp" -#include "util.hpp" +#include "dagmcmetadata.hpp" using moab::DagMC; From 866687019606b1c7d3b9e96a62bbc804839e5b1f Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Wed, 11 Dec 2024 20:58:53 +0100 Subject: [PATCH 21/34] moving to_lower in utils --- src/dagmc/dagmcmetadata.cpp | 19 +++++++------------ src/dagmc/dagmcmetadata.hpp | 2 -- src/dagmc/util.hpp | 5 +++++ src/mcnp/mcnp_funcs.cpp | 16 ++++++++-------- 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/dagmc/dagmcmetadata.cpp b/src/dagmc/dagmcmetadata.cpp index 081328d60..e46489bc7 100644 --- a/src/dagmc/dagmcmetadata.cpp +++ b/src/dagmc/dagmcmetadata.cpp @@ -210,8 +210,8 @@ void dagmcMetaData::parse_material_data() { // set the material value volume_material_property_data_eh[eh] = grp_name; logger.message("Group name -- " + grp_name); - bool is_graveyard = to_lower(grp_name) == to_lower(graveyard_mat_str()); - bool is_vacuum = to_lower(grp_name) == to_lower(vacuum_mat_str()); + bool is_graveyard = dagmc_util::to_lower(grp_name) == dagmc_util::to_lower(graveyard_mat_str()); + bool is_vacuum = dagmc_util::to_lower(grp_name) == dagmc_util::to_lower(vacuum_mat_str()); // not graveyard or vacuum or implicit compliment if (!is_graveyard && !is_vacuum && !DAG->is_implicit_complement(eh)) { @@ -345,11 +345,6 @@ void dagmcMetaData::parse_tally_volume_data() { } } -std::string dagmcMetaData::to_lower(std::string input) { - dagmc_util::lowercase_str(input); - return input; -} - // parse the boundary data void dagmcMetaData::parse_boundary_data() { auto boundary_assignments = get_property_assignments("boundary", 2, ":"); @@ -379,15 +374,15 @@ void dagmcMetaData::parse_boundary_data() { // 2d entities have been tagged with the boundary condition property // ie. both surfaces and its member triangles - std::string bc_string = to_lower(boundary_assignment[0]); + std::string bc_string = dagmc_util::to_lower(boundary_assignment[0]); - if (bc_string.find(to_lower(reflecting_str())) != std::string::npos) + if (bc_string.find(dagmc_util::to_lower(reflecting_str())) != std::string::npos) surface_boundary_data_eh[eh] = reflecting_str(); - if (bc_string.find(to_lower(white_str())) != std::string::npos) + if (bc_string.find(dagmc_util::to_lower(white_str())) != std::string::npos) surface_boundary_data_eh[eh] = white_str(); - if (bc_string.find(to_lower(periodic_str())) != std::string::npos) + if (bc_string.find(dagmc_util::to_lower(periodic_str())) != std::string::npos) surface_boundary_data_eh[eh] = periodic_str(); - if (bc_string.find(to_lower(vacuum_str())) != std::string::npos) + if (bc_string.find(dagmc_util::to_lower(vacuum_str())) != std::string::npos) surface_boundary_data_eh[eh] = vacuum_str(); } } diff --git a/src/dagmc/dagmcmetadata.hpp b/src/dagmc/dagmcmetadata.hpp index d3a940f3f..405c060af 100644 --- a/src/dagmc/dagmcmetadata.hpp +++ b/src/dagmc/dagmcmetadata.hpp @@ -250,8 +250,6 @@ class dagmcMetaData { */ std::set set_remove_rich(std::set properties_set); - std::string to_lower(const std::string input); - // public member variables public: /** diff --git a/src/dagmc/util.hpp b/src/dagmc/util.hpp index 9a8b64c0e..639f7c542 100644 --- a/src/dagmc/util.hpp +++ b/src/dagmc/util.hpp @@ -10,5 +10,10 @@ inline void lowercase_str(std::string& input) { [](unsigned char c) { return std::tolower(c); }); } +inline std::string to_lower(std::string input) { + lowercase_str(input); + return input; +} + } // namespace dagmc_util #endif \ No newline at end of file diff --git a/src/mcnp/mcnp_funcs.cpp b/src/mcnp/mcnp_funcs.cpp index 1001c6e78..c80f7707b 100644 --- a/src/mcnp/mcnp_funcs.cpp +++ b/src/mcnp/mcnp_funcs.cpp @@ -201,8 +201,8 @@ void write_cell_cards(std::ostringstream& lcadfile, // that material numbers are assigned mat_num = DMD->volume_material_data_eh[entity]; // if we cant make an int from the mat_num - if (DMD->to_lower(mat_num) != DMD->to_lower(DMD->graveyard_mat_str()) && - DMD->to_lower(mat_num) != DMD->to_lower(DMD->vacuum_mat_str())) { + if (dagmc_util::to_lower(mat_num) != dagmc_util::to_lower(DMD->graveyard_mat_str()) && + dagmc_util::to_lower(mat_num) != dagmc_util::to_lower(DMD->vacuum_mat_str())) { if (!DMD->try_to_make_int(mat_num)) { std::cerr << "Failed to cast material number to an integer" << std::endl; @@ -225,8 +225,8 @@ void write_cell_cards(std::ostringstream& lcadfile, } else { std::string mat_name = DMD->volume_material_property_data_eh[entity]; // if we not vacuum or graveyard - if (DMD->to_lower(mat_num) != DMD->to_lower(DMD->graveyard_mat_str()) && - DMD->to_lower(mat_num) != DMD->to_lower(DMD->vacuum_mat_str())) { + if (dagmc_util::to_lower(mat_num) != dagmc_util::to_lower(DMD->graveyard_mat_str()) && + dagmc_util::to_lower(mat_num) != dagmc_util::to_lower(DMD->vacuum_mat_str())) { if (workflow_data->material_library.count(mat_name) == 0) { std::cerr << "Material with name " << mat_name << " not found " << std::endl; @@ -267,10 +267,10 @@ void write_cell_cards(std::ostringstream& lcadfile, } double imp = 1.0; // if we find graveyard always have importance 0.0 - if (DMD->to_lower(mat_nanme) == DMD->to_lower(DMD->graveyard_mat_str()) { + if (dagmc_util::to_lower(mat_nanme) == dagmc_util::to_lower(DMD->graveyard_mat_str()) { imp = 0.0; // no splitting can happenin vacuum set to 1 - } else if (DMD->to_lower(mat_nanme) == DMD->to_lower(DMD->vacuum_mat_str())) { + } else if (dagmc_util::to_lower(mat_nanme) == dagmc_util::to_lower(DMD->vacuum_mat_str())) { imp = 1.0; // otherwise as the map says } else { @@ -280,7 +280,7 @@ void write_cell_cards(std::ostringstream& lcadfile, } // its possible no importances were assigned if (set.size() == 0) { - if (DMD->to_lower(mat_nanme) != DMD->to_lower(DMD->graveyard_mat_str()) { + if (dagmc_util::to_lower(mat_nanme) != dagmc_util::to_lower(DMD->graveyard_mat_str()) { importances = "imp:n=1"; } else { importances = "imp:n=0"; @@ -288,7 +288,7 @@ void write_cell_cards(std::ostringstream& lcadfile, } // add descriptive comments for special volumes - if (DMD->to_lower(mat_nanme) == DMD->to_lower(DMD->graveyard_mat_str()) { + if (dagmc_util::to_lower(mat_nanme) == dagmc_util::to_lower(DMD->graveyard_mat_str()) { importances += " $ graveyard"; } else if (DAG->is_implicit_complement(entity)) { importances += " $ implicit complement"; From d205455c5c05573d745fa88ab5bf2e6f490a2b01 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Wed, 11 Dec 2024 21:05:10 +0100 Subject: [PATCH 22/34] missing import and formating --- src/dagmc/dagmcmetadata.cpp | 18 ++++++++++++------ src/mcnp/mcnp_funcs.cpp | 13 +++++++++---- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/dagmc/dagmcmetadata.cpp b/src/dagmc/dagmcmetadata.cpp index e46489bc7..4ac85601b 100644 --- a/src/dagmc/dagmcmetadata.cpp +++ b/src/dagmc/dagmcmetadata.cpp @@ -210,8 +210,10 @@ void dagmcMetaData::parse_material_data() { // set the material value volume_material_property_data_eh[eh] = grp_name; logger.message("Group name -- " + grp_name); - bool is_graveyard = dagmc_util::to_lower(grp_name) == dagmc_util::to_lower(graveyard_mat_str()); - bool is_vacuum = dagmc_util::to_lower(grp_name) == dagmc_util::to_lower(vacuum_mat_str()); + bool is_graveyard = dagmc_util::to_lower(grp_name) == + dagmc_util::to_lower(graveyard_mat_str()); + bool is_vacuum = dagmc_util::to_lower(grp_name) == + dagmc_util::to_lower(vacuum_mat_str()); // not graveyard or vacuum or implicit compliment if (!is_graveyard && !is_vacuum && !DAG->is_implicit_complement(eh)) { @@ -376,13 +378,17 @@ void dagmcMetaData::parse_boundary_data() { std::string bc_string = dagmc_util::to_lower(boundary_assignment[0]); - if (bc_string.find(dagmc_util::to_lower(reflecting_str())) != std::string::npos) + if (bc_string.find(dagmc_util::to_lower(reflecting_str())) != + std::string::npos) surface_boundary_data_eh[eh] = reflecting_str(); - if (bc_string.find(dagmc_util::to_lower(white_str())) != std::string::npos) + if (bc_string.find(dagmc_util::to_lower(white_str())) != + std::string::npos) surface_boundary_data_eh[eh] = white_str(); - if (bc_string.find(dagmc_util::to_lower(periodic_str())) != std::string::npos) + if (bc_string.find(dagmc_util::to_lower(periodic_str())) != + std::string::npos) surface_boundary_data_eh[eh] = periodic_str(); - if (bc_string.find(dagmc_util::to_lower(vacuum_str())) != std::string::npos) + if (bc_string.find(dagmc_util::to_lower(vacuum_str())) != + std::string::npos) surface_boundary_data_eh[eh] = vacuum_str(); } } diff --git a/src/mcnp/mcnp_funcs.cpp b/src/mcnp/mcnp_funcs.cpp index c80f7707b..f9833f7ca 100644 --- a/src/mcnp/mcnp_funcs.cpp +++ b/src/mcnp/mcnp_funcs.cpp @@ -2,6 +2,7 @@ #include "DagMC.hpp" #include "dagmcmetadata.hpp" +#include "util.hpp" using moab::DagMC; @@ -201,8 +202,10 @@ void write_cell_cards(std::ostringstream& lcadfile, // that material numbers are assigned mat_num = DMD->volume_material_data_eh[entity]; // if we cant make an int from the mat_num - if (dagmc_util::to_lower(mat_num) != dagmc_util::to_lower(DMD->graveyard_mat_str()) && - dagmc_util::to_lower(mat_num) != dagmc_util::to_lower(DMD->vacuum_mat_str())) { + if (dagmc_util::to_lower(mat_num) != + dagmc_util::to_lower(DMD->graveyard_mat_str()) && + dagmc_util::to_lower(mat_num) != + dagmc_util::to_lower(DMD->vacuum_mat_str())) { if (!DMD->try_to_make_int(mat_num)) { std::cerr << "Failed to cast material number to an integer" << std::endl; @@ -225,8 +228,10 @@ void write_cell_cards(std::ostringstream& lcadfile, } else { std::string mat_name = DMD->volume_material_property_data_eh[entity]; // if we not vacuum or graveyard - if (dagmc_util::to_lower(mat_num) != dagmc_util::to_lower(DMD->graveyard_mat_str()) && - dagmc_util::to_lower(mat_num) != dagmc_util::to_lower(DMD->vacuum_mat_str())) { + if (dagmc_util::to_lower(mat_num) != + dagmc_util::to_lower(DMD->graveyard_mat_str()) && + dagmc_util::to_lower(mat_num) != + dagmc_util::to_lower(DMD->vacuum_mat_str())) { if (workflow_data->material_library.count(mat_name) == 0) { std::cerr << "Material with name " << mat_name << " not found " << std::endl; From 4d82712c8cd83029e337080a33ece27f57eec560 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Wed, 11 Dec 2024 21:12:14 +0100 Subject: [PATCH 23/34] mat_num --- src/dagmc/dagmcmetadata.cpp | 13 ++++++------- src/mcnp/mcnp_funcs.cpp | 12 ++++++------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/dagmc/dagmcmetadata.cpp b/src/dagmc/dagmcmetadata.cpp index 4ac85601b..5a9f118b1 100644 --- a/src/dagmc/dagmcmetadata.cpp +++ b/src/dagmc/dagmcmetadata.cpp @@ -210,9 +210,9 @@ void dagmcMetaData::parse_material_data() { // set the material value volume_material_property_data_eh[eh] = grp_name; logger.message("Group name -- " + grp_name); - bool is_graveyard = dagmc_util::to_lower(grp_name) == + bool is_graveyard = dagmc_util::to_lower(grp_name) == dagmc_util::to_lower(graveyard_mat_str()); - bool is_vacuum = dagmc_util::to_lower(grp_name) == + bool is_vacuum = dagmc_util::to_lower(grp_name) == dagmc_util::to_lower(vacuum_mat_str()); // not graveyard or vacuum or implicit compliment @@ -378,17 +378,16 @@ void dagmcMetaData::parse_boundary_data() { std::string bc_string = dagmc_util::to_lower(boundary_assignment[0]); - if (bc_string.find(dagmc_util::to_lower(reflecting_str())) != + if (bc_string.find(dagmc_util::to_lower(reflecting_str())) != std::string::npos) surface_boundary_data_eh[eh] = reflecting_str(); - if (bc_string.find(dagmc_util::to_lower(white_str())) != + if (bc_string.find(dagmc_util::to_lower(white_str())) != std::string::npos) surface_boundary_data_eh[eh] = white_str(); - if (bc_string.find(dagmc_util::to_lower(periodic_str())) != + if (bc_string.find(dagmc_util::to_lower(periodic_str())) != std::string::npos) surface_boundary_data_eh[eh] = periodic_str(); - if (bc_string.find(dagmc_util::to_lower(vacuum_str())) != - std::string::npos) + if (bc_string.find(dagmc_util::to_lower(vacuum_str())) != std::string::npos) surface_boundary_data_eh[eh] = vacuum_str(); } } diff --git a/src/mcnp/mcnp_funcs.cpp b/src/mcnp/mcnp_funcs.cpp index f9833f7ca..8795cee51 100644 --- a/src/mcnp/mcnp_funcs.cpp +++ b/src/mcnp/mcnp_funcs.cpp @@ -202,9 +202,9 @@ void write_cell_cards(std::ostringstream& lcadfile, // that material numbers are assigned mat_num = DMD->volume_material_data_eh[entity]; // if we cant make an int from the mat_num - if (dagmc_util::to_lower(mat_num) != + if (dagmc_util::to_lower(mat_num) != dagmc_util::to_lower(DMD->graveyard_mat_str()) && - dagmc_util::to_lower(mat_num) != + dagmc_util::to_lower(mat_num) != dagmc_util::to_lower(DMD->vacuum_mat_str())) { if (!DMD->try_to_make_int(mat_num)) { std::cerr << "Failed to cast material number to an integer" @@ -272,10 +272,10 @@ void write_cell_cards(std::ostringstream& lcadfile, } double imp = 1.0; // if we find graveyard always have importance 0.0 - if (dagmc_util::to_lower(mat_nanme) == dagmc_util::to_lower(DMD->graveyard_mat_str()) { + if (dagmc_util::to_lower(mat_num) == dagmc_util::to_lower(DMD->graveyard_mat_str()) { imp = 0.0; // no splitting can happenin vacuum set to 1 - } else if (dagmc_util::to_lower(mat_nanme) == dagmc_util::to_lower(DMD->vacuum_mat_str())) { + } else if (dagmc_util::to_lower(mat_num) == dagmc_util::to_lower(DMD->vacuum_mat_str())) { imp = 1.0; // otherwise as the map says } else { @@ -285,7 +285,7 @@ void write_cell_cards(std::ostringstream& lcadfile, } // its possible no importances were assigned if (set.size() == 0) { - if (dagmc_util::to_lower(mat_nanme) != dagmc_util::to_lower(DMD->graveyard_mat_str()) { + if (dagmc_util::to_lower(mat_num) != dagmc_util::to_lower(DMD->graveyard_mat_str()) { importances = "imp:n=1"; } else { importances = "imp:n=0"; @@ -293,7 +293,7 @@ void write_cell_cards(std::ostringstream& lcadfile, } // add descriptive comments for special volumes - if (dagmc_util::to_lower(mat_nanme) == dagmc_util::to_lower(DMD->graveyard_mat_str()) { + if (dagmc_util::to_lower(mat_num) == dagmc_util::to_lower(DMD->graveyard_mat_str()) { importances += " $ graveyard"; } else if (DAG->is_implicit_complement(entity)) { importances += " $ implicit complement"; From 12b0bfed91405321468b2abb912e554de83410ef Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Wed, 11 Dec 2024 21:15:09 +0100 Subject: [PATCH 24/34] typo + formating --- src/dagmc/dagmcmetadata.cpp | 3 +-- src/mcnp/mcnp_funcs.cpp | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/dagmc/dagmcmetadata.cpp b/src/dagmc/dagmcmetadata.cpp index 5a9f118b1..07e5d77f4 100644 --- a/src/dagmc/dagmcmetadata.cpp +++ b/src/dagmc/dagmcmetadata.cpp @@ -378,8 +378,7 @@ void dagmcMetaData::parse_boundary_data() { std::string bc_string = dagmc_util::to_lower(boundary_assignment[0]); - if (bc_string.find(dagmc_util::to_lower(reflecting_str())) != - std::string::npos) + if (bc_string.find(dagmc_util::to_lower(reflecting_str())) != std::string::npos) surface_boundary_data_eh[eh] = reflecting_str(); if (bc_string.find(dagmc_util::to_lower(white_str())) != std::string::npos) diff --git a/src/mcnp/mcnp_funcs.cpp b/src/mcnp/mcnp_funcs.cpp index 8795cee51..b07ac50fb 100644 --- a/src/mcnp/mcnp_funcs.cpp +++ b/src/mcnp/mcnp_funcs.cpp @@ -228,9 +228,9 @@ void write_cell_cards(std::ostringstream& lcadfile, } else { std::string mat_name = DMD->volume_material_property_data_eh[entity]; // if we not vacuum or graveyard - if (dagmc_util::to_lower(mat_num) != + if (dagmc_util::to_lower(mat_num) != dagmc_util::to_lower(DMD->graveyard_mat_str()) && - dagmc_util::to_lower(mat_num) != + dagmc_util::to_lower(mat_num) != dagmc_util::to_lower(DMD->vacuum_mat_str())) { if (workflow_data->material_library.count(mat_name) == 0) { std::cerr << "Material with name " << mat_name << " not found " @@ -272,7 +272,7 @@ void write_cell_cards(std::ostringstream& lcadfile, } double imp = 1.0; // if we find graveyard always have importance 0.0 - if (dagmc_util::to_lower(mat_num) == dagmc_util::to_lower(DMD->graveyard_mat_str()) { + if (dagmc_util::to_lower(mat_num) == dagmc_util::to_lower(DMD->graveyard_mat_str())) { imp = 0.0; // no splitting can happenin vacuum set to 1 } else if (dagmc_util::to_lower(mat_num) == dagmc_util::to_lower(DMD->vacuum_mat_str())) { From 9af81245de4a61fafe7034deabde3a9aac957b43 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Wed, 11 Dec 2024 21:18:25 +0100 Subject: [PATCH 25/34] typo + formating --- src/dagmc/dagmcmetadata.cpp | 3 ++- src/mcnp/mcnp_funcs.cpp | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/dagmc/dagmcmetadata.cpp b/src/dagmc/dagmcmetadata.cpp index 07e5d77f4..5a9f118b1 100644 --- a/src/dagmc/dagmcmetadata.cpp +++ b/src/dagmc/dagmcmetadata.cpp @@ -378,7 +378,8 @@ void dagmcMetaData::parse_boundary_data() { std::string bc_string = dagmc_util::to_lower(boundary_assignment[0]); - if (bc_string.find(dagmc_util::to_lower(reflecting_str())) != std::string::npos) + if (bc_string.find(dagmc_util::to_lower(reflecting_str())) != + std::string::npos) surface_boundary_data_eh[eh] = reflecting_str(); if (bc_string.find(dagmc_util::to_lower(white_str())) != std::string::npos) diff --git a/src/mcnp/mcnp_funcs.cpp b/src/mcnp/mcnp_funcs.cpp index b07ac50fb..ec2be8471 100644 --- a/src/mcnp/mcnp_funcs.cpp +++ b/src/mcnp/mcnp_funcs.cpp @@ -272,10 +272,12 @@ void write_cell_cards(std::ostringstream& lcadfile, } double imp = 1.0; // if we find graveyard always have importance 0.0 - if (dagmc_util::to_lower(mat_num) == dagmc_util::to_lower(DMD->graveyard_mat_str())) { + if (dagmc_util::to_lower(mat_num) == + dagmc_util::to_lower(DMD->graveyard_mat_str())) { imp = 0.0; // no splitting can happenin vacuum set to 1 - } else if (dagmc_util::to_lower(mat_num) == dagmc_util::to_lower(DMD->vacuum_mat_str())) { + } else if (dagmc_util::to_lower(mat_num) == + dagmc_util::to_lower(DMD->vacuum_mat_str())) { imp = 1.0; // otherwise as the map says } else { @@ -285,7 +287,7 @@ void write_cell_cards(std::ostringstream& lcadfile, } // its possible no importances were assigned if (set.size() == 0) { - if (dagmc_util::to_lower(mat_num) != dagmc_util::to_lower(DMD->graveyard_mat_str()) { + if (dagmc_util::to_lower(mat_num) != dagmc_util::to_lower(DMD->graveyard_mat_str())) { importances = "imp:n=1"; } else { importances = "imp:n=0"; @@ -293,7 +295,7 @@ void write_cell_cards(std::ostringstream& lcadfile, } // add descriptive comments for special volumes - if (dagmc_util::to_lower(mat_num) == dagmc_util::to_lower(DMD->graveyard_mat_str()) { + if (dagmc_util::to_lower(mat_num) == dagmc_util::to_lower(DMD->graveyard_mat_str())) { importances += " $ graveyard"; } else if (DAG->is_implicit_complement(entity)) { importances += " $ implicit complement"; From f868037028349914b892dd4858764c0b06ec8cd6 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Wed, 11 Dec 2024 21:27:42 +0100 Subject: [PATCH 26/34] back to origin --- src/mcnp/mcnp_funcs.cpp | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/mcnp/mcnp_funcs.cpp b/src/mcnp/mcnp_funcs.cpp index ec2be8471..29462ebfb 100644 --- a/src/mcnp/mcnp_funcs.cpp +++ b/src/mcnp/mcnp_funcs.cpp @@ -2,8 +2,6 @@ #include "DagMC.hpp" #include "dagmcmetadata.hpp" -#include "util.hpp" - using moab::DagMC; #include @@ -202,10 +200,8 @@ void write_cell_cards(std::ostringstream& lcadfile, // that material numbers are assigned mat_num = DMD->volume_material_data_eh[entity]; // if we cant make an int from the mat_num - if (dagmc_util::to_lower(mat_num) != - dagmc_util::to_lower(DMD->graveyard_mat_str()) && - dagmc_util::to_lower(mat_num) != - dagmc_util::to_lower(DMD->vacuum_mat_str())) { + if (mat_num.find(DMD->graveyard_str()) == std::string::npos && + mat_num.find(DMD->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; @@ -228,10 +224,8 @@ void write_cell_cards(std::ostringstream& lcadfile, } else { std::string mat_name = DMD->volume_material_property_data_eh[entity]; // if we not vacuum or graveyard - if (dagmc_util::to_lower(mat_num) != - dagmc_util::to_lower(DMD->graveyard_mat_str()) && - dagmc_util::to_lower(mat_num) != - dagmc_util::to_lower(DMD->vacuum_mat_str())) { + if (mat_name.find(DMD->vacuum_str()) == std::string::npos && + mat_name.find(DMD->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; @@ -272,12 +266,10 @@ void write_cell_cards(std::ostringstream& lcadfile, } double imp = 1.0; // if we find graveyard always have importance 0.0 - if (dagmc_util::to_lower(mat_num) == - dagmc_util::to_lower(DMD->graveyard_mat_str())) { + if (mat_name.find(DMD->graveyard_str()) != std::string::npos) { imp = 0.0; // no splitting can happenin vacuum set to 1 - } else if (dagmc_util::to_lower(mat_num) == - dagmc_util::to_lower(DMD->vacuum_mat_str())) { + } else if (mat_name.find(DMD->vacuum_str()) != std::string::npos) { imp = 1.0; // otherwise as the map says } else { @@ -287,7 +279,7 @@ void write_cell_cards(std::ostringstream& lcadfile, } // its possible no importances were assigned if (set.size() == 0) { - if (dagmc_util::to_lower(mat_num) != dagmc_util::to_lower(DMD->graveyard_mat_str())) { + if (mat_name.find(DMD->graveyard_str()) == std::string::npos) { importances = "imp:n=1"; } else { importances = "imp:n=0"; @@ -295,7 +287,7 @@ void write_cell_cards(std::ostringstream& lcadfile, } // add descriptive comments for special volumes - if (dagmc_util::to_lower(mat_num) == dagmc_util::to_lower(DMD->graveyard_mat_str())) { + if (mat_name.find(DMD->graveyard_str()) != std::string::npos) { importances += " $ graveyard"; } else if (DAG->is_implicit_complement(entity)) { importances += " $ implicit complement"; From b8695748ba90407ce5c0910cbde499ef544e11e7 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Wed, 11 Dec 2024 21:32:21 +0100 Subject: [PATCH 27/34] back to origin --- src/dagmc/dagmcmetadata.cpp | 24 ++++++++++++------------ src/dagmc/dagmcmetadata.hpp | 2 ++ src/dagmc/util.hpp | 5 ----- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/dagmc/dagmcmetadata.cpp b/src/dagmc/dagmcmetadata.cpp index 5a9f118b1..0c86a27ae 100644 --- a/src/dagmc/dagmcmetadata.cpp +++ b/src/dagmc/dagmcmetadata.cpp @@ -210,10 +210,8 @@ void dagmcMetaData::parse_material_data() { // set the material value volume_material_property_data_eh[eh] = grp_name; logger.message("Group name -- " + grp_name); - bool is_graveyard = dagmc_util::to_lower(grp_name) == - dagmc_util::to_lower(graveyard_mat_str()); - bool is_vacuum = dagmc_util::to_lower(grp_name) == - dagmc_util::to_lower(vacuum_mat_str()); + bool is_graveyard = to_lower(grp_name) == to_lower(graveyard_mat_str()); + bool is_vacuum = to_lower(grp_name) == to_lower(vacuum_mat_str()); // not graveyard or vacuum or implicit compliment if (!is_graveyard && !is_vacuum && !DAG->is_implicit_complement(eh)) { @@ -347,6 +345,11 @@ void dagmcMetaData::parse_tally_volume_data() { } } +std::string dagmcMetaData::to_lower(std::string input) { + dagmc_util::lowercase_str(input); + return input; +} + // parse the boundary data void dagmcMetaData::parse_boundary_data() { auto boundary_assignments = get_property_assignments("boundary", 2, ":"); @@ -376,18 +379,15 @@ void dagmcMetaData::parse_boundary_data() { // 2d entities have been tagged with the boundary condition property // ie. both surfaces and its member triangles - std::string bc_string = dagmc_util::to_lower(boundary_assignment[0]); + std::string bc_string = to_lower(boundary_assignment[0]); - if (bc_string.find(dagmc_util::to_lower(reflecting_str())) != - std::string::npos) + if (bc_string.find(to_lower(reflecting_str())) != std::string::npos) surface_boundary_data_eh[eh] = reflecting_str(); - if (bc_string.find(dagmc_util::to_lower(white_str())) != - std::string::npos) + if (bc_string.find(to_lower(white_str())) != std::string::npos) surface_boundary_data_eh[eh] = white_str(); - if (bc_string.find(dagmc_util::to_lower(periodic_str())) != - std::string::npos) + if (bc_string.find(to_lower(periodic_str())) != std::string::npos) surface_boundary_data_eh[eh] = periodic_str(); - if (bc_string.find(dagmc_util::to_lower(vacuum_str())) != std::string::npos) + if (bc_string.find(to_lower(vacuum_str())) != std::string::npos) surface_boundary_data_eh[eh] = vacuum_str(); } } diff --git a/src/dagmc/dagmcmetadata.hpp b/src/dagmc/dagmcmetadata.hpp index 405c060af..d3a940f3f 100644 --- a/src/dagmc/dagmcmetadata.hpp +++ b/src/dagmc/dagmcmetadata.hpp @@ -250,6 +250,8 @@ class dagmcMetaData { */ std::set set_remove_rich(std::set properties_set); + std::string to_lower(const std::string input); + // public member variables public: /** diff --git a/src/dagmc/util.hpp b/src/dagmc/util.hpp index 639f7c542..9a8b64c0e 100644 --- a/src/dagmc/util.hpp +++ b/src/dagmc/util.hpp @@ -10,10 +10,5 @@ inline void lowercase_str(std::string& input) { [](unsigned char c) { return std::tolower(c); }); } -inline std::string to_lower(std::string input) { - lowercase_str(input); - return input; -} - } // namespace dagmc_util #endif \ No newline at end of file From 7dafb3fbac02e19d1de462df5be63159573772ef Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Wed, 11 Dec 2024 21:35:28 +0100 Subject: [PATCH 28/34] formating --- src/dagmc/dagmcmetadata.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dagmc/dagmcmetadata.cpp b/src/dagmc/dagmcmetadata.cpp index 0c86a27ae..081328d60 100644 --- a/src/dagmc/dagmcmetadata.cpp +++ b/src/dagmc/dagmcmetadata.cpp @@ -385,7 +385,7 @@ void dagmcMetaData::parse_boundary_data() { surface_boundary_data_eh[eh] = reflecting_str(); if (bc_string.find(to_lower(white_str())) != std::string::npos) surface_boundary_data_eh[eh] = white_str(); - if (bc_string.find(to_lower(periodic_str())) != std::string::npos) + if (bc_string.find(to_lower(periodic_str())) != std::string::npos) surface_boundary_data_eh[eh] = periodic_str(); if (bc_string.find(to_lower(vacuum_str())) != std::string::npos) surface_boundary_data_eh[eh] = vacuum_str(); From c4fe0f0829eaa98b7dfc30a1ecc5b704f081dabb Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot <15145274+bam241@users.noreply.github.com> Date: Fri, 13 Dec 2024 09:43:26 +0100 Subject: [PATCH 29/34] Apply suggestions from code review Co-authored-by: Paul Wilson --- src/dagmc/dagmcmetadata.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dagmc/dagmcmetadata.cpp b/src/dagmc/dagmcmetadata.cpp index 081328d60..eb6b3aff8 100644 --- a/src/dagmc/dagmcmetadata.cpp +++ b/src/dagmc/dagmcmetadata.cpp @@ -210,8 +210,8 @@ void dagmcMetaData::parse_material_data() { // set the material value volume_material_property_data_eh[eh] = grp_name; logger.message("Group name -- " + grp_name); - bool is_graveyard = to_lower(grp_name) == to_lower(graveyard_mat_str()); - bool is_vacuum = to_lower(grp_name) == to_lower(vacuum_mat_str()); + bool is_graveyard = (to_lower(grp_name) == to_lower(graveyard_mat_str())); + bool is_vacuum = (to_lower(grp_name) == to_lower(vacuum_mat_str())); // not graveyard or vacuum or implicit compliment if (!is_graveyard && !is_vacuum && !DAG->is_implicit_complement(eh)) { From 73f3198612585b8b16fc9f15a0e340509c6963f8 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Mon, 16 Dec 2024 19:30:18 +0100 Subject: [PATCH 30/34] one vacuum mat was not set using vacuum_mat_str method --- src/dagmc/dagmcmetadata.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dagmc/dagmcmetadata.cpp b/src/dagmc/dagmcmetadata.cpp index eb6b3aff8..fcb23dae4 100644 --- a/src/dagmc/dagmcmetadata.cpp +++ b/src/dagmc/dagmcmetadata.cpp @@ -231,7 +231,7 @@ void dagmcMetaData::parse_material_data() { else if (DAG->is_implicit_complement(eh)) { if (implicit_complement_material == "") { logger.message("Implicit Complement assumed to be Vacuum"); - volume_material_property_data_eh[eh] = "mat:Vacuum"; + volume_material_property_data_eh[eh] = vacuum_mat_str(); volume_material_data_eh[eh] = vacuum_str(); } else { volume_material_property_data_eh[eh] = From 05b2eb04b4674b7178b2cc5d28ea0a74426e3241 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Mon, 16 Dec 2024 19:33:41 +0100 Subject: [PATCH 31/34] adding setting and tests to check detection of vacuum to avoid regression --- src/dagmc/dagmcmetadata.hpp | 17 +++++--- src/dagmc/tests/dagmc_unit_tests.cpp | 58 ++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 5 deletions(-) diff --git a/src/dagmc/dagmcmetadata.hpp b/src/dagmc/dagmcmetadata.hpp index d3a940f3f..137c99049 100644 --- a/src/dagmc/dagmcmetadata.hpp +++ b/src/dagmc/dagmcmetadata.hpp @@ -316,7 +316,7 @@ class dagmcMetaData { */ std::map> importance_map; - // Some constant keyword values + // Getting some constant keyword values const std::string& graveyard_str() const { return graveyard_str_; } const std::string& vacuum_str() const { return vacuum_str_; } const std::string& vacuum_mat_str() const { return vacuum_mat_str_; } @@ -325,6 +325,12 @@ class dagmcMetaData { const std::string& white_str() const { return white_str_; } const std::string& periodic_str() const { return periodic_str_; } + // Allowing modify some constant keyword values + void set_graveyard_str(std::string val) { graveyard_str_ = val; } + void set_vacuum_str(std::string val) { vacuum_str_ = val; } + void set_vacuum_mat_str(std::string val) { vacuum_mat_str_ = val; } + void set_graveyard_mat_str(std::string val) { graveyard_mat_str_ = val; } + // private member variables private: /** @@ -360,13 +366,14 @@ class dagmcMetaData { std::map keyword_synonyms; // Some constant keyword values - const std::string graveyard_str_{"Graveyard"}; - const std::string vacuum_str_{"Vacuum"}; - const std::string vacuum_mat_str_{"mat:Vacuum"}; - const std::string graveyard_mat_str_{"mat:Graveyard"}; const std::string reflecting_str_{"Reflecting"}; const std::string white_str_{"White"}; const std::string periodic_str_{"Periodic"}; + // Some less constant keyword values + std::string graveyard_str_{"Graveyard"}; + std::string vacuum_str_{"Vacuum"}; + std::string vacuum_mat_str_{"mat:Vacuum"}; + std::string graveyard_mat_str_{"mat:Graveyard"}; DagMC_Logger logger; }; diff --git a/src/dagmc/tests/dagmc_unit_tests.cpp b/src/dagmc/tests/dagmc_unit_tests.cpp index a3eab1799..1dafdb380 100644 --- a/src/dagmc/tests/dagmc_unit_tests.cpp +++ b/src/dagmc/tests/dagmc_unit_tests.cpp @@ -81,6 +81,64 @@ TEST_F(DagmcMetadataTest, TestMatAssigns) { } } //---------------------------------------------------------------------------// +// FIXTURE-BASED TESTS: Tests to make sure that all volumes have successfully +// been assigned and successfully retreved from the metadata class +//---------------------------------------------------------------------------// +TEST_F(DagmcMetadataTest, TestVacuumName) { + // Test default behavior for vacuum name + { + // new metadata instance + dgm = std::make_shared(DAG.get()); + // process + dgm->load_property_data(); + + + std::string base_property = "mat:Hydrogen"; + std::string impl_comp_prop = "mat:Vacuum"; + + int num_vol = DAG->num_entities(3); + std::vector vol_ids = {1, 2, 3, 4}; + + std::vector vacuum_names = {"Hydrogen", "Hydrogen", "Hydrogen", "Vacuum"}; + for (int id : vol_ids){ + std::string mat_prop = dgm->get_volume_property("material", id, false); + EXPECT_EQ(mat_prop, vacuum_names[id-1]); + } + } + + // Changing the vacuum name to detect mat:Hydrogen as the vacuum + { + dgm = std::make_shared(DAG.get()); + + dgm->set_vacuum_mat_str("mat:Hydrogen"); + dgm->load_property_data(); + int num_vol = DAG->num_entities(3); + std::vector vol_ids = {1, 2, 3, 4}; + + std::vector vacuum_names = {"Vacuum", "Vacuum", "Vacuum", "Vacuum"}; + for (int id : vol_ids){ + std::string mat_prop = dgm->get_volume_property("material", id, false); + EXPECT_EQ(mat_prop, vacuum_names[id-1]); + } + } + + // Ensuring that partial name overlap don't affect vacuum detection + { + dgm = std::make_shared(DAG.get()); + + dgm->set_vacuum_mat_str("Hydro"); + dgm->load_property_data(); + int num_vol = DAG->num_entities(3); + std::vector vol_ids = {1, 2, 3, 4}; + + std::vector vacuum_names = {"Hydrogen", "Hydrogen", "Hydrogen", "Vacuum"}; + for (int id : vol_ids){ + std::string mat_prop = dgm->get_volume_property("material", id, false); + EXPECT_EQ(mat_prop, vacuum_names[id-1]); + } + } +} +//---------------------------------------------------------------------------// // FIXTURE-BASED TESTS: Tests to make sure that all densities have successfully // been assigned and successfully retreved from the metadata class // in this test there was no density data assigned, so it should be "" From 3e8f9a1ca0a9661e2dd5914596123a396442e754 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Mon, 16 Dec 2024 19:38:27 +0100 Subject: [PATCH 32/34] syntax and comment --- src/dagmc/tests/dagmc_unit_tests.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/dagmc/tests/dagmc_unit_tests.cpp b/src/dagmc/tests/dagmc_unit_tests.cpp index 1dafdb380..e6c59b7d4 100644 --- a/src/dagmc/tests/dagmc_unit_tests.cpp +++ b/src/dagmc/tests/dagmc_unit_tests.cpp @@ -81,8 +81,8 @@ TEST_F(DagmcMetadataTest, TestMatAssigns) { } } //---------------------------------------------------------------------------// -// FIXTURE-BASED TESTS: Tests to make sure that all volumes have successfully -// been assigned and successfully retreved from the metadata class +// FIXTURE-BASED TESTS: Tests to make sure that vacuum detection is done +// properly //---------------------------------------------------------------------------// TEST_F(DagmcMetadataTest, TestVacuumName) { // Test default behavior for vacuum name @@ -92,14 +92,11 @@ TEST_F(DagmcMetadataTest, TestVacuumName) { // process dgm->load_property_data(); - - std::string base_property = "mat:Hydrogen"; - std::string impl_comp_prop = "mat:Vacuum"; - int num_vol = DAG->num_entities(3); std::vector vol_ids = {1, 2, 3, 4}; - std::vector vacuum_names = {"Hydrogen", "Hydrogen", "Hydrogen", "Vacuum"}; + std::vector vacuum_names = {"Hydrogen", "Hydrogen", "Hydrogen", + "Vacuum"}; for (int id : vol_ids){ std::string mat_prop = dgm->get_volume_property("material", id, false); EXPECT_EQ(mat_prop, vacuum_names[id-1]); @@ -115,7 +112,8 @@ TEST_F(DagmcMetadataTest, TestVacuumName) { int num_vol = DAG->num_entities(3); std::vector vol_ids = {1, 2, 3, 4}; - std::vector vacuum_names = {"Vacuum", "Vacuum", "Vacuum", "Vacuum"}; + std::vector vacuum_names = {"Vacuum", "Vacuum", "Vacuum", + "Vacuum"}; for (int id : vol_ids){ std::string mat_prop = dgm->get_volume_property("material", id, false); EXPECT_EQ(mat_prop, vacuum_names[id-1]); @@ -131,7 +129,8 @@ TEST_F(DagmcMetadataTest, TestVacuumName) { int num_vol = DAG->num_entities(3); std::vector vol_ids = {1, 2, 3, 4}; - std::vector vacuum_names = {"Hydrogen", "Hydrogen", "Hydrogen", "Vacuum"}; + std::vector vacuum_names = {"Hydrogen", "Hydrogen", "Hydrogen", + "Vacuum"}; for (int id : vol_ids){ std::string mat_prop = dgm->get_volume_property("material", id, false); EXPECT_EQ(mat_prop, vacuum_names[id-1]); From 19bc256359fd7471411497418ee133e0eacade1c Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Mon, 16 Dec 2024 19:42:19 +0100 Subject: [PATCH 33/34] syntax --- src/dagmc/tests/dagmc_unit_tests.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/dagmc/tests/dagmc_unit_tests.cpp b/src/dagmc/tests/dagmc_unit_tests.cpp index e6c59b7d4..78fe938dc 100644 --- a/src/dagmc/tests/dagmc_unit_tests.cpp +++ b/src/dagmc/tests/dagmc_unit_tests.cpp @@ -97,9 +97,9 @@ TEST_F(DagmcMetadataTest, TestVacuumName) { std::vector vacuum_names = {"Hydrogen", "Hydrogen", "Hydrogen", "Vacuum"}; - for (int id : vol_ids){ + for (int id : vol_ids) { std::string mat_prop = dgm->get_volume_property("material", id, false); - EXPECT_EQ(mat_prop, vacuum_names[id-1]); + EXPECT_EQ(mat_prop, vacuum_names[id - 1]); } } @@ -114,9 +114,9 @@ TEST_F(DagmcMetadataTest, TestVacuumName) { std::vector vacuum_names = {"Vacuum", "Vacuum", "Vacuum", "Vacuum"}; - for (int id : vol_ids){ + for (int id : vol_ids) { std::string mat_prop = dgm->get_volume_property("material", id, false); - EXPECT_EQ(mat_prop, vacuum_names[id-1]); + EXPECT_EQ(mat_prop, vacuum_names[id - 1]); } } @@ -131,9 +131,9 @@ TEST_F(DagmcMetadataTest, TestVacuumName) { std::vector vacuum_names = {"Hydrogen", "Hydrogen", "Hydrogen", "Vacuum"}; - for (int id : vol_ids){ + for (int id : vol_ids) { std::string mat_prop = dgm->get_volume_property("material", id, false); - EXPECT_EQ(mat_prop, vacuum_names[id-1]); + EXPECT_EQ(mat_prop, vacuum_names[id - 1]); } } } From 8eb8480ca9e24e6e0af36fe33f5e2363fb5afc00 Mon Sep 17 00:00:00 2001 From: Baptiste Mouginot Date: Mon, 16 Dec 2024 19:57:57 +0100 Subject: [PATCH 34/34] syntax --- src/dagmc/tests/dagmc_unit_tests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dagmc/tests/dagmc_unit_tests.cpp b/src/dagmc/tests/dagmc_unit_tests.cpp index 78fe938dc..9633138b6 100644 --- a/src/dagmc/tests/dagmc_unit_tests.cpp +++ b/src/dagmc/tests/dagmc_unit_tests.cpp @@ -81,7 +81,7 @@ TEST_F(DagmcMetadataTest, TestMatAssigns) { } } //---------------------------------------------------------------------------// -// FIXTURE-BASED TESTS: Tests to make sure that vacuum detection is done +// FIXTURE-BASED TESTS: Tests to make sure that vacuum detection is done // properly //---------------------------------------------------------------------------// TEST_F(DagmcMetadataTest, TestVacuumName) {