18#include <AMReX_ParallelDescriptor.H>
19#include <AMReX_PlotFileUtil.H>
20#include <AMReX_iMultiFab.H>
23#define INFO __FILE__, __func__, __LINE__
27#ifndef ALAMO_SINGLE_DEFINITION
28#define ALAMO_SINGLE_DEFINITION AMREX_ATTRIBUTE_WEAK
51void Terminate(
const char * msg,
int signal,
bool backtrace);
53void Abort (
const char * msg);
55template<
typename... Args>
57void Assert (std::string file, std::string func,
int line, std::string smt,
bool pass, Args
const &... args)
61 std::ostringstream infostream;
67 std::string info = infostream.str();
70 std::ostringstream messagestream;
72 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
73 std::string message = messagestream.str();
76 std::cout << info << message << std::endl;
82template<
typename... Args>
83void Abort (std::string file, std::string func,
int line, Args
const &... args)
85 if (amrex::ParallelDescriptor::IOProcessor())
87 std::ostringstream infostream;
92 std::string info = infostream.str();
94 std::ostringstream messagestream;
96 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
97 std::string message = messagestream.str();
100 std::cout << info << message << std::endl;
102 Abort(
"Fatal Error");
105template<
typename... Args>
106void ParallelAbort (std::string file, std::string func,
int line, Args
const &... args)
109 std::ostringstream infostream;
114 std::string info = infostream.str();
116 std::ostringstream messagestream;
118 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
119 std::string message = messagestream.str();
122 std::cout << info << message << std::endl;
124 Abort(
"Fatal Error");
127template<
typename... Args>
128void Message (std::string file, std::string func,
int line, Args
const &... args)
130 if (amrex::ParallelDescriptor::IOProcessor())
132 std::ostringstream infostream;
137 std::string info = infostream.str();
139 std::ostringstream messagestream;
141 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
142 std::string message = messagestream.str();
146 std::cout << info << message << std::endl;
151template<
typename... Args>
152void DebugMessage (std::string file, std::string func,
int line, Args
const &... args)
154 if (amrex::ParallelDescriptor::IOProcessor())
156 std::ostringstream infostream;
161 std::string info = infostream.str();
163 std::ostringstream messagestream;
165 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
166 std::string message = messagestream.str();
170 std::cout << info << message << std::endl;
174template<
typename... Args>
183template<
typename... Args>
184void ParallelMessage (std::string file, std::string func,
int line, Args
const &... args)
186 std::ostringstream infostream;
191 std::string info = infostream.str();
192 std::ostringstream messagestream;
194 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
195 std::string message = messagestream.str();
197 std::cout << info << message << std::endl;
200template<
typename... Args>
201void Warning (std::string file, std::string func,
int line, Args
const &... args)
203 if (amrex::ParallelDescriptor::IOProcessor())
205 std::ostringstream infostream;
210 std::string info = infostream.str();
212 std::ostringstream messagestream;
214 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
215 std::string message = messagestream.str();
219 std::cout << info << message << std::endl;
224template<
typename... Args>
225void Exception (std::string file, std::string func,
int line, Args
const &... args)
227 if (amrex::ParallelDescriptor::IOProcessor())
229 std::ostringstream infostream;
233 std::string info = infostream.str();
235 std::ostringstream messagestream;
238 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
241 std::string message = messagestream.str();
245 std::cout << info << message << std::endl;
247 std::throw_with_nested(std::runtime_error(
"IO::Exception"));
251template<
typename... Args>
253void AssertException (std::string file, std::string func,
int line, std::string smt,
bool pass, Args
const &... args)
257 if (amrex::ParallelDescriptor::IOProcessor())
259 std::ostringstream infostream;
265 std::string info = infostream.str();
268 std::ostringstream messagestream;
270 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
271 std::string message = messagestream.str();
274 std::cout << info << message << std::endl;
282template<
typename... Args>
284 std::string fullname,
285 Args
const &... args)
287 if (amrex::ParallelDescriptor::IOProcessor())
289 std::ostringstream infostream;
293 std::string info = infostream.str();
295 std::ostringstream messagestream;
298 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
301 const std::size_t nargs =
sizeof...(Args);
303 if (nargs) messagestream <<
"\n";
307 std::string message = messagestream.str();
311 std::cout << info << message << std::endl;
313 std::throw_with_nested(std::runtime_error(
"IO::ParmParse Exception"));
318std::pair<std::string,std::string>
325int Message(std::string testname);
326int Message(std::string testname,
int passed);
327int SubMessage(std::string testname,
int passed);
338void RealFillBoundary(amrex::FabArray<amrex::BaseFab<T>> &a_mf,
const amrex::Geometry &,
const int nghost=2)
341 BL_PROFILE(
"Util::RealFillBoundary");
343 else a_mf.setMultiGhost(
true);
350 BL_PROFILE(
"Util::RealFillBoundary");
352 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)