16#include <AMReX_ParallelDescriptor.H>
17#include <AMReX_PlotFileUtil.H>
20#define INFO __FILE__, __func__, __LINE__
24#ifndef ALAMO_SINGLE_DEFINITION
25#define ALAMO_SINGLE_DEFINITION AMREX_ATTRIBUTE_WEAK
35int ReplaceAll(std::string &str,
const std::string before,
const std::string after);
36int ReplaceAll(std::string &str,
const char before,
const std::string after);
37std::string
Wrap(std::string text,
unsigned per_line);
38std::string
Join(std::vector<std::string> & vec,
char separator =
'_');
39std::vector<std::string>
Split(std::string &str,
const char token =
' ');
40bool Contains(std::string &str,
const std::string find);
44std::complex<int>
Parse(std::string);
64void Terminate(
const char * msg,
int signal,
bool backtrace);
66void Abort (
const char * msg);
68template<
typename... Args>
70void Assert (std::string file, std::string func,
int line, std::string smt,
bool pass, Args
const &... args)
74 std::ostringstream infostream;
80 std::string info = infostream.str();
83 std::ostringstream messagestream;
85 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
86 std::string message = messagestream.str();
89 std::cout << info << message << std::endl;
95template<
typename... Args>
96void Abort (std::string file, std::string func,
int line, Args
const &... args)
98 if (amrex::ParallelDescriptor::IOProcessor())
100 std::ostringstream infostream;
105 std::string info = infostream.str();
107 std::ostringstream messagestream;
109 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
110 std::string message = messagestream.str();
113 std::cout << info << message << std::endl;
115 Abort(
"Fatal Error");
118template<
typename... Args>
119void ParallelAbort (std::string file, std::string func,
int line, Args
const &... args)
122 std::ostringstream infostream;
127 std::string info = infostream.str();
129 std::ostringstream messagestream;
131 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
132 std::string message = messagestream.str();
135 std::cout << info << message << std::endl;
137 Abort(
"Fatal Error");
140template<
typename... Args>
141void Message (std::string file, std::string func,
int line, Args
const &... args)
143 if (amrex::ParallelDescriptor::IOProcessor())
145 std::ostringstream infostream;
150 std::string info = infostream.str();
152 std::ostringstream messagestream;
154 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
155 std::string message = messagestream.str();
159 std::cout << info << message << std::endl;
163template<
typename... Args>
164void ParallelMessage (std::string file, std::string func,
int line, Args
const &... args)
166 std::ostringstream infostream;
171 std::string info = infostream.str();
172 std::ostringstream messagestream;
174 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
175 std::string message = messagestream.str();
177 std::cout << info << message << std::endl;
180template<
typename... Args>
181void Warning (std::string file, std::string func,
int line, Args
const &... args)
183 if (amrex::ParallelDescriptor::IOProcessor())
185 std::ostringstream infostream;
190 std::string info = infostream.str();
192 std::ostringstream messagestream;
194 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
195 std::string message = messagestream.str();
199 std::cout << info << message << std::endl;
204template<
typename... Args>
205void Exception (std::string file, std::string func,
int line, Args
const &... args)
207 if (amrex::ParallelDescriptor::IOProcessor())
209 std::ostringstream infostream;
213 std::string info = infostream.str();
215 std::ostringstream messagestream;
218 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
221 std::string message = messagestream.str();
225 std::cout << info << message << std::endl;
227 std::throw_with_nested(std::runtime_error(
"IO::Exception"));
231template<
typename... Args>
233void AssertException (std::string file, std::string func,
int line, std::string smt,
bool pass, Args
const &... args)
237 if (amrex::ParallelDescriptor::IOProcessor())
239 std::ostringstream infostream;
245 std::string info = infostream.str();
248 std::ostringstream messagestream;
250 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
251 std::string message = messagestream.str();
254 std::cout << info << message << std::endl;
262template<
typename... Args>
264 std::string file2, std::string ,
int line2,
265 std::string fullname,
266 Args
const &... args)
268 if (amrex::ParallelDescriptor::IOProcessor())
270 std::ostringstream infostream;
274 std::string info = infostream.str();
276 std::ostringstream messagestream;
279 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
282 const std::size_t nargs =
sizeof...(Args);
284 if (nargs) messagestream <<
"\n";
289 messagestream <<
" at " << file2 <<
":" << line2;
292 std::string message = messagestream.str();
296 std::cout << info << message << std::endl;
298 std::throw_with_nested(std::runtime_error(
"IO::ParmParse Exception"));
303std::pair<std::string,std::string>
310int Message(std::string testname);
311int Message(std::string testname,
int passed);
312int SubMessage(std::string testname,
int passed);
324 BL_PROFILE(
"Util::RealFillBoundary");
325 a_mf.setMultiGhost(
true);
331 BL_PROFILE(
"Util::RealFillBoundary");
332 a_mf.setMultiGhost(
true);
337void AverageCellcenterToNode(amrex::MultiFab& node_mf,
const int &dcomp,
const amrex::MultiFab &cell_mf,
const int &scomp,
const int &ncomp);
static std::string DarkGray
static std::string LightGreen
static std::string LightGray
static std::string Yellow
static std::string LightBlue
static std::string Underlined
std::string Wrap(std::string text, unsigned per_line)
bool Contains(std::string &str, const std::string find)
std::vector< std::string > Split(std::string &str, const char delim)
std::string Join(std::vector< std::string > &vec, char separator)
int ReplaceAll(std::string &str, const std::string before, const std::string after)
std::complex< int > Parse(std::string input)
int Message(std::string testname)
int SubMessage(std::string testname, int failed)
int SubFinalMessage(int failed)
A collection of utility routines.
std::pair< std::string, std::string > CreateCleanDirectory(const std::string &path, bool callbarrier)
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 RealFillBoundary(amrex::FabArray< amrex::BaseFab< T > > &a_mf, const amrex::Geometry &)
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)
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 ParmParseException(std::string file, std::string func, int line, std::string file2, std::string, int line2, std::string fullname, 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 Exception(std::string file, std::string func, int line, Args const &... args)
void Terminate(const char *, int signal, bool)
void SignalHandler(int s)