20#include <AMReX_ParallelDescriptor.H>
21#include <AMReX_PlotFileUtil.H>
22#include <AMReX_iMultiFab.H>
23#include <AMReX_Reduce.H>
26#define INFO __FILE__, __func__, __LINE__
30#ifndef ALAMO_SINGLE_DEFINITION
31#define ALAMO_SINGLE_DEFINITION AMREX_ATTRIBUTE_WEAK
54void Terminate(
const char * msg,
int signal,
bool backtrace);
57void Abort (
const char * msg);
59template<
typename... Args>
62void Assert (
const char *file,
const char *func,
int line,
const char *smt,
bool pass, Args
const &... args)
67 std::ostringstream infostream;
73 std::string info = infostream.str();
76 std::ostringstream messagestream;
78 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
79 std::string message = messagestream.str();
82 std::cout << info << message << std::endl;
86 if (!pass) amrex::Abort();
91template<
typename... Args>
93void Abort (
const char *file,
const char *func,
int line, Args
const &... args)
96 if (amrex::ParallelDescriptor::IOProcessor())
98 std::ostringstream infostream;
103 std::string info = infostream.str();
105 std::ostringstream messagestream;
107 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
108 std::string message = messagestream.str();
111 std::cout << info << message << std::endl;
113 Abort(
"Fatal Error");
119template<
typename... Args>
120void ParallelAbort (std::string file, std::string func,
int line, Args
const &... args)
123 std::ostringstream infostream;
128 std::string info = infostream.str();
130 std::ostringstream messagestream;
132 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
133 std::string message = messagestream.str();
136 std::cout << info << message << std::endl;
138 Abort(
"Fatal Error");
141template<
typename... Args>
142void Message (std::string file, std::string func,
int line, Args
const &... args)
144 if (amrex::ParallelDescriptor::IOProcessor())
146 std::ostringstream infostream;
151 std::string info = infostream.str();
153 std::ostringstream messagestream;
155 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
156 std::string message = messagestream.str();
160 std::cout << info << message << std::endl;
165template<
typename... Args>
166void DebugMessage (std::string file, std::string func,
int line, Args
const &... args)
168 if (amrex::ParallelDescriptor::IOProcessor())
170 std::ostringstream infostream;
175 std::string info = infostream.str();
177 std::ostringstream messagestream;
179 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
180 std::string message = messagestream.str();
184 std::cout << info << message << std::endl;
188template<
typename... Args>
197template<
typename... Args>
198void ParallelMessage (std::string file, std::string func,
int line, Args
const &... args)
200 std::ostringstream infostream;
205 std::string info = infostream.str();
206 std::ostringstream messagestream;
208 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
209 std::string message = messagestream.str();
211 std::cout << info << message << std::endl;
214template<
typename... Args>
215void Warning (std::string file, std::string func,
int line, Args
const &... args)
217 if (amrex::ParallelDescriptor::IOProcessor())
219 std::ostringstream infostream;
224 std::string info = infostream.str();
226 std::ostringstream messagestream;
228 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
229 std::string message = messagestream.str();
233 std::cout << info << message << std::endl;
238template<
typename... Args>
239void Exception (std::string file, std::string func,
int line, Args
const &... args)
241 if (amrex::ParallelDescriptor::IOProcessor())
243 std::ostringstream infostream;
247 std::string info = infostream.str();
249 std::ostringstream messagestream;
252 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
255 std::string message = messagestream.str();
259 std::cout << info << message << std::endl;
261 std::throw_with_nested(std::runtime_error(
"IO::Exception"));
265template<
typename... Args>
267void AssertException (std::string file, std::string func,
int line, std::string smt,
bool pass, Args
const &... args)
271 if (amrex::ParallelDescriptor::IOProcessor())
273 std::ostringstream infostream;
279 std::string info = infostream.str();
282 std::ostringstream messagestream;
284 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
285 std::string message = messagestream.str();
288 std::cout << info << message << std::endl;
296template<
typename... Args>
298 std::string fullname,
299 Args
const &... args)
301 if (amrex::ParallelDescriptor::IOProcessor())
303 std::ostringstream infostream;
307 std::string info = infostream.str();
309 std::ostringstream messagestream;
312 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
315 const std::size_t nargs =
sizeof...(Args);
317 if (nargs) messagestream <<
"\n";
321 std::string message = messagestream.str();
325 std::cout << info << message << std::endl;
327 std::throw_with_nested(std::runtime_error(
"IO::ParmParse Exception"));
332std::pair<std::string,std::string>
339int Message(std::string testname);
340int Message(std::string testname,
int passed);
341int SubMessage(std::string testname,
int passed);
352void RealFillBoundary(amrex::FabArray<amrex::BaseFab<T>> &a_mf,
const amrex::Geometry &,
const int nghost=2)
355 BL_PROFILE(
"Util::RealFillBoundary");
357 else a_mf.setMultiGhost(
true);
364 BL_PROFILE(
"Util::RealFillBoundary");
366 else a_mf.setMultiGhost(
true);
370void AverageCellcenterToNode(amrex::MultiFab& node_mf,
const int &dcomp,
const amrex::MultiFab &cell_mf,
const int &scomp,
const int &ncomp);
374AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
377 return a < T(0) ? -a : a;
381AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
384 return a < b ? a : b;
388AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
391 return a > b ? a : b;
395AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
402AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
405 return value == value && value < T(1.0e300) && value > T(-1.0e300);
409AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
412 return IsFinite(value) ? value : fallback;
416AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
419 if (a * b <= T(0))
return T(0);
421 return a < T(0) ? -mag : mag;
425AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
430 return MinMod(T(0.5) * (dl + dr),
MinMod(T(2.0) * dl, T(2.0) * dr));
434AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
437 T x =
Clamp(value, T(0), T(1));
438 return x * x * x * (x * (x * T(6.0) - T(15.0)) + T(10.0));
442template <
class... Ts>
443AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
static std::string DarkGray
static std::string LightGreen
static std::string LightGray
static std::string Yellow
static std::string LightBlue
static std::string Underlined
AMREX_FORCE_INLINE int ReplaceAll(std::string &str, const std::string before, const std::string after)
int Message(std::string testname)
int SubMessage(std::string testname, int failed)
int SubFinalMessage(int failed)
void SubWarning(std::string testname)
A collection of utility routines.
std::pair< std::string, std::string > CreateCleanDirectory(const std::string &path, bool callbarrier)
void DebugMessage(std::string, std::string, int, Args const &...)
void ParallelAbort(std::string file, std::string func, int line, Args const &... args)
void ParallelMessage(std::string file, std::string func, int line, Args const &... args)
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T MCSlope(T lo, T center, T hi)
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T FiniteOr(T value, T fallback)
std::string GetFileName()
AMREX_FORCE_INLINE void AssertException(std::string file, std::string func, int line, std::string smt, bool pass, Args const &... args)
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T MinMod(T a, T b)
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T Min(T a, T b)
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void IgnoreUnused(const Ts &...)
void AverageCellcenterToNode(amrex::MultiFab &node_mf, const int &dcomp, const amrex::MultiFab &cell_mf, const int &scomp, const int &ncomp)
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool IsFinite(T value)
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T Abs(T a)
AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE void Assert(const char *file, const char *func, int line, const char *smt, bool pass, Args const &... args)
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T Clamp(T value, T lo, T hi)
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T Max(T a, T b)
void CopyFileToOutputDir(std::string a_path, bool fullpath, std::string prefix)
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T SmootherStep(T value)
void Warning(std::string file, std::string func, int line, Args const &... args)
std::pair< std::string, std::string > GetOverwrittenFile()
void Message(std::string file, std::string func, int line, Args const &... args)
AMREX_GPU_HOST_DEVICE void Abort(const char *msg)
void ParmParseException(std::string file, std::string func, int line, std::string fullname, Args const &... args)
void Exception(std::string file, std::string func, int line, Args const &... args)
void Terminate(const char *, int signal, bool)
void SignalHandler(int s)
AMREX_FORCE_INLINE void RealFillBoundary(amrex::FabArray< amrex::BaseFab< T > > &a_mf, const amrex::Geometry &, const int nghost=2)