Skip to content

Commit

Permalink
moving to_lower in utils
Browse files Browse the repository at this point in the history
  • Loading branch information
bam241 committed Dec 11, 2024
1 parent 71bb4e0 commit f126a40
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 22 deletions.
19 changes: 7 additions & 12 deletions src/dagmc/dagmcmetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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, ":");
Expand Down Expand Up @@ -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();
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/dagmc/dagmcmetadata.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,6 @@ class dagmcMetaData {
*/
std::set<std::string> set_remove_rich(std::set<std::string> properties_set);

std::string to_lower(const std::string input);

// public member variables
public:
/**
Expand Down
5 changes: 5 additions & 0 deletions src/dagmc/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 8 additions & 8 deletions src/mcnp/mcnp_funcs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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 {
Expand All @@ -280,15 +280,15 @@ 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";
}
}

// 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";
Expand Down

0 comments on commit f126a40

Please sign in to comment.