Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
bam241 committed Sep 4, 2024
1 parent 8e5c3ef commit 548c64e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 24 deletions.
4 changes: 2 additions & 2 deletions src/cell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,12 @@ void Cell::to_hdf5(hid_t cell_group) const
// default constructor
CSGCell::CSGCell()
{
geom_type() = GeometryType::CSG;
geom_type_ = GeometryType::CSG;
}

CSGCell::CSGCell(pugi::xml_node cell_node)
{
geom_type() = GeometryType::CSG;
geom_type_ = GeometryType::CSG;

if (check_for_node(cell_node, "id")) {
id_ = std::stoi(get_node_value(cell_node, "id"));
Expand Down
41 changes: 20 additions & 21 deletions src/dagmc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ DAGUniverse::DAGUniverse(pugi::xml_node node)
}

// get material assignment overloading
if (check_for_node(node, "material_overrides")) {
auto mat_node = node.child("material_overrides");
if (check_for_node(node, "mat_assignment")) {
auto mat_node = node.child("mat_assignment");
// loop over all attributes (each attribute corresponds to a material)
for (pugi::xml_attribute attr = mat_node.first_attribute(); attr;
attr = attr.next_attribute()) {
Expand All @@ -83,10 +83,13 @@ DAGUniverse::DAGUniverse(pugi::xml_node node)

// Get mat name for each assignement instances
std::stringstream iss {attr.value()};
vector<std::string> instance_mats = split(iss.str());
vector<std::string> instance_mats;
std::string value;
while (iss >> value)
instance_mats.push_back(value);

// Store mat name for each instances
instance_material_overrides.insert(
instance_mat_assignment.insert(
std::make_pair(mat_ref_assignment, instance_mats));
}
}
Expand Down Expand Up @@ -129,6 +132,7 @@ void DAGUniverse::set_id()

void DAGUniverse::initialize()
{
std::cout << "INITIALIZE DAGMC" << std::endl;
geom_type() = GeometryType::DAG;

init_dagmc();
Expand Down Expand Up @@ -232,12 +236,11 @@ void DAGUniverse::init_geometry()
if (uses_uwuw()) {
uwuw_assign_material(vol_handle, c);
} else {
if (instance_material_overrides.size() > 0 and
instance_material_overrides.find(mat_str) !=
instance_material_overrides.end()) {
if (instance_mat_assignment.size() > 0 and
instance_mat_assignment.find(mat_str) !=
instance_mat_assignment.end()) {

for (auto mat_str_instance :
instance_material_overrides.at(mat_str)) {
for (auto mat_str_instance : instance_mat_assignment.at(mat_str)) {
legacy_assign_material(mat_str_instance, c);
}
} else {
Expand Down Expand Up @@ -642,7 +645,7 @@ void DAGUniverse::uwuw_assign_material(
DAGCell::DAGCell(std::shared_ptr<moab::DagMC> dag_ptr, int32_t dag_idx)
: Cell {}, dagmc_ptr_(dag_ptr), dag_index_(dag_idx)
{
geom_type() = GeometryType::DAG;
geom_type_ = GeometryType::DAG;
};

std::pair<double, int32_t> DAGCell::distance(
Expand Down Expand Up @@ -844,24 +847,23 @@ int32_t next_cell(int32_t surf, int32_t curr_cell, int32_t univ)
return univp->cell_index(new_vol);
}

extern "C" int openmc_get_dagmc_cell_ids(
extern "C" void openmc_get_dagmc_cell_ids(
int32_t univ_id, int32_t* ids, size_t* n)
{
// make sure the universe id is a DAGMC Universe
const auto& univ = model::universes[model::universe_map[univ_id]];
if (univ->geom_type() != GeometryType::DAG) {
const auto& univ = universe_map[univ_id];
if (univ.geom_type_ != GeometryType::DAG) {
fatal_error(
"Universe " + std::to_string(univ_id) + " is not a DAGMC Universe!");
}

std::vector<int32_t> dag_cell_ids;
for (const auto& cell_index : univ->cells_) {
const auto& cell = model::cells[cell_index];
if (cell->geom_type() == GeometryType::DAG)
for (const auto& cell : univ.cells_) {
if (cell->geom_type_ == GeometryType::DAG)
dag_cell_ids.push_back(cell->id_);
}
std::copy(dag_cell_ids.begin(), dag_cell_ids.end(), ids);
*n = dag_cell_ids.size();
std::copy(dag_cell_ids.begin(), dag_cell_ids.end(), ids)* n =
dag_cell_ids.size();
}

} // namespace openmc
Expand All @@ -870,9 +872,6 @@ extern "C" int openmc_get_dagmc_cell_ids(

namespace openmc {

extern "C" int openmc_get_dagmc_cell_ids(
int32_t univ_id, int32_t* ids, size_t* n) {};

void read_dagmc_universes(pugi::xml_node node)
{
if (check_for_node(node, "dagmc_universe")) {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/unit_tests/dagmc/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_model_differentiate_with_DAGMC():
mats["Water"].add_s_alpha_beta("c_H_in_H2O")
mats["Water"].name = "Water"

p = pkg_resources.resource_filename(__name__, "UseCaseBam.h5m")
p = pkg_resources.resource_filename(__name__, "dagmc_mat_split.h5m")

daguniv = openmc.DAGMCUniverse(p,auto_geom_ids=True,)

Expand Down

0 comments on commit 548c64e

Please sign in to comment.