int main(int argc, char **argv) { if (argc < 8) { fprintf(stderr, "Usage: %s <dataname> <ts> <tl> <gvid0> <gvid1> <gvid2> <gvid3>\n", argv[0]); return EXIT_FAILURE; } const std::string dataname = argv[1]; const int ts = atoi(argv[2]), tl = atoi(argv[3]); const int gvid0 = atoi(argv[4]), gvid1 = atoi(argv[5]), gvid2 = atoi(argv[6]), gvid3 = atoi(argv[7]); LoadTimesteps(dataname); VortexTransition vt; vt.LoadFromFile(dataname, ts, tl); vt.ConstructSequence(); // vt.PrintSequence(); for (int frame=ts; frame<ts+tl; frame++) { float dist; const int lvid0 = vt.gvid2lvid(frame, gvid0), lvid1 = vt.gvid2lvid(frame, gvid1), lvid2 = vt.gvid2lvid(frame, gvid2), lvid3 = vt.gvid2lvid(frame, gvid3); if (lvid0 != -1 && lvid1 != -1) dist = Dist(dataname, frame, lvid0, lvid1); else if (lvid2 != -1 && lvid3 != -1) dist = Dist(dataname, frame, lvid2, lvid3); else dist = -DBL_MAX; if (dist >= 0) fprintf(stderr, "%d, %f, %f\n", frame, timesteps[frame], dist); } return 0; }
void seqDist(int gvid0, int gvid1, int f0_, std::map<int, float>& dist) { const VortexSequence &s0 = vt.Sequences()[gvid0]; const VortexSequence &s1 = vt.Sequences()[gvid1]; int f0 = std::max(20000, std::max(s0.its, s1.its)), // limit: 20000 f1 = std::min((int)distMatrices.size()-1, std::min(s0.its+s0.itl-1, s1.its+s1.itl-1)); const int t0 = vt.Frames()[f0_]; if (f0>f1) return; for (int f=f0; f<=f1; f++) { const int lvid0 = vt.gvid2lvid(f, gvid0); const int lvid1 = vt.gvid2lvid(f, gvid1); // fprintf(stderr, "f=%d, lvid0=%d, lvid1=%d\n", f, lvid0, lvid1); const int t = vt.Frames()[f]; const int nv = sqrt(distMatrices[f].size()); const float d = distMatrices[f][lvid0*nv + lvid1]; dist[t-t0] = d; // for (auto d : distMatrices[f]) fprintf(stderr, "%f ", d); // fprintf(stderr, "\n"); } }