RCLGQ2LZMFVPBPTU2G55DJ6HZPOGGTPZRZCY54VGP6YLHANJ2LAQC WE6MDRN5SPK3THM4COLQFE3IUWBCQ5ZYUIAUCBJAZVEMMOVTNBOAC 722HZ7UFINNE3YKSYKP2NHZ5XEG5QQLQHSKC7PREJZR3EX6RDYUAC UUGQGVC4WEKN64WAP7F5QPS2UHGQB5ZLMFRIYNWKMIEBDO3QRX4AC BVR7DVINVPQG7PA6Z7QYVYNQ43YZL7XCC6AOMSMWMGAAB2Q43STAC U77PE56ICORZNQW33NXGSEMW7GDHCSSZ4EXB6OHBJSHEG6WHYSSQC ORAAQXS3UNKXYDJBCTHNEIDJIZDHWMM5EVCZKVMFRKQK2NIQNJGAC AEVGZIZEUIC52MCK3J4V547YEV2R4YQL3JUJW7FSP4R34PSZ43DAC #include <AMReX.hxx>#include <io.hxx>#include <cctk.h>#include <cctk_Arguments.h>#include <cctk_Parameters.h>#include <AMReX.H>#include <AMReX_PlotFileUtil.H>#include <cctype>#include <memory>#include <regex>#include <sstream>#include <string>#include <string>#include <type_traits>#include <utility>namespace AMReX {using namespace amrex;using namespace std;int OutputGH(const cGH *restrict cctkGH) {DECLARE_CCTK_ARGUMENTS;DECLARE_CCTK_PARAMETERS;int count_vars = 0;const int numgroups = CCTK_NumGroups();for (int gi = 0; gi < numgroups; ++gi) {auto &restrict groupdata = ghext->groupdata.at(gi);string groupname = unique_ptr<char>(CCTK_GroupName(gi)).get();groupname = regex_replace(groupname, regex("::"), "-");for (auto &c : groupname)c = tolower(c);ostringstream buf;buf << "wavetoy/" << groupname << "." << setw(6) << setfill('0')<< cctk_iteration;string filename = buf.str();Vector<string> varnames(groupdata.numvars * groupdata.numtimelevels);for (int tl = 0; tl < groupdata.numtimelevels; ++tl) {for (int n = 0; n < groupdata.numvars; ++n) {ostringstream buf;buf << CCTK_VarName(groupdata.firstvarindex + n);for (int i = 0; i < tl; ++i)buf << "_p";varnames.at(tl * groupdata.numvars + n) = buf.str();}}// TODO: Output only current time level. This might require having one// mfab per time level// TODO: Output everything into a single fileWriteSingleLevelPlotfile(filename, groupdata.mfab, varnames, ghext->geom,cctk_time, cctk_iteration);count_vars += groupdata.numvars;}return count_vars;}} // namespace AMReX
#ifndef IO_HXX#define IO_HXX#include <cctk.h>namespace AMReX {int OutputGH(const cGH *cctkGH);} // namespace AMReX#endif // #ifndef IO_HXX
extern "C" void WaveToyAMReX_Output(CCTK_ARGUMENTS) {DECLARE_CCTK_ARGUMENTS;DECLARE_CCTK_PARAMETERS;// Output phiconst int numgroups = CCTK_NumGroups();for (int gi = 0; gi < numgroups; ++gi) {auto &restrict groupdata = ghext->groupdata.at(gi);
string groupname = unique_ptr<char>(CCTK_GroupName(gi)).get();groupname = regex_replace(groupname, regex("::"), "-");for (auto &c : groupname)c = tolower(c);ostringstream buf;buf << "wavetoy/" << groupname << "." << setw(6) << setfill('0')<< cctk_iteration;string filename = buf.str();Vector<string> varnames(groupdata.numvars * groupdata.numtimelevels);for (int tl = 0; tl < groupdata.numtimelevels; ++tl) {for (int n = 0; n < groupdata.numvars; ++n) {ostringstream buf;buf << CCTK_VarName(groupdata.firstvarindex + n);for (int i = 0; i < tl; ++i)buf << "_p";varnames.at(tl * groupdata.numvars + n) = buf.str();}}WriteSingleLevelPlotfile(filename, groupdata.mfab, varnames, ghext->geom,cctk_time, cctk_iteration);}}