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
35 int ReplaceAll(std::string &str,
const std::string before,
const std::string after);
36 int ReplaceAll(std::string &str,
const char before,
const std::string after);
37 std::string
Wrap(std::string text,
unsigned per_line);
38 std::string
Join(std::vector<std::string> & vec,
char separator =
'_');
39 std::vector<std::string>
Split(std::string &str,
const char token =
' ');
40 bool Contains(std::string &str,
const std::string find);
44 std::complex<int>
Parse(std::string);
48 void CopyFileToOutputDir(std::string a_path,
bool fullpath =
true, std::string prefix =
"");
59 void Terminate(
const char * msg,
int signal,
bool backtrace);
61 void Abort (
const char * msg);
63 template<
typename... Args>
65 void Assert (std::string file, std::string func,
int line, std::string smt,
bool pass, Args
const &... args)
69 std::ostringstream infostream;
74 std::string info = infostream.str();
77 std::ostringstream messagestream;
79 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
80 std::string message = messagestream.str();
83 std::cout << info << message << std::endl;
89 template<
typename... Args>
90 void Abort (std::string file, std::string func,
int line, Args
const &... args)
92 if (amrex::ParallelDescriptor::IOProcessor())
94 std::ostringstream infostream;
98 std::string info = infostream.str();
100 std::ostringstream messagestream;
102 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
103 std::string message = messagestream.str();
106 std::cout << info << message << std::endl;
108 Abort(
"Fatal Error");
111 template<
typename... Args>
112 void ParallelAbort (std::string file, std::string func,
int line, Args
const &... args)
115 std::ostringstream infostream;
119 std::string info = infostream.str();
121 std::ostringstream messagestream;
123 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
124 std::string message = messagestream.str();
127 std::cout << info << message << std::endl;
129 Abort(
"Fatal Error");
132 template<
typename... Args>
133 void Message (std::string file, std::string func,
int line, Args
const &... args)
135 if (amrex::ParallelDescriptor::IOProcessor())
137 std::ostringstream infostream;
141 std::string info = infostream.str();
143 std::ostringstream messagestream;
145 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
146 std::string message = messagestream.str();
150 std::cout << info << message << std::endl;
154 template<
typename... Args>
155 void ParallelMessage (std::string file, std::string func,
int line, Args
const &... args)
157 std::ostringstream infostream;
161 std::string info = infostream.str();
162 std::ostringstream messagestream;
164 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
165 std::string message = messagestream.str();
167 std::cout << info << message << std::endl;
170 template<
typename... Args>
171 void Warning (std::string file, std::string func,
int line, Args
const &... args)
173 if (amrex::ParallelDescriptor::IOProcessor())
175 std::ostringstream infostream;
179 std::string info = infostream.str();
181 std::ostringstream messagestream;
183 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
184 std::string message = messagestream.str();
188 std::cout << info << message << std::endl;
193 template<
typename... Args>
194 void Exception (std::string file, std::string func,
int line, Args
const &... args)
196 if (amrex::ParallelDescriptor::IOProcessor())
198 std::ostringstream infostream;
201 std::string info = infostream.str();
203 std::ostringstream messagestream;
206 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
209 std::string message = messagestream.str();
213 std::cout << info << message << std::endl;
215 std::throw_with_nested(std::runtime_error(
"IO::Exception"));
219 template<
typename... Args>
221 void AssertException (std::string file, std::string func,
int line, std::string smt,
bool pass, Args
const &... args)
225 if (amrex::ParallelDescriptor::IOProcessor())
227 std::ostringstream infostream;
232 std::string info = infostream.str();
235 std::ostringstream messagestream;
237 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
238 std::string message = messagestream.str();
241 std::cout << info << message << std::endl;
249 template<
typename... Args>
251 std::string file2, std::string ,
int line2,
252 std::string fullname,
253 Args
const &... args)
255 if (amrex::ParallelDescriptor::IOProcessor())
257 std::ostringstream infostream;
260 std::string info = infostream.str();
262 std::ostringstream messagestream;
265 (void)List{0, ( (void)(messagestream << args), 0 ) ... };
268 const std::size_t nargs =
sizeof...(Args);
270 if (nargs) messagestream <<
"\n";
274 messagestream <<
" at " << file2 <<
":" << line2;
277 std::string message = messagestream.str();
281 std::cout << info << message << std::endl;
283 std::throw_with_nested(std::runtime_error(
"IO::ParmParse Exception"));
288 std::pair<std::string,std::string>
295 int Message(std::string testname);
296 int Message(std::string testname,
int passed);
297 int SubMessage(std::string testname,
int passed);
309 BL_PROFILE(
"Util::RealFillBoundary");
310 a_mf.setMultiGhost(
true);
316 BL_PROFILE(
"Util::RealFillBoundary");
317 a_mf.setMultiGhost(
true);
322 void AverageCellcenterToNode(amrex::MultiFab& node_mf,
const int &dcomp,
const amrex::MultiFab &cell_mf,
const int &scomp,
const int &ncomp);