EulerCoordinateRotation.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 | Copyright (C) 2011-2015 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>(NULL);
74 }
75 
76 
78 (
79  const vectorField& st
80 ) const
81 {
83  return tmp<vectorField>(NULL);
84 }
85 
86 
88 {
90  return NullObjectRef<tensorField>();
91 }
92 
93 
95 (
96  const tensorField& st
97 ) const
98 {
100  return tmp<tensorField>(NULL);
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>(NULL);
121 }
122 
123 
126 (
127  const vectorField& st
128 ) const
129 {
130  tmp<symmTensorField> tfld(new symmTensorField(st.size()));
131  symmTensorField& fld = tfld();
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 
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  {
167  theta *= 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  const EulerCoordinateRotation& r
280 )
281 :
282  R_(r.R_),
283  Rtr_(r.Rtr_)
284 {}
285 
286 
288 {
289  os.writeKeyword("e1") << e1() << token::END_STATEMENT << nl;
290  os.writeKeyword("e2") << e2() << token::END_STATEMENT << nl;
291  os.writeKeyword("e3") << e3() << token::END_STATEMENT << nl;
292 }
293 
294 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::EulerCoordinateRotation::calcTransform
void calcTransform(const scalar phiAngle, const scalar thetaAngle, const scalar psiAngle, const bool inDegrees=true)
Calculate transformation tensor.
Definition: EulerCoordinateRotation.C:153
Foam::Tensor
Templated 3D tensor derived from VectorSpace adding construction from 9 components,...
Definition: complexI.H:224
Foam::token::END_STATEMENT
@ END_STATEMENT
Definition: token.H:99
mathematicalConstants.H
Foam::SymmTensor< scalar >
Foam::Vector< scalar >::Z
@ Z
Definition: Vector.H:89
EulerCoordinateRotation.H
Foam::Vector< scalar >::Y
@ Y
Definition: Vector.H:89
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
Foam::sin
dimensionedScalar sin(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:255
Foam::tensor
Tensor< scalar > tensor
Tensor of scalars.
Definition: tensor.H:51
Foam::dictionary::lookup
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:449
Foam::EulerCoordinateRotation::transform
virtual tmp< vectorField > transform(const vectorField &st) const
Transform vectorField using transformation tensor field.
Definition: EulerCoordinateRotation.C:68
Foam::EulerCoordinateRotation::transformTensor
virtual tmp< tensorField > transformTensor(const tensorField &st) const
Transform tensor field using transformation tensorField.
Definition: EulerCoordinateRotation.C:95
Foam::EulerCoordinateRotation::Rtr_
tensor Rtr_
Global-to-Local transformation tensor.
Definition: EulerCoordinateRotation.H:74
Foam::dictionary::lookupOrDefault
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
Definition: dictionaryTemplates.C:33
Foam::VectorSpace::component
const Cmpt & component(const direction) const
Foam::EulerCoordinateRotation::invTransform
virtual tmp< vectorField > invTransform(const vectorField &st) const
Inverse transform vectorField using transformation tensor field.
Definition: EulerCoordinateRotation.C:78
Foam::symmTensorField
Field< symmTensor > symmTensorField
Specialisation of Field<T> for symmTensor.
Definition: primitiveFieldsFwd.H:51
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:365
Foam::EulerCoordinateRotation::Tr
virtual const tensorField & Tr() const
Return transformation tensor field.
Definition: EulerCoordinateRotation.C:87
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::EulerCoordinateRotation::EulerCoordinateRotation
EulerCoordinateRotation()
Construct null.
Definition: EulerCoordinateRotation.C:195
Foam::Vector< scalar >::X
@ X
Definition: Vector.H:89
Foam::EulerCoordinateRotation::write
virtual void write(Ostream &) const
Write.
Definition: EulerCoordinateRotation.C:287
Foam::I
static const sphericalTensor I(1)
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
fld
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))
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::SphericalTensor
Templated 3D SphericalTensor derived from VectorSpace adding construction from 1 component,...
Definition: SphericalTensor.H:51
psi
const volScalarField & psi
Definition: setRegionFluidFields.H:13
Foam::Vector< scalar >
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::Ostream::writeKeyword
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:59
Foam::EulerCoordinateRotation
A coordinateRotation defined in the z-x-y Euler convention.
Definition: EulerCoordinateRotation.H:63
Foam::constant::mathematical::pi
const scalar pi(M_PI)
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::SphericalTensor::I
static const SphericalTensor I
Definition: SphericalTensor.H:78
Foam::EulerCoordinateRotation::R_
tensor R_
Local-to-global transformation tensor.
Definition: EulerCoordinateRotation.H:71
Foam::EulerCoordinateRotation::transformVector
virtual tmp< symmTensorField > transformVector(const vectorField &st) const
Transform vectorField using transformation tensorField and return.
Definition: EulerCoordinateRotation.C:126
Foam::cos
dimensionedScalar cos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:256