STARCDCoordinateRotation.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(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>(nullptr);
75 }
76 
77 
79 (
80  const vectorField& st
81 ) const
82 {
84  return tmp<vectorField>(nullptr);
85 }
86 
87 
89 {
91  return NullObjectRef<tensorField>();
92 }
93 
94 
96 (
97  const tensorField& st
98 ) const
99 {
101  return tmp<tensorField>(nullptr);
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>(nullptr);
122 }
123 
124 
127 (
128  const vectorField& st
129 ) const
130 {
131  tmp<symmTensorField> tfld(new symmTensorField(st.size()));
132  symmTensorField& fld = tfld.ref();
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 
152 void Foam::STARCDCoordinateRotation::calcTransform
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  writeEntry(os, "e1", e1());
277  writeEntry(os, "e2", e2());
278  writeEntry(os, "e3", e3());
279 }
280 
281 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
virtual tmp< vectorField > transform(const vectorField &st) const
Transform vectorField using transformation tensor field.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
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
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:163
virtual const tensorField & Tr() const
Return transformation tensor field.
Macros for easy insertion into run-time selection tables.
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.
virtual void write(Ostream &) const
Write.
scalar y
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 const vector e1() const
Return local Cartesian x-axis in global coordinates.
virtual const vector e3() const
Return local Cartesian z-axis in global coordinates.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
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
virtual tmp< symmTensorField > transformVector(const vectorField &st) const
Transform vectorField using transformation tensorField and return.
virtual tmp< tensorField > transformTensor(const tensorField &st) const
Transform tensor field using transformation tensorField.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
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
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
virtual const vector e2() const
Return local Cartesian y-axis in global coordinates.
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:583