FEDEM Solver  R8.0
Source code of the dynamics solver
FiRPC3File.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 FI_RPC3_FILE_H
9 #define FI_RPC3_FILE_H
10 
11 #include "FiDeviceFunctionBase.H"
12 
13 
15 {
16 public:
17  FiRPC3File();
18  FiRPC3File(const char* devicename=0);
19  FiRPC3File(const char* devicename, int endianFormat);
20  FiRPC3File(const char* devicename, int endianFormat, int numberOfChannels);
21  virtual ~FiRPC3File() {}
22 
23  // --- Read parameters
24  virtual size_t getValueCount() const { return myNumDatavals; }
25  virtual void getValueRange(double& min, double& max) const;
26 
27  // --- Read single file value
28  virtual double getValue(double x, int channel = 0,
29  bool zeroAdjust = false, double vertShift = 0.0,
30  double scaleFac = 1.0);
31 
32  // --- Read all file values between the given range
33  virtual bool getValues(double x0, double x1,
34  std::vector<double>& x, std::vector<double>& y,
35  int channel = 0, bool zeroAdjust = false,
36  double shift = 0.0, double scale = 1.0);
37 
38  // --- Read all file values
39  virtual void getRawData(std::vector<double>& x, std::vector<double>& y,
40  double minX, double maxX, int channel = 0);
41 
42  virtual void getData(std::vector<double>& x, std::vector<double>& y,
43  const std::string& channel,
44  double minX = 0.0, double maxX = -1.0);
45 
46  // --- Write all file values
47  virtual void setValue(double, double) {}
48  virtual bool setData(const std::vector<double>& x,
49  const std::vector<double>& y);
50 
51  // --- Utilities
52  virtual bool getChannelList(std::vector<std::string>& list);
53  virtual int isChannelPresentInFile(const std::string& channel);
54  virtual bool isChannelPresentInFile(int channel);
55  virtual void setDescription(const std::string& desc);
56  virtual void setTimeSpan(double timeSpan) { myTimeSpan = timeSpan; }
57  virtual void setPrecision(int type) { myDataType = type; }
58 
59  int getRepeats() const { return myRepeats; }
60  void setRepeats(int rep) { myRepeats = rep; }
61 
62  int getAverages() const { return myAverages; }
63  void setAverages(int avg) { myAverages = avg; }
64 
65  int getFramePoints() const { return myNumFrmPts; }
66  void setFramePoints(int frm) { myNumFrmPts = frm; }
67 
68  int getGroupPoints() const { return myNumGrpPts; }
69  void setGroupPoints(int grp) { myNumGrpPts = grp; }
70 
71 protected:
72  virtual bool initialDeviceRead();
73  virtual bool preliminaryDeviceWrite();
74  virtual bool concludingDeviceWrite(bool);
75 
76 private:
77  void commonConstructor();
78 
79  // --- Internal utilities
80  bool readChannelList();
81  bool initTHChannel(int channel, int action);
82  int getPartition(int channel);
83  void setReadParams(int channel);
84 
85  // --- Key handling
86  void setKeyInt (const std::string& key, const int val, const int numb);
87  void setKeyFloat (const std::string& key, const float val, const int numb);
88  void setKeyString (const std::string& key, const std::string& val, const int numb);
89  int getKeyInt (const std::string& key, bool& ok);
90  float getKeyFloat (const std::string& key, bool& ok);
91  std::string getKeyString (const std::string& key, bool& ok);
92 
93  // --- Direct read and write
94  void writeString(const std::string& buf, FT_int pos, bool skipRepos = false);
95  void writeDouble(const double val, FT_int pos, bool skipRepos = false);
96  void writeFloat (const float val, FT_int pos, bool skipRepos = false);
97  void writeInt16 (const short val, FT_int pos, bool skipRepos = false);
98  std::string readString(FT_int pos, bool castToUpperCase = false);
99  double readDouble(FT_int pos, bool asciiField = false);
100  float readFloat (FT_int pos, bool asciiField = false);
101  short readInt16 (FT_int pos, bool asciiField = false);
102  int readInt32 (FT_int pos, bool asciiField = false);
103 
104  // --- Temporary test tool
105  void dumpAllKeysToScreen() const;
106 
107  // enums
112  enum DataType {ShortInt,Float,Double}; // Double is non-standard
114 
115  // vars
116  double myMaxVal;
117  double myMinVal;
118 
119  std::vector<std::string> myKeys;
120  std::vector<std::string> myChannels;
131 
143 
146  double myTimeSpan;
148 
149  struct chParams
150  {
152  int part;
154  };
155 
156  std::map<int,chParams> parameters;
157 
159  bool stepSet;
160  int kInd;
161 };
162 
163 #endif
#define FT_int
64-bit integer type.
Definition: FFaIO.H:134
Definition: FiDeviceFunctionBase.H:19
Definition: FiRPC3File.H:15
std::vector< std::string > myChannels
Definition: FiRPC3File.H:120
double readDouble(FT_int pos, bool asciiField=false)
Definition: FiRPC3File.C:1074
void setKeyInt(const std::string &key, const int val, const int numb)
Definition: FiRPC3File.C:837
FT_int myByteShift
Definition: FiRPC3File.H:134
int myNumPartitions
Definition: FiRPC3File.H:123
std::map< int, chParams > parameters
Definition: FiRPC3File.H:156
virtual ~FiRPC3File()
Definition: FiRPC3File.H:21
int getPartition(int channel)
Definition: FiRPC3File.C:448
int myFileType
Definition: FiRPC3File.H:136
int kInd
Definition: FiRPC3File.H:160
int readInt32(FT_int pos, bool asciiField=false)
Definition: FiRPC3File.C:1030
int myDataType
Definition: FiRPC3File.H:137
int myAverages
Definition: FiRPC3File.H:141
void writeDouble(const double val, FT_int pos, bool skipRepos=false)
Definition: FiRPC3File.C:943
int getFramePoints() const
Definition: FiRPC3File.H:65
virtual size_t getValueCount() const
Definition: FiRPC3File.H:24
std::string getKeyString(const std::string &key, bool &ok)
Definition: FiRPC3File.C:892
virtual bool getChannelList(std::vector< std::string > &list)
Definition: FiRPC3File.C:220
bool stepSet
Definition: FiRPC3File.H:159
void setReadParams(int channel)
Definition: FiRPC3File.C:542
void writeFloat(const float val, FT_int pos, bool skipRepos=false)
Definition: FiRPC3File.C:932
void setAverages(int avg)
Definition: FiRPC3File.H:63
int myNumGrpPts
Definition: FiRPC3File.H:125
void dumpAllKeysToScreen() const
Definition: FiRPC3File.C:1096
virtual bool getValues(double x0, double x1, std::vector< double > &x, std::vector< double > &y, int channel=0, bool zeroAdjust=false, double shift=0.0, double scale=1.0)
Definition: FiRPC3File.C:602
void setRepeats(int rep)
Definition: FiRPC3File.H:60
virtual void getData(std::vector< double > &x, std::vector< double > &y, const std::string &channel, double minX=0.0, double maxX=-1.0)
Definition: FiRPC3File.C:560
short readInt16(FT_int pos, bool asciiField=false)
Definition: FiRPC3File.C:1008
double myMaxVal
Definition: FiRPC3File.H:116
Action
Definition: FiRPC3File.H:113
@ toRead
Definition: FiRPC3File.H:113
@ toWrite
Definition: FiRPC3File.H:113
FiRPC3File()
Definition: FiRPC3File.C:27
virtual void getValueRange(double &min, double &max) const
Definition: FiRPC3File.C:213
int getGroupPoints() const
Definition: FiRPC3File.H:68
bool readChannelList()
Definition: FiRPC3File.C:228
int getAverages() const
Definition: FiRPC3File.H:62
int myPartition
Definition: FiRPC3File.H:139
float readFloat(FT_int pos, bool asciiField=false)
Definition: FiRPC3File.C:1052
int myRepeats
Definition: FiRPC3File.H:140
void setKeyFloat(const std::string &key, const float val, const int numb)
Definition: FiRPC3File.C:845
int myNumParams
Definition: FiRPC3File.H:128
double myTimeSpan
Definition: FiRPC3File.H:146
int myPhysChan
Definition: FiRPC3File.H:147
double myXaxisOrigin
Definition: FiRPC3File.H:132
virtual void setDescription(const std::string &desc)
Definition: FiRPC3File.C:745
int myChannel
Definition: FiRPC3File.H:142
double myMinVal
Definition: FiRPC3File.H:117
float getKeyFloat(const std::string &key, bool &ok)
Definition: FiRPC3File.C:877
double myFirstReadValue
Definition: FiRPC3File.H:133
int myDataFormat
Definition: FiRPC3File.H:138
int getRepeats() const
Definition: FiRPC3File.H:59
int myDataSize
Definition: FiRPC3File.H:129
virtual bool preliminaryDeviceWrite()
Definition: FiRPC3File.C:752
FileType
Definition: FiRPC3File.H:108
@ Configuration
Definition: FiRPC3File.H:108
@ Start
Definition: FiRPC3File.H:109
@ Regions
Definition: FiRPC3File.H:108
@ Road_Surface
Definition: FiRPC3File.H:109
@ Time_History
Definition: FiRPC3File.H:108
@ Histogram
Definition: FiRPC3File.H:108
@ Matrix
Definition: FiRPC3File.H:108
@ Fatigue
Definition: FiRPC3File.H:109
@ Spectral
Definition: FiRPC3File.H:109
int myNumChannels
Definition: FiRPC3File.H:124
void setFramePoints(int frm)
Definition: FiRPC3File.H:66
int myNumFrmPts
Definition: FiRPC3File.H:127
int myNumHeaderBlocks
Definition: FiRPC3File.H:122
size_t myNumDatavals
Definition: FiRPC3File.H:121
double myChannelScale
Definition: FiRPC3File.H:145
virtual bool concludingDeviceWrite(bool)
Definition: FiRPC3File.C:824
bool swapStringBytes
Definition: FiRPC3File.H:158
std::vector< std::string > myKeys
Definition: FiRPC3File.H:119
bool myHalfFrameUse
Definition: FiRPC3File.H:130
std::string readString(FT_int pos, bool castToUpperCase=false)
Definition: FiRPC3File.C:992
void writeInt16(const short val, FT_int pos, bool skipRepos=false)
Definition: FiRPC3File.C:921
int myNumFrames
Definition: FiRPC3File.H:126
bool initTHChannel(int channel, int action)
Definition: FiRPC3File.C:468
void writeString(const std::string &buf, FT_int pos, bool skipRepos=false)
Definition: FiRPC3File.C:909
void commonConstructor()
Definition: FiRPC3File.C:55
virtual bool initialDeviceRead()
Definition: FiRPC3File.C:98
virtual void setTimeSpan(double timeSpan)
Definition: FiRPC3File.H:56
TimeType
Definition: FiRPC3File.H:110
@ Mult_Resp
Definition: FiRPC3File.H:110
@ Mult_Drive
Definition: FiRPC3File.H:110
@ Response
Definition: FiRPC3File.H:110
@ Drive
Definition: FiRPC3File.H:110
@ Peak_pick
Definition: FiRPC3File.H:111
@ Config_Drive
Definition: FiRPC3File.H:110
@ Config_Resp
Definition: FiRPC3File.H:111
virtual void getRawData(std::vector< double > &x, std::vector< double > &y, double minX, double maxX, int channel=0)
Definition: FiRPC3File.C:567
virtual void setPrecision(int type)
Definition: FiRPC3File.H:57
virtual bool setData(const std::vector< double > &x, const std::vector< double > &y)
Definition: FiRPC3File.C:641
virtual double getValue(double x, int channel=0, bool zeroAdjust=false, double vertShift=0.0, double scaleFac=1.0)
Definition: FiRPC3File.C:288
void setKeyString(const std::string &key, const std::string &val, const int numb)
Definition: FiRPC3File.C:853
FT_int myPartShift
Definition: FiRPC3File.H:135
virtual int isChannelPresentInFile(const std::string &channel)
Definition: FiRPC3File.C:262
int getKeyInt(const std::string &key, bool &ok)
Definition: FiRPC3File.C:862
virtual void setValue(double, double)
Definition: FiRPC3File.H:47
DataType
Definition: FiRPC3File.H:112
@ Double
Definition: FiRPC3File.H:112
@ ShortInt
Definition: FiRPC3File.H:112
@ Float
Definition: FiRPC3File.H:112
void setGroupPoints(int grp)
Definition: FiRPC3File.H:69
bool myBypassFilter
Definition: FiRPC3File.H:144
integer(ptr), save, private x
Definition: extCtrlSysRoutinesModule.f90:16
integer channel
Column index for data file.
Definition: initiateFunctionTypeModule.f90:26
character(len=40) type
Function type flag.
Definition: initiateFunctionTypeModule.f90:33
Definition: FiRPC3File.H:150
double maxVal
Definition: FiRPC3File.H:151
double chScale
Definition: FiRPC3File.H:151
double X0val
Definition: FiRPC3File.H:151
FT_int partShift
Definition: FiRPC3File.H:153
FT_int byteShift
Definition: FiRPC3File.H:153
double minVal
Definition: FiRPC3File.H:151
int part
Definition: FiRPC3File.H:152
subroutine scale(vec, a)
Definition: windTurbineRoutinesModule.f90:510