Skip to content

Commit 9febb99

Browse files
add error checking to determine which periodic axis is specified by the user
1 parent 3109665 commit 9febb99

File tree

4 files changed

+41
-10
lines changed

4 files changed

+41
-10
lines changed

include/openmc/boundary_condition.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ class TranslationalPeriodicBC : public PeriodicBC {
144144
class RotationalPeriodicBC : public PeriodicBC {
145145
public:
146146
enum PeriodicAxis { x, y, z };
147-
RotationalPeriodicBC(int i_surf, int j_surf, PeriodicAxis axis = z);
147+
RotationalPeriodicBC(int i_surf, int j_surf, PeriodicAxis axis);
148148
double compute_periodic_rotation(
149149
double rise_1, double run_1, double rise_2, double run_2) const;
150150
void handle_particle(Particle& p, const Surface& surf) const override;

src/surface.cpp

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,8 +1334,37 @@ void read_surfaces(pugi::xml_node node)
13341334
surf1.bc_ = make_unique<TranslationalPeriodicBC>(i_surf, j_surf);
13351335
surf2.bc_ = make_unique<TranslationalPeriodicBC>(i_surf, j_surf);
13361336
} else {
1337-
surf1.bc_ = make_unique<RotationalPeriodicBC>(i_surf, j_surf);
1338-
surf2.bc_ = make_unique<RotationalPeriodicBC>(i_surf, j_surf);
1337+
// check that both normals have at least one 0 component
1338+
if (norm1.x != 0.0 && norm1.y != 0.0 && norm1.z != 0.0) {
1339+
fatal_error(fmt::format(
1340+
"The normal ({}) of the periodic surface ({}) does not contain any "
1341+
"component with a zero value. A RotationalPeriodicBC requires one "
1342+
"component which is zero for both plane normals.",
1343+
norm1, i_surf));
1344+
}
1345+
if (norm2.x != 0.0 && norm2.y != 0.0 && norm2.z != 0.0) {
1346+
fatal_error(fmt::format(
1347+
"The normal ({}) of the periodic surface ({}) does not contain any "
1348+
"component with a zero value. A RotationalPeriodicBC requires one "
1349+
"component which is zero for both plane normals.",
1350+
norm2, j_surf));
1351+
}
1352+
// find common zero component, which indicates the periodic axis
1353+
RotationalPeriodicBC::PeriodicAxis axis;
1354+
if (norm1.x == 0.0 && norm2.x == 0.0) {
1355+
axis = RotationalPeriodicBC::PeriodicAxis::x;
1356+
} else if (norm1.y == 0.0 && norm2.y == 0.0) {
1357+
axis = RotationalPeriodicBC::PeriodicAxis::y;
1358+
} else if (norm1.z == 0.0 && norm2.z == 0.0) {
1359+
axis = RotationalPeriodicBC::PeriodicAxis::z;
1360+
} else {
1361+
fatal_error(
1362+
fmt::format("There is no component which is 0.0 in both normals. This "
1363+
"indicates that the two planes are not periodic about "
1364+
"the X, Y, or Z axis, which is not supported."));
1365+
}
1366+
surf1.bc_ = make_unique<RotationalPeriodicBC>(i_surf, j_surf, axis);
1367+
surf2.bc_ = make_unique<RotationalPeriodicBC>(i_surf, j_surf, axis);
13391368
}
13401369

13411370
// If albedo data is present in albedo map, set the boundary albedo.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
k-combined:
2+
1.082283E+00 6.676373E-02

tests/regression_tests/periodic_cyls/ycyl_model/inputs_true.dat

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<?xml version='1.0' encoding='utf-8'?>
22
<model>
33
<materials>
4-
<material id="1" depletable="true">
4+
<material id="2" depletable="true">
55
<density value="19.1" units="g/cc"/>
66
<nuclide name="U235" ao="0.2"/>
77
<nuclide name="U238" ao="0.8"/>
88
</material>
99
</materials>
1010
<geometry>
11-
<cell id="1" material="1" region="1 -2 -3 4 5" universe="1"/>
12-
<surface id="1" type="y-plane" boundary="reflective" coeffs="0.0"/>
13-
<surface id="2" type="y-plane" boundary="reflective" coeffs="20.0"/>
14-
<surface id="3" type="y-cylinder" boundary="vacuum" coeffs="0.0 0.0 20.0"/>
15-
<surface id="4" type="x-plane" boundary="periodic" coeffs="0" periodic_surface_id="5"/>
16-
<surface id="5" type="plane" boundary="periodic" coeffs="-0.5773502691896257 0.0 1 0.0" periodic_surface_id="4"/>
11+
<cell id="1" material="2" region="6 -7 -8 9 10" universe="2"/>
12+
<surface id="6" type="y-plane" boundary="reflective" coeffs="0.0"/>
13+
<surface id="7" type="y-plane" boundary="reflective" coeffs="20.0"/>
14+
<surface id="8" type="y-cylinder" boundary="vacuum" coeffs="0.0 0.0 20.0"/>
15+
<surface id="9" type="x-plane" boundary="periodic" coeffs="0" periodic_surface_id="10"/>
16+
<surface id="10" type="plane" boundary="periodic" coeffs="-0.5773502691896257 0.0 1 0.0" periodic_surface_id="9"/>
1717
</geometry>
1818
<settings>
1919
<run_mode>eigenvalue</run_mode>

0 commit comments

Comments
 (0)