EulerCoordinateRotation.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-2020 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  points
47  );
48 }
49 
50 
51 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
52 
53 void Foam::EulerCoordinateRotation::calcTransform
54 (
55  const scalar phiAngle,
56  const scalar thetaAngle,
57  const scalar psiAngle,
58  const bool inDegrees
59 )
60 {
61  scalar phi = phiAngle;
62  scalar theta = thetaAngle;
63  scalar psi = psiAngle;
64 
65  if (inDegrees)
66  {
67  phi *= constant::mathematical::pi/180.0;
68  theta *= constant::mathematical::pi/180.0;
69  psi *= constant::mathematical::pi/180.0;
70  }
71 
72  R_ =
73  (
74  tensor
75  (
76  cos(phi)*cos(psi) - sin(phi)*sin(psi)*cos(theta),
77  -sin(phi)*cos(psi)*cos(theta) - cos(phi)*sin(psi),
78  sin(phi)*sin(theta),
79 
80  cos(phi)*sin(psi)*cos(theta) + sin(phi)*cos(psi),
81  cos(phi)*cos(psi)*cos(theta) - sin(phi)*sin(psi),
82  -cos(phi)*sin(theta),
83 
84  sin(psi)*sin(theta),
85  cos(psi)*sin(theta),
86  cos(theta)
87  )
88  );
89 
90  Rtr_ = R_.T();
91 }
92 
93 
94 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
95 
97 (
98  const dictionary& dict
99 )
100 :
101  R_(sphericalTensor::I),
102  Rtr_(R_)
103 {
104  vector rotation(dict.lookup("rotation"));
105 
106  calcTransform
107  (
108  rotation.component(vector::X),
109  rotation.component(vector::Y),
110  rotation.component(vector::Z),
111  dict.lookupOrDefault("degrees", true)
112  );
113 }
114 
115 
117 (
118  const dictionary& dict,
119  const UList<vector>& points
120 )
121 :
123 {}
124 
125 
126 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
127 
129 {
130  return (R_ & st);
131 }
132 
133 
135 (
136  const vector& st
137 ) const
138 {
139  return (Rtr_ & st);
140 }
141 
142 
144 (
145  const vectorField& st
146 ) const
147 {
149  return tmp<vectorField>(nullptr);
150 }
151 
152 
154 (
155  const vectorField& st
156 ) const
157 {
159  return tmp<vectorField>(nullptr);
160 }
161 
162 
164 (
165  const tensorField& st
166 ) const
167 {
169  return tmp<tensorField>(nullptr);
170 }
171 
172 
174 (
175  const tensor& st
176 ) const
177 {
178  return (R_ & st & Rtr_);
179 }
180 
181 
184 (
185  const vectorField& st
186 ) const
187 {
188  tmp<symmTensorField> tfld(new symmTensorField(st.size()));
189  symmTensorField& fld = tfld.ref();
190 
191  forAll(fld, i)
192  {
193  fld[i] = transformPrincipal(R_, st[i]);
194  }
195  return tfld;
196 }
197 
198 
200 (
201  const vector& st
202 ) const
203 {
204  return transformPrincipal(R_, st);
205 }
206 
207 
209 {
210  writeEntry(os, "e1", e1());
211  writeEntry(os, "e2", e2());
212  writeEntry(os, "e3", e3());
213 }
214 
215 
216 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
A coordinateRotation defined in the z-x-y Euler convention.
Field< symmTensor > symmTensorField
Specialisation of Field<T> for symmTensor.
EulerCoordinateRotation(const dictionary &)
Construct from dictionary.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:181
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
virtual tmp< tensorField > transformTensor(const tensorField &st) const
Transform tensor field using transformation tensorField.
virtual void write(Ostream &) const
Write.
Macros for easy insertion into run-time selection tables.
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)
virtual tmp< vectorField > transform(const vectorField &st) const
Transform vectorField using transformation tensor field.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
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
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.
A class for managing temporary objects.
Definition: PtrList.H:53
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:353
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:864
virtual tmp< symmTensorField > transformVector(const vectorField &st) const
Transform vectorField using transformation tensorField and return.