@@ -520,15 +520,29 @@ Geometry::growPeriodicDomain (int ngrow) const noexcept
520520void
521521Geometry::computeRoundoffDomain ()
522522{
523+ bool valid_domain = true ;
523524 for (int k = 0 ; k < AMREX_SPACEDIM; k++)
524525 {
525526 offset[k] = prob_domain.lo (k);
526527 dx[k] = prob_domain.length (k)/(Real (domain.length (k)));
527528 inv_dx[k] = 1 .0_rt/dx[k];
529+ valid_domain = valid_domain && (prob_domain.length (k) > 0 ) &&
530+ (domain.length (k) > 0 );
528531 }
529532
533+ std::stringstream ss;
534+ ss << std::setprecision (std::numeric_limits<double >::max_digits10)
535+ << prob_domain << " " << domain << " sizeof Real: "
536+ << sizeof (Real) << " sizeof ParticleReal: " << sizeof (ParticleReal);
537+ auto const error_msg = ss.str ();
538+
539+ AMREX_ALWAYS_ASSERT_WITH_MESSAGE (valid_domain, error_msg);
540+
530541 constexpr int maxiters = 200 ;
531542
543+ std::string error_msg_2 (" computeRoundoffDomain failed to converge. To help us improve, please submit a GitHub issue with the following information: " );
544+ error_msg_2.append (error_msg);
545+
532546 for (int idim = 0 ; idim < AMREX_SPACEDIM; ++idim)
533547 {
534548 int ilo = Domain ().smallEnd (idim);
@@ -539,7 +553,7 @@ Geometry::computeRoundoffDomain ()
539553 Real dxinv = InvCellSize (idim);
540554
541555 // Check that the grid is well formed and that deltax > roundoff
542- AMREX_ASSERT ((plo + ihi*CellSize (idim)) < (plo + (ihi + 1 )*CellSize (idim)));
556+ AMREX_ALWAYS_ASSERT_WITH_MESSAGE ((plo + ihi*CellSize (idim)) < (plo + (ihi + 1 )*CellSize (idim)), error_msg_2 );
543557
544558 // roundoff_lo will be the lowest value that will be inside the domain
545559 // roundoff_hi will be the highest value that will be inside the domain
@@ -571,8 +585,8 @@ Geometry::computeRoundoffDomain ()
571585 ++iters;
572586 }
573587 // The assertion on rlo_out makes sure the compiler cannot optimize it away.
574- AMREX_ALWAYS_ASSERT (rlo_out > std::numeric_limits<ParticleReal>::lowest ()
575- && iters < maxiters);
588+ AMREX_ALWAYS_ASSERT_WITH_MESSAGE (rlo_out > std::numeric_limits<ParticleReal>::lowest ()
589+ && iters < maxiters, error_msg_2 );
576590 }
577591 else
578592 {
@@ -587,8 +601,8 @@ Geometry::computeRoundoffDomain ()
587601 rlo_out = rlo;
588602 rlo = rtmp;
589603 // The assertion on rtmp makes sure the compiler cannot optimize it away.
590- AMREX_ALWAYS_ASSERT (rtmp > std::numeric_limits<ParticleReal>::lowest ()
591- && iters < maxiters);
604+ AMREX_ALWAYS_ASSERT_WITH_MESSAGE (rtmp > std::numeric_limits<ParticleReal>::lowest ()
605+ && iters < maxiters, error_msg_2 );
592606 }
593607
594608 {
@@ -618,8 +632,8 @@ Geometry::computeRoundoffDomain ()
618632 ++iters;
619633 }
620634 // The assertion on rlo_minus makes sure the compiler cannot optimize it away.
621- AMREX_ALWAYS_ASSERT (rlo_minus > std::numeric_limits<ParticleReal>::lowest ()
622- && iters < maxiters);
635+ AMREX_ALWAYS_ASSERT_WITH_MESSAGE (rlo_minus > std::numeric_limits<ParticleReal>::lowest ()
636+ && iters < maxiters, error_msg_2 );
623637 }
624638
625639 ParticleReal rhi_out;
@@ -634,8 +648,8 @@ Geometry::computeRoundoffDomain ()
634648 ++iters;
635649 }
636650 // The assertion on rhi_out makes sure the compiler cannot optimize it away.
637- AMREX_ALWAYS_ASSERT (rhi_out > std::numeric_limits<ParticleReal>::lowest ()
638- && iters < maxiters);
651+ AMREX_ALWAYS_ASSERT_WITH_MESSAGE (rhi_out > std::numeric_limits<ParticleReal>::lowest ()
652+ && iters < maxiters, error_msg_2 );
639653 }
640654 else
641655 {
@@ -653,8 +667,8 @@ Geometry::computeRoundoffDomain ()
653667 rhi_out = rhi;
654668 rhi = rtmp;
655669 // The assertion on rtmp makes sure the compiler cannot optimize it away.
656- AMREX_ALWAYS_ASSERT (rtmp > std::numeric_limits<ParticleReal>::lowest ()
657- && iters < maxiters);
670+ AMREX_ALWAYS_ASSERT_WITH_MESSAGE (rtmp > std::numeric_limits<ParticleReal>::lowest ()
671+ && iters < maxiters, error_msg_2 );
658672 }
659673
660674 {
@@ -684,8 +698,8 @@ Geometry::computeRoundoffDomain ()
684698 ++iters;
685699 }
686700 // The assertion on rhi_plus makes sure the compiler cannot optimize it away.
687- AMREX_ALWAYS_ASSERT (rhi_plus > std::numeric_limits<ParticleReal>::lowest ()
688- && iters < maxiters);
701+ AMREX_ALWAYS_ASSERT_WITH_MESSAGE (rhi_plus > std::numeric_limits<ParticleReal>::lowest ()
702+ && iters < maxiters, error_msg_2 );
689703 }
690704 }
691705}
0 commit comments