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);
54void Abort (
const char * msg);
56template<
typename... Args>
58void Assert (std::string file, std::string func,
int line, std::string smt,
bool pass, Args
const &... args)
62 std::ostringstream infostream;
68 std::string info = infostream.str();
71 std::ostringstream messagestream;
73 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
74 std::string message = messagestream.str();
77 std::cout << info << message << std::endl;
83template<
typename... Args>
84void Abort (std::string file, std::string func,
int line, Args
const &... args)
86 if (amrex::ParallelDescriptor::IOProcessor())
88 std::ostringstream infostream;
93 std::string info = infostream.str();
95 std::ostringstream messagestream;
97 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
98 std::string message = messagestream.str();
101 std::cout << info << message << std::endl;
103 Abort(
"Fatal Error");
106template<
typename... Args>
107void ParallelAbort (std::string file, std::string func,
int line, Args
const &... args)
110 std::ostringstream infostream;
115 std::string info = infostream.str();
117 std::ostringstream messagestream;
119 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
120 std::string message = messagestream.str();
123 std::cout << info << message << std::endl;
125 Abort(
"Fatal Error");
128template<
typename... Args>
129void Message (std::string file, std::string func,
int line, Args
const &... args)
131 if (amrex::ParallelDescriptor::IOProcessor())
133 std::ostringstream infostream;
138 std::string info = infostream.str();
140 std::ostringstream messagestream;
142 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
143 std::string message = messagestream.str();
147 std::cout << info << message << std::endl;
152template<
typename... Args>
153void DebugMessage (std::string file, std::string func,
int line, Args
const &... args)
155 if (amrex::ParallelDescriptor::IOProcessor())
157 std::ostringstream infostream;
162 std::string info = infostream.str();
164 std::ostringstream messagestream;
166 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
167 std::string message = messagestream.str();
171 std::cout << info << message << std::endl;
175template<
typename... Args>
184template<
typename... Args>
185void ParallelMessage (std::string file, std::string func,
int line, Args
const &... args)
187 std::ostringstream infostream;
192 std::string info = infostream.str();
193 std::ostringstream messagestream;
195 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
196 std::string message = messagestream.str();
198 std::cout << info << message << std::endl;
201template<
typename... Args>
202void Warning (std::string file, std::string func,
int line, Args
const &... args)
204 if (amrex::ParallelDescriptor::IOProcessor())
206 std::ostringstream infostream;
211 std::string info = infostream.str();
213 std::ostringstream messagestream;
215 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
216 std::string message = messagestream.str();
220 std::cout << info << message << std::endl;
225template<
typename... Args>
226void Exception (std::string file, std::string func,
int line, Args
const &... args)
228 if (amrex::ParallelDescriptor::IOProcessor())
230 std::ostringstream infostream;
234 std::string info = infostream.str();
236 std::ostringstream messagestream;
239 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
242 std::string message = messagestream.str();
246 std::cout << info << message << std::endl;
248 std::throw_with_nested(std::runtime_error(
"IO::Exception"));
252template<
typename... Args>
254void AssertException (std::string file, std::string func,
int line, std::string smt,
bool pass, Args
const &... args)
258 if (amrex::ParallelDescriptor::IOProcessor())
260 std::ostringstream infostream;
266 std::string info = infostream.str();
269 std::ostringstream messagestream;
271 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
272 std::string message = messagestream.str();
275 std::cout << info << message << std::endl;
283template<
typename... Args>
285 std::string fullname,
286 Args
const &... args)
288 if (amrex::ParallelDescriptor::IOProcessor())
290 std::ostringstream infostream;
294 std::string info = infostream.str();
296 std::ostringstream messagestream;
299 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
302 const std::size_t nargs =
sizeof...(Args);
304 if (nargs) messagestream <<
"\n";
308 std::string message = messagestream.str();
312 std::cout << info << message << std::endl;
314 std::throw_with_nested(std::runtime_error(
"IO::ParmParse Exception"));
319std::pair<std::string,std::string>
326int Message(std::string testname);
327int Message(std::string testname,
int passed);
328int SubMessage(std::string testname,
int passed);
339void RealFillBoundary(amrex::FabArray<amrex::BaseFab<T>> &a_mf,
const amrex::Geometry &,
const int nghost=2)
342 BL_PROFILE(
"Util::RealFillBoundary");
344 else a_mf.setMultiGhost(
true);
351 BL_PROFILE(
"Util::RealFillBoundary");
353 else a_mf.setMultiGhost(
true);
357void AverageCellcenterToNode(amrex::MultiFab& node_mf,
const int &dcomp,
const amrex::MultiFab &cell_mf,
const int &scomp,
const int &ncomp);
360template <
class... Ts>
361AMREX_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)
std::string GetFileName()
AMREX_FORCE_INLINE void AssertException(std::string file, std::string func, int line, std::string smt, bool pass, Args const &... args)
void Abort(const char *msg)
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_FORCE_INLINE void Assert(std::string file, std::string func, int line, std::string smt, bool pass, Args const &... args)
void CopyFileToOutputDir(std::string a_path, bool fullpath, std::string prefix)
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)
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)