Ejemplo n.º 1
0
int main(int argc, char **argv)
{
  if (argc < 3) {
    fprintf(stderr, "Usage: %s <dataname> <ts> <tl>\n", argv[0]);
    return EXIT_FAILURE;
  }
  
  const std::string dataname = argv[1];
  const int ts = atoi(argv[2]), 
            tl = atoi(argv[3]), 
            span = 1;

  QApplication app(argc, argv); 

  QGLFormat fmt = QGLFormat::defaultFormat();
  fmt.setSampleBuffers(true);
  fmt.setSamples(16); 
  QGLFormat::setDefaultFormat(fmt); 
  
  VortexTransition vt;
  vt.LoadFromFile(dataname, ts, tl);
  vt.ConstructSequence();

  CStorylineWidget *widget = new CStorylineWidget;
  widget->SetVortexTrasition(&vt);
  widget->show();

  return app.exec(); 
}
Ejemplo n.º 2
0
int main(int argc, char **argv)
{
  if (argc < 2) return 1;

  rocksdb::DB* db;
  rocksdb::Options options;
  rocksdb::Status status = rocksdb::DB::OpenForReadOnly(options, argv[1], &db);

  vt.LoadFromDB(db);
  // vt.PrintSequence();

  for (int i=0; i<vt.Frames().size()-1; i++) {
    int f = vt.Frames()[i];
    std::stringstream ss;
    ss << "v." << f << "d." << f;
    std::string buf;
    std::vector<float> dist;
    
    rocksdb::Status s = db->Get(rocksdb::ReadOptions(), ss.str(), &buf);
    if (buf.size()>0) diy::unserialize(buf, dist);
    distMatrices.push_back(dist);
  }

  const std::vector<VortexEvent>& events = vt.Events();
  for (int i=0; i<events.size(); i++) {
    const VortexEvent& e = events[i];
    if (e.type == VORTEX_EVENT_RECOMBINATION) {
      std::vector<int> lhs, rhs;
      for (auto const &id : e.lhs) lhs.push_back(vt.lvid2gvid(e.if0, id));
      for (auto const &id : e.rhs) rhs.push_back(vt.lvid2gvid(e.if1, id));

      fprintf(stderr, "EVENT=%d, f0=%d, lhs={%d, %d}, f1=%d, rhs={%d, %d}\n", 
          i, e.if0, e.if1, lhs[0], lhs[1], rhs[0], rhs[1]);

      std::map<int, float> dist;
      seqDist(lhs[0], lhs[1], e.if0, dist);
      seqDist(rhs[0], rhs[1], e.if0, dist);

      for (std::map<int, float>::iterator it = dist.begin(); it != dist.end(); it ++) {
        int t = dist[0]>dist[1] ? it->first-1: it->first;
        if (t<-200 || t>200) continue;
        fprintf(stderr, "%d,%d,%f\n", i, t, it->second);
      }
    }
  }

  delete db;
  return 0;
}
Ejemplo n.º 3
0
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;
}
Ejemplo n.º 4
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");
  }
}
Ejemplo n.º 5
0
int main(int argc, char **argv)
{
  if (argc < 2) return 1;
  infile = argv[1];
  
  FILE *fp = fopen(infile.c_str(), "rb");
  if (!fp) return 1;

#if WITH_ROCKSDB
  std::string dbname = infile + ".rocksdb";

  rocksdb::Options options;
  options.create_if_missing = true;
  // options.compression = rocksdb::kLZ4Compression;
  options.compression = rocksdb::kBZip2Compression;
  // options.write_buffer_size = 64*1024*1024; // 64 MB
  rocksdb::Status status = rocksdb::DB::Open(options, dbname.c_str(), &db);
  assert(status.ok());
#endif

  using namespace tbb::flow;
  graph g;

  int type_msg;
  vfgpu_hdr_t hdr;
  int pfcount, pecount;
  const int max_frames = 5000; // INT_MAX;
  int frame_count = 0;
  std::vector<int> frames;
  std::vector<vfgpu_hdr_t> hdrs;

  fread(&cfg, sizeof(vfgpu_cfg_t), 1, fp);

  while (!feof(fp)) {
    if (frame_count ++ > max_frames) break;
    
    // simple flow control
    __sync_fetch_and_add(&num_buffered_frames, 1);
    while (num_buffered_frames >= max_buffered_frames) 
      usleep(100000);

    size_t count = fread(&type_msg, sizeof(int), 1, fp);
    if (count != 1) break;

    if (type_msg == VFGPU_MSG_PF) {
      fread(&hdr, sizeof(vfgpu_hdr_t), 1, fp);
      fread(&pfcount, sizeof(int), 1, fp);
      
      hdrs_all[hdr.frame] = hdr;
      std::vector<vfgpu_pf_t> &pfs = pfs_all[hdr.frame];
      pfs.resize(pfcount);
      fread(pfs.data(), sizeof(vfgpu_pf_t), pfcount, fp);
      
      continue_node<continue_msg> *e = new continue_node<continue_msg>(g, extract(hdr.frame));
      e->try_put(continue_msg());
      extract_tasks[hdr.frame] = e;

      hdrs.push_back(hdr);
      frames.push_back(hdr.frame);
      // fprintf(stderr, "pushed frame %d\n", hdr.frame);
    } else if (type_msg == VFGPU_MSG_PE) {
      std::pair<int, int> interval;
      fread(&interval, sizeof(int), 2, fp);
      fread(&pecount, sizeof(int), 1, fp);

      std::vector<vfgpu_pe_t> &pes = pes_all[interval];
      pes.resize(pecount);
      fread(pes.data(), sizeof(vfgpu_pe_t), pecount, fp);
    
      continue_node<continue_msg> *t = new continue_node<continue_msg>(g, track(interval));
      track_tasks[interval] = t;
     
      make_edge(*extract_tasks[interval.first], *t);
      make_edge(*extract_tasks[interval.second], *t);
      // fprintf(stderr, "pushed interval {%d, %d}\n", interval.first, interval.second);
    }
  }

  fclose(fp);

  g.wait_for_all();
  
#if WITH_ROCKSDB
  std::string buf;
 
  diy::serialize(cfg, buf);
  db->Put(rocksdb::WriteOptions(), "cfg", buf);

  diy::serialize(hdrs, buf);
  db->Put(rocksdb::WriteOptions(), "hdrs", buf);

  fprintf(stderr, "constructing sequences...\n");
  vt.SetFrames(frames);
  vt.ConstructSequence();
  vt.PrintSequence();
  diy::serialize(vt, buf);
  db->Put(rocksdb::WriteOptions(), "trans", buf);
  
  delete db;
#endif

  fprintf(stderr, "exiting...\n");
  return 0;
}
Ejemplo n.º 6
0
  void operator()(tbb::flow::continue_msg) const {
    const vfgpu_hdr_t& hdr0 = hdrs_all[f0], 
                       hdr1 = hdrs_all[f1];
    GLHeader h0 = conv_hdr(cfg, hdr0), 
             h1 = conv_hdr(cfg, hdr1);
    const std::vector<vfgpu_pf_t>& pfs0 = pfs_all[f0], 
                                   pfs1 = pfs_all[f1];
    const std::vector<vfgpu_pe_t>& pes = pes_all[interval];
    const std::vector<VortexObject>& vobjs0 = vobjs_all[f0],
                                     vobjs1 = vobjs_all[f1];
    std::vector<VortexLine>& vlines0 = vlines_all[f0], 
                             vlines1 = vlines_all[f1];

    GLGPU3DDataset *ds = new GLGPU3DDataset;
    ds->SetHeader(h0);
    ds->SetMeshType(cfg.meshtype);
    ds->BuildMeshGraph();

    VortexExtractor *ex = new VortexExtractor;
    ex->SetDataset(ds);
    
    for (int i=0; i<pfs0.size(); i++) {
      const vfgpu_pf_t &pf = pfs0[i];
      int chirality = pf.fid_and_chirality & 0x80000000 ? 1 : -1;
      int fid = pf.fid_and_chirality & 0x7fffffff;
      ex->AddPuncturedFace(fid, 0, chirality, pf.pos);
    }
    
    for (int i=0; i<pfs1.size(); i++) {
      const vfgpu_pf_t &pf = pfs1[i];
      int chirality = pf.fid_and_chirality & 0x80000000 ? 1 : -1;
      int fid = pf.fid_and_chirality & 0x7fffffff;
      ex->AddPuncturedFace(fid, 1, chirality, pf.pos);
    }

    for (int i=0; i<pes.size(); i++) {
      const vfgpu_pe_t &pe = pes[i];
      int chirality = pe & 0x80000000 ? 1 : -1;
      int eid = pe & 0x7fffffff;
      ex->AddPuncturedEdge(eid, chirality, 0);
    }

    ex->SetVortexObjects(vobjs0, 0);
    ex->SetVortexObjects(vobjs1, 1);
    VortexTransitionMatrix mat = ex->TraceOverTime();
    mat.SetInterval(interval);
    mat.Modularize();
    vt.AddMatrix(mat);

    delete ex;
    delete ds;
    
    // compute_moving_speed(f0, f1, vlines0, vlines1, mat);
    write_mat(f0, f1, mat);
    write_vlines(f0, vlines0);
    
    fprintf(stderr, "interval={%d, %d}, #pfs0=%d, #pfs1=%d, #pes=%d\n", 
        interval.first, interval.second, (int)pfs0.size(), (int)pfs1.size(), (int)pes.size());
    
    // release resources
    pes_all[interval].clear();
    int &fc0 = frame_counter[f0], 
        &fc1 = frame_counter[f1];
    __sync_fetch_and_add(&fc0, 1);
    __sync_fetch_and_add(&fc1, 1);
    if (fc0 == 2) {
      pfs_all[fc0] = std::vector<vfgpu_pf_t>();
      vobjs_all[fc0] = std::vector<VortexObject>();
      vlines_all[fc0] = std::vector<VortexLine>();
    }
    if (fc1 == 2) {
      pfs_all[fc1] = std::vector<vfgpu_pf_t>();
      vobjs_all[fc1] = std::vector<VortexObject>();
      vlines_all[fc1] = std::vector<VortexLine>();
    }
    
    __sync_fetch_and_sub(&num_buffered_frames, 1);
  }