From e584b9c9185698f62bdeadb4dc6fd35a31d9029b Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 14 Apr 2021 09:27:08 -0500 Subject: [PATCH 1/3] Prevent divide-by-zero in bins_crossed methods --- src/mesh.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mesh.cpp b/src/mesh.cpp index 19cbeae10..16ce630ae 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -594,6 +594,7 @@ void StructuredMesh::bins_crossed(const Particle& p, std::vector& bins, // Compute the length of the entire track. double total_distance = (r - last_r).norm(); + if (total_distance == 0.0) return; // While determining if this track intersects the mesh, offset the starting // and ending coords by a bit. This avoid finite-precision errors that can @@ -1713,6 +1714,7 @@ MOABMesh::bins_crossed(const Particle& p, moab::CartVect dir(u.x, u.y, u.z); double track_len = (r1 - r0).length(); + if (track_len == 0.0) return; r0 -= TINY_BIT * dir; r1 += TINY_BIT * dir; From b489cd628f243d3ad8fb8f53719826e534a490e7 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 14 Apr 2021 09:44:12 -0500 Subject: [PATCH 2/3] Support periodic boundaries in rectangular_prism --- openmc/model/funcs.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/openmc/model/funcs.py b/openmc/model/funcs.py index 00a092cc3..53f3a4b2a 100644 --- a/openmc/model/funcs.py +++ b/openmc/model/funcs.py @@ -175,10 +175,17 @@ def rectangular_prism(width, height, axis='z', origin=(0., 0.), max_x1 = plane(x1, 'maximum', width/2 + origin[0]) min_x2 = plane(x2, 'minimum', -height/2 + origin[1]) max_x2 = plane(x2, 'maximum', height/2 + origin[1]) + if boundary_type == 'periodic': + min_x1.periodic_surface = max_x1 + min_x2.periodic_surface = max_x2 prism = +min_x1 & -max_x1 & +min_x2 & -max_x2 # Handle rounded corners if given if corner_radius > 0.: + if boundary_type == 'periodic': + raise ValueError('Periodic boundary conditions not permitted when ' + 'rounded corners are used.') + args = {'R': corner_radius, 'boundary_type': boundary_type} args[x1 + '0'] = origin[0] - width/2 + corner_radius From 977dfd62acd1930325a6edb2f024d4b7347e8822 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Thu, 15 Apr 2021 07:31:56 -0500 Subject: [PATCH 3/3] Add action to fix /etc/hosts --- .github/actions/fix-etc-hosts/action.yml | 18 ++++++++++++++++++ .github/workflows/ci.yml | 5 +++-- 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 .github/actions/fix-etc-hosts/action.yml diff --git a/.github/actions/fix-etc-hosts/action.yml b/.github/actions/fix-etc-hosts/action.yml new file mode 100644 index 000000000..15efcaed2 --- /dev/null +++ b/.github/actions/fix-etc-hosts/action.yml @@ -0,0 +1,18 @@ +name: Fix /etc/hosts +description: | + Workaround for + "Reverse name lookup is broken for current hostname in ubuntu-latest VMs", + reported as https://github.com/actions/virtual-environments/issues/3185 +runs: + using: composite + steps: + - run: | + if [[ "$OSTYPE" == "linux-gnu"* ]]; then + # Ensure that reverse lookups for current hostname are handled properly + # Add the current IP address, long hostname and short hostname record to /etc/hosts file + eth0_ip_addr=$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1) + hostname_fqdn=$(hostname -f) + hostname_short=$(hostname -s) + echo -e "${eth0_ip_addr}\t${hostname_fqdn} ${hostname_short}" | sudo tee -a /etc/hosts + fi + shell: bash diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 499d241b7..1f4bff233 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,8 +76,9 @@ jobs: LIBMESH: ${{ matrix.libmesh }} steps: - - - uses: actions/checkout@v2 + - uses: actions/checkout@v2 + + - uses: ./.github/actions/fix-etc-hosts - name: Set up Python ${{ matrix.python-version }}