FEDEM Solver  R8.0
Source code of the dynamics solver
FiRAOTable.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_RAO_TABLE_H
9 #define FI_RAO_TABLE_H
10 
11 #include <map>
12 #include <vector>
13 #include <iostream>
14 
15 
17 
18 struct RAOcomp
19 {
20  double ampl, phase;
21  RAOcomp(double a = 0.0, double p = 0.0) : ampl(a), phase(p) {}
22 
23  friend std::istream& operator>>(std::istream& is, RAOcomp& rao)
24  { is >> rao.ampl >> rao.phase; return is; }
25  friend std::ostream& operator<<(std::ostream& os, const RAOcomp& rao)
26  { os << rao.ampl <<' '<< rao.phase; return os; }
27 };
28 
29 struct RAOentry
30 {
38 
40  Roll(dof[ROLL]), Pitch(dof[PITCH]), Yaw(dof[YAW])
41  {
42  Surge = Sway = Heave = Roll = Pitch = Yaw = 0.0;
43  }
44 
45  const RAOcomp& operator[](int i) const { return dof[i]; }
46 
48  { for (int i = 0; i < NDOF; i++) dof[i] = rao.dof[i]; return *this; }
49 
50  friend std::istream& operator>>(std::istream& is, RAOentry& rao)
51  { for (int i = 0; i < NDOF; i++) is >> rao.dof[i]; return is; }
52  friend std::ostream& operator<<(std::ostream& os, const RAOentry& rao)
53  { for (int i = 0; i < NDOF; i++) os <<'\t'<< rao.dof[i]; return os; }
54 };
55 
56 typedef std::map<double,RAOentry> RAOTable;
57 typedef RAOTable::const_iterator RAOIter;
58 
59 
60 struct WaveComp
61 {
62  double A, omega, eps;
63  WaveComp() { A = omega = eps = 0.0; }
64  WaveComp(double a, double o, double e) : A(a), omega(o), eps(e) {}
66  { A = wc.A; omega = wc.omega; eps = wc.eps; return *this; }
67 };
68 
69 typedef std::vector<WaveComp> FiWave;
70 
71 
73 {
74 public:
75  size_t size() const { return myData.size(); }
76 
77  bool getValues(std::vector<double>& x,
78  std::vector<RAOcomp>& y, RAOdof idof) const;
79 
80  bool readDirection(std::istream& is, int angle = 0);
81 
82 private:
83  RAOcomp getValue(double freq, RAOdof idof) const;
84 
85  void applyToWave(FiWave& wave, RAOdof d) const;
86 
87 public:
88  static bool getDirections(const std::string& RAOfile,
89  std::vector<int>& angles);
90 
91  static bool applyRAO(const std::string& RAOfile, int direction,
92  const FiWave& wave, std::vector<FiWave>& motion);
93 
94  static bool applyRAO(const std::string& RAOfile, int direction,
95  int nRw, int nComp, const double* waveData,
96  std::vector<FiWave>& motion);
97 
98  static bool applyRAO(const std::string& RAOfile, int direction,
99  int nRw, int nComp, const double* waveData,
100  double** motionData);
101 
102  static bool extractMotion(const std::vector<FiWave>& motion,
103  int dof, double* motionData);
104 
105  friend std::istream& operator>>(std::istream& is, FiRAOTable& rao);
106  friend std::ostream& operator<<(std::ostream& os, const FiRAOTable& rao);
107 
108 private:
110 };
111 
112 #endif
RAOTable::const_iterator RAOIter
Definition: FiRAOTable.H:57
std::map< double, RAOentry > RAOTable
Definition: FiRAOTable.H:56
std::vector< WaveComp > FiWave
Definition: FiRAOTable.H:69
RAOdof
Definition: FiRAOTable.H:16
@ ROLL
Definition: FiRAOTable.H:16
@ SWAY
Definition: FiRAOTable.H:16
@ HEAVE
Definition: FiRAOTable.H:16
@ YAW
Definition: FiRAOTable.H:16
@ NDOF
Definition: FiRAOTable.H:16
@ SURGE
Definition: FiRAOTable.H:16
@ PITCH
Definition: FiRAOTable.H:16
Definition: FiRAOTable.H:73
bool getValues(std::vector< double > &x, std::vector< RAOcomp > &y, RAOdof idof) const
Definition: FiRAOTable.C:50
bool readDirection(std::istream &is, int angle=0)
Definition: FiRAOTable.C:104
void applyToWave(FiWave &wave, RAOdof d) const
Definition: FiRAOTable.C:172
static bool applyRAO(const std::string &RAOfile, int direction, const FiWave &wave, std::vector< FiWave > &motion)
Definition: FiRAOTable.C:183
RAOTable myData
Definition: FiRAOTable.H:109
static bool getDirections(const std::string &RAOfile, std::vector< int > &angles)
Definition: FiRAOTable.C:69
RAOcomp getValue(double freq, RAOdof idof) const
Definition: FiRAOTable.C:30
friend std::istream & operator>>(std::istream &is, FiRAOTable &rao)
Definition: FiRAOTable.C:136
size_t size() const
Definition: FiRAOTable.H:75
friend std::ostream & operator<<(std::ostream &os, const FiRAOTable &rao)
Definition: FiRAOTable.C:163
static bool extractMotion(const std::vector< FiWave > &motion, int dof, double *motionData)
Definition: FiRAOTable.C:242
real(sp), dimension(:,:,:), pointer a
Definition: diffractionModule.f90:21
real(sp), dimension(:,:), allocatable wave
Definition: diffractionModule.f90:18
integer(ptr), save, private x
Definition: extCtrlSysRoutinesModule.f90:16
Definition: FiRAOTable.H:19
RAOcomp(double a=0.0, double p=0.0)
Definition: FiRAOTable.H:21
double ampl
Definition: FiRAOTable.H:20
friend std::istream & operator>>(std::istream &is, RAOcomp &rao)
Definition: FiRAOTable.H:23
double phase
Definition: FiRAOTable.H:20
friend std::ostream & operator<<(std::ostream &os, const RAOcomp &rao)
Definition: FiRAOTable.H:25
Definition: FiRAOTable.H:30
RAOcomp & Pitch
Definition: FiRAOTable.H:36
RAOcomp & Surge
Definition: FiRAOTable.H:32
RAOentry()
Definition: FiRAOTable.H:39
friend std::ostream & operator<<(std::ostream &os, const RAOentry &rao)
Definition: FiRAOTable.H:52
RAOentry & operator=(const RAOentry &rao)
Definition: FiRAOTable.H:47
RAOcomp & Sway
Definition: FiRAOTable.H:33
RAOcomp & Heave
Definition: FiRAOTable.H:34
RAOcomp & Yaw
Definition: FiRAOTable.H:37
RAOcomp & Roll
Definition: FiRAOTable.H:35
RAOcomp dof[NDOF]
Definition: FiRAOTable.H:31
const RAOcomp & operator[](int i) const
Definition: FiRAOTable.H:45
friend std::istream & operator>>(std::istream &is, RAOentry &rao)
Definition: FiRAOTable.H:50
Definition: FiRAOTable.H:61
WaveComp()
Definition: FiRAOTable.H:63
double eps
Definition: FiRAOTable.H:62
WaveComp & operator=(const WaveComp &wc)
Definition: FiRAOTable.H:65
WaveComp(double a, double o, double e)
Definition: FiRAOTable.H:64
double omega
Definition: FiRAOTable.H:62
double A
Definition: FiRAOTable.H:62