NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
plotasset.hpp
Go to the documentation of this file.
1/*****************************************************************************
2 NumeRe: Framework fuer Numerische Rechnungen
3 Copyright (C) 2021 Erik Haenel et al.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17******************************************************************************/
18
19#ifndef PLOTASSET_HPP
20#define PLOTASSET_HPP
21
22#include "plotdef.hpp"
23#include "../interval.hpp"
24#include "../utils/tools.hpp"
25#include <mgl2/mgl.h>
26#include <string>
27#include <vector>
28#include <utility>
29
30
37{
38 std::vector<std::pair<mglData, mglData>> data;
39 std::vector<mglData> axes; // Might be reasonable to use an IntervalSet here to avoid blocking too much memory
41 std::string legend;
42 std::string boundAxes;
43
49 {
50 }
51
52 void create(PlotType _t, size_t nDim, size_t nAxes, const std::vector<size_t>& samples, size_t nLayers = 1);
53 void writeData(const mu::value_type& val, size_t layer, size_t x, size_t y = 0, size_t z = 0);
54 void writeAxis(double val, size_t pos, PlotCoords c = XCOORD);
55 void duplicatePoints();
58 IntervalSet getDataIntervals(size_t layer = 0) const;
59 mglData norm(size_t layer) const;
60 mglData arg(size_t layer) const;
61 bool isComplex(size_t layer = 0) const;
62 void applyModulus(PlotCoords c, double mod);
63 mglData vectorsToMatrix() const;
64 IntervalSet getWeightedRanges(size_t layer = 0, double dLowerPercentage = 1.0, double dUpperPercentage = 1.0) const;
65
76 void create1DPlot(PlotType _t, size_t nSamples, size_t datarows = 1)
77 {
78 create(_t, 1, 1, {nSamples}, datarows);
79 }
80
91 void create3DPlot(PlotType _t, size_t nSamples, size_t datarows = 1)
92 {
93 create(_t, 1, 0, {nSamples}, 3*datarows);
94 }
95
106 void create2DMesh(PlotType _t, const std::vector<size_t>& samples, size_t nLayers = 1)
107 {
108 create(_t, 2, 2, samples, nLayers);
109 }
110
121 void create3DMesh(PlotType _t, const std::vector<size_t>& samples, size_t nLayers = 1)
122 {
123 create(_t, 3, 3, samples, nLayers);
124 }
125
135 void create2DVect(PlotType _t, const std::vector<size_t>& samples)
136 {
137 create(_t, 2, 2, samples, 2);
138 }
139
149 void create3DVect(PlotType _t, const std::vector<size_t>& samples)
150 {
151 create(_t, 3, 3, samples, 3);
152 }
153
160 size_t getDim() const
161 {
162 return axes.size();
163 }
164
171 size_t getLayers() const
172 {
173 return data.size();
174 }
175};
176
177
179{
182 ONLYRIGHT = -3
184
185
191{
192 public:
193 std::vector<PlotAsset> assets;
194
196 {
202 };
203
204 private:
205 std::pair<double,double> m_maxnorm;
206 IntervalSet getIntervalsOfType(PlotType t, int coord) const;
208
209 public:
210 void normalize(int t_animate);
211 IntervalSet getDataIntervals(int coord = ALLRANGES) const;
212 IntervalSet getFunctionIntervals(int coord = ALLRANGES) const;
213 IntervalSet getWeightedFunctionIntervals(int coord = ALLRANGES, double dLowerPercentage = 1.0, double dUpperPercentage = 1.0) const;
215 IntervalSet getDataAxes() const;
216 void weightedRange(int coord, Interval& ivl) const;
217 bool hasDataPlots() const;
218 void applyCoordSys(CoordinateSystem coords, size_t every = 1);
219};
220
221#endif // PLOTASSET_HPP
222
223
This class represents a single interval in code providing reading access functionality.
Definition: interval.hpp:34
This class combines the plotassets into a single structure.
Definition: plotasset.hpp:191
void weightedRange(int coord, Interval &ivl) const
This member function does the "undefined data point" magic, where the range of the plot is chosen so ...
Definition: plotasset.cpp:636
IntervalSet getIntervalsOfType(PlotType t, int coord) const
Returns the intervals fitting to all selected data and type.
Definition: plotasset.cpp:413
IntervalSet getFunctionAxes() const
Returns the axis intervals of function plots.
Definition: plotasset.cpp:619
IntervalSet getDataIntervals(int coord=ALLRANGES) const
Returns the intervals fitting to all selected data.
Definition: plotasset.cpp:532
IntervalSet getFunctionIntervals(int coord=ALLRANGES) const
Returns the intervals fitting to all selected data.
Definition: plotasset.cpp:546
IntervalSet getDataAxes() const
Returns the axis intervals of data plots.
Definition: plotasset.cpp:606
bool hasDataPlots() const
Returns true, if the manager contains some data plots.
Definition: plotasset.cpp:666
void applyCoordSys(CoordinateSystem coords, size_t every=1)
Apply the necessary transformation for the selected coordinate system to the managed assets.
Definition: plotasset.cpp:688
IntervalSet getWeightedFunctionIntervals(int coord=ALLRANGES, double dLowerPercentage=1.0, double dUpperPercentage=1.0) const
Returns the central function quantiles.
Definition: plotasset.cpp:561
std::pair< double, double > m_maxnorm
Definition: plotasset.hpp:205
void normalize(int t_animate)
Normalize the managed data to be below 1 (or the starting amplitude in an animation).
Definition: plotasset.cpp:489
std::vector< PlotAsset > assets
Definition: plotasset.hpp:193
IntervalSet getAxisIntervalsOfType(PlotType t) const
Returns the axis intervals of the selected type.
Definition: plotasset.cpp:461
MUP_BASETYPE value_type
The numeric datatype used by the parser.
Definition: muParserDef.h:251
FunctionIntervalType
Definition: plotasset.hpp:179
@ ALLRANGES
Definition: plotasset.hpp:180
@ ONLYLEFT
Definition: plotasset.hpp:181
@ ONLYRIGHT
Definition: plotasset.hpp:182
PlotType
Definition: plotdef.hpp:24
@ PT_NONE
Definition: plotdef.hpp:25
CoordinateSystem
Definition: plotdef.hpp:59
PlotCoords
Definition: plotdef.hpp:40
@ XCOORD
Definition: plotdef.hpp:41
This class represents a set of intervals used together for calculations and simulations.
Definition: interval.hpp:84
A single plot data asset to be plotted. Contains the data, its axes and its type.
Definition: plotasset.hpp:37
size_t getDim() const
Return the internal data dimensions.
Definition: plotasset.hpp:160
std::vector< mglData > axes
Definition: plotasset.hpp:39
void create3DMesh(PlotType _t, const std::vector< size_t > &samples, size_t nLayers=1)
Convenience member function for 3D meshgrid-like plots.
Definition: plotasset.hpp:121
void create2DVect(PlotType _t, const std::vector< size_t > &samples)
Convenience member function for 2D vectorfield plots.
Definition: plotasset.hpp:135
void create2DMesh(PlotType _t, const std::vector< size_t > &samples, size_t nLayers=1)
Convenience member function for 2D meshgrid-like plots.
Definition: plotasset.hpp:106
size_t getLayers() const
Return the internal data layers.
Definition: plotasset.hpp:171
mglData norm(size_t layer) const
Get the absolute value of the complex value contained within this asset.
Definition: plotasset.cpp:238
IntervalSet getWeightedRanges(size_t layer=0, double dLowerPercentage=1.0, double dUpperPercentage=1.0) const
Get the centralized data quantiles.
Definition: plotasset.cpp:371
mglData arg(size_t layer) const
Get the phase angle of the complex value contained within this asset.
Definition: plotasset.cpp:260
PlotAsset()
PlotAsset constructor. Creates an empty and invalid asset.
Definition: plotasset.hpp:48
void duplicatePoints()
This function is a fix for the MathGL bug, which connects points outside of the data range.
Definition: plotasset.cpp:135
void applyModulus(PlotCoords c, double mod)
Apply a modulus to a selected axis (e.g. for curvilinear coordinates).
Definition: plotasset.cpp:300
std::vector< std::pair< mglData, mglData > > data
Definition: plotasset.hpp:38
void create3DPlot(PlotType _t, size_t nSamples, size_t datarows=1)
Convenience member function for 3D plots.
Definition: plotasset.hpp:91
IntervalSet getDataIntervals(size_t layer=0) const
Return the internal data arrays for real and imaginary values.
Definition: plotasset.cpp:208
void writeData(const mu::value_type &val, size_t layer, size_t x, size_t y=0, size_t z=0)
Convenience function to write multi- dimensional data to the internal data object.
Definition: plotasset.cpp:92
std::string legend
Definition: plotasset.hpp:41
void create1DPlot(PlotType _t, size_t nSamples, size_t datarows=1)
Convenience member function for 1D plots.
Definition: plotasset.hpp:76
bool isComplex(size_t layer=0) const
Return true, if the internal data is complex valued.
Definition: plotasset.cpp:282
std::string boundAxes
Definition: plotasset.hpp:42
void removeNegativeValues(PlotCoords c)
This function is a fix for the MathGL bug to connect points, which are out of data range....
Definition: plotasset.cpp:161
PlotType type
Definition: plotasset.hpp:40
mglData vectorsToMatrix() const
Converts the vectors in multiple layers into a single matrix.
Definition: plotasset.cpp:336
void writeAxis(double val, size_t pos, PlotCoords c=XCOORD)
Convenience function to write the axis values.
Definition: plotasset.cpp:115
void create(PlotType _t, size_t nDim, size_t nAxes, const std::vector< size_t > &samples, size_t nLayers=1)
Prepares the internal memory to fit the desired elements.
Definition: plotasset.cpp:36
Interval getAxisInterval(PlotCoords c=XCOORD) const
Return the interval, which is governed by the corresponding axis.
Definition: plotasset.cpp:191
void create3DVect(PlotType _t, const std::vector< size_t > &samples)
Convenience member function for 3D vectorfield plots.
Definition: plotasset.hpp:149