SPH
Plot.cpp
Go to the documentation of this file.
1 #include "post/Plot.h"
2 #include "io/Logger.h"
3 #include "post/Point.h"
4 #include "quantities/IMaterial.h"
5 #include "quantities/Storage.h"
6 #include "system/Statistics.h"
7 #include <set>
8 
10 
11 // ----------------------------------------------------------------------------------------------------------
12 // SpatialPlot
13 // ----------------------------------------------------------------------------------------------------------
14 
16 template <typename TDerived>
17 void SpatialPlot<TDerived>::onTimeStep(const Storage& storage, const Statistics& UNUSED(stats)) {
18  // no temporal dependence - reset everything
19  this->clear();
20 
21  Array<PlotPoint> particlePoints;
22  ArrayView<const Float> quantity = storage.getValue<Float>(id);
24  for (Size i = 0; i < r.size(); ++i) {
25  PlotPoint p{ getX(r[i]), quantity[i] };
26  particlePoints.push(p);
27  ranges.x.extend(p.x);
28  ranges.y.extend(p.y);
29  }
30  std::sort(particlePoints.begin(), particlePoints.end(), [](PlotPoint& p1, PlotPoint& p2) {
31  return p1.x < p2.x;
32  });
33 
34  if (!binCnt) {
35  points = std::move(particlePoints);
36  } else {
37  SPH_ASSERT(binCnt.value() >= 1);
38  points.resize(binCnt.value());
39  Array<Size> weights(binCnt.value());
40  points.fill(PlotPoint(0.f, 0.f));
41  weights.fill(0);
42 
43  const Float lastX = particlePoints[particlePoints.size() - 1].x;
44  for (PlotPoint& p : particlePoints) {
45  const Size bin = min(Size(p.x * (binCnt.value() - 1) / lastX), binCnt.value() - 1);
46  points[bin] += p;
47  weights[bin]++;
48  }
49 
50  for (Size i = 0; i < points.size(); ++i) {
51  if (weights[i] > 0) {
52  points[i].x /= weights[i];
53  points[i].y /= weights[i];
54  } else {
55  SPH_ASSERT(points[i] == PlotPoint(0.f, 0.f));
56  }
57  }
58  }
59 }
60 
61 template <typename TDerived>
63  points.clear();
64  ranges.x = ranges.y = Interval();
65 }
66 
67 template <typename TDerived>
69  for (Size i = 0; i < points.size(); ++i) {
70  if (i > 0) {
71  dc.drawLine(points[i], points[i - 1]);
72  }
73  dc.drawPoint(points[i]);
74  }
75 }
76 
78  : SpatialPlot<RadialDistributionPlot>(id, binCnt) {}
79 
80 
81 // ----------------------------------------------------------------------------------------------------------
82 // TemporalPlot
83 // ----------------------------------------------------------------------------------------------------------
84 
85 void TemporalPlot::onTimeStep(const Storage& storage, const Statistics& stats) {
86  // add new point to the queue
87  const Float t = stats.get<Float>(StatisticsId::RUN_TIME);
88  if (t - lastTime < actPeriod) {
89  return;
90  }
91  lastTime = t;
92 
93  const Float y = integral.evaluate(storage);
94  points.pushBack(PlotPoint{ t, y });
95 
96  if (params.segment == INFTY && points.size() > params.maxPointCnt) {
97  // plot is unnecessarily detailed, drop every second point to reduce the drawing time
98  Queue<PlotPoint> newPoints;
99  for (Size i = 0; i < points.size(); i += 2) {
100  newPoints.pushBack(points[i]);
101  }
102  points = std::move(newPoints);
103  // also add new points with double period
104  actPeriod *= 2._f;
105  }
106 
107  // pop expired points
108  bool needUpdateRange = false;
109  while (!points.empty() && this->isExpired(points.front().x, t)) {
110  points.popFront();
111  needUpdateRange = true;
112  }
113 
114  // update ranges
115  if (needUpdateRange && params.shrinkY) {
116  // we removed some points, so we don't know how much to shrink, let's construct it from scrach
117  ranges.y = Interval();
118  for (PlotPoint& p : points) {
119  ranges.y.extend(p.y);
120  }
121  } else if (!points.empty()) {
122  // we just added points, no need to shrink the range, just extend it with the new point
123  ranges.y.extend(points.back().y);
124  }
125  // make sure the y-range is larger than the minimal allowed value
126  if (ranges.y.size() < params.minRangeY) {
127  const Float dy = 0.5_f * (params.minRangeY - ranges.y.size());
128  SPH_ASSERT(dy >= 0._f, params.minRangeY, ranges.y);
129  ranges.y.extend(ranges.y.upper() + dy);
130  ranges.y.extend(ranges.y.lower() - dy);
131  }
132  if (points.empty()) {
133  ranges.x = Interval(); // nothing to draw
134  } else if (params.fixedRangeX.empty()) {
135  const Float t0 = max(points.front().x, t - params.segment);
136  ranges.x = Interval(t0, t);
137  } else {
138  ranges.x = params.fixedRangeX;
139  }
140 }
141 
143  points.clear();
144  lastTime = -INFTY;
145  ranges.x = ranges.y = Interval();
146  actPeriod = params.period;
147 }
148 
150  if (points.empty()) {
151  return;
152  }
153  AutoPtr<IDrawPath> path = dc.drawPath();
154  for (const PlotPoint& p : points) {
155  dc.drawPoint(p);
156  path->addPoint(p);
157  }
158  path->endPath();
159 }
160 
161 bool TemporalPlot::isExpired(const Float x, const Float t) const {
162  if (params.fixedRangeX.empty()) {
163  // compare with the segment
164  return x < t - params.segment;
165  } else {
166  // compare with the range
167  return !params.fixedRangeX.contains(t);
168  }
169 }
170 
171 // ----------------------------------------------------------------------------------------------------------
172 // HistogramPlot
173 // ----------------------------------------------------------------------------------------------------------
174 
175 void HistogramPlot::onTimeStep(const Storage& storage, const Statistics& stats) {
176  const Float time = stats.get<Float>(StatisticsId::RUN_TIME);
177  if (time - lastTime < period) {
178  return;
179  }
180  lastTime = time;
181 
182  Post::HistogramParams params;
183  params.binCnt = 0;
184  if (interval) {
185  params.range = interval.value();
186  }
188 
189  this->clear();
190  for (Post::HistPoint& p : points) {
191  ranges.x.extend(p.value);
192  ranges.y.extend(p.count);
193  }
194  // always include y=0
195  ranges.y.extend(0);
196 }
197 
199  ranges.x = ranges.y = Interval();
200 }
201 
203  if (points.empty()) {
204  return;
205  }
206  for (Size i = 0; i < points.size() - 1; ++i) {
207  dc.drawLine(
208  { points[i].value, Float(points[i].count) }, { points[i + 1].value, Float(points[i].count) });
209  dc.drawLine({ points[i + 1].value, Float(points[i].count) },
210  { points[i + 1].value, Float(points[i + 1].count) });
211  }
212 }
213 
214 // ----------------------------------------------------------------------------------------------------------
215 // AngularHistogramPlot
216 // ----------------------------------------------------------------------------------------------------------
217 
219  : period(period) {}
220 
221 void AngularHistogramPlot::onTimeStep(const Storage& storage, const Statistics& stats) {
222  const Float time = stats.get<Float>(StatisticsId::RUN_TIME);
223  if (time - lastTime < period) {
224  return;
225  }
226  lastTime = time;
227 
229  Array<Float> angles(v.size());
230  for (Size i = 0; i < v.size(); ++i) {
231  angles[i] = atan2(v[i][Y], v[i][X]);
232  }
233 
234  Post::HistogramParams params;
235  params.binCnt = 0;
236  params.range = Interval(-PI, PI);
238 
239  this->clear();
240  points.clear();
241  for (const Post::HistPoint& p : hist) {
242  const Float x = p.count * cos(p.value);
243  const Float y = p.count * sin(p.value);
244  points.push(PlotPoint{ x, y });
245  ranges.x.extend(x);
246  ranges.y.extend(y);
247  }
248 
249  // include (0,0)
250  ranges.x.extend(0._f);
251  ranges.y.extend(0._f);
252 
253  // make square
254  ranges.x.extend(ranges.y);
255  ranges.y.extend(ranges.x);
256 }
257 
259  ranges.x = Interval();
260  ranges.y = Interval();
261 }
262 
264  if (points.size() <= 1) {
265  return;
266  }
267  for (Size i = 0; i < points.size() - 1; ++i) {
268  dc.drawLine(points[i], points[i + 1]);
269  }
270  dc.drawLine(points.back(), points.front());
271 }
272 
273 // ----------------------------------------------------------------------------------------------------------
274 // SfdPlot
275 // ----------------------------------------------------------------------------------------------------------
276 
277 SfdPlot::SfdPlot(const Flags<Post::ComponentFlag> connectivity, const Float period)
278  : period(period) {
280  connect = connectivity;
281  name = connect.has(Post::ComponentFlag::ESCAPE_VELOCITY) ? "Predicted SFD" : "Current SFD";
282 }
283 
284 SfdPlot::SfdPlot(const Float period)
285  : period(period) {
287  name = "Particle SFD";
288 }
289 
290 std::string SfdPlot::getCaption() const {
291  return name;
292 }
293 
294 void SfdPlot::onTimeStep(const Storage& storage, const Statistics& stats) {
295  const Float time = stats.get<Float>(StatisticsId::RUN_TIME);
296  if (time - lastTime < period) {
297  return;
298  }
299  lastTime = time;
300  Post::HistogramParams params;
301  params.components.flags = connect;
302  params.velocityCutoff = 3.e3_f; // km/s /// \todo generalize
303  if (storage.getMaterialCnt() > 0) {
304  const BodySettings& body = storage.getMaterial(0)->getParams();
305  if (body.has(BodySettingsId::DENSITY)) {
307  }
308  }
309  Array<Post::HistPoint> points =
311 
312  ranges.x = ranges.y = Interval();
313  sfd.clear();
314  sfd.reserve(points.size());
315  for (Post::HistPoint& p : points) {
316  SPH_ASSERT(p.value > 0._f && p.count > 0);
317  const Float value = log10(p.value);
318  const Float count = log10(Float(p.count));
319  ranges.x.extend(value);
320  ranges.y.extend(count);
321  sfd.emplaceBack(PlotPoint{ value, count });
322  }
323 }
324 
326  ranges.x = ranges.y = Interval();
327  lastTime = 0._f;
328  sfd.clear();
329 }
330 
332  if (!sfd.empty()) {
333  AutoPtr<IDrawPath> path = dc.drawPath();
334  for (Size i = 0; i < sfd.size() - 1; ++i) {
335  dc.drawPoint(sfd[i]);
336  path->addPoint(sfd[i]);
337  }
338  dc.drawPoint(sfd.back());
339  path->addPoint(sfd.back());
340  path->endPath();
341  }
342 }
343 
344 // ----------------------------------------------------------------------------------------------------------
345 // DataPlot
346 // ----------------------------------------------------------------------------------------------------------
347 
349  const Flags<AxisScaleEnum> scale,
350  const std::string& name)
351  : name(name) {
352  for (const Post::HistPoint& p : points) {
353  if (scale.has(AxisScaleEnum::LOG_X) && p.value <= 0._f) {
354  continue;
355  }
356  if (scale.has(AxisScaleEnum::LOG_Y) && p.count <= 0) {
357  continue;
358  }
359  const Float value = scale.has(AxisScaleEnum::LOG_X) ? log10(p.value) : p.value;
360  const Float count = scale.has(AxisScaleEnum::LOG_Y) ? log10(Float(p.count)) : Float(p.count);
361  ranges.x.extend(value);
362  ranges.y.extend(count);
363  values.emplaceBack(PlotPoint{ value, count });
364  }
365 }
366 
367 std::string DataPlot::getCaption() const {
368  return name;
369 }
370 
371 void DataPlot::onTimeStep(const Storage& UNUSED(storage), const Statistics& UNUSED(stats)) {
372  // plot is contant
373 }
374 
376  // data are fixed, we cannot clear anything
377 }
378 
380  if (!values.empty()) {
381  AutoPtr<IDrawPath> path = dc.drawPath();
382  for (Size i = 0; i < values.size() - 1; ++i) {
383  dc.drawPoint(values[i]);
384  path->addPoint(values[i]);
385  }
386  dc.drawPoint(values.back());
387  path->addPoint(values.back());
388  path->endPath();
389  }
390 }
391 
392 // ----------------------------------------------------------------------------------------------------------
393 // MultiPlot
394 // ----------------------------------------------------------------------------------------------------------
395 
396 void MultiPlot::onTimeStep(const Storage& storage, const Statistics& stats) {
397  ranges.x = ranges.y = Interval();
398  for (auto& plot : plots) {
399  plot->onTimeStep(storage, stats);
400  ranges.x.extend(plot->rangeX());
401  ranges.y.extend(plot->rangeY());
402  }
403 }
404 
406  ranges.x = ranges.y = Interval();
407  for (auto& plot : plots) {
408  plot->clear();
409  }
410 }
411 
413  for (auto plotAndIndex : iterateWithIndex(plots)) {
414  dc.setStyle(plotAndIndex.index());
415  plotAndIndex.value()->plot(dc);
416  }
417 }
418 
419 // ----------------------------------------------------------------------------------------------------------
420 // getTics
421 // ----------------------------------------------------------------------------------------------------------
422 
423 Array<Float> getLinearTics(const Interval& interval, const Size minCount) {
424  Float order = floor(log10(interval.size()));
425 
426  auto getTicsInterval = [interval](const Float step) {
427  return Interval(ceil(interval.lower() / step) * step, floor(interval.upper() / step) * step);
428  };
429 
430  Float step;
431  while (true) {
432  step = pow(10._f, order);
433  SPH_ASSERT(step >= std::numeric_limits<Float>::denorm_min());
434  if (getTicsInterval(step).size() < step * minCount) {
435  order--;
436  } else {
437  break;
438  }
439  }
440 
441  // Now we have step 10^order, which might be too small, we thus also allow step 2*10^order (2, 4, 6, ...)
442  // and 5*10^order (5, 10, 15, ...). This can be modified if necessary.
443  if (getTicsInterval(5 * step).size() >= 5 * step * minCount) {
444  step *= 5;
445  } else if (getTicsInterval(2 * step).size() >= 2 * step * minCount) {
446  step *= 2;
447  }
448  const Interval ticsInterval = getTicsInterval(step);
449 
450  Array<Float> tics;
451  for (Float x = ticsInterval.lower(); x <= ticsInterval.upper() + EPS * step; x += step) {
452  tics.push(x);
453  }
454  SPH_ASSERT(tics.size() >= minCount && tics.size() < 10 * minCount);
455  return tics;
456 }
457 
458 Array<Float> getLogTics(const Interval& interval, const Size minCount) {
459  SPH_ASSERT(interval.lower() > EPS); // could be relaxed if we need to plot some very low quantities
460  const Float fromOrder = floor(log10(interval.lower()));
461  const Float toOrder = ceil(log10(interval.upper()));
462  SPH_ASSERT(isReal(fromOrder) && isReal(toOrder) && toOrder >= fromOrder);
463 
464  std::set<Float> tics;
465  // try stepping in integer orders (1, 10, 100, ...)
466  for (Float order = fromOrder; order <= toOrder; order++) {
467  const Float value = pow(10._f, order);
468  if (interval.contains(value)) {
469  tics.insert(value);
470  }
471  }
472 
473  if (tics.size() < minCount) {
474  // add 2, 5, 20, 50, ...
475  for (Float order = fromOrder; order <= toOrder; order++) {
476  const Float value = pow(10._f, order);
477  if (interval.contains(2._f * value)) {
478  tics.insert(2._f * value);
479  }
480  if (interval.contains(5._f * value)) {
481  tics.insert(5._f * value);
482  }
483  }
484  }
485 
486  // sanity check that we do not create a large number of tics - increase the 20 if more tics is ever
487  // actually needed
488  SPH_ASSERT(tics.size() >= minCount && tics.size() < 20);
489 
490  Array<Float> result;
491  for (Float t : tics) {
492  result.push(t);
493  }
494  return result;
495 }
496 
INLINE bool isReal(const AntisymmetricTensor &t)
#define SPH_ASSERT(x,...)
Definition: Assert.h:94
NAMESPACE_SPH_BEGIN
Definition: BarnesHut.cpp:13
uint32_t Size
Integral type used to index arrays (by default).
Definition: Globals.h:16
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
Definition: Globals.h:13
Base class for all particle materials.
IndexAdapter< TContainer > iterateWithIndex(TContainer &&container)
Logging routines of the run.
constexpr INLINE T max(const T &f1, const T &f2)
Definition: MathBasic.h:20
NAMESPACE_SPH_BEGIN constexpr INLINE T min(const T &f1, const T &f2)
Minimum & Maximum value.
Definition: MathBasic.h:15
constexpr Float EPS
Definition: MathUtils.h:30
INLINE T sin(const T f)
Definition: MathUtils.h:296
INLINE auto floor(const T &f)
Definition: MathUtils.h:346
INLINE T cos(const T f)
Definition: MathUtils.h:291
constexpr INLINE Float pow(const Float v)
Power for floats.
INLINE T log10(const T f)
Definition: MathUtils.h:331
constexpr Float INFTY
Definition: MathUtils.h:38
INLINE T atan2(const T y, const T x)
Definition: MathUtils.h:321
INLINE auto ceil(const T &f)
Definition: MathUtils.h:351
constexpr Float PI
Mathematical constants.
Definition: MathUtils.h:361
#define UNUSED(x)
Definition: Object.h:37
#define NAMESPACE_SPH_END
Definition: Object.h:12
Array< Float > getLinearTics(const Interval &interval, const Size minCount)
Returns the tics to be drawn on a linear axis of a plot.
Definition: Plot.cpp:423
Array< Float > getLogTics(const Interval &interval, const Size minCount)
Returns the tics to be drawn on a logarithmic axis of a plot.
Definition: Plot.cpp:458
Drawing quantity values as functions of time or spatial coordinates.
QuantityId
Unique IDs of basic quantities of SPH particles.
Definition: QuantityIds.h:19
@ POSITION
Positions (velocities, accelerations) of particles, always a vector quantity,.
Statistics gathered and periodically displayed during the run.
@ RUN_TIME
Current time of the simulation in code units. Does not necessarily have to be 0 when run starts.
Container for storing particle quantities and materials.
@ Y
Definition: Vector.h:23
@ X
Definition: Vector.h:22
virtual void onTimeStep(const Storage &storage, const Statistics &stats) override
Updates the plot with new data.
Definition: Plot.cpp:221
AngularHistogramPlot(const Float period)
Definition: Plot.cpp:218
virtual void clear() override
Clears all cached data, prepares for next run.
Definition: Plot.cpp:258
virtual void plot(IDrawingContext &dc) const override
Draws the plot into the drawing context.
Definition: Plot.cpp:263
INLINE TCounter size() const
Definition: ArrayView.h:101
void reserve(const TCounter newMaxSize)
Allocates enough memory to store the given number of elements.
Definition: Array.h:279
INLINE Iterator< StorageType > end() noexcept
Definition: Array.h:462
INLINE void push(U &&u)
Adds new element to the end of the array, resizing the array if necessary.
Definition: Array.h:306
StorageType & emplaceBack(TArgs &&... args)
Constructs a new element at the end of the array in place, using the provided arguments.
Definition: Array.h:332
void fill(const T &t)
Sets all elements of the array to given value.
Definition: Array.h:187
INLINE T & back() noexcept
Definition: Array.h:176
void clear()
Removes all elements from the array, but does NOT release the memory.
Definition: Array.h:434
INLINE TCounter size() const noexcept
Definition: Array.h:193
INLINE T & front() noexcept
Definition: Array.h:166
INLINE bool empty() const noexcept
Definition: Array.h:201
INLINE Iterator< StorageType > begin() noexcept
Definition: Array.h:450
Wrapper of pointer that deletes the resource from destructor.
Definition: AutoPtr.h:15
virtual void plot(IDrawingContext &dc) const override
Draws the plot into the drawing context.
Definition: Plot.cpp:379
virtual void onTimeStep(const Storage &storage, const Statistics &stats) override
Updates the plot with new data.
Definition: Plot.cpp:371
virtual std::string getCaption() const override
Returns the caption of the plot.
Definition: Plot.cpp:367
DataPlot(const Array< Post::HistPoint > &points, const Flags< AxisScaleEnum > scale, const std::string &name)
Definition: Plot.cpp:348
virtual void clear() override
Clears all cached data, prepares for next run.
Definition: Plot.cpp:375
constexpr INLINE bool has(const TEnum flag) const
Checks if the object has a given flag.
Definition: Flags.h:77
Float period
Period of redrawing the histogram. Zero means the histogram is drawn every time step.
Definition: Plot.h:256
virtual void plot(IDrawingContext &dc) const override
Draws the plot into the drawing context.
Definition: Plot.cpp:202
Float lastTime
Definition: Plot.h:261
virtual void clear() override
Clears all cached data, prepares for next run.
Definition: Plot.cpp:198
Optional< Interval > interval
Definition: Plot.h:253
Array< Post::HistPoint > points
Points representing the histogram.
Definition: Plot.h:248
virtual void onTimeStep(const Storage &storage, const Statistics &stats) override
Updates the plot with new data.
Definition: Plot.cpp:175
Abstraction of a drawing context.
Definition: Plot.h:34
virtual void drawLine(const PlotPoint &from, const PlotPoint &to)=0
Draws a line connecting two points.
virtual AutoPtr< IDrawPath > drawPath()=0
Draws a path connecting points.
virtual void setStyle(const Size index)=0
Changes the current drawing style.
virtual void drawPoint(const PlotPoint &point)=0
Adds a single point to the plot.
struct IPlot::@12 ranges
Interval y
Definition: Plot.h:79
Interval x
Definition: Plot.h:78
virtual Float evaluate(const Storage &storage) const override
Computes the integral quantity using particles in the storage.
Definition: Integrals.h:246
Object representing a 1D interval of real numbers.
Definition: Interval.h:17
INLINE Float lower() const
Returns lower bound of the interval.
Definition: Interval.h:74
INLINE Float upper() const
Returns upper bound of the interval.
Definition: Interval.h:79
INLINE Float size() const
Returns the size of the interval.
Definition: Interval.h:89
INLINE bool contains(const Float &value) const
Checks whether value is inside the interval.
Definition: Interval.h:55
INLINE bool empty() const
Returns true if the interval is empty (default constructed).
Definition: Interval.h:104
virtual void clear() override
Clears all cached data, prepares for next run.
Definition: Plot.cpp:405
virtual void onTimeStep(const Storage &storage, const Statistics &stats) override
Updates the plot with new data.
Definition: Plot.cpp:396
virtual void plot(IDrawingContext &dc) const override
Draws the plot into the drawing context.
Definition: Plot.cpp:412
INLINE Type & value()
Returns the reference to the stored value.
Definition: Optional.h:172
INLINE bool empty() const
Returns true if the queue contains no elements.
Definition: Queue.h:145
INLINE T & back()
Returns a reference to the last element in the queue.
Definition: Queue.h:122
INLINE Size size() const
Returns the number of elements in the queue.
Definition: Queue.h:138
void clear()
Removes all elements from the queue.
Definition: Queue.h:202
INLINE T & front()
Returns a reference to the first element in the queue.
Definition: Queue.h:106
T popFront()
Removes an element from the front of the queue.
Definition: Queue.h:180
void pushBack(const T &value)
Adds a new element to the back of the queue.
Definition: Queue.h:166
Plots a dependence of given quantity on the distance from the origin.
Definition: Plot.h:159
RadialDistributionPlot(const QuantityId id, const Optional< Size > binCnt=NOTHING)
Definition: Plot.cpp:77
TValue get(const TEnum idx, std::enable_if_t<!std::is_enum< std::decay_t< TValue >>::value, int >=0) const
Returns a value of given type from the settings.
Definition: Settings.h:326
bool has(const TEnum idx) const
Checks if the given entry is stored in the settings.
Definition: Settings.h:414
virtual void clear() override
Clears all cached data, prepares for next run.
Definition: Plot.cpp:325
virtual std::string getCaption() const override
Returns the caption of the plot.
Definition: Plot.cpp:290
virtual void plot(IDrawingContext &dc) const override
Draws the plot into the drawing context.
Definition: Plot.cpp:331
virtual void onTimeStep(const Storage &storage, const Statistics &stats) override
Updates the plot with new data.
Definition: Plot.cpp:294
SfdPlot(const Flags< Post::ComponentFlag > connectivity, const Float period)
Plots SFD of components, given their connectivity.
Definition: Plot.cpp:277
Base class for plots showing a dependence of given quantity on a spatial coordinate.
Definition: Plot.h:113
virtual void clear() override
Clears all cached data, prepares for next run.
Definition: Plot.cpp:62
virtual void plot(IDrawingContext &dc) const override
Draws the plot into the drawing context.
Definition: Plot.cpp:68
virtual void onTimeStep(const Storage &storage, const Statistics &UNUSED(stats)) override
Definition: Plot.cpp:17
Object holding various statistics about current run.
Definition: Statistics.h:22
TValue get(const StatisticsId idx) const
Returns value of a statistic.
Definition: Statistics.h:88
Container storing all quantities used within the simulations.
Definition: Storage.h:230
Size getMaterialCnt() const
Return the number of materials in the storage.
Definition: Storage.cpp:437
Array< TValue > & getDt(const QuantityId key)
Retrieves a quantity derivative from the storage, given its key and value type.
Definition: Storage.cpp:217
MaterialView getMaterial(const Size matIdx) const
Returns an object containing a reference to given material.
Definition: Storage.cpp:366
Array< TValue > & getValue(const QuantityId key)
Retrieves a quantity values from the storage, given its key and value type.
Definition: Storage.cpp:191
virtual void plot(IDrawingContext &dc) const override
Draws the plot into the drawing context.
Definition: Plot.cpp:149
virtual void clear() override
Clears all cached data, prepares for next run.
Definition: Plot.cpp:142
virtual void onTimeStep(const Storage &storage, const Statistics &stats) override
Updates the plot with new data.
Definition: Plot.cpp:85
2D point and other primitives for 2D geometry
@ DENSITY
Density at zero pressure.
Array< HistPoint > getDifferentialHistogram(ArrayView< const Float > values, const HistogramParams &params)
Computes the differential histogram from given values.
Definition: Analysis.cpp:861
@ COMPONENTS
Equivalent radii of connected chunks of particles (SPH framework)
@ PARTICLES
Radii of individual particles, considering particles as spheres (N-body framework)
Array< HistPoint > getCumulativeHistogram(const Storage &storage, const ExtHistogramId id, const HistogramSource source, const HistogramParams &params)
Computes cumulative (integral) histogram of particles in the storage.
Definition: Analysis.cpp:814
Point in 2D plot.
Definition: Point.h:16
Float y
Definition: Point.h:17
Float x
Definition: Point.h:17
Point in the histogram.
Definition: Analysis.h:277
Flags< Post::ComponentFlag > flags
Determines how the particles are clustered into the components.
Definition: Analysis.h:266
Parameters of the histogram.
Definition: Analysis.h:227
Float velocityCutoff
Cutoff value (upper bound) of particle velocity for inclusion in the histogram.
Definition: Analysis.h:253
Float referenceDensity
Reference density, used when computing particle radii from their masses.
Definition: Analysis.h:240
Interval range
Range of values from which the histogram is constructed.
Definition: Analysis.h:232
struct Post::HistogramParams::ComponentParams components
Size binCnt
Number of histogram bins.
Definition: Analysis.h:237
Float segment
Plotted time segment.
Definition: Plot.h:178
Interval fixedRangeX
Fixed x-range for the plot. If empty, a dynamic range is used.
Definition: Plot.h:181
Float minRangeY
Minimal size of the y-range.
Definition: Plot.h:184
Float period
Time that needs to pass before a new point is added.
Definition: Plot.h:194
bool shrinkY
When discarting points out of plotted range, shrink y-axis to fit currently visible points.
Definition: Plot.h:187