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-2013 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  (
74  "tmp<vectorField> Foam::EulerCoordinateRotation:: "
75  "transform(const vectorField& st) const"
76  );
77  return tmp<vectorField>(NULL);
78 }
79 
80 
82 (
83  const vectorField& st
84 ) const
85 {
87  (
88  "tmp<vectorField> Foam::EulerCoordinateRotation::"
89  "invTransform(const vectorField& st) const"
90  );
91  return tmp<vectorField>(NULL);
92 }
93 
94 
96 {
98  (
99  "const tensorField& EulerCoordinateRotation::Tr() const"
100  );
101  return NullObjectRef<tensorField>();
102 }
103 
104 
106 (
107  const tensorField& st
108 ) const
109 {
111  (
112  "const tensorField& EulerCoordinateRotation::transformTensor() const"
113  );
114  return tmp<tensorField>(NULL);
115 }
116 
117 
119 (
120  const tensor& st
121 ) const
122 {
123  return (R_ & st & Rtr_);
124 }
125 
126 
128 (
129  const tensorField& st,
130  const labelList& cellMap
131 ) const
132 {
134  (
135  "tmp<Foam::tensorField> EulerCoordinateRotation::transformTensor "
136  " const tensorField& st,"
137  " const labelList& cellMap "
138  ") const"
139  );
140  return tmp<tensorField>(NULL);
141 }
142 
143 
146 (
147  const vectorField& st
148 ) const
149 {
150  tmp<symmTensorField> tfld(new symmTensorField(st.size()));
151  symmTensorField& fld = tfld();
152 
153  forAll(fld, i)
154  {
155  fld[i] = transformPrincipal(R_, st[i]);
156  }
157  return tfld;
158 }
159 
160 
162 (
163  const vector& st
164 ) const
165 {
166  return transformPrincipal(R_, st);
167 }
168 
169 
170 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
171 
172 void Foam::EulerCoordinateRotation::calcTransform
173 (
174  const scalar phiAngle,
175  const scalar thetaAngle,
176  const scalar psiAngle,
177  const bool inDegrees
178 )
179 {
180  scalar phi = phiAngle;
181  scalar theta = thetaAngle;
182  scalar psi = psiAngle;
183 
184  if (inDegrees)
185  {
186  phi *= constant::mathematical::pi/180.0;
187  theta *= constant::mathematical::pi/180.0;
188  psi *= constant::mathematical::pi/180.0;
189  }
190 
191  R_ =
192  (
193  tensor
194  (
195  cos(phi)*cos(psi) - sin(phi)*sin(psi)*cos(theta),
196  -sin(phi)*cos(psi)*cos(theta) - cos(phi)*sin(psi),
197  sin(phi)*sin(theta),
198 
199  cos(phi)*sin(psi)*cos(theta) + sin(phi)*cos(psi),
200  cos(phi)*cos(psi)*cos(theta) - sin(phi)*sin(psi),
201  -cos(phi)*sin(theta),
202 
203  sin(psi)*sin(theta),
204  cos(psi)*sin(theta),
205  cos(theta)
206  )
207  );
208 
209  Rtr_ = R_.T();
210 }
211 
212 
213 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
214 
216 :
217  R_(sphericalTensor::I),
218  Rtr_(R_)
219 {}
220 
221 
223 (
224  const vector& phiThetaPsi,
225  const bool inDegrees
226 )
227 :
228  R_(sphericalTensor::I),
229  Rtr_(R_)
230 {
231  calcTransform
232  (
233  phiThetaPsi.component(vector::X),
234  phiThetaPsi.component(vector::Y),
235  phiThetaPsi.component(vector::Z),
236  inDegrees
237  );
238 }
239 
240 
242 (
243  const scalar phiAngle,
244  const scalar thetaAngle,
245  const scalar psiAngle,
246  const bool inDegrees
247 )
248 :
249  R_(sphericalTensor::I),
250  Rtr_(R_)
251 {
252  calcTransform(phiAngle, thetaAngle, psiAngle, inDegrees);
253 }
254 
255 
257 (
258  const dictionary& dict
259 )
260 :
261  R_(sphericalTensor::I),
262  Rtr_(R_)
263 {
264  vector rotation(dict.lookup("rotation"));
265 
266  calcTransform
267  (
268  rotation.component(vector::X),
269  rotation.component(vector::Y),
270  rotation.component(vector::Z),
271  dict.lookupOrDefault("degrees", true)
272  );
273 }
274 
275 
277 (
278  const dictionary& dict,
279  const objectRegistry&
280 )
281 :
282  R_(sphericalTensor::I),
283  Rtr_(R_)
284 {
285  vector rotation(dict.lookup("rotation"));
286 
287  calcTransform
288  (
289  rotation.component(vector::X),
290  rotation.component(vector::Y),
291  rotation.component(vector::Z),
292  dict.lookupOrDefault("degrees", true)
293  );
294 }
295 
296 
298 {
299  os.writeKeyword("e1") << e1() << token::END_STATEMENT << nl;
300  os.writeKeyword("e2") << e2() << token::END_STATEMENT << nl;
301  os.writeKeyword("e3") << e3() << token::END_STATEMENT << nl;
302 }
303 
304 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
virtual const vector e1() const
Return local Cartesian x-axis.
virtual const vector e2() const
Return local Cartesian y-axis.
virtual tmp< vectorField > invTransform(const vectorField &st) const
Inverse transform vectorField using transformation tensor field.
virtual tmp< tensorField > transformTensor(const tensorField &st) const
Transform tensor field using transformation tensorField.
Tensor< scalar > tensor
Tensor of scalars.
Definition: tensor.H:51
const Cmpt & component(const direction) const
Definition: VectorSpaceI.H:75
Templated 3D symmetric tensor derived from VectorSpace adding construction from 6 components...
Definition: SymmTensor.H:53
Field< symmTensor > symmTensorField
Specialisation of Field<T> for symmTensor.
static const sphericalTensor I(1)
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:76
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.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Namespace for OpenFOAM.
static const char nl
Definition: Ostream.H:260
virtual tmp< vectorField > transform(const vectorField &st) const
Transform vectorField using transformation tensor field.
#define forAll(list, i)
Definition: UList.H:421
dimensionedScalar cos(const dimensionedScalar &ds)
const volScalarField & psi
Definition: createFields.H:24
Macros for easy insertion into run-time selection tables.
virtual const tensorField & Tr() const
Return transformation tensor field.
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:59
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 ))
surfaceScalarField & phi
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:452
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
Registry of regIOobjects.
static const SphericalTensor I
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
virtual tmp< symmTensorField > transformVector(const vectorField &st) const
Transform vectorField using transformation tensorField and return.
#define notImplemented(functionName)
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:356
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
A class for managing temporary objects.
Definition: PtrList.H:118
virtual const vector e3() const
Return local Cartesian z-axis.
virtual void write(Ostream &) const
Write.
defineTypeNameAndDebug(combustionModel, 0)
dimensionedScalar sin(const dimensionedScalar &ds)