FEDEM Solver  R8.0
Source code of the dynamics solver
FFpCurve.H
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2023 SAP SE
2 //
3 // SPDX-License-Identifier: Apache-2.0
4 //
5 // This file is part of FEDEM - https://openfedem.org
7 
8 #ifndef FFP_CURVE_H
9 #define FFP_CURVE_H
10 
11 #include <vector>
12 #include <string>
13 
14 #include "FFpLib/FFpFatigue/FFpCycle.H"
17 
18 class FFrExtractor;
21 class FFpSNCurve;
22 struct DFTparams;
23 
24 struct RFprm
25 {
26  double start;
27  double stop;
28  double gateValue;
29  RFprm(double g = 0.0) : start(0.0), stop(-1.0), gateValue(g) {}
30  RFprm(double t0, double t1, double g) : start(t0), stop(t1), gateValue(g) {}
31 };
32 
33 
34 class FFpCurve
35 {
36  enum { X = 0, Y = 1, N_AXES = 2 };
37 
38 public:
39  enum TimeOp { None, Min, Max, AMax, Mean, RMS };
40 
42  FFaEnumEntry(None, "None");
43  FFaEnumEntry(Min, "Min");
44  FFaEnumEntry(Max, "Max");
45  FFaEnumEntry(AMax, "Absolute Max");
46  FFaEnumEntry(Mean, "Mean");
47  FFaEnumEntry(RMS, "RMS");
49  };
50 
51  FFpCurve (size_t nSpatialPoints = 1) { this->resize(nSpatialPoints); }
52  FFpCurve (const FFpCurve& curve);
53  ~FFpCurve ();
54 
55  FFpCurve& operator= (const FFpCurve&) = delete;
56 
57  void clear ();
58  void resize (size_t nSpatialPoints);
59  void unref (bool clearReadOp = false);
60  bool initAxis (const FFaResultDescription& desc,
61  const std::string& oper, int axis);
62  bool initAxes (const std::vector<FFaResultDescription>& xdesc,
63  const std::vector<FFaResultDescription>& ydesc,
64  const std::string& xOper, const std::string& yOper,
65  const std::pair<double,double>& tRange,
66  const std::string& tOper, short int end1);
67  int getSpatialXaxisObject (size_t i) const;
68 
69  const std::pair<double,double>& getTimeRange() const { return timeRange; }
70 
71  bool notReadThisFar (double& lastStep) const;
72  bool findVarRefsAndOpers (FFrExtractor* extractor, std::string& errMsg);
73  void printPosition (std::ostream& os) const;
74 
75  bool loadTemporalData (double currentTime);
76  bool loadSpatialData (double currentTime, const double epsT = 0.0);
77  bool loadCurrentSpatialX ();
78  void finalizeTimeOp ();
79  bool usingInitialXaxis () const { return useInitialXaxis; }
80 
81  bool loadFileData (const std::string& filePath, const std::string& channel,
82  std::string& errMsg, double minX = 0.0, double maxX =-1.0);
83 
84  bool combineData (int ID, const std::string& expression,
85  const std::vector<FFpCurve*>& compCurves,
86  const char** compNames, bool clipXdomain,
87  std::string& message);
88 
89  bool replaceByScaledShifted (const DFTparams& dft);
90  bool replaceByDerivative ();
91  bool replaceByIntegral ();
92  bool replaceByDFT (const DFTparams& dft, const std::string& cId,
93  std::string& errMsg);
94  bool replaceByRainflow (const RFprm& rf, double toMPa, bool doPVXonly,
95  const std::string& cId, std::string& errMsg);
96 
97  bool getCurveStatistics (bool entire, double start, double stop,
98  bool useScaledShifted, const DFTparams& dft,
99  double& rms, double& avg, double& stdDev,
100  double& integral, double& min, double& max,
101  std::string& errMsg) const;
102 
103  double getDamage (const RFprm& rf, double toMPa, const FFpSNCurve& sn);
104 
105  bool empty () const { return points[X].empty() && points[Y].empty(); }
106 
107  bool hasDataChanged () const { return dataChanged; }
108  void onDataPlotted () { dataChanged = false; }
109  void setDataChanged ();
110 
111  std::vector<double>& operator[](int axis) { return points[axis]; }
112  const std::vector<double>& getAxisData (int ax) const { return points[ax]; }
113 
114  double getValue (double x, bool& monotonX) const;
115 
116  double getXrange () const { return Xrange; }
117  bool inDomain (double x) const;
118  bool clipX (double Xmin, double Xmax);
119 
120  bool checkAxesSize ();
121 
122 private:
123  int numberOfSamples (double delta, double start, double stop) const;
124 
125  bool sample (double start, double stop, double shift, double scale,
126  bool subMean, size_t n, std::vector<double>& yOut,
127  std::string& errMsg) const;
128 
129  bool performRainflowCalc (const RFprm& rf, bool doPVXonly = false);
130 
131  bool reversePoints ();
132 
133  struct PointData
134  {
138  PointData() { rDescr = NULL; varRef = NULL; readOp = NULL; }
139  };
140 
141  friend std::ostream& operator<< (std::ostream& os, const PointData&);
142 
143  std::vector<PointData> reader[N_AXES];
144  std::string* rdOper[N_AXES];
145  std::vector<double> points[N_AXES];
146  std::vector<FFpCycle> cycles;
148  double lastKey;
149  double Xrange;
150  mutable size_t lastX;
151  mutable size_t timeSamples;
152  std::pair<double,double> timeRange;
155  short int beamEndFlag;
158 };
159 
160 #endif
Enum variables with text representations.
#define FFaEnumEntryEnd
Defines the end of an enum mapping definition.
Definition: FFaEnum.H:238
#define FFaEnumEntry(EnumValue, EnumText)
Adds one entry to the current enum mapping definition.
Definition: FFaEnum.H:234
Classes that make up the core of a operation/transformation system.
Class representing a result variable description.
Definition: FFaResultDescription.H:31
Definition: FFpCurve.H:35
double Xrange
Definition: FFpCurve.H:149
size_t timeSamples
Definition: FFpCurve.H:151
bool initAxis(const FFaResultDescription &desc, const std::string &oper, int axis)
Definition: FFpCurve.C:179
bool replaceByIntegral()
Definition: FFpCurve.C:815
bool reversePoints()
Definition: FFpCurve.C:1232
friend std::ostream & operator<<(std::ostream &os, const PointData &)
Definition: FFpCurve.C:362
int getSpatialXaxisObject(size_t i) const
Definition: FFpCurve.C:261
std::vector< FFpCycle > cycles
Definition: FFpCurve.H:146
int numberOfSamples(double delta, double start, double stop) const
Definition: FFpCurve.C:940
bool combineData(int ID, const std::string &expression, const std::vector< FFpCurve * > &compCurves, const char **compNames, bool clipXdomain, std::string &message)
Definition: FFpCurve.C:583
std::pair< double, double > timeRange
Definition: FFpCurve.H:152
short int beamEndFlag
Definition: FFpCurve.H:155
double getXrange() const
Definition: FFpCurve.H:116
void resize(size_t nSpatialPoints)
Definition: FFpCurve.C:84
double getDamage(const RFprm &rf, double toMPa, const FFpSNCurve &sn)
Definition: FFpCurve.C:1130
bool loadTemporalData(double currentTime)
Definition: FFpCurve.C:383
bool clipX(double Xmin, double Xmax)
Definition: FFpCurve.C:135
bool loadSpatialData(double currentTime, const double epsT=0.0)
Definition: FFpCurve.C:424
double getValue(double x, bool &monotonX) const
Definition: FFpCurve.C:703
bool hasDataChanged() const
Definition: FFpCurve.H:107
double lastKey
Definition: FFpCurve.H:148
const std::pair< double, double > & getTimeRange() const
Definition: FFpCurve.H:69
RFprm lastRF
Definition: FFpCurve.H:147
std::string * rdOper[N_AXES]
Definition: FFpCurve.H:144
bool getCurveStatistics(bool entire, double start, double stop, bool useScaledShifted, const DFTparams &dft, double &rms, double &avg, double &stdDev, double &integral, double &min, double &max, std::string &errMsg) const
Definition: FFpCurve.C:1027
const std::vector< double > & getAxisData(int ax) const
Definition: FFpCurve.H:112
std::vector< PointData > reader[N_AXES]
Definition: FFpCurve.H:143
void clear()
Definition: FFpCurve.C:66
bool inDomain(double x) const
Definition: FFpCurve.C:692
bool loadFileData(const std::string &filePath, const std::string &channel, std::string &errMsg, double minX=0.0, double maxX=-1.0)
Definition: FFpCurve.C:534
bool useInitialXaxis
Definition: FFpCurve.H:154
~FFpCurve()
Definition: FFpCurve.C:57
void setDataChanged()
Definition: FFpCurve.C:124
TimeOp
Definition: FFpCurve.H:39
@ AMax
Definition: FFpCurve.H:39
@ Min
Definition: FFpCurve.H:39
@ None
Definition: FFpCurve.H:39
@ RMS
Definition: FFpCurve.H:39
@ Mean
Definition: FFpCurve.H:39
@ Max
Definition: FFpCurve.H:39
size_t lastX
Definition: FFpCurve.H:150
bool usingInitialXaxis() const
Definition: FFpCurve.H:79
void finalizeTimeOp()
Definition: FFpCurve.C:519
void printPosition(std::ostream &os) const
Definition: FFpCurve.C:375
std::vector< double > points[N_AXES]
Definition: FFpCurve.H:145
void unref(bool clearReadOp=false)
Definition: FFpCurve.C:113
bool replaceByDFT(const DFTparams &dft, const std::string &cId, std::string &errMsg)
Definition: FFpCurve.C:839
bool performRainflowCalc(const RFprm &rf, bool doPVXonly=false)
Definition: FFpCurve.C:1187
bool replaceByScaledShifted(const DFTparams &dft)
Definition: FFpCurve.C:758
bool notReadThisFar(double &lastStep) const
Definition: FFpCurve.C:270
bool initAxes(const std::vector< FFaResultDescription > &xdesc, const std::vector< FFaResultDescription > &ydesc, const std::string &xOper, const std::string &yOper, const std::pair< double, double > &tRange, const std::string &tOper, short int end1)
Definition: FFpCurve.C:192
bool sample(double start, double stop, double shift, double scale, bool subMean, size_t n, std::vector< double > &yOut, std::string &errMsg) const
Definition: FFpCurve.C:992
bool dataChanged
Definition: FFpCurve.H:156
@ Y
Definition: FFpCurve.H:36
@ X
Definition: FFpCurve.H:36
@ N_AXES
Definition: FFpCurve.H:36
TimeOp timeOper
Definition: FFpCurve.H:153
bool empty() const
Definition: FFpCurve.H:105
FFpCurve(size_t nSpatialPoints=1)
Definition: FFpCurve.H:51
bool replaceByDerivative()
Definition: FFpCurve.C:787
bool loadCurrentSpatialX()
Definition: FFpCurve.C:498
bool replaceByRainflow(const RFprm &rf, double toMPa, bool doPVXonly, const std::string &cId, std::string &errMsg)
Definition: FFpCurve.C:1148
bool needRainflow
Definition: FFpCurve.H:157
FFpCurve & operator=(const FFpCurve &)=delete
bool checkAxesSize()
Definition: FFpCurve.C:164
bool findVarRefsAndOpers(FFrExtractor *extractor, std::string &errMsg)
Definition: FFpCurve.C:286
FFaEnumMapping(TimeOp)
Definition: FFpCurve.H:41
std::vector< double > & operator[](int axis)
Definition: FFpCurve.H:111
void onDataPlotted()
Definition: FFpCurve.H:108
Front-end for the result extraction module.
Definition: FFrExtractor.H:44
Definition: FFrVariableReference.H:18
integer(ptr), save, private x
Definition: extCtrlSysRoutinesModule.f90:16
real(dp), save, private g
Definition: FNVwaveForceModule.f90:42
integer channel
Column index for data file.
Definition: initiateFunctionTypeModule.f90:26
character(len=500) expression
Explicit function expression.
Definition: initiateFunctionTypeModule.f90:35
Definition: FFpDFTparams.H:13
Definition: FFpCurve.H:134
FFaResultDescription * rDescr
Definition: FFpCurve.H:135
FFaOperation< double > * readOp
Definition: FFpCurve.H:137
FFrVariableReference * varRef
Definition: FFpCurve.H:136
PointData()
Definition: FFpCurve.H:138
Definition: FFpCurve.H:25
double start
Definition: FFpCurve.H:26
RFprm(double g=0.0)
Definition: FFpCurve.H:29
double gateValue
Definition: FFpCurve.H:28
double stop
Definition: FFpCurve.H:27
RFprm(double t0, double t1, double g)
Definition: FFpCurve.H:30
subroutine scale(vec, a)
Definition: windTurbineRoutinesModule.f90:510