mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 05:35:49 -04:00
Reorganizing some of the DAGMC-related code and using shared pointers instead.
This commit is contained in:
parent
4c4b7a8234
commit
be5318fdb0
6 changed files with 42 additions and 17 deletions
|
|
@ -75,6 +75,20 @@ public:
|
|||
unique_ptr<UniversePartitioner> partitioner_;
|
||||
};
|
||||
|
||||
#ifdef DAGMC
|
||||
|
||||
class DAGUniverse : public Universe {
|
||||
|
||||
public:
|
||||
explicit DAGUniverse(std::string filename);
|
||||
|
||||
|
||||
// Data Members
|
||||
std::shared_ptr<moab::DagMC> dag_instance_; //! DAGMC Instance for this universe
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
//==============================================================================
|
||||
|
||||
|
|
@ -271,7 +285,7 @@ public:
|
|||
|
||||
void to_hdf5(hid_t group_id) const;
|
||||
|
||||
moab::DagMC* dagmc_ptr_; //!< Pointer to DagMC instance
|
||||
std::shared_ptr<moab::DagMC> dagmc_ptr_; //!< Pointer to DagMC instance
|
||||
int32_t dag_index_; //!< DagMC index of cell
|
||||
};
|
||||
#endif
|
||||
|
|
@ -343,6 +357,7 @@ struct CellInstanceHash {
|
|||
void read_cells(pugi::xml_node node);
|
||||
|
||||
#ifdef DAGMC
|
||||
void read_dagmc_universes(pugi::xml_node node);
|
||||
int32_t next_cell(DAGCell* cur_cell, DAGSurface* surf_xed);
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ extern "C" const bool DAGMC_ENABLED;
|
|||
namespace openmc {
|
||||
|
||||
namespace model {
|
||||
extern moab::DagMC* DAG;
|
||||
extern std::shared_ptr<moab::DagMC> DAG;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -23,7 +23,7 @@ namespace model {
|
|||
//==============================================================================
|
||||
|
||||
void load_dagmc_geometry();
|
||||
void free_memory_dagmc();
|
||||
void create_dagmc_universe(const std::string& filename);
|
||||
void read_geometry_dagmc();
|
||||
bool read_uwuw_materials(pugi::xml_document& doc);
|
||||
bool get_uwuw_materials_xml(std::string& s);
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ public:
|
|||
|
||||
void to_hdf5(hid_t group_id) const;
|
||||
|
||||
moab::DagMC* dagmc_ptr_; //!< Pointer to DagMC instance
|
||||
std::shared_ptr<moab::DagMC> dagmc_ptr_; //!< Pointer to DagMC instance
|
||||
int32_t dag_index_; //!< DagMC index of surface
|
||||
};
|
||||
#endif
|
||||
|
|
|
|||
16
src/cell.cpp
16
src/cell.cpp
|
|
@ -1013,6 +1013,11 @@ void read_cells(pugi::xml_node node)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef DAGMC
|
||||
// read any DAGMC universes
|
||||
read_dagmc_universes(node);
|
||||
#endif
|
||||
|
||||
// Populate the Universe vector and map.
|
||||
for (int i = 0; i < model::cells.size(); i++) {
|
||||
int32_t uid = model::cells[i]->universe_;
|
||||
|
|
@ -1034,6 +1039,17 @@ void read_cells(pugi::xml_node node)
|
|||
}
|
||||
}
|
||||
|
||||
void read_dagmc_universes(pugi::xml_node node) {
|
||||
|
||||
// determine the max cell id
|
||||
int32_t next_cell_id = 0;
|
||||
for (const auto& c : model::cells) {
|
||||
if (c->id_ > next_cell_id) next_cell_id = c->id_;
|
||||
}
|
||||
next_cell_id++;
|
||||
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// C-API functions
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ const std::string DAGMC_FILENAME = "dagmc.h5m";
|
|||
|
||||
namespace model {
|
||||
|
||||
moab::DagMC* DAG;
|
||||
std::shared_ptr<moab::DagMC> DAG;
|
||||
|
||||
} // namespace model
|
||||
|
||||
|
|
@ -151,14 +151,17 @@ void legacy_assign_material(std::string mat_string, DAGCell* c)
|
|||
|
||||
void load_dagmc_geometry()
|
||||
{
|
||||
create_dagmc_universe(dagmc_file());
|
||||
}
|
||||
|
||||
void create_dagmc_universe(const std::string& filename) {
|
||||
if (!model::DAG) {
|
||||
model::DAG = new moab::DagMC();
|
||||
model::DAG = std::make_shared<moab::DagMC>();
|
||||
}
|
||||
|
||||
// --- Materials ---
|
||||
|
||||
// create uwuw instance
|
||||
auto filename = dagmc_file();
|
||||
UWUW uwuw(filename.c_str());
|
||||
|
||||
// check for uwuw material definitions
|
||||
|
|
@ -180,7 +183,7 @@ void load_dagmc_geometry()
|
|||
MB_CHK_ERR_CONT(rval);
|
||||
|
||||
// parse model metadata
|
||||
dagmcMetaData DMD(model::DAG, false, false);
|
||||
dagmcMetaData DMD(model::DAG.get(), false, false);
|
||||
DMD.load_property_data();
|
||||
|
||||
vector<std::string> keywords {"temp"};
|
||||
|
|
@ -346,11 +349,5 @@ void read_geometry_dagmc()
|
|||
model::root_universe = find_root_universe();
|
||||
}
|
||||
|
||||
void free_memory_dagmc()
|
||||
{
|
||||
delete model::DAG;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -51,9 +51,6 @@ void free_memory()
|
|||
if (settings::event_based) {
|
||||
free_event_queues();
|
||||
}
|
||||
#ifdef DAGMC
|
||||
free_memory_dagmc();
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue