16 : colorizer(colorizer)
24 virtual std::string
getName()
const override {
25 return colorizer->
name() +
" " + std::to_string(selectedIdx);
30 : initialPeriod(initialPeriod) {}
35 if (selectedIdx.valueOr(-1) == idx.
valueOr(-1)) {
39 if (selectedIdx && currentPlot) {
41 plotCache.
insert(selectedIdx.value(), currentPlot);
50 currentPlot = cachedPlot.
value();
59 if (colorizer != newColorizer) {
60 colorizer = newColorizer;
70 return "Selected particle";
75 if (selectedIdx && currentPlot) {
81 for (
auto&
plot : plotCache) {
82 plot.value->onTimeStep(storage, stats);
90 makeAuto<SelectedParticleIntegral>(colorizer, selectedIdx.value());
94 params.
period = initialPeriod;
96 currentPlot = makeAuto<TemporalPlot>(std::move(integral), params);
105 currentPlot->
plot(dc);
119 if (!E_0 || E_0.
value() == 0._f) {
122 return E / E_0.
value() - 1._f;
125 virtual std::string
getName()
const override {
126 return "Relative energy change";
143 integral = makeAuto<TotalEnergy>();
144 data.plot = makeLocking<TemporalPlot>(integral, params);
145 data.color =
Rgba(wxColour(240, 255, 80));
152 integral = makeAuto<RelativeEnergyChange>();
153 data.plot = makeLocking<TemporalPlot>(integral, actParams);
154 data.color =
Rgba(wxColour(240, 255, 80));
159 integral = makeAuto<TotalKineticEnergy>();
160 data.plot = makeLocking<TemporalPlot>(integral, params);
161 data.color =
Rgba(wxColour(200, 0, 0));
166 integral = makeAuto<TotalInternalEnergy>();
167 data.plot = makeLocking<TemporalPlot>(integral, params);
168 data.color =
Rgba(wxColour(255, 50, 50));
173 integral = makeAuto<TotalMomentum>();
175 data.plot = makeLocking<TemporalPlot>(integral, params);
176 data.color =
Rgba(wxColour(100, 200, 0));
181 integral = makeAuto<TotalAngularMomentum>();
182 data.plot = makeLocking<TemporalPlot>(integral, params);
183 data.color =
Rgba(wxColour(130, 80, 255));
192 if (!overplotSfd.empty()) {
195 data.plot = makeLocking<MultiPlot>(std::move(multiplot));
196 data.color =
Rgba(wxColour(255, 40, 255));
204 if (!overplotSfd.empty()) {
207 data.plot = makeLocking<MultiPlot>(std::move(multiplot));
208 data.color =
Rgba(wxColour(80, 150, 255));
213 data.plot = makeLocking<HistogramPlot>(
215 data.color =
Rgba(wxColour(40, 100, 150));
220 data.plot = makeLocking<AngularHistogramPlot>(params.
period);
221 data.color =
Rgba(wxColour(250, 100, 50));
276 std::ifstream is(path.
native());
#define SPH_ASSERT(x,...)
Object converting quantity values of particles into colors.
uint32_t Size
Integral type used to index arrays (by default).
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
#define NAMESPACE_SPH_END
const NothingType NOTHING
Object representing a path on a filesystem, similar to std::filesystem::path in c++17.
Array< PlotData > getPlotList(const GuiSettings &gui)
AutoPtr< IPlot > getDataPlot(const Path &path, const std::string &name)
Generic dynamically allocated resizable storage.
INLINE void push(U &&u)
Adds new element to the end of the array, resizing the array if necessary.
StorageType & emplaceBack(TArgs &&... args)
Constructs a new element at the end of the array in place, using the provided arguments.
Wrapper of pointer that deletes the resource from destructor.
Wrapper of an integral value providing functions for reading and modifying individual bits.
constexpr INLINE bool has(const TEnum flag) const
Checks if the object has a given flag.
INLINE TValue & insert(const TKey &key, const TValue &value)
Adds a new element into the map or sets new value of element with the same key.
INLINE void clear()
Removes all elements from the map.
INLINE Optional< TValue & > tryGet(const TKey &key)
Returns a reference to the value matching the given key, or NOTHING if no such value exists.
INLINE TValue get(const GuiSettingsId id) const
virtual std::string name() const =0
Returns the name of the colorizer.
virtual Optional< float > evalScalar(const Size UNUSED(idx)) const
Returns the scalar representation of the colorized quantity for idx-th particle.
virtual bool isInitialized() const =0
Checks if the colorizer has been initialized.
Abstraction of a drawing context.
Interface for classes computing integral quantities from storage.
Helper integral wrapping another integral and converting the returned value to scalar.
INLINE Type & value()
Returns the reference to the stored value.
INLINE Type valueOr(const TOther &other) const
Returns the stored value if the object has been initialized, otherwise returns provided parameter.
Object representing a path on a filesystem.
std::string native() const
Returns the native version of the path.
virtual Float evaluate(const Storage &storage) const override
Computes the integral quantity using particles in the storage.
RelativeEnergyChange()=default
virtual std::string getName() const override
Returns the name of the integral.
virtual Float evaluate(const Storage &UNUSED(storage)) const override
SelectedParticleIntegral(SharedPtr< IColorizer > colorizer, const Size idx)
virtual std::string getName() const override
Returns the name of the integral.
void selectParticle(const Optional< Size > idx)
virtual void onTimeStep(const Storage &storage, const Statistics &stats) override
Updates the plot with new data.
SelectedParticlePlot(const Float initialPeriod)
virtual void plot(IDrawingContext &dc) const override
Draws the plot into the drawing context.
virtual std::string getCaption() const override
Returns the caption of the plot.
virtual void clear() override
Clears all cached data, prepares for next run.
void setColorizer(const SharedPtr< IColorizer > &newColorizer)
Flags< TValue > getFlags(const TEnum idx) const
Returns Flags from underlying value stored in settings.
Object holding various statistics about current run.
Container storing all quantities used within the simulations.
virtual void plot(IDrawingContext &dc) const override
Draws the plot into the drawing context.
virtual std::string getCaption() const override
Returns the caption of the plot.
virtual void onTimeStep(const Storage &storage, const Statistics &stats) override
Updates the plot with new data.
Returns the total energy of all particles.
virtual Float evaluate(const Storage &storage) const override
Computes the integral quantity using particles in the storage.
2D point and other primitives for 2D geometry
@ TOTAL_MOMENTUM
Evolution of the total momentum in time.
@ SPEED_HISTOGRAM
Speed histogram.
@ INTERNAL_ENERGY
Evolution of the total internal energy in time.
@ TOTAL_ANGULAR_MOMENTUM
Evolution of the total angular momentum in time.
@ KINETIC_ENERGY
Evolution of the total kinetic energy in time.
@ RELATIVE_ENERGY_CHANGE
Relative change of total energy.
@ CURRENT_SFD
Current size-frequency distribution.
@ ANGULAR_HISTOGRAM_OF_VELOCITIES
Angular histogram (in x-y plane) of velocity directions.
@ PREDICTED_SFD
Predicted size-frequency distribution.
@ OVERLAP
Specifies that overlapping particles belong into the same component.
@ VELOCITIES
Particle velocities.
Float minRangeY
Minimal size of the y-range.
Float period
Time that needs to pass before a new point is added.
bool shrinkY
When discarting points out of plotted range, shrink y-axis to fit currently visible points.