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 | 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(STARCDCoordinateRotation, 0);
37  (
38  coordinateRotation,
39  STARCDCoordinateRotation,
40  dictionary
41  );
43  (
44  coordinateRotation,
45  STARCDCoordinateRotation,
46  objectRegistry
47  );
48 }
49 
50 
51 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
52 
54 {
55  return (R_ & st);
56 }
57 
58 
60 (
61  const vector& st
62 ) const
63 {
64  return (Rtr_ & st);
65 }
66 
67 
69 (
70  const vectorField& st
71 ) const
72 {
74  (
75  "tmp<vectorField> Foam::STARCDCoordinateRotation:: "
76  "transform(const vectorField& st) const"
77  );
78  return tmp<vectorField>(NULL);
79 }
80 
81 
83 (
84  const vectorField& st
85 ) const
86 {
88  (
89  "tmp<vectorField> Foam::STARCDCoordinateRotation::"
90  "invTransform(const vectorField& st) const"
91  );
92  return tmp<vectorField>(NULL);
93 }
94 
95 
97 {
99  (
100  "const tensorField& STARCDCoordinateRotatio::Tr() const"
101  );
102  return NullObjectRef<tensorField>();
103 }
104 
105 
107 (
108  const tensorField& st
109 ) const
110 {
112  (
113  "tmp<Foam::tensorField> STARCDCoordinateRotation::transformTensor()"
114  );
115  return tmp<tensorField>(NULL);
116 }
117 
118 
120 (
121  const tensor& st
122 ) const
123 {
124  return (R_ & st & Rtr_);
125 }
126 
127 
129 (
130  const tensorField& st,
131  const labelList& cellMap
132 ) const
133 {
135  (
136  "tmp<Foam::tensorField> STARCDCoordinateRotation::transformTensor "
137  " const tensorField& st,"
138  " const labelList& cellMap "
139  ") const"
140  );
141  return tmp<tensorField>(NULL);
142 }
143 
144 
147 (
148  const vectorField& st
149 ) const
150 {
151  tmp<symmTensorField> tfld(new symmTensorField(st.size()));
152  symmTensorField& fld = tfld();
153 
154  forAll(fld, i)
155  {
156  fld[i] = transformPrincipal(R_, st[i]);
157  }
158  return tfld;
159 }
160 
161 
163 (
164  const vector& st
165 ) const
166 {
167  return transformPrincipal(R_, st);
168 }
169 
170 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
171 
172 void Foam::STARCDCoordinateRotation::calcTransform
173 (
174  const scalar rotZ,
175  const scalar rotX,
176  const scalar rotY,
177  const bool inDegrees
178 )
179 {
180  scalar x = rotX;
181  scalar y = rotY;
182  scalar z = rotZ;
183 
184  if (inDegrees)
185  {
186  x *= constant::mathematical::pi/180.0;
187  y *= constant::mathematical::pi/180.0;
188  z *= constant::mathematical::pi/180.0;
189  }
190 
191  R_ =
192  (
193  tensor
194  (
195  cos(y)*cos(z) - sin(x)*sin(y)*sin(z),
196  -cos(x)*sin(z),
197  sin(x)*cos(y)*sin(z) + sin(y)*cos(z),
198 
199  cos(y)*sin(z) + sin(x)*sin(y)*cos(z),
200  cos(x)*cos(z),
201  sin(y)*sin(z) - sin(x)*cos(y)*cos(z),
202 
203  -cos(x)*sin(y),
204  sin(x),
205  cos(x)*cos(y)
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& rotZrotXrotY,
225  const bool inDegrees
226 )
227 :
228  R_(sphericalTensor::I),
229  Rtr_(R_)
230 {
231  calcTransform
232  (
233  rotZrotXrotY.component(vector::X),
234  rotZrotXrotY.component(vector::Y),
235  rotZrotXrotY.component(vector::Z),
236  inDegrees
237  );
238 }
239 
240 
242 (
243  const scalar rotZ,
244  const scalar rotX,
245  const scalar rotY,
246  const bool inDegrees
247 )
248 :
249  R_(sphericalTensor::I),
250  Rtr_(R_)
251 {
252  calcTransform(rotZ, rotX, rotY, 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  vector rotation(dict.lookup("rotation"));
283 
284  calcTransform
285  (
286  rotation.component(vector::X),
287  rotation.component(vector::Y),
288  rotation.component(vector::Z),
289  dict.lookupOrDefault("degrees", true)
290  );
291 }
292 
293 
295 {
296  os.writeKeyword("e1") << e1() << token::END_STATEMENT << nl;
297  os.writeKeyword("e2") << e2() << token::END_STATEMENT << nl;
298  os.writeKeyword("e3") << e3() << token::END_STATEMENT << nl;
299 }
300 
301 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
virtual tmp< tensorField > transformTensor(const tensorField &st) const
Transform tensor field using transformation tensorField.
virtual const vector e1() const
Return local Cartesian x-axis.
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.
virtual const vector e2() const
Return local Cartesian y-axis.
static const sphericalTensor I(1)
virtual const tensorField & Tr() const
Return transformation tensor field.
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 > invTransform(const vectorField &st) const
Inverse transform vectorField using transformation tensor field.
#define forAll(list, i)
Definition: UList.H:421
dimensionedScalar cos(const dimensionedScalar &ds)
Macros for easy insertion into run-time selection tables.
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 ))
virtual tmp< symmTensorField > transformVector(const vectorField &st) const
Transform vectorField using transformation tensorField and return.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:452
scalar y
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< vectorField > transform(const vectorField &st) const
Transform vectorField using transformation tensor field.
#define notImplemented(functionName)
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:356
virtual const vector e3() const
Return local Cartesian z-axis.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
A class for managing temporary objects.
Definition: PtrList.H:118
defineTypeNameAndDebug(combustionModel, 0)
virtual void write(Ostream &) const
Write.
dimensionedScalar sin(const dimensionedScalar &ds)