mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-26 05:05:30 -04:00
User option on collision cap & minor debugging
This commit is contained in:
parent
a57ada41b5
commit
73b9727f1e
4 changed files with 29 additions and 12 deletions
|
|
@ -106,13 +106,15 @@ public:
|
|||
//! \param[in] auto_geom_ids Whether or not to automatically assign cell and
|
||||
//! surface IDs \param[in] auto_mat_ids Whether or not to automatically assign
|
||||
//! material IDs
|
||||
//! \param[in] use_collision_distance_cap Whether or not to cap the distance to
|
||||
//! boundaries to the collision distance when finding the next boundary
|
||||
explicit DAGUniverse(const std::string& filename, bool auto_geom_ids = false,
|
||||
bool auto_mat_ids = false);
|
||||
bool auto_mat_ids = false, bool use_collision_distance_cap = false);
|
||||
|
||||
//! Alternative DAGMC universe constructor for external DAGMC instance
|
||||
explicit DAGUniverse(std::shared_ptr<moab::DagMC> external_dagmc_ptr,
|
||||
const std::string& filename = "", bool auto_geom_ids = false,
|
||||
bool auto_mat_ids = false);
|
||||
bool auto_mat_ids = false, bool use_collision_distance_cap = false);
|
||||
|
||||
//! Initialize the DAGMC accel. data structures, indices, material
|
||||
//! assignments, etc.
|
||||
|
|
@ -191,6 +193,7 @@ public:
|
|||
// Accessors
|
||||
moab::DagMC* dagmc_ptr() const { return dagmc_instance_.get(); }
|
||||
bool has_graveyard() const { return has_graveyard_; }
|
||||
bool use_collision_distance_cap() const { return use_collision_distance_cap_; }
|
||||
|
||||
private:
|
||||
void set_id(); //!< Deduce the universe id from model::universes
|
||||
|
|
@ -212,6 +215,9 @@ private:
|
|||
//!< generate new material IDs for the universe
|
||||
bool has_graveyard_; //!< Indicates if the DAGMC geometry has a "graveyard"
|
||||
//!< volume
|
||||
bool use_collision_distance_cap_; //!< Indicates whether or not to cap the
|
||||
//!< distance to boundaries to the collision
|
||||
//!< distance when finding the next boundary
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -80,6 +80,11 @@ DAGUniverse::DAGUniverse(pugi::xml_node node)
|
|||
adjust_material_ids_ = get_node_value_bool(node, "auto_mat_ids");
|
||||
}
|
||||
|
||||
use_collision_distance_cap_ = false;
|
||||
if (check_for_node(node, "use_collision_distance_cap")) {
|
||||
use_collision_distance_cap_ = get_node_value_bool(node, "use_collision_distance_cap");
|
||||
}
|
||||
|
||||
// Get material assignment overrides from nested DAGMC cell elements.
|
||||
if (node.child("cell")) {
|
||||
for (pugi::xml_node cell_node : node.children("cell")) {
|
||||
|
|
@ -154,18 +159,18 @@ DAGUniverse::DAGUniverse(pugi::xml_node node)
|
|||
}
|
||||
|
||||
DAGUniverse::DAGUniverse(
|
||||
const std::string& filename, bool auto_geom_ids, bool auto_mat_ids)
|
||||
const std::string& filename, bool auto_geom_ids, bool auto_mat_ids, bool use_collision_distance_cap)
|
||||
: filename_(filename), adjust_geometry_ids_(auto_geom_ids),
|
||||
adjust_material_ids_(auto_mat_ids)
|
||||
adjust_material_ids_(auto_mat_ids), use_collision_distance_cap_(use_collision_distance_cap)
|
||||
{
|
||||
set_id();
|
||||
initialize();
|
||||
}
|
||||
|
||||
DAGUniverse::DAGUniverse(std::shared_ptr<moab::DagMC> dagmc_ptr,
|
||||
const std::string& filename, bool auto_geom_ids, bool auto_mat_ids)
|
||||
const std::string& filename, bool auto_geom_ids, bool auto_mat_ids, bool use_collision_distance_cap)
|
||||
: dagmc_instance_(dagmc_ptr), filename_(filename),
|
||||
adjust_geometry_ids_(auto_geom_ids), adjust_material_ids_(auto_mat_ids)
|
||||
adjust_geometry_ids_(auto_geom_ids), adjust_material_ids_(auto_mat_ids), use_collision_distance_cap_(use_collision_distance_cap)
|
||||
{
|
||||
MaterialOverrides material_overrides;
|
||||
TemperatureOverrides temperature_overrides;
|
||||
|
|
@ -829,7 +834,7 @@ std::pair<double, int32_t> DAGCell::distance(Position r, Direction u,
|
|||
// surface idx of 1 and distance of infinity occur when no previous collisions
|
||||
// recorded
|
||||
int surf_idx = -1;
|
||||
double dist = max_distance;
|
||||
double dist = INFTY;
|
||||
|
||||
moab::EntityHandle vol = dagmc_ptr_->entity_by_index(3, dag_index_);
|
||||
moab::EntityHandle hit_surf;
|
||||
|
|
@ -838,12 +843,12 @@ std::pair<double, int32_t> DAGCell::distance(Position r, Direction u,
|
|||
double pnt[3] = {r.x, r.y, r.z};
|
||||
double dir[3] = {u.x, u.y, u.z};
|
||||
MB_CHK_ERR_CONT(
|
||||
dagmc_ptr_->ray_fire(vol, pnt, dir, hit_surf, dist, &p->history()));
|
||||
dagmc_ptr_->ray_fire(vol, pnt, dir, hit_surf, dist, &p->history(), max_distance));
|
||||
if (hit_surf != 0) {
|
||||
surf_idx =
|
||||
dag_univ->surf_idx_offset_ + dagmc_ptr_->index_by_handle(hit_surf);
|
||||
} else if (dist == INFTY && !dagmc_ptr_->is_implicit_complement(vol) ||
|
||||
is_root_universe(dag_univ->id_)) {
|
||||
} else if (max_distance == INFTY && (!dagmc_ptr_->is_implicit_complement(vol) ||
|
||||
is_root_universe(dag_univ->id_))) {
|
||||
// surface boundary conditions are ignored for projection plotting, meaning
|
||||
// that the particle may move through the graveyard (bounding) volume and
|
||||
// into the implicit complement on the other side where no intersection will
|
||||
|
|
|
|||
|
|
@ -374,7 +374,7 @@ BoundaryInfo distance_to_boundary(GeometryState& p, double max_distance)
|
|||
Cell& c {*model::cells[coord.cell()]};
|
||||
|
||||
// Find the oncoming surface in this cell and the distance to it.
|
||||
auto surface_distance = c.distance(r, u, p.surface(), &p);
|
||||
auto surface_distance = c.distance(r, u, p.surface(), &p, max_distance);
|
||||
d_surf = surface_distance.first;
|
||||
level_surf_cross = surface_distance.second;
|
||||
|
||||
|
|
|
|||
|
|
@ -284,7 +284,13 @@ void Particle::event_advance()
|
|||
|
||||
// Find distance to nearest boundary;
|
||||
// cap bvh traversal distance to collision distance
|
||||
double max_distance = std::min(collision_distance(), distance_cutoff);
|
||||
double max_distance = INFTY;
|
||||
const auto& univ = model::universes[lowest_coord().universe()];
|
||||
if (auto* dag_univ = dynamic_cast<DAGUniverse*>(univ.get())) {
|
||||
if (dag_univ->use_collision_distance_cap()) {
|
||||
max_distance = std::min(collision_distance(), distance_cutoff);
|
||||
}
|
||||
}
|
||||
boundary() = distance_to_boundary(*this, max_distance);
|
||||
|
||||
// Select smaller of the three distances
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue