From 197009548adb258f749f9e9bbc4e4000b7648982 Mon Sep 17 00:00:00 2001 From: Candace Gilet Date: Tue, 8 Oct 2024 19:06:11 +0200 Subject: [PATCH] For certain 2D EB geometries, fix out of bounds access in Print (#137) statement --- src/embedded_boundaries/eb_annulus.cpp | 14 ++++++++++---- src/embedded_boundaries/eb_cyl_tuscan.cpp | 14 ++++++++++---- src/embedded_boundaries/eb_sphere.cpp | 5 ++++- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/embedded_boundaries/eb_annulus.cpp b/src/embedded_boundaries/eb_annulus.cpp index 9779b4b19..51ac551ae 100644 --- a/src/embedded_boundaries/eb_annulus.cpp +++ b/src/embedded_boundaries/eb_annulus.cpp @@ -55,10 +55,16 @@ void incflo::make_eb_annulus() amrex::Print() << " Direction: " << direction << std::endl; amrex::Print() << " Outer radius: " << outer_radius << std::endl; amrex::Print() << " Inner radius: " << inner_radius << std::endl; - amrex::Print() << " Outer center: " - << outer_center[0] << ", " << outer_center[1] << ", " << outer_center[2] << std::endl; - amrex::Print() << " Inner center: " - << inner_center[0] << ", " << inner_center[1] << ", " << inner_center[2] << std::endl; + amrex::Print() << " Outer center: " << outer_center[0] << ", " << outer_center[1] +#if (AMREX_SPACEDIM ==3) + << ", " << outer_center[2] +#endif + << std::endl; + amrex::Print() << " Inner center: " << inner_center[0] << ", " << inner_center[1] +#if (AMREX_SPACEDIM ==3) + << ", " << inner_center[2] +#endif + << std::endl; amrex::Print() << " Offset: " << offset << std::endl; amrex::Print() << " Smallest gap: " << smallest_gap_width << std::endl; amrex::Print() << " Standoff: " << standoff << std::endl; diff --git a/src/embedded_boundaries/eb_cyl_tuscan.cpp b/src/embedded_boundaries/eb_cyl_tuscan.cpp index 590645857..9d0de4c9b 100644 --- a/src/embedded_boundaries/eb_cyl_tuscan.cpp +++ b/src/embedded_boundaries/eb_cyl_tuscan.cpp @@ -51,15 +51,21 @@ void incflo::make_eb_cyl_tuscan() amrex::Print() << " Direction: " << direction1 << std::endl; amrex::Print() << " Height: " << height1 << std::endl; amrex::Print() << " Radius: " << radius1 << std::endl; - amrex::Print() << " Center: " - << center1[0] << ", " << center1[1] << ", " << center1[2] << std::endl; + amrex::Print() << " Center: " << center1[0] << ", " << center1[1] +#if (AMREX_SPACEDIM == 3) + << ", " << center1[2] +#endif + << std::endl; amrex::Print() << " CYLINDER 2" << std::endl; amrex::Print() << " Direction: " << direction2 << std::endl; amrex::Print() << " Height: " << height2 << std::endl; amrex::Print() << " Radius: " << radius2 << std::endl; - amrex::Print() << " Center: " - << center2[0] << ", " << center2[1] << ", " << center2[2] << std::endl; + amrex::Print() << " Center: " << center2[0] << ", " << center2[1] +#if (AMREX_SPACEDIM == 3) + << ", " << center2[2] +#endif + << std::endl; // Build the implicit function as a union of two cylinders EB2::CylinderIF cyl1(radius1, height1, direction1, center1, true); diff --git a/src/embedded_boundaries/eb_sphere.cpp b/src/embedded_boundaries/eb_sphere.cpp index 9fc22bb73..cecf2246b 100644 --- a/src/embedded_boundaries/eb_sphere.cpp +++ b/src/embedded_boundaries/eb_sphere.cpp @@ -31,7 +31,10 @@ void incflo::make_eb_sphere() amrex::Print() << " " << std::endl; amrex::Print() << " Internal Flow: " << inside << std::endl; amrex::Print() << " Radius: " << radius << std::endl; - amrex::Print() << " Center: " << center[0] << ", " << center[1] << ", " << center[2] + amrex::Print() << " Center: " << center[0] << ", " << center[1] +#if (AMREX_SPACEDIM == 3) + << ", " << center[2] +#endif << std::endl; // Build the sphere implicit function