69int main(
int argc,
char** argv) {
71 std::fprintf(stderr,
"usage: vofmom_probe DIR\n");
74 const std::string dir = argv[1];
75 Kokkos::initialize(argc, argv);
79 double dth = 0, rg = 0, rl = 0, weps = 0, cfl = 0;
81 std::ifstream m(dir +
"/meta.txt");
82 if (!(m >> n >> dth >> step >> rg >> rl >> weps >> cfl >> muscl))
83 throw std::runtime_error(
"bad meta.txt");
85 const long len =
static_cast<long>(n) * n * n;
87 w.init(n, n, n, 1.0, 3);
89 w.interfaceLocalCfl =
true;
91 const I3 e = w.extent();
92 const int g = w.ghost();
93 w.exchange = [e, g](
SField f) { vf::periodicFill(f, e, g,
true,
true,
true); };
95 putInner(w.colour(), e, g, n, readBin(dir +
"/C.bin", len), 0, 0, 0);
96 const char* vn[3] = {
"/u.bin",
"/v.bin",
"/w.bin"};
97 for (
int d = 0; d < 3; ++d)
98 putInner(w.faceVel(d), e, g, n, readBin(dir + vn[d], len), d == 0, d == 1, d == 2);
99 w.exchange(w.colour());
100 for (
int d = 0; d < 3; ++d)
101 w.exchange(w.faceVel(d));
103 vf::MomentumConsistentAdvector mom;
105 mom.momentumScheme = muscl != 0 ? vf::MomentumScheme::MusclMixed : vf::MomentumScheme::Upwind;
108 mom.buildShiftedColour(w);
109 for (
int c = 0; c < 3; ++c)
110 writeBin(dir +
"/Ce" + std::to_string(c) +
"_seed.bin",
111 getInner(mom.shiftedColour(c), e, g, n));
113 mom.advect(w, dth, step);
114 for (
int c = 0; c < 3; ++c) {
115 writeBin(dir +
"/Ce" + std::to_string(c) +
".bin", getInner(mom.shiftedColour(c), e, g, n));
116 writeBin(dir +
"/ua" + std::to_string(c) +
".bin",
117 getInner(mom.advectedVelocity(c), e, g, n));
119 writeBin(dir +
"/Cnew.bin", getInner(w.colour(), e, g, n));
120 const auto dg = mom.diagnostics();
122 "VOFMOM_PROBE n=%d step=%ld floored=%ld clamped=%ld minRhoC=%.6e sumM0=%.17g "
124 n, step, dg.floored, mom.clampedFluxes(), dg.minRhoC, dg.sumM0[0], dg.sumM[0]);