FEDEM Solver  R8.0
Source code of the dynamics solver
FFa3DLocation.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 FFA_3D_LOCATION_H
9 #define FFA_3D_LOCATION_H
10 
13 
14 class FaMat33;
15 class FaMat34;
16 
17 
19 {
20 public:
21 
22  enum PosType {
30  };
31 
32  enum RotType {
36  DIR_EX_EXY
37  };
38 
39 private:
40 
42  FFaEnumEntry(CART_X_Y_Z , "CART_X_Y_Z");
43  FFaEnumEntry(CYL_R_YR_X , "CYL_R_YR_X");
44  FFaEnumEntry(CYL_R_ZR_Y , "CYL_R_ZR_Y");
45  FFaEnumEntry(CYL_R_XR_Z , "CYL_R_XR_Z");
46  FFaEnumEntry(SPH_R_XR_YZ, "SPH_R_XR_YZ");
47  FFaEnumEntry(SPH_R_YR_ZX, "SPH_R_YR_ZX");
48  FFaEnumEntry(SPH_R_ZR_XY, "SPH_R_ZR_XY");
50  };
51 
53  FFaEnumEntry(EUL_Z_Y_X , "EUL_Z_Y_X" );
54  FFaEnumEntry(PNT_PZ_PXZ, "PNT_PZ_PXZ");
55  FFaEnumEntry(PNT_PX_PXY, "PNT_PX_PXY");
56  FFaEnumEntry(DIR_EX_EXY, "DIR_EX_EXY");
58  };
59 
61 
62  FaVec3 myL[3];
63  PosTypeEnum myPosTyp;
64  RotTypeEnum myRotTyp;
65 
66 public:
67  FFa3DLocation(bool saveNumericalData = true);
68  FFa3DLocation(PosType t, const FaVec3& v0,
69  RotType r, const FaVec3& v1, const FaVec3& v2);
70  FFa3DLocation(PosType t, const FaVec3& v0, RotType r, const FaVec3& v1);
71  FFa3DLocation(const FFa3DLocation& m) { *this = m; saveMyNumericalData = true; }
72  FFa3DLocation(const FaMat34& m);
73 
74  void setSaveNumericalData(bool doSave) { saveMyNumericalData = doSave; }
75 
76  // Local operators
77 
80 
81  bool operator== (const FFa3DLocation& m) const { return isCoincident(m); }
82  bool operator!= (const FFa3DLocation& m) const { return !isCoincident(m); }
83  bool isCoincident (const FFa3DLocation& m, double tolerance = 1.0e-7) const;
84 
85  // Indexing
86 
87  const FaVec3& operator[] (int i) const;
88  FaVec3& operator[] (int i);
89 
90  PosType getPosType() const { return myPosTyp; }
91  RotType getRotType() const { return myRotTyp; }
92  int getNumFields() const;
93 
94  // Converting and setting
95 
98 
99  FFa3DLocation& changePosRefCS(const FaMat34& newRef, const FaMat34& oldRef);
100  FFa3DLocation& changeRotRefCS(const FaMat34& newRef, const FaMat34& oldRef);
101 
102  FFa3DLocation& set(PosType p, const FaMat34& posRelMx,
103  RotType r, const FaMat34& rotRelMx, const FaMat34& glbPos);
104  FFa3DLocation& set(PosType p, RotType r, const FaMat34& glbPos);
105 
106  FFa3DLocation& setPos(PosType p, const FaVec3& cartPos);
107  FFa3DLocation& setRot(RotType r, const FaMat33& rotMat);
108 
109  FaVec3 translation() const;
110  FaMat33 direction () const;
111  FaMat34 getMatrix () const;
112  FaMat34 getMatrix (const FaMat34& posRelMx, const FaMat34& rotRelMx) const;
113 
114  FFa3DLocation& setIdentity() { *this = FFa3DLocation(); return *this; }
115  bool isValid() const;
116 
117  // Global operators
118 
119  friend std::ostream& operator<< ( std::ostream& s, const FFa3DLocation& m);
120  friend std::istream& operator>> ( std::istream& s, FFa3DLocation& m);
121 };
122 
123 
124 // --- inline functions ---
125 
126 inline const FaVec3& FFa3DLocation::operator[] (int i) const
127 {
128 #ifdef FFA_INDEXCHECK
129  if (i < 0 || i > 2)
130  std::cerr <<"FFa3DLocation::operator[]: index i="<< i
131  <<" is out of range [0,2]"<< std::endl;
132 #endif
133  return myL[i];
134 }
135 
137 {
138 #ifdef FFA_INDEXCHECK
139  if (i < 0 || i > 2)
140  std::cerr <<"FFa3DLocation::operator[]: index i="<< i
141  << " is out of range [0,2]"<< std::endl;
142 #endif
143  return myL[i];
144 }
145 
146 #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
Point vectors in 3D space.
Definition: FFa3DLocation.H:19
FFa3DLocation & setPos(PosType p, const FaVec3 &cartPos)
Definition: FFa3DLocation.C:220
PosType getPosType() const
Definition: FFa3DLocation.H:90
FFa3DLocation & changePosType(PosType newType)
Definition: FFa3DLocation.C:99
bool saveMyNumericalData
If false, only the type enums are saved.
Definition: FFa3DLocation.H:58
FFa3DLocation & set(PosType p, const FaMat34 &posRelMx, RotType r, const FaMat34 &rotRelMx, const FaMat34 &glbPos)
Definition: FFa3DLocation.C:178
RotType
Definition: FFa3DLocation.H:32
@ EUL_Z_Y_X
Euler ZYX-angles. Supposed to be entered [ X, Y, Z].
Definition: FFa3DLocation.H:33
@ PNT_PX_PXY
Point on X-axis and point in XY-plane.
Definition: FFa3DLocation.H:34
@ PNT_PZ_PXZ
Point on Z-axis and point in XZ-plane.
Definition: FFa3DLocation.H:35
@ DIR_EX_EXY
Direction vector along X-axis, direction vector in XY-plane.
Definition: FFa3DLocation.H:36
FaVec3 translation() const
Definition: FFa3DLocation.C:308
bool isValid() const
Definition: FFa3DLocation.C:429
const FaVec3 & operator[](int i) const
Definition: FFa3DLocation.H:126
FFa3DLocation & changeRotRefCS(const FaMat34 &newRef, const FaMat34 &oldRef)
Definition: FFa3DLocation.C:151
FFa3DLocation & setIdentity()
Definition: FFa3DLocation.H:114
FFa3DLocation & operator=(const FFa3DLocation &m)
Definition: FFa3DLocation.C:67
int getNumFields() const
Definition: FFa3DLocation.C:386
FFa3DLocation(bool saveNumericalData=true)
Definition: FFa3DLocation.C:20
FaMat33 direction() const
Definition: FFa3DLocation.C:349
friend std::ostream & operator<<(std::ostream &s, const FFa3DLocation &m)
Definition: FFa3DLocation.C:468
bool operator==(const FFa3DLocation &m) const
Definition: FFa3DLocation.H:81
void setSaveNumericalData(bool doSave)
Definition: FFa3DLocation.H:74
FaVec3 myL[3]
Definition: FFa3DLocation.H:62
bool isCoincident(const FFa3DLocation &m, double tolerance=1.0e-7) const
Definition: FFa3DLocation.C:89
PosType
Definition: FFa3DLocation.H:22
@ CART_X_Y_Z
Cartesian coordinates.
Definition: FFa3DLocation.H:23
@ CYL_R_YR_X
Cylindric coordinates, angle from Y-axis about X-axis.
Definition: FFa3DLocation.H:24
@ SPH_R_ZR_XY
Spherical coordinates, asimuth angle from Z-axis.
Definition: FFa3DLocation.H:29
@ CYL_R_ZR_Y
Cylindric coordinates, angle from Z-axis about Y-axis.
Definition: FFa3DLocation.H:25
@ SPH_R_XR_YZ
Spherical coordinates, asimuth angle from X-axis.
Definition: FFa3DLocation.H:27
@ CYL_R_XR_Z
Cylindric coordinates, angle from X-axis about Z-axis.
Definition: FFa3DLocation.H:26
@ SPH_R_YR_ZX
Spherical coordinates, asimuth angle from Y-axis.
Definition: FFa3DLocation.H:28
friend std::istream & operator>>(std::istream &s, FFa3DLocation &m)
Definition: FFa3DLocation.C:491
FFaEnumMapping(PosType)
Definition: FFa3DLocation.H:41
FFa3DLocation(const FFa3DLocation &m)
Definition: FFa3DLocation.H:71
bool operator!=(const FFa3DLocation &m) const
Definition: FFa3DLocation.H:82
PosTypeEnum myPosTyp
Definition: FFa3DLocation.H:63
FFa3DLocation & changeRotType(RotType newType)
Definition: FFa3DLocation.C:112
FaMat34 getMatrix() const
Definition: FFa3DLocation.C:404
RotTypeEnum myRotTyp
Definition: FFa3DLocation.H:64
FFa3DLocation & setRot(RotType r, const FaMat33 &rotMat)
Definition: FFa3DLocation.C:264
RotType getRotType() const
Definition: FFa3DLocation.H:91
FFaEnumMapping(RotType)
Definition: FFa3DLocation.H:52
FFa3DLocation & changePosRefCS(const FaMat34 &newRef, const FaMat34 &oldRef)
Definition: FFa3DLocation.C:126
Definition: FFaMat33.H:15
Definition: FFaMat34.H:16
Class for point vectors in 3D space.
Definition: FFaVec3.H:40
real(dp), dimension(:,:), allocatable m
Definition: inverseModule.f90:38
real(dp), dimension(:), allocatable v0
Definition: inverseModule.f90:26
real(dp), dimension(:), allocatable v1
Definition: inverseModule.f90:27
real(dp), dimension(:), allocatable v2
Definition: inverseModule.f90:28