Skip to content

Commit

Permalink
Adding accessors for material strings and using in mcnp_funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
pshriwise authored and bam241 committed Dec 11, 2024
1 parent 0731127 commit 26c673f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 26 deletions.
28 changes: 14 additions & 14 deletions src/dagmc/dagmcmetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,23 +211,23 @@ 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)) {
volume_material_data_eh[eh] = material_props[0];
}
// 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)) {
Expand Down Expand Up @@ -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();
}
}

Expand Down
9 changes: 9 additions & 0 deletions src/dagmc/dagmcmetadata.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,15 @@ class dagmcMetaData {
*/
std::map<moab::EntityHandle, std::map<std::string, double>> 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:
/**
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 != 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;
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 != 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;
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 == 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 {
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 != DMD->graveyard_mat_str()) {
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 == DMD->graveyard_mat_str()) {
importances += " $ graveyard";
} else if (DAG->is_implicit_complement(entity)) {
importances += " $ implicit complement";
Expand Down

0 comments on commit 26c673f

Please sign in to comment.