Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix vaccum name in materials #971

Open
wants to merge 34 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
89b3b98
Switching to exact match for vacuum and graveyard checks.
pshriwise Apr 20, 2022
01a7fdf
Removing extra print in uwuw test
pshriwise Apr 20, 2022
0731127
Using new member variables for comprision and assignment
pshriwise Apr 20, 2022
26c673f
Adding accessors for material strings and using in mcnp_funcs
pshriwise Apr 20, 2022
cf805d6
turning cout into a logged message
bam241 Dec 11, 2024
d521de4
Add changelog
bam241 Dec 11, 2024
e539b9b
bug fix
bam241 Dec 11, 2024
ebaa4d2
formating
bam241 Dec 11, 2024
425fba7
fixing mcnp bug
bam241 Dec 11, 2024
a170860
fixing mcnp bug
bam241 Dec 11, 2024
00b0d05
fixing mcnp bug
bam241 Dec 11, 2024
0d3d4f5
dagmc_util not dagmc_utils
bam241 Dec 11, 2024
e2e51b4
formating
bam241 Dec 11, 2024
e079784
using DMD to_lower
bam241 Dec 11, 2024
6f3b216
fix
bam241 Dec 11, 2024
e895f55
fix
bam241 Dec 11, 2024
6e8b942
fix typo
bam241 Dec 11, 2024
033a7af
propagating change
bam241 Dec 11, 2024
c205c03
propagating change
bam241 Dec 11, 2024
71bb4e0
removed the wrong import
bam241 Dec 11, 2024
f126a40
moving to_lower in utils
bam241 Dec 11, 2024
052e446
missing import and formating
bam241 Dec 11, 2024
bd5bfe4
mat_num
bam241 Dec 11, 2024
eb7c22d
typo + formating
bam241 Dec 11, 2024
92a7a39
typo + formating
bam241 Dec 11, 2024
2b8ba5d
back to origin
bam241 Dec 11, 2024
bcd0ce4
back to origin
bam241 Dec 11, 2024
aa5f3d9
formating
bam241 Dec 11, 2024
e850f99
Apply suggestions from code review
bam241 Dec 13, 2024
7048bdb
one vacuum mat was not set using vacuum_mat_str method
bam241 Dec 16, 2024
2576dfc
adding setting and tests to check detection of vacuum to avoid regres…
bam241 Dec 16, 2024
a4c164c
syntax and comment
bam241 Dec 16, 2024
06bc32a
syntax
bam241 Dec 16, 2024
b7f322c
syntax
bam241 Dec 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Next version
* Update github actions to newer versions as necessary (#958)
* CMake error message update (#960)
* Updated documentation to build dependencies (#963)
* Fixed the name of the Graveyard and the Vaccuum to mat:Graveyard and mat:Vacuum (and lower case) (#971)

v3.2.3
====================
Expand Down
38 changes: 18 additions & 20 deletions src/dagmc/dagmcmetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,32 +209,30 @@ void dagmcMetaData::parse_material_data() {

// set the material value
volume_material_property_data_eh[eh] = grp_name;

bool is_graveyard =
to_lower(grp_name).find(to_lower(graveyard_str)) != std::string::npos;
bool is_vacuum =
to_lower(grp_name).find(to_lower(vacuum_str)) != std::string::npos;
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()));

// not graveyard or vacuum or implicit compliment
if (!is_graveyard && !is_vacuum && !DAG->is_implicit_complement(eh)) {
volume_material_data_eh[eh] = material_props[0];
}
// found graveyard
else if (is_graveyard) {
volume_material_property_data_eh[eh] = "mat:Graveyard";
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] = "mat:Vacuum";
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)) {
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_property_data_eh[eh] = vacuum_mat_str();
volume_material_data_eh[eh] = vacuum_str();
} else {
volume_material_property_data_eh[eh] =
"mat:" + implicit_complement_material;
Expand Down Expand Up @@ -379,18 +377,18 @@ 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]);

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();
}
}

Expand Down
28 changes: 23 additions & 5 deletions src/dagmc/dagmcmetadata.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,21 @@ class dagmcMetaData {
*/
std::map<moab::EntityHandle, std::map<std::string, double>> importance_map;

// 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_; }
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_; }

// 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:
/**
Expand Down Expand Up @@ -351,11 +366,14 @@ class dagmcMetaData {
std::map<std::string, std::string> keyword_synonyms;

// Some constant keyword values
const std::string graveyard_str{"Graveyard"};
const std::string vacuum_str{"Vacuum"};
const std::string reflecting_str{"Reflecting"};
const std::string white_str{"White"};
const std::string periodic_str{"Periodic"};
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;
};
Expand Down
57 changes: 57 additions & 0 deletions src/dagmc/tests/dagmc_unit_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,63 @@ TEST_F(DagmcMetadataTest, TestMatAssigns) {
}
}
//---------------------------------------------------------------------------//
// FIXTURE-BASED TESTS: Tests to make sure that vacuum detection is done
// properly
//---------------------------------------------------------------------------//
TEST_F(DagmcMetadataTest, TestVacuumName) {
// Test default behavior for vacuum name
{
// new metadata instance
dgm = std::make_shared<dagmcMetaData>(DAG.get());
// process
dgm->load_property_data();

int num_vol = DAG->num_entities(3);
std::vector<int> vol_ids = {1, 2, 3, 4};

std::vector<std::string> 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<dagmcMetaData>(DAG.get());

dgm->set_vacuum_mat_str("mat:Hydrogen");
dgm->load_property_data();
int num_vol = DAG->num_entities(3);
std::vector<int> vol_ids = {1, 2, 3, 4};

std::vector<std::string> 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<dagmcMetaData>(DAG.get());

dgm->set_vacuum_mat_str("Hydro");
dgm->load_property_data();
int num_vol = DAG->num_entities(3);
std::vector<int> vol_ids = {1, 2, 3, 4};

std::vector<std::string> 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 ""
Expand Down
21 changes: 9 additions & 12 deletions src/mcnp/mcnp_funcs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.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;
Expand All @@ -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.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;
Expand Down Expand Up @@ -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.find(DMD->graveyard_str()) != std::string::npos) {
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.find(DMD->vacuum_str()) != std::string::npos) {
imp = 1.0;
// otherwise as the map says
} else {
Expand All @@ -282,15 +279,15 @@ 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.find(DMD->graveyard_str()) == std::string::npos) {
importances = "imp:n=1";
} else {
importances = "imp:n=0";
}
}

// add descriptive comments for special volumes
if (mat_name.find(graveyard_str) != std::string::npos) {
if (mat_name.find(DMD->graveyard_str()) != std::string::npos) {
importances += " $ graveyard";
} else if (DAG->is_implicit_complement(entity)) {
importances += " $ implicit complement";
Expand Down
1 change: 0 additions & 1 deletion src/uwuw/tests/uwuw_unit_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 << " <material id=\"1\" name=\"Water\" >\n";
expected_rep << " <density value=\"1.\" units=\"g/cc\" />\n";
Expand Down
Loading