mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
Move all BCs to the new BoundaryCondtion class
This commit is contained in:
parent
05ea9ea585
commit
1d07f49861
4 changed files with 38 additions and 27 deletions
|
|
@ -247,7 +247,8 @@ public:
|
|||
void cross_reflective_bc(const Surface& surf, Direction new_u);
|
||||
|
||||
//! Cross a periodic boundary condition.
|
||||
void cross_periodic_bc(const Surface& surf);
|
||||
void cross_periodic_bc(const Surface& surf, Position new_r, Direction new_u,
|
||||
int new_surface);
|
||||
|
||||
//! mark a particle as lost and create a particle restart file
|
||||
//! \param message A warning message to display
|
||||
|
|
|
|||
|
|
@ -3,6 +3,12 @@
|
|||
|
||||
namespace openmc {
|
||||
|
||||
void
|
||||
VacuumBC::handle_particle(Particle& p, const Surface& surf) const
|
||||
{
|
||||
p.cross_vacuum_bc(surf);
|
||||
}
|
||||
|
||||
void
|
||||
ReflectiveBC::handle_particle(Particle& p, const Surface& surf) const
|
||||
{
|
||||
|
|
@ -21,9 +27,26 @@ WhiteBC::handle_particle(Particle& p, const Surface& surf) const
|
|||
p.cross_reflective_bc(surf, u);
|
||||
}
|
||||
|
||||
//void
|
||||
//PeriodicBC::handle_particle(Particle& p, const Surface& surf) const
|
||||
//{
|
||||
//}
|
||||
void
|
||||
PeriodicBC::handle_particle(Particle& p, const Surface& surf) const
|
||||
{
|
||||
// Get a pointer to the partner periodic surface
|
||||
auto surf_p = dynamic_cast<const PeriodicSurface*>(&surf);
|
||||
auto other = dynamic_cast<const PeriodicSurface*>(
|
||||
model::surfaces[surf_p->i_periodic_].get());
|
||||
|
||||
// Compute the new particle location and direction
|
||||
Position r {p.r()};
|
||||
Direction u {p.u()};
|
||||
bool rotational = other->periodic_translate(surf_p, r, u);
|
||||
|
||||
// Pick the particle's new surface
|
||||
// TODO: off-by-one
|
||||
int new_surface = rotational ?
|
||||
surf_p->i_periodic_ + 1 :
|
||||
((p.surface_ > 0) ? surf_p->i_periodic_ + 1 : -(surf_p->i_periodic_ + 1));
|
||||
|
||||
p.cross_periodic_bc(surf, r, u, new_surface);
|
||||
}
|
||||
|
||||
} // namespace openmc
|
||||
|
|
|
|||
|
|
@ -413,23 +413,9 @@ Particle::cross_surface()
|
|||
write_message(1, " Crossing surface {}", surf->id_);
|
||||
}
|
||||
|
||||
if (surf->bc_ == Surface::BoundaryType::VACUUM && (settings::run_mode != RunMode::PLOTTING)) {
|
||||
|
||||
cross_vacuum_bc(*surf);
|
||||
|
||||
return;
|
||||
|
||||
} else if ((surf->bc_ == Surface::BoundaryType::REFLECT ||
|
||||
surf->bc_ == Surface::BoundaryType::WHITE)
|
||||
&& (settings::run_mode != RunMode::PLOTTING)) {
|
||||
|
||||
// Handle any applicable boundary conditions.
|
||||
if (surf->new_bc_ && settings::run_mode != RunMode::PLOTTING) {
|
||||
surf->new_bc_->handle_particle(*this, *surf);
|
||||
|
||||
return;
|
||||
|
||||
} else if (surf->bc_ == Surface::BoundaryType::PERIODIC && settings::run_mode != RunMode::PLOTTING) {
|
||||
cross_periodic_bc(*surf);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -570,7 +556,8 @@ Particle::cross_reflective_bc(const Surface& surf, Direction new_u)
|
|||
}
|
||||
|
||||
void
|
||||
Particle::cross_periodic_bc(const Surface& surf)
|
||||
Particle::cross_periodic_bc(const Surface& surf, Position new_r,
|
||||
Direction new_u, int new_surface)
|
||||
{
|
||||
// Do not handle periodic boundary conditions on lower universes
|
||||
if (n_coord_ != 1) {
|
||||
|
|
@ -596,13 +583,11 @@ Particle::cross_periodic_bc(const Surface& surf)
|
|||
model::surfaces[surf_p->i_periodic_].get());
|
||||
|
||||
// Adjust the particle's location and direction.
|
||||
bool rotational = other->periodic_translate(surf_p, this->r(), this->u());
|
||||
r() = new_r;
|
||||
u() = new_u;
|
||||
|
||||
// Reassign particle's surface
|
||||
// TODO: off-by-one
|
||||
surface_ = rotational ?
|
||||
surf_p->i_periodic_ + 1 :
|
||||
((surface_ > 0) ? surf_p->i_periodic_ + 1 : -(surf_p->i_periodic_ + 1));
|
||||
surface_ = new_surface;
|
||||
|
||||
// Figure out what cell particle is in now
|
||||
n_coord_ = 1;
|
||||
|
|
|
|||
|
|
@ -130,6 +130,7 @@ Surface::Surface(pugi::xml_node surf_node)
|
|||
|
||||
} else if (surf_bc == "vacuum") {
|
||||
bc_ = BoundaryType::VACUUM;
|
||||
new_bc_ = std::make_shared<VacuumBC>();
|
||||
|
||||
} else if (surf_bc == "reflective" || surf_bc == "reflect"
|
||||
|| surf_bc == "reflecting") {
|
||||
|
|
@ -140,6 +141,7 @@ Surface::Surface(pugi::xml_node surf_node)
|
|||
new_bc_ = std::make_shared<WhiteBC>();
|
||||
} else if (surf_bc == "periodic") {
|
||||
bc_ = BoundaryType::PERIODIC;
|
||||
new_bc_ = std::make_shared<PeriodicBC>();
|
||||
} else {
|
||||
fatal_error(fmt::format("Unknown boundary condition \"{}\" specified "
|
||||
"on surface {}", surf_bc, id_));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue