STARCDCoordinateRotation.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2017-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
30 #include "unitConversion.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37  namespace coordinateRotations
38  {
39  defineTypeName(starcd);
40 
41  // Standard short name
43  (
44  coordinateRotation,
45  starcd,
46  dictionary,
47  starcd
48  );
49 
50  // Longer name - Compat 1806
52  (
53  coordinateRotation,
54  starcd,
55  dictionary,
56  STARCDRotation
57  );
58  }
59 }
60 
61 
62 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
63 
65 (
66  const vector& angles,
67  bool degrees
68 )
69 {
70  scalar z = angles.component(vector::X); // 1. Rotate about Z
71  scalar x = angles.component(vector::Y); // 2. Rotate about X
72  scalar y = angles.component(vector::Z); // 3. Rotate about Y
73 
74  if (degrees)
75  {
76  x *= degToRad();
77  y *= degToRad();
78  z *= degToRad();
79  }
80 
81  const scalar cx = cos(x); const scalar sx = sin(x);
82  const scalar cy = cos(y); const scalar sy = sin(y);
83  const scalar cz = cos(z); const scalar sz = sin(z);
84 
85  return
86  tensor
87  (
88  cy*cz - sx*sy*sz, -cx*sz, sx*cy*sz + sy*cz,
89  cy*sz + sx*sy*cz, cx*cz, sy*sz - sx*cy*cz,
90  -cx*sy, sx, cx*cy
91  );
92 }
93 
94 
95 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
96 
98 :
100  angles_(Zero),
101  degrees_(true)
102 {}
103 
104 
106 :
108  angles_(crot.angles_),
109  degrees_(crot.degrees_)
110 {}
111 
112 
114 (
115  const vector& rotZrotXrotY,
116  bool degrees
117 )
118 :
120  angles_(rotZrotXrotY),
121  degrees_(degrees)
122 {}
123 
124 
126 (
127  scalar rotZ,
128  scalar rotX,
129  scalar rotY,
130  bool degrees
131 )
132 :
134  angles_(rotZ, rotX, rotY),
135  degrees_(degrees)
136 {}
137 
138 
140 :
142  angles_(dict.get<vector>("angles")),
143  degrees_(dict.getOrDefault("degrees", true))
144 {}
145 
146 
147 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
148 
150 {
151  angles_ = Zero;
152  degrees_ = true;
153 }
154 
155 
157 {
158  return starcd::rotation(angles_, degrees_);
159 }
160 
161 
163 {
164  os << "starcd-angles(" << (degrees_ ? "deg" : "rad") << "): " << angles_;
165 }
166 
167 
169 (
170  const word& keyword,
171  Ostream& os
172 ) const
173 {
174  os.beginBlock(keyword);
175 
176  os.writeEntry("type", type());
177  os.writeEntry("angles", angles_);
178  if (!degrees_)
179  {
180  os.writeEntry("degrees", "false");
181  }
182 
183  os.endBlock();
184 }
185 
186 
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::Tensor
A templated (3 x 3) tensor of objects of <T> derived from MatrixSpace.
Definition: complexI.H:268
Foam::Vector< scalar >::Z
@ Z
Definition: Vector.H:77
Foam::Vector< scalar >::Y
@ Y
Definition: Vector.H:77
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:63
Foam::Zero
static constexpr const zero Zero
Definition: zero.H:131
Foam::sin
dimensionedScalar sin(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:257
Foam::coordinateRotations::starcd::R
virtual tensor R() const
Definition: STARCDCoordinateRotation.C:149
unitConversion.H
Unit conversion functions.
Foam::VectorSpace::component
const Cmpt & component(const direction) const
Foam::coordinateRotations::starcd::clear
virtual void clear()
Definition: STARCDCoordinateRotation.C:142
STARCDCoordinateRotation.H
Foam::coordinateRotations::starcd::writeEntry
virtual void writeEntry(const word &keyword, Ostream &os) const
Definition: STARCDCoordinateRotation.C:162
Foam::coordinateRotations::starcd
A coordinateRotation defined by the STAR-CD convention.
Definition: STARCDCoordinateRotation.H:91
Foam::coordinateRotation
User specification of a coordinate rotation.
Definition: coordinateRotation.H:75
Foam::Vector< scalar >::X
@ X
Definition: Vector.H:77
Foam::coordinateRotations::defineTypeName
defineTypeName(axes)
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:119
os
OBJstream os(runTime.globalPath()/outputName)
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Definition: atmBoundaryLayer.C:26
Foam::coordinateRotations::addNamedToRunTimeSelectionTable
addNamedToRunTimeSelectionTable(coordinateRotation, axes, dictionary, axes)
Y
PtrList< volScalarField > & Y
Definition: createFieldRefs.H:7
Foam::degToRad
constexpr scalar degToRad(const scalar deg) noexcept
Definition: unitConversion.H:44
Foam::coordinateRotations::starcd::write
virtual void write(Ostream &os) const
Definition: STARCDCoordinateRotation.C:155
Foam::Vector< scalar >
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Definition: POSIX.C:717
x
x
Definition: LISASMDCalcMethod2.H:52
Foam::PtrListOps::get
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:52
Foam::coordinateRotations::starcd::starcd
starcd()
Definition: STARCDCoordinateRotation.C:90
Foam::tensor
Tensor< scalar > tensor
Tensor of scalars, i.e. Tensor<scalar>.
Definition: symmTensor.H:57
Foam::coordinateRotations::starcd::rotation
static tensor rotation(const vector &angles, bool degrees)
Definition: STARCDCoordinateRotation.C:58
y
scalar y
Definition: LISASMDCalcMethod1.H:14
Foam::cos
dimensionedScalar cos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:258