18#include <AMReX_ParallelDescriptor.H>
19#include <AMReX_PlotFileUtil.H>
20#include <AMReX_iMultiFab.H>
21#include <AMReX_Reduce.H>
24#define INFO __FILE__, __func__, __LINE__
28#ifndef ALAMO_SINGLE_DEFINITION
29#define ALAMO_SINGLE_DEFINITION AMREX_ATTRIBUTE_WEAK
52void Terminate(
const char * msg,
int signal,
bool backtrace);
55void Abort (
const char * msg);
57template<
typename... Args>
60void Assert (
const char *file,
const char *func,
int line,
const char *smt,
bool pass, Args
const &... args)
65 std::ostringstream infostream;
71 std::string info = infostream.str();
74 std::ostringstream messagestream;
76 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
77 std::string message = messagestream.str();
80 std::cout << info << message << std::endl;
84 if (!pass) amrex::Abort();
89template<
typename... Args>
91void Abort (
const char *file,
const char *func,
int line, Args
const &... args)
94 if (amrex::ParallelDescriptor::IOProcessor())
96 std::ostringstream infostream;
101 std::string info = infostream.str();
103 std::ostringstream messagestream;
105 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
106 std::string message = messagestream.str();
109 std::cout << info << message << std::endl;
111 Abort(
"Fatal Error");
117template<
typename... Args>
118void ParallelAbort (std::string file, std::string func,
int line, Args
const &... args)
121 std::ostringstream infostream;
126 std::string info = infostream.str();
128 std::ostringstream messagestream;
130 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
131 std::string message = messagestream.str();
134 std::cout << info << message << std::endl;
136 Abort(
"Fatal Error");
139template<
typename... Args>
140void Message (std::string file, std::string func,
int line, Args
const &... args)
142 if (amrex::ParallelDescriptor::IOProcessor())
144 std::ostringstream infostream;
149 std::string info = infostream.str();
151 std::ostringstream messagestream;
153 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
154 std::string message = messagestream.str();
158 std::cout << info << message << std::endl;
163template<
typename... Args>
164void DebugMessage (std::string file, std::string func,
int line, Args
const &... args)
166 if (amrex::ParallelDescriptor::IOProcessor())
168 std::ostringstream infostream;
173 std::string info = infostream.str();
175 std::ostringstream messagestream;
177 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
178 std::string message = messagestream.str();
182 std::cout << info << message << std::endl;
186template<
typename... Args>
195template<
typename... Args>
196void ParallelMessage (std::string file, std::string func,
int line, Args
const &... args)
198 std::ostringstream infostream;
203 std::string info = infostream.str();
204 std::ostringstream messagestream;
206 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
207 std::string message = messagestream.str();
209 std::cout << info << message << std::endl;
212template<
typename... Args>
213void Warning (std::string file, std::string func,
int line, Args
const &... args)
215 if (amrex::ParallelDescriptor::IOProcessor())
217 std::ostringstream infostream;
222 std::string info = infostream.str();
224 std::ostringstream messagestream;
226 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
227 std::string message = messagestream.str();
231 std::cout << info << message << std::endl;
236template<
typename... Args>
237void Exception (std::string file, std::string func,
int line, Args
const &... args)
239 if (amrex::ParallelDescriptor::IOProcessor())
241 std::ostringstream infostream;
245 std::string info = infostream.str();
247 std::ostringstream messagestream;
250 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
253 std::string message = messagestream.str();
257 std::cout << info << message << std::endl;
259 std::throw_with_nested(std::runtime_error(
"IO::Exception"));
263template<
typename... Args>
265void AssertException (std::string file, std::string func,
int line, std::string smt,
bool pass, Args
const &... args)
269 if (amrex::ParallelDescriptor::IOProcessor())
271 std::ostringstream infostream;
277 std::string info = infostream.str();
280 std::ostringstream messagestream;
282 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
283 std::string message = messagestream.str();
286 std::cout << info << message << std::endl;
294template<
typename... Args>
296 std::string fullname,
297 Args
const &... args)
299 if (amrex::ParallelDescriptor::IOProcessor())
301 std::ostringstream infostream;
305 std::string info = infostream.str();
307 std::ostringstream messagestream;
310 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
313 const std::size_t nargs =
sizeof...(Args);
315 if (nargs) messagestream <<
"\n";
319 std::string message = messagestream.str();
323 std::cout << info << message << std::endl;
325 std::throw_with_nested(std::runtime_error(
"IO::ParmParse Exception"));
330std::pair<std::string,std::string>
337int Message(std::string testname);
338int Message(std::string testname,
int passed);
339int SubMessage(std::string testname,
int passed);
350void RealFillBoundary(amrex::FabArray<amrex::BaseFab<T>> &a_mf,
const amrex::Geometry &,
const int nghost=2)
353 BL_PROFILE(
"Util::RealFillBoundary");
355 else a_mf.setMultiGhost(
true);
362 BL_PROFILE(
"Util::RealFillBoundary");
364 else a_mf.setMultiGhost(
true);
368void AverageCellcenterToNode(amrex::MultiFab& node_mf,
const int &dcomp,
const amrex::MultiFab &cell_mf,
const int &scomp,
const int &ncomp);
372AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
375 return a < T(0) ? -a : a;
379AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
382 return a < b ? a : b;
386AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
389 return a > b ? a : b;
393AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
400AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
403 return value == value && value < T(1.0e300) && value > T(-1.0e300);
407AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
410 return IsFinite(value) ? value : fallback;
414AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
417 if (a * b <= T(0))
return T(0);
419 return a < T(0) ? -mag : mag;
423AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
428 return MinMod(T(0.5) * (dl + dr),
MinMod(T(2.0) * dl, T(2.0) * dr));
432AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
435 T x =
Clamp(value, T(0), T(1));
436 return x * x * x * (x * (x * T(6.0) - T(15.0)) + T(10.0));
440template <
class... Ts>
441AMREX_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)