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-2022 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 {
37  (
41  );
43  (
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;
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_ & v);
131 }
132 
133 
135 {
136  return (Rtr_ & v);
137 }
138 
139 
141 (
142  const vectorField& vf
143 ) const
144 {
146  return tmp<vectorField>(nullptr);
147 }
148 
149 
151 (
152  const vectorField& vf
153 ) const
154 {
156  return tmp<vectorField>(nullptr);
157 }
158 
159 
161 (
163 ) const
164 {
166  return tmp<tensorField>(nullptr);
167 }
168 
169 
171 (
172  const vector& p,
173  const tensor& t
174 ) const
175 {
176  return (R_ & t & Rtr_);
177 }
178 
179 
182 (
183  const vectorField& vf
184 ) const
185 {
186  tmp<symmTensorField> tfld(new symmTensorField(vf.size()));
187  symmTensorField& fld = tfld.ref();
188 
189  forAll(fld, i)
190  {
191  fld[i] = transformVectorDiagTensor(R_, vf[i]);
192  }
193  return tfld;
194 }
195 
196 
198 (
199  const vector& p,
200  const vector& v
201 ) const
202 {
203  return transformVectorDiagTensor(R_, v);
204 }
205 
206 
208 {
209  writeEntry(os, "e1", e1());
210  writeEntry(os, "e2", e2());
211  writeEntry(os, "e3", e3());
212 }
213 
214 
215 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
Macros for easy insertion into run-time selection tables.
A coordinateRotation defined in the z-x-y Euler convention.
virtual void write(Ostream &) const
Write.
EulerCoordinateRotation(const dictionary &)
Construct from dictionary.
virtual tmp< vectorField > invTransform(const vectorField &vf) const
Inverse transform vectorField using transformation tensor field.
virtual tmp< vectorField > transform(const vectorField &vf) const
Transform vectorField using transformation tensor field.
virtual symmTensor transformDiagTensor(const vector &p, const vector &v) const
Transform diagTensor masquerading as a vector using transformation.
Generic GeometricField class.
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Templated 3D SphericalTensor derived from VectorSpace adding construction from 1 component,...
Tensor< Cmpt > T() const
Return transpose.
Definition: TensorI.H:331
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: UList.H:74
const Cmpt & component(const direction) const
Definition: VectorSpaceI.H:91
Abstract base class for coordinate rotation.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
A class for managing temporary objects.
Definition: tmp.H:55
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:181
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:353
const pointField & points
gmvFile<< "tracers "<< particles.size()<< nl;{ pointField positions(particles.size());label particlei=0;forAllConstIter(Cloud< passiveParticle >, particles, iter) { positions[particlei++]=iter().position(mesh);} for(i=0;i< pTraits< point >::nComponents;i++) { forAll(positions, particlei) { gmvFile<< component(positions[particlei], i)<< ' ';} gmvFile<< nl;}}forAll(lagrangianScalarNames, i){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const volScalarField & psi
Namespace for OpenFOAM.
Tensor< scalar > tensor
Tensor of scalars.
Definition: tensor.H:51
dimensionedScalar sin(const dimensionedScalar &ds)
static const Identity< scalar > I
Definition: Identity.H:93
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
defineTypeNameAndDebug(combustionModel, 0)
Field< symmTensor > symmTensorField
Specialisation of Field<T> for symmTensor.
dimensionedScalar cos(const dimensionedScalar &ds)
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
dictionary dict
volScalarField & p