Skip to content

Commit 4d09691

Browse files
authored
Geometry: Exceptions (#5219)
## Summary We use AMReX interactively with `amrex.throw_exception = true` to be able to handle user errors or convergence issues and act on them. In Geometry, some methods are defined `noexcept` which breaks exception propagation in ImpactX BLAST-ImpactX/impactx#1348 and still aborts the process as a consequence. This removes the `noexcept` where they are not guaranteed to be true at runtime. First seen in `computeRoundoffDomain` which is called from a couple of places. Performance impact for this host-side code should be minimal / not a problem. ## Additional background Throwing an actual abort in a Python script will abort the whole interpreter, resetting all its state, terminating the process. That is a big problem in interactive usage, e.g., Jupyter Notebooks, but also for general C++ - Python and back error handling logic. BLAST-ImpactX/impactx#1350 ## Checklist The proposed changes: - [x] fix a bug or incorrect behavior in AMReX - [ ] add new capabilities to AMReX - [ ] changes answers in the test suite to more than roundoff level - [ ] are likely to significantly affect the results of downstream AMReX users - [ ] include documentation in the code and/or rst files, if appropriate
1 parent f4a778d commit 4d09691

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

Src/Base/AMReX_Geometry.H

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public:
148148
* \param is_per pointer to memory space specifying periodicity in each coordinate direction.
149149
* Optional. Default is non-periodic.
150150
*/
151-
void define (const Box& dom, const RealBox* rb = nullptr, int coord = -1, int const* is_per = nullptr) noexcept;
151+
void define (const Box& dom, const RealBox* rb = nullptr, int coord = -1, int const* is_per = nullptr);
152152

153153
/**
154154
* Defines a geometry object that describes the problem domain and coordinate system for rectangular problem
@@ -165,12 +165,12 @@ public:
165165
* \param is_per amrex::Array specifying periodicity in each coordinate direction. Optional.
166166
* Default is non-periodic.
167167
*/
168-
void define (const Box& dom, const RealBox& rb, int coord, Array<int,AMREX_SPACEDIM> const& is_per) noexcept;
168+
void define (const Box& dom, const RealBox& rb, int coord, Array<int,AMREX_SPACEDIM> const& is_per);
169169

170170
//! Returns the problem domain.
171171
[[nodiscard]] const RealBox& ProbDomain () const noexcept { return prob_domain; }
172172
//! Sets the problem domain.
173-
void ProbDomain (const RealBox& rb) noexcept
173+
void ProbDomain (const RealBox& rb)
174174
{
175175
prob_domain = rb;
176176
computeRoundoffDomain();
@@ -210,7 +210,7 @@ public:
210210
//! Returns our rectangular domain.
211211
[[nodiscard]] const Box& Domain () const noexcept { return domain; }
212212
//! Sets our rectangular domain.
213-
void Domain (const Box& bx) noexcept
213+
void Domain (const Box& bx)
214214
{
215215
AMREX_ASSERT(bx.cellCentered());
216216
domain = bx;

Src/Base/AMReX_Geometry.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ Geometry::Geometry (const Box& dom, const RealBox& rb, int coord,
6161

6262
void
6363
Geometry::define (const Box& dom, const RealBox& rb, int coord,
64-
Array<int,AMREX_SPACEDIM> const& is_per) noexcept
64+
Array<int,AMREX_SPACEDIM> const& is_per)
6565
{
6666
define(dom, &rb, coord, is_per.data());
6767
}
6868

6969
void
7070
Geometry::define (const Box& dom, const RealBox* rb, int coord,
71-
int const* is_per) noexcept
71+
int const* is_per)
7272
{
7373
AMREX_ASSERT(dom.cellCentered());
7474

0 commit comments

Comments
 (0)