Skip to content

Commit 551bf07

Browse files
authored
Simplify translational periodic boundary conditions (#3697)
1 parent dfc80c7 commit 551bf07

File tree

2 files changed

+3
-18
lines changed

2 files changed

+3
-18
lines changed

src/boundary_condition.cpp

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -129,23 +129,8 @@ TranslationalPeriodicBC::TranslationalPeriodicBC(int i_surf, int j_surf)
129129
void TranslationalPeriodicBC::handle_particle(
130130
Particle& p, const Surface& surf) const
131131
{
132-
int i_particle_surf = p.surface_index();
133-
134-
// Figure out which of the two BC surfaces were struck then find the
135-
// particle's new location and surface.
136-
Position new_r;
137-
int new_surface;
138-
if (i_particle_surf == i_surf_) {
139-
new_r = p.r() + translation_;
140-
new_surface = p.surface() > 0 ? j_surf_ + 1 : -(j_surf_ + 1);
141-
} else if (i_particle_surf == j_surf_) {
142-
new_r = p.r() - translation_;
143-
new_surface = p.surface() > 0 ? i_surf_ + 1 : -(i_surf_ + 1);
144-
} else {
145-
throw std::runtime_error(
146-
"Called BoundaryCondition::handle_particle after "
147-
"hitting a surface, but that surface is not recognized by the BC.");
148-
}
132+
auto new_r = p.r() + translation_;
133+
int new_surface = p.surface() > 0 ? j_surf_ + 1 : -(j_surf_ + 1);
149134

150135
// Handle the effects of the surface albedo on the particle's weight.
151136
BoundaryCondition::handle_albedo(p, surf);

src/surface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1357,7 +1357,7 @@ void prepare_boundary_conditions(std::set<std::pair<int, int>>& periodic_pairs,
13571357
// condition. Otherwise, it is a rotational periodic BC.
13581358
if (std::abs(1.0 - dot_prod) < FP_PRECISION) {
13591359
surf1.bc_ = make_unique<TranslationalPeriodicBC>(i_surf, j_surf);
1360-
surf2.bc_ = make_unique<TranslationalPeriodicBC>(i_surf, j_surf);
1360+
surf2.bc_ = make_unique<TranslationalPeriodicBC>(j_surf, i_surf);
13611361
} else {
13621362
// check that both normals have at least one 0 component
13631363
if (std::abs(norm1.x) > FP_PRECISION &&

0 commit comments

Comments
 (0)