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 ""