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-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(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  return tmp<vectorField>(NULL);
75 }
76 
77 
79 (
80  const vectorField& st
81 ) const
82 {
84  return tmp<vectorField>(NULL);
85 }
86 
87 
89 {
91  return NullObjectRef<tensorField>();
92 }
93 
94 
96 (
97  const tensorField& st
98 ) const
99 {
101  return tmp<tensorField>(NULL);
102 }
103 
104 
106 (
107  const tensor& st
108 ) const
109 {
110  return (R_ & st & Rtr_);
111 }
112 
113 
115 (
116  const tensorField& st,
117  const labelList& cellMap
118 ) const
119 {
121  return tmp<tensorField>(NULL);
122 }
123 
124 
127 (
128  const vectorField& st
129 ) const
130 {
131  tmp<symmTensorField> tfld(new symmTensorField(st.size()));
132  symmTensorField& fld = tfld();
133 
134  forAll(fld, i)
135  {
136  fld[i] = transformPrincipal(R_, st[i]);
137  }
138  return tfld;
139 }
140 
141 
143 (
144  const vector& st
145 ) const
146 {
147  return transformPrincipal(R_, st);
148 }
149 
150 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
151 
153 (
154  const scalar rotZ,
155  const scalar rotX,
156  const scalar rotY,
157  const bool inDegrees
158 )
159 {
160  scalar x = rotX;
161  scalar y = rotY;
162  scalar z = rotZ;
163 
164  if (inDegrees)
165  {
166  x *= constant::mathematical::pi/180.0;
167  y *= constant::mathematical::pi/180.0;
168  z *= constant::mathematical::pi/180.0;
169  }
170 
171  R_ =
172  (
173  tensor
174  (
175  cos(y)*cos(z) - sin(x)*sin(y)*sin(z),
176  -cos(x)*sin(z),
177  sin(x)*cos(y)*sin(z) + sin(y)*cos(z),
178 
179  cos(y)*sin(z) + sin(x)*sin(y)*cos(z),
180  cos(x)*cos(z),
181  sin(y)*sin(z) - sin(x)*cos(y)*cos(z),
182 
183  -cos(x)*sin(y),
184  sin(x),
185  cos(x)*cos(y)
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& rotZrotXrotY,
205  const bool inDegrees
206 )
207 :
208  R_(sphericalTensor::I),
209  Rtr_(R_)
210 {
211  calcTransform
212  (
213  rotZrotXrotY.component(vector::X),
214  rotZrotXrotY.component(vector::Y),
215  rotZrotXrotY.component(vector::Z),
216  inDegrees
217  );
218 }
219 
220 
222 (
223  const scalar rotZ,
224  const scalar rotX,
225  const scalar rotY,
226  const bool inDegrees
227 )
228 :
229  R_(sphericalTensor::I),
230  Rtr_(R_)
231 {
232  calcTransform(rotZ, rotX, rotY, 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  vector rotation(dict.lookup("rotation"));
263 
264  calcTransform
265  (
266  rotation.component(vector::X),
267  rotation.component(vector::Y),
268  rotation.component(vector::Z),
269  dict.lookupOrDefault("degrees", true)
270  );
271 }
272 
273 
275 (
276  const STARCDCoordinateRotation& r
277 )
278 :
279  R_(r.R_),
280  Rtr_(r.Rtr_)
281 {}
282 
283 
285 {
286  os.writeKeyword("e1") << e1() << token::END_STATEMENT << nl;
287  os.writeKeyword("e2") << e2() << token::END_STATEMENT << nl;
288  os.writeKeyword("e3") << e3() << token::END_STATEMENT << nl;
289 }
290 
291 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::Tensor
Templated 3D tensor derived from VectorSpace adding construction from 9 components,...
Definition: complexI.H:224
Foam::STARCDCoordinateRotation::Rtr_
tensor Rtr_
Global-to-Local transformation tensor.
Definition: STARCDCoordinateRotation.H:71
Foam::STARCDCoordinateRotation::Tr
virtual const tensorField & Tr() const
Return transformation tensor field.
Definition: STARCDCoordinateRotation.C:88
Foam::token::END_STATEMENT
@ END_STATEMENT
Definition: token.H:99
mathematicalConstants.H
Foam::SymmTensor< scalar >
Foam::Vector< scalar >::Z
@ Z
Definition: Vector.H:89
Foam::Vector< scalar >::Y
@ Y
Definition: Vector.H:89
Foam::STARCDCoordinateRotation::transform
virtual tmp< vectorField > transform(const vectorField &st) const
Transform vectorField using transformation tensor field.
Definition: STARCDCoordinateRotation.C:69
Foam::STARCDCoordinateRotation
A coordinateRotation defined by the STAR-CD convention.
Definition: STARCDCoordinateRotation.H:60
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)
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::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::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::STARCDCoordinateRotation::calcTransform
void calcTransform(const scalar rotZ, const scalar rotX, const scalar rotY, const bool inDegrees=true)
Calculate transformation tensor.
Definition: STARCDCoordinateRotation.C:153
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
STARCDCoordinateRotation.H
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::STARCDCoordinateRotation::write
virtual void write(Ostream &) const
Write.
Definition: STARCDCoordinateRotation.C:284
Foam::Vector< scalar >::X
@ X
Definition: Vector.H:89
Foam::STARCDCoordinateRotation::transformTensor
virtual tmp< tensorField > transformTensor(const tensorField &st) const
Transform tensor field using transformation tensorField.
Definition: STARCDCoordinateRotation.C:96
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::STARCDCoordinateRotation::R_
tensor R_
Local-to-Global transformation tensor.
Definition: STARCDCoordinateRotation.H:68
Foam::SphericalTensor
Templated 3D SphericalTensor derived from VectorSpace adding construction from 1 component,...
Definition: SphericalTensor.H:51
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
x
x
Definition: LISASMDCalcMethod2.H:52
Foam::constant::mathematical::pi
const scalar pi(M_PI)
Foam::STARCDCoordinateRotation::STARCDCoordinateRotation
STARCDCoordinateRotation()
Construct null.
Definition: STARCDCoordinateRotation.C:195
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::STARCDCoordinateRotation::transformVector
virtual tmp< symmTensorField > transformVector(const vectorField &st) const
Transform vectorField using transformation tensorField and return.
Definition: STARCDCoordinateRotation.C:127
Foam::SphericalTensor::I
static const SphericalTensor I
Definition: SphericalTensor.H:78
Foam::STARCDCoordinateRotation::invTransform
virtual tmp< vectorField > invTransform(const vectorField &st) const
Inverse transform vectorField using transformation tensor field.
Definition: STARCDCoordinateRotation.C:79
y
scalar y
Definition: LISASMDCalcMethod1.H:14
Foam::cos
dimensionedScalar cos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:256