EulerCoordinateRotation.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
27 
28 #include "mathematicalConstants.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  defineTypeNameAndDebug(EulerCoordinateRotation, 0);
37  (
38  coordinateRotation,
39  EulerCoordinateRotation,
40  dictionary
41  );
43  (
44  coordinateRotation,
45  EulerCoordinateRotation,
46  objectRegistry
47  );
48 }
49 
50 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
51 
53 {
54  return (R_ & st);
55 }
56 
57 
59 (
60  const vector& st
61 ) const
62 {
63  return (Rtr_ & st);
64 }
65 
66 
68 (
69  const vectorField& st
70 ) const
71 {
73  return tmp<vectorField>(nullptr);
74 }
75 
76 
78 (
79  const vectorField& st
80 ) const
81 {
83  return tmp<vectorField>(nullptr);
84 }
85 
86 
88 {
90  return NullObjectRef<tensorField>();
91 }
92 
93 
95 (
96  const tensorField& st
97 ) const
98 {
100  return tmp<tensorField>(nullptr);
101 }
102 
103 
105 (
106  const tensor& st
107 ) const
108 {
109  return (R_ & st & Rtr_);
110 }
111 
112 
114 (
115  const tensorField& st,
116  const labelList& cellMap
117 ) const
118 {
120  return tmp<tensorField>(nullptr);
121 }
122 
123 
126 (
127  const vectorField& st
128 ) const
129 {
130  tmp<symmTensorField> tfld(new symmTensorField(st.size()));
131  symmTensorField& fld = tfld.ref();
132 
133  forAll(fld, i)
134  {
135  fld[i] = transformPrincipal(R_, st[i]);
136  }
137  return tfld;
138 }
139 
140 
142 (
143  const vector& st
144 ) const
145 {
146  return transformPrincipal(R_, st);
147 }
148 
149 
150 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
151 
152 void Foam::EulerCoordinateRotation::calcTransform
153 (
154  const scalar phiAngle,
155  const scalar thetaAngle,
156  const scalar psiAngle,
157  const bool inDegrees
158 )
159 {
160  scalar phi = phiAngle;
161  scalar theta = thetaAngle;
162  scalar psi = psiAngle;
163 
164  if (inDegrees)
165  {
166  phi *= constant::mathematical::pi/180.0;
167  theta *= constant::mathematical::pi/180.0;
168  psi *= constant::mathematical::pi/180.0;
169  }
170 
171  R_ =
172  (
173  tensor
174  (
175  cos(phi)*cos(psi) - sin(phi)*sin(psi)*cos(theta),
176  -sin(phi)*cos(psi)*cos(theta) - cos(phi)*sin(psi),
177  sin(phi)*sin(theta),
178 
179  cos(phi)*sin(psi)*cos(theta) + sin(phi)*cos(psi),
180  cos(phi)*cos(psi)*cos(theta) - sin(phi)*sin(psi),
181  -cos(phi)*sin(theta),
182 
183  sin(psi)*sin(theta),
184  cos(psi)*sin(theta),
185  cos(theta)
186  )
187  );
188 
189  Rtr_ = R_.T();
190 }
191 
192 
193 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
194 
196 :
197  R_(sphericalTensor::I),
198  Rtr_(R_)
199 {}
200 
201 
203 (
204  const vector& phiThetaPsi,
205  const bool inDegrees
206 )
207 :
208  R_(sphericalTensor::I),
209  Rtr_(R_)
210 {
211  calcTransform
212  (
213  phiThetaPsi.component(vector::X),
214  phiThetaPsi.component(vector::Y),
215  phiThetaPsi.component(vector::Z),
216  inDegrees
217  );
218 }
219 
220 
222 (
223  const scalar phiAngle,
224  const scalar thetaAngle,
225  const scalar psiAngle,
226  const bool inDegrees
227 )
228 :
229  R_(sphericalTensor::I),
230  Rtr_(R_)
231 {
232  calcTransform(phiAngle, thetaAngle, psiAngle, inDegrees);
233 }
234 
235 
237 (
238  const dictionary& dict
239 )
240 :
241  R_(sphericalTensor::I),
242  Rtr_(R_)
243 {
244  vector rotation(dict.lookup("rotation"));
245 
246  calcTransform
247  (
248  rotation.component(vector::X),
249  rotation.component(vector::Y),
250  rotation.component(vector::Z),
251  dict.lookupOrDefault("degrees", true)
252  );
253 }
254 
255 
257 (
258  const dictionary& dict,
259  const objectRegistry&
260 )
261 :
262  R_(sphericalTensor::I),
263  Rtr_(R_)
264 {
265  vector rotation(dict.lookup("rotation"));
266 
267  calcTransform
268  (
269  rotation.component(vector::X),
270  rotation.component(vector::Y),
271  rotation.component(vector::Z),
272  dict.lookupOrDefault("degrees", true)
273  );
274 }
275 
276 
278 {
279  writeEntry(os, "e1", e1());
280  writeEntry(os, "e2", e2());
281  writeEntry(os, "e3", e3());
282 }
283 
284 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
virtual const vector e2() const
Return local Cartesian y-axis in global coordinates.
Field< symmTensor > symmTensorField
Specialisation of Field<T> for symmTensor.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
virtual const vector e1() const
Return local Cartesian x-axis in global coordinates.
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:174
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
virtual tmp< tensorField > transformTensor(const tensorField &st) const
Transform tensor field using transformation tensorField.
virtual void write(Ostream &) const
Write.
Macros for easy insertion into run-time selection tables.
phi
Definition: pEqn.H:104
virtual const vector e3() const
Return local Cartesian z-axis in global coordinates.
Templated 3D SphericalTensor derived from VectorSpace adding construction from 1 component, element access using th ii() member function and the inner-product (dot-product) and outer-product operators.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< ' ';}gmvFile<< nl;forAll(lagrangianScalarNames, i){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
dimensionedScalar cos(const dimensionedScalar &ds)
static const Identity< scalar > I
Definition: Identity.H:93
virtual tmp< vectorField > transform(const vectorField &st) const
Transform vectorField using transformation tensor field.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
dimensionedScalar sin(const dimensionedScalar &ds)
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
defineTypeNameAndDebug(combustionModel, 0)
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
virtual const tensorField & Tr() const
Return transformation tensor field.
virtual tmp< vectorField > invTransform(const vectorField &st) const
Inverse transform vectorField using transformation tensor field.
const Cmpt & component(const direction) const
Definition: VectorSpaceI.H:91
const volScalarField & psi
A class for managing temporary objects.
Definition: PtrList.H:53
Registry of regIOobjects.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:366
Tensor< scalar > tensor
Tensor of scalars.
Definition: tensor.H:51
Namespace for OpenFOAM.
static const SphericalTensor I
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:812
virtual tmp< symmTensorField > transformVector(const vectorField &st) const
Transform vectorField using transformation tensorField and return.