hdf5_diagnostics.cpp
1 #include "hdf5_diagnostics.hpp"
2 #include "../../misc/hdf5_utils.hpp"
3 #include "../../misc/lazy_list.hpp"
4 #ifdef RICH_MPI
5 #include "../../tessellation/VoronoiMesh.hpp"
6 #endif
7 
8 using namespace H5;
9 
11  mesh_points(),
12  cells(),
13  time(),
14  cycle(),
15  tracerstickernames()
16 #ifdef RICH_MPI
17  ,proc_points()
18 #endif
19 {}
20 
21 Snapshot::Snapshot(const Snapshot& source) :
22  mesh_points(source.mesh_points),
23  cells(source.cells),
24  time(source.time),
25  cycle(source.cycle),
27 #ifdef RICH_MPI
28  ,proc_points(source.proc_points)
29 #endif
30 {}
31 
33 {
34  mesh_points = other.mesh_points;
35  cells = other.cells;
36  time = other.time;
37  cycle = other.cycle;
39 #ifdef RICH_MPI
40  proc_points = other.proc_points;
41 #endif // RICH_MPI
42 
43  return *this;
44 }
45 
47 
48 namespace
49 {
50 
51  template<class T> vector<T> read_vector_from_hdf5
52  (const Group& file,
53  const string& caption,
54  const DataType& datatype)
55  {
56  DataSet dataset = file.openDataSet(caption);
57  DataSpace filespace = dataset.getSpace();
58  hsize_t dims_out[2];
59  filespace.getSimpleExtentDims(dims_out, NULL);
60  const size_t NX = static_cast<size_t>(dims_out[0]);
61  vector<T> result(NX);
62  dataset.read(&result[0], datatype);
63  return result;
64  }
65 
66  vector<double> read_double_vector_from_hdf5
67  (Group& file, string const& caption)
68  {
69  return read_vector_from_hdf5<double>
70  (file,
71  caption,
72  PredType::NATIVE_DOUBLE);
73  }
74 
75  vector<int> read_int_vector_from_hdf5
76  (const Group& file,
77  const string& caption)
78  {
79  return read_vector_from_hdf5<int>
80  (file,
81  caption,
82  PredType::NATIVE_INT);
83  }
84 }
85 
86 namespace {
87  class MeshGeneratingPointCoordinate : public LazyList<double>
88  {
89  public:
90 
91  MeshGeneratingPointCoordinate(const Tessellation& tess,
92  double Vector2D::* component) :
93  tess_(tess), component_(component) {}
94 
95  size_t size(void) const
96  {
97  return static_cast<size_t>(tess_.GetPointNo());
98  }
99 
100  double operator[](size_t i) const
101  {
102  return tess_.GetMeshPoint(static_cast<int>(i)).*component_;
103  }
104 
105  private:
106  const Tessellation& tess_;
107  double Vector2D::* component_;
108  };
109 
110  class CMGeneratingPointCoordinate : public LazyList<double>
111  {
112  public:
113 
114  CMGeneratingPointCoordinate(const Tessellation& tess,
115  double Vector2D::* component) :
116  tess_(tess), component_(component) {}
117 
118  size_t size(void) const
119  {
120  return static_cast<size_t>(tess_.GetPointNo());
121  }
122 
123  double operator[](size_t i) const
124  {
125  return tess_.GetCellCM(static_cast<int>(i)).*component_;
126  }
127 
128  private:
129  const Tessellation& tess_;
130  double Vector2D::* component_;
131  };
132 
133  class SingleCellPropertyExtractor
134  {
135  public:
136 
137  virtual double operator()(const ComputationalCell& p) const = 0;
138 
139  virtual ~SingleCellPropertyExtractor(void) {}
140  };
141 
142  class ThermalPropertyExtractor : public SingleCellPropertyExtractor
143  {
144  public:
145 
146  explicit ThermalPropertyExtractor(double ComputationalCell::* var) :
147  var_(var) {}
148 
149  double operator()(const ComputationalCell& p) const
150  {
151  return p.*var_;
152  }
153 
154  private:
155  double ComputationalCell::* var_;
156  };
157 
158  class CellVelocityComponentExtractor : public SingleCellPropertyExtractor
159  {
160  public:
161 
162  explicit CellVelocityComponentExtractor(double Vector2D::* component) :
163  component_(component) {}
164 
165  double operator()(const ComputationalCell& p) const
166  {
167  return p.velocity.*component_;
168  }
169 
170  private:
171  double Vector2D::* component_;
172  };
173 
174  class CellsPropertyExtractor : public LazyList<double>
175  {
176  public:
177 
178  CellsPropertyExtractor(const hdsim& sim,
179  const SingleCellPropertyExtractor& scpe) :
180  sim_(sim), scpe_(scpe) {}
181 
182  size_t size(void) const
183  {
184  return static_cast<size_t>(sim_.getTessellation().GetPointNo());
185  }
186 
187  double operator[](size_t i) const
188  {
189  return scpe_(sim_.getAllCells()[i]);
190  }
191 
192  private:
193  const hdsim& sim_;
194  const SingleCellPropertyExtractor& scpe_;
195  };
196 
197  class ConvexHullData
198  {
199  public:
200 
201  vector<double> xvert;
202  vector<double> yvert;
203  vector<double> nvert;
204 
205  explicit ConvexHullData(const Tessellation& tess) :
206  xvert(),
207  yvert(),
208  nvert(static_cast<size_t>(tess.GetPointNo()))
209  {
210  xvert.reserve(7 * static_cast<size_t>(tess.GetPointNo()));
211  yvert.reserve(7 * static_cast<size_t>(tess.GetPointNo()));
212  for (int i = 0; i < tess.GetPointNo(); ++i) {
213  vector<Vector2D> convhull;
214  ConvexHull(convhull, tess, i);
215  for (size_t j = 0; j < convhull.size(); ++j) {
216  xvert.push_back(convhull[j].x);
217  yvert.push_back(convhull[j].y);
218  }
219  nvert[static_cast<size_t>(i)] = static_cast<int>(convhull.size());
220  }
221  }
222  };
223 
224  class StickerSlice : public LazyList<double>
225  {
226  public:
227 
228  StickerSlice(const hdsim& sim,
229  size_t index) :
230  sim_(sim), index_(index) {}
231 
232  size_t size(void) const
233  {
234  return static_cast<size_t>(sim_.getTessellation().GetPointNo());
235  }
236 
237  double operator[](size_t i) const
238  {
239  return static_cast<double>(sim_.getAllCells()[i].stickers[index_]);
240  }
241 
242  private:
243  const hdsim& sim_;
244  const size_t index_;
245  };
246 
247  class TracerSlice : public LazyList<double>
248  {
249  public:
250 
251  TracerSlice(const hdsim& sim,
252  size_t index) :
253  sim_(sim), index_(index) {}
254 
255  size_t size(void) const
256  {
257  return static_cast<size_t>(sim_.getTessellation().GetPointNo());
258  }
259 
260  double operator[](size_t i) const
261  {
262  return sim_.getAllCells()[i].tracers[index_];
263  }
264 
265  private:
266  const hdsim& sim_;
267  const size_t index_;
268  };
269 }
270 
271 void write_snapshot_to_hdf5(hdsim const& sim, string const& fname,
272  const vector<DiagnosticAppendix*>& appendices)
273 {
274  ConvexHullData chd(sim.getTessellation());
275  H5File file(H5std_string(fname), H5F_ACC_TRUNC);
276  Group geometry = file.createGroup("/geometry");
277  Group gappendices = file.createGroup("/appendices");
278  Group hydrodynamic = file.createGroup("/hydrodynamic");
279  Group tracers = file.createGroup("/tracers");
280  Group stickers = file.createGroup("/stickers");
281 #ifdef RICH_MPI
282  Group mpi = file.createGroup("/mpi");
283 #endif
284 
285  // General
287  (file,
288  vector<double>(1, sim.getTime()),
289  "time");
291  (file,
292  vector<int>(1, sim.getCycle()),
293  "cycle");
294  vector<double> area
295  (static_cast<size_t>(sim.getTessellation().GetPointNo()), 0);
296  for(size_t i=0;i<area.size();++i)
297  area[i]=sim.getCacheData().volumes[i];
298  write_std_vector_to_hdf5(file,area,"Volumes");
299 
300  // Geometry
302  (geometry,
304  (MeshGeneratingPointCoordinate
305  (sim.getTessellation(), &Vector2D::x)),
306  "x_coordinate");
308  (geometry,
310  (MeshGeneratingPointCoordinate
311  (sim.getTessellation(), &Vector2D::y)),
312  "y_coordinate");
314  (geometry,
316  (CMGeneratingPointCoordinate
317  (sim.getTessellation(), &Vector2D::x)),
318  "CM_x_coordinate");
320  (geometry,
322  (CMGeneratingPointCoordinate
323  (sim.getTessellation(), &Vector2D::y)),
324  "CM_y_coordinate");
326  (geometry,
327  chd.xvert,
328  "x_vertices");
330  (geometry,
331  chd.yvert,
332  "y_vertices");
334  (geometry,
335  chd.nvert,
336  "n_vertices");
337  //MPI
338 #ifdef RICH_MPI
340  (mpi,
342  (MeshGeneratingPointCoordinate
343  (sim.GetProcTessellation(), &Vector2D::x)),
344  "proc_x_coordinate");
346  (mpi,
348  (MeshGeneratingPointCoordinate
349  (sim.GetProcTessellation(), &Vector2D::y)),
350  "proc_y_coordinate");
351 #endif
352 
353  // Hydrodynamic
355  (hydrodynamic,
357  (CellsPropertyExtractor
358  (sim, ThermalPropertyExtractor(&ComputationalCell::density))),
359  "density");
361  (hydrodynamic,
363  (CellsPropertyExtractor
364  (sim, ThermalPropertyExtractor(&ComputationalCell::pressure))),
365  "pressure");
367  (hydrodynamic,
369  (CellsPropertyExtractor
370  (sim, CellVelocityComponentExtractor(&Vector2D::x))),
371  "x_velocity");
373  (hydrodynamic,
375  (CellsPropertyExtractor
376  (sim, CellVelocityComponentExtractor(&Vector2D::y))),
377  "y_velocity");
378 
379  // Tracers
381  size_t Ntracers = sim.getAllCells().front().tracers.size();
382  for (size_t i = 0; i < Ntracers; ++i)
383  write_std_vector_to_hdf5(tracers, serial_generate(TracerSlice(sim, i)), tracerstickernames.tracer_names[i]);
384 
385  // Stickers
386  size_t Nstickers = sim.getAllCells().front().stickers.size();
387  for (size_t i = 0; i < Nstickers; ++i)
388  write_std_vector_to_hdf5(stickers, serial_generate(StickerSlice(sim, i)), tracerstickernames.sticker_names[i]);
389 
390  // Appendices
391  for (size_t i = 0; i < appendices.size(); ++i)
392  write_std_vector_to_hdf5
393  (gappendices,
394  (*(appendices.at(i)))(sim),
395  appendices.at(i)->getName());
396 }
397 
399 (const string& fname, bool mpioverride)
400 {
401  Snapshot res;
402  H5File file(fname, H5F_ACC_RDONLY);
403  Group g_geometry = file.openGroup("geometry");
404  Group g_hydrodynamic = file.openGroup("hydrodynamic");
405  Group g_tracers = file.openGroup("tracers");
406  Group g_stickers = file.openGroup("stickers");
407 #ifdef RICH_MPI
408  Group mpi;
409  if (!mpioverride)
410  mpi = file.openGroup("/mpi");
411 #else
412  if (mpioverride)
413  mpioverride = true;
414 #endif
415 
416 
417  // Mesh points
418  {
419  const vector<double> x =
420  read_double_vector_from_hdf5(g_geometry, "x_coordinate");
421  const vector<double> y =
422  read_double_vector_from_hdf5(g_geometry, "y_coordinate");
423  res.mesh_points.resize(x.size());
424  for (size_t i = 0; i < x.size(); ++i)
425  res.mesh_points.at(i) = Vector2D(x.at(i), y.at(i));
426  }
427 
428 #ifdef RICH_MPI
429  // MPI
430  {
431  if (!mpioverride)
432  {
433  const vector<double> x =
434  read_double_vector_from_hdf5(mpi, "proc_x_coordinate");
435  const vector<double> y =
436  read_double_vector_from_hdf5(mpi, "proc_y_coordinate");
437  res.proc_points.resize(x.size());
438  for (size_t i = 0; i < x.size(); ++i)
439  res.proc_points.at(i) = Vector2D(x.at(i), y.at(i));
440  }
441  }
442 #endif
443 
444  // Hydrodynamic
445  {
446  const vector<double> density =
447  read_double_vector_from_hdf5(g_hydrodynamic, "density");
448  const vector<double> pressure =
449  read_double_vector_from_hdf5(g_hydrodynamic, "pressure");
450  const vector<double> x_velocity =
451  read_double_vector_from_hdf5(g_hydrodynamic, "x_velocity");
452  const vector<double> y_velocity =
453  read_double_vector_from_hdf5(g_hydrodynamic, "y_velocity");
454 
455  vector<vector<double> > tracers(g_tracers.getNumObjs());
456  vector<string> tracernames(tracers.size());
457  for (hsize_t n = 0; n < g_tracers.getNumObjs(); ++n)
458  {
459  const H5std_string name = g_tracers.getObjnameByIdx(n);
460  tracernames[n] = name;
461  tracers[n]= read_double_vector_from_hdf5(g_tracers, name);
462  }
463 
464  vector<vector<int> > stickers(g_stickers.getNumObjs());
465  vector<string> stickernames(stickers.size());
466  for (hsize_t n = 0; n < g_stickers.getNumObjs(); ++n)
467  {
468  const H5std_string name = g_stickers.getObjnameByIdx(n);
469  stickernames[n] = name;
470  stickers[n] =read_int_vector_from_hdf5(g_stickers, name);
471  }
472  res.tracerstickernames.sticker_names = stickernames;
473  res.tracerstickernames.tracer_names = tracernames;
474  res.cells.resize(density.size());
475  for (size_t i = 0; i < res.cells.size(); ++i)
476  {
477  res.cells.at(i).density = density.at(i);
478  res.cells.at(i).pressure = pressure.at(i);
479  res.cells.at(i).velocity.x = x_velocity.at(i);
480  res.cells.at(i).velocity.y = y_velocity.at(i);
481  res.cells.at(i).tracers.resize(tracernames.size());
482  for (size_t j = 0; j < tracernames.size(); ++j)
483  res.cells.at(i).tracers.at(j) = tracers.at(j).at(i);
484  res.cells.at(i).stickers.resize(stickernames.size());
485  for (size_t j = 0; j < stickernames.size(); ++j)
486  res.cells.at(i).stickers.at(j) = stickers.at(j).at(i)==1;
487  }
488  }
489 
490  // Misc
491  {
492  const vector<double> time =
493  read_double_vector_from_hdf5(file, "time");
494  res.time = time.at(0);
495  const vector<int> cycle =
496  read_int_vector_from_hdf5(file, "cycle");
497  res.cycle = cycle.at(0);
498  }
499 
500  return res;
501 }
502 
503 void WriteDelaunay(Delaunay const& tri, string const& filename)
504 {
505  vector<Vector2D> const& cor = tri.getCor();
506  vector<double> x_cor, y_cor;
507  vector<int> facets;
508  int nfacets = tri.get_num_facet();
509 
510  H5File file(H5std_string(filename), H5F_ACC_TRUNC);
511 
512  for (size_t i = 0; i < cor.size(); ++i)
513  {
514  x_cor.push_back(cor[i].x);
515  y_cor.push_back(cor[i].y);
516  }
517 
518  for (int i = 0; i < nfacets; ++i)
519  {
520  facets.push_back(tri.get_facet(i).vertices.first);
521  facets.push_back(tri.get_facet(i).vertices.second);
522  facets.push_back(tri.get_facet(i).vertices.third);
523  }
524 
525  write_std_vector_to_hdf5(file, x_cor, "x_coordinate");
526  write_std_vector_to_hdf5(file, y_cor, "y_coordinate");
527  write_std_vector_to_hdf5(file, vector<int>(1, tri.GetOriginalLength()), "point number");
528  write_std_vector_to_hdf5(file, facets, "triangles");
529 }
530 
531 #ifdef RICH_MPI
532 
533 Snapshot ReDistributeData(string const& filename, Tessellation const& proctess, size_t snapshot_number)
534 {
535  int ws, rank;
536  MPI_Comm_size(MPI_COMM_WORLD, &ws);
537  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
538  double read_num =
539  static_cast<double>(snapshot_number)*1.0 /
540  static_cast<double>(ws);
541  // Read the data
542  int start = static_cast<int>
543  (floor
544  (static_cast<double>(rank)*read_num + 0.1));
545  int stop = static_cast<int>
546  (floor((1 + rank)*read_num - 0.9));
547  Snapshot res, snap;
548  for (int i = start; i < stop; ++i)
549  {
550  Snapshot temp = read_hdf5_snapshot(filename + int2str(i) + ".h5");
551  snap.cells.insert(snap.cells.end(), temp.cells.begin(), temp.cells.end());
552  snap.mesh_points.insert(snap.mesh_points.end(), temp.mesh_points.begin(), temp.mesh_points.end());
553  if (i == start)
554  {
555  snap.time = temp.time;
556  snap.cycle = temp.cycle;
558  }
559  }
560  vector<vector<Vector2D> > chull(static_cast<size_t>(ws));
561  vector<vector<ComputationalCell> > cell_recv(chull.size());
562  vector<vector<Vector2D> > mesh_recv(chull.size());
563  vector<vector<size_t> > indeces(chull.size());
564  for (size_t i = 0; i < chull.size(); ++i)
565  ConvexHull(chull[i], proctess, static_cast<int>(i));
566  for (size_t i = 0; i < snap.mesh_points.size(); ++i)
567  {
568  bool added = false;
569  for (size_t j = 0; j < chull.size(); ++j)
570  {
571  if (PointInCell(chull[j], snap.mesh_points[i]))
572  {
573  indeces[j].push_back(i);
574  added = true;
575  break;
576  }
577  }
578  if (!added)
579  throw UniversalError("Didn't find point in ReDistributeData");
580  }
581  // Send/Recv data
582  vector<MPI_Request> req(chull.size() * 2);
583  vector<vector<double> > tosend(chull.size() * 2);
584  vector<double> temprecv;
585  double dtemp = 0;
586  for (size_t i = 0; i < chull.size(); ++i)
587  {
588  if (i == static_cast<size_t>(rank))
589  {
590  res.cells = VectorValues(snap.cells, indeces[i]);
591  req[2 * i] = MPI_REQUEST_NULL;
592  continue;
593  }
594  tosend[i * 2] = list_serialize(VectorValues(snap.cells, indeces[i]));
595  if (tosend[i * 2].empty())
596  MPI_Isend(&dtemp, 1, MPI_DOUBLE, static_cast<int>(i), 2, MPI_COMM_WORLD, &req[2 * i]);
597  else
598  MPI_Isend(&tosend[i * 2][0], static_cast<int>(tosend[i * 2].size()), MPI_DOUBLE, static_cast<int>(i), 0, MPI_COMM_WORLD, &req[2 * i]);
599  }
600  for (size_t i = 0; i < chull.size(); ++i)
601  {
602  if (i == static_cast<size_t>(rank))
603  {
604  res.mesh_points = VectorValues(snap.mesh_points, indeces[i]);
605  req[2 * i + 1] = MPI_REQUEST_NULL;
606  continue;
607  }
608  tosend[i * 2 + 1] = list_serialize(VectorValues(snap.mesh_points, indeces[i]));
609  if (tosend[i * 2 + 1].empty())
610  MPI_Isend(&dtemp, 1, MPI_DOUBLE, static_cast<int>(i), 3, MPI_COMM_WORLD, &req[2 * i + 1]);
611  else
612  MPI_Isend(&tosend[i * 2 + 1][0], static_cast<int>(tosend[i * 2 + 1].size()), MPI_DOUBLE, static_cast<int>(i), 1, MPI_COMM_WORLD, &req[2 * i + 1]);
613  }
614  for (size_t i = 0; i < 2 * chull.size() - 2; ++i)
615  {
616  MPI_Status status;
617  MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
618  int count;
619  MPI_Get_count(&status, MPI_DOUBLE, &count);
620  temprecv.resize(static_cast<size_t>(count));
621  MPI_Recv(&temprecv[0], count, MPI_DOUBLE, status.MPI_SOURCE, status.MPI_TAG, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
622  if (status.MPI_TAG == 0)
623  cell_recv[static_cast<size_t>(status.MPI_SOURCE)] = list_unserialize(temprecv, snap.cells[0]);
624  if (status.MPI_TAG == 1)
625  mesh_recv[static_cast<size_t>(status.MPI_SOURCE)] = list_unserialize(temprecv, snap.mesh_points[0]);
626  if (status.MPI_TAG > 3)
627  throw UniversalError("Wrong mpi tag");
628  }
629  MPI_Waitall(static_cast<int>(req.size()), &req[0], MPI_STATUSES_IGNORE);
630 
631  for (size_t i = 0; i < chull.size(); ++i)
632  {
633  if (i == static_cast<size_t>(rank))
634  continue;
635  res.cells.insert(res.cells.end(), cell_recv[i].begin(), cell_recv[i].end());
636  res.mesh_points.insert(res.mesh_points.end(), mesh_recv[i].begin(), mesh_recv[i].end());
637  }
638 
639  res.time = snap.time;
640  res.cycle = snap.cycle;
642  return res;
643 }
644 
645 Snapshot ReDistributeData2(string const& filename, Tessellation const& proctess, size_t snapshot_number, bool mpioverride)
646 {
647  int rank;
648  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
649  // Read the data
650  Snapshot snap;
651  for (int i = 0; i < static_cast<int>(snapshot_number); ++i)
652  {
653  Snapshot temp = read_hdf5_snapshot(filename + int2str(i) + ".h5", mpioverride);
654  snap.cells.insert(snap.cells.end(), temp.cells.begin(), temp.cells.end());
655  snap.mesh_points.insert(snap.mesh_points.end(), temp.mesh_points.begin(), temp.mesh_points.end());
656  if (i == 0)
657  {
658  snap.time = temp.time;
659  snap.cycle = temp.cycle;
661  }
662  }
663  vector<Vector2D> chull;
664  ConvexHull(chull, proctess, rank);
665  vector<size_t> indeces;
666  for (size_t i = 0; i < snap.mesh_points.size(); ++i)
667  if (PointInCell(chull, snap.mesh_points[i]))
668  indeces.push_back(i);
669  snap.mesh_points = VectorValues(snap.mesh_points, indeces);
670  snap.cells = VectorValues(snap.cells, indeces);
671  return snap;
672 }
673 #endif
674 
675 void WriteTess(Tessellation const& tess, string const& fname)
676 {
677  ConvexHullData chd(tess);
678  H5File file(H5std_string(fname), H5F_ACC_TRUNC);
679  Group geometry = file.createGroup("/geometry");
680  write_std_vector_to_hdf5(geometry, serial_generate(MeshGeneratingPointCoordinate(tess, &Vector2D::x)),
681  "x_coordinate");
682  write_std_vector_to_hdf5(geometry, serial_generate(MeshGeneratingPointCoordinate(tess, &Vector2D::y)),
683  "y_coordinate");
684  write_std_vector_to_hdf5(geometry, chd.xvert, "x_vertices");
685  write_std_vector_to_hdf5(geometry, chd.yvert, "y_vertices");
686  write_std_vector_to_hdf5(geometry, chd.nvert, "n_vertices");
687 }
const Tessellation & GetProcTessellation(void) const
Returns the processor tessellation.
Definition: hdsim2d.cpp:819
vector< T > VectorValues(vector< T > const &v, vector< int > const &index)
Returns only the values with indeces in index.
Definition: utils.hpp:326
Container for snapshot data.
Snapshot ReDistributeData2(string const &filename, Tessellation const &proctess, size_t snapshot_number, bool mpioverride=false)
Reads an HDF5 snapshot file in order to restart the simulation with a different cpu number...
std::vector< std::string > sticker_names
The names of the stickers.
Abstract class for tessellation.
Snapshot ReDistributeData(string const &filename, Tessellation const &proctess, size_t snapshot_number)
Reads an HDF5 snapshot file in order to restart the simulation with a different cpu number...
virtual int GetPointNo(void) const =0
Get Total number of mesh generating points.
const facet & get_facet(int index) const
Returns a facet.
Definition: Delaunay.cpp:691
Container for error reports.
const vector< Vector2D > & getCor(void) const
Access to coordinates.
Definition: Delaunay.cpp:686
bool PointInCell(vector< Vector2D > const &cpoints, Vector2D const &vec)
Checks if a point is inside a Voronoi cell.
Triplet< int > vertices
Indices of vertices.
Definition: facet.hpp:24
Newtonian hydrodynamic simulation.
Definition: hdsim2d.hpp:43
vector< T > serial_generate(const LazyList< T > &ll)
Creates a vector from an LazyList.
Definition: lazy_list.hpp:49
double getTime(void) const
Returns the time.
Definition: hdsim2d.cpp:729
void write_std_vector_to_hdf5(const Group &file, const vector< T > &data, const string &caption, const DataType &dt)
Master function for writing vectors to hdf5 files.
Definition: hdf5_utils.hpp:31
vector< Vector2D > mesh_points
Mesh points.
void WriteDelaunay(Delaunay const &tri, string const &filename)
Writes the Delaunay triangulation data into an HDF5 file.
virtual ~DiagnosticAppendix(void)
Class destructor.
const Tessellation & getTessellation(void) const
Returns the tessellation.
Definition: hdsim2d.cpp:722
std::string int2str(int n)
Converts an integer to a string.
Definition: int2str.cpp:6
double y
Component in the y direction.
Definition: geometry.hpp:48
double time
Time.
Ordered list whose terms are evaluated lazily.
Definition: lazy_list.hpp:17
TracerStickerNames const & GetTracerStickerNames(void) const
Returns the TracerStickerNames.
Definition: hdsim2d.cpp:172
double pressure
Pressure.
int getCycle(void) const
Returns the number cycles.
Definition: hdsim2d.cpp:734
const CacheData & getCacheData(void) const
Returns reference to the cached data.
Definition: hdsim2d.cpp:813
void ConvexHull(vector< Vector2D > &result, Tessellation const &tess, int index)
Returns the ConvexHull for a set of points.
Definition: ConvexHull.cpp:31
Snapshot & operator=(const Snapshot &other)
Copy operator.
int get_num_facet(void) const
Returns the number of facets.
Definition: Delaunay.cpp:719
The Delaunay data structure. Gets a set of points and constructs the Delaunay tessellation.
Definition: Delaunay.hpp:30
int cycle
Cycle number.
void write_snapshot_to_hdf5(hdsim const &sim, string const &fname, const vector< DiagnosticAppendix *> &appendices=vector< DiagnosticAppendix *>())
Writes the simulation data into an HDF5 file.
const CachedLazyList< double > volumes
List of cell volumes.
Definition: cache_data.hpp:81
Simulation output to hdf5 file format.
std::vector< std::string > tracer_names
The names of the tracers.
Class for keeping the names of the tracers and stickers.
T third
Third item.
Definition: triplet.hpp:50
void WriteTess(Tessellation const &tess, string const &filename)
Writes the tessellation data into an HDF5 file.
Snapshot(void)
Default constructor.
int GetOriginalLength(void) const
Returns the original length of the points (without duplicated points)
Definition: Delaunay.cpp:739
Vector2D velocity
Velocity.
const vector< ComputationalCell > & getAllCells(void) const
Returns a list of all computational cells.
Definition: hdsim2d.cpp:739
T second
Second item.
Definition: triplet.hpp:47
2D Mathematical vector
Definition: geometry.hpp:15
vector< Vector2D > proc_points
Locations of cpus.
double x
Component in the x direction.
Definition: geometry.hpp:45
TracerStickerNames tracerstickernames
THe names of the tracers and stickers.
vector< ComputationalCell > cells
Computational cells.
T first
First item.
Definition: triplet.hpp:44
Computational cell.
Snapshot read_hdf5_snapshot(const string &fname, bool mpioverride=false)
Load snapshot data into memory.