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-2024 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 #include "unitConversions.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
36  (
40  );
42  (
45  points
46  );
47 }
48 
49 
50 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
51 
52 void Foam::EulerCoordinateRotation::calcTransform
53 (
54  const scalar phi,
55  const scalar theta,
56  const scalar psi
57 )
58 {
59  R_ =
60  (
61  tensor
62  (
63  cos(phi)*cos(psi) - sin(phi)*sin(psi)*cos(theta),
64  -sin(phi)*cos(psi)*cos(theta) - cos(phi)*sin(psi),
65  sin(phi)*sin(theta),
66 
67  cos(phi)*sin(psi)*cos(theta) + sin(phi)*cos(psi),
68  cos(phi)*cos(psi)*cos(theta) - sin(phi)*sin(psi),
69  -cos(phi)*sin(theta),
70 
71  sin(psi)*sin(theta),
72  cos(psi)*sin(theta),
73  cos(theta)
74  )
75  );
76 
77  Rtr_ = R_.T();
78 }
79 
80 
81 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
82 
84 (
85  const dictionary& dict
86 )
87 :
88  R_(sphericalTensor::I),
89  Rtr_(R_)
90 {
91  const vector rotation(dict.lookup<vector>("rotation", unitDegrees));
92 
93  if (dict.found("degrees"))
94  {
96  << "Angle units are no longer specified with a 'degrees' entry. "
97  << "Instead, the 'rotation' can have its units specified directly."
98  << " e.g., rotation (30 45 60) [deg]."
99  << exit(FatalIOError);
100  }
101 
102  calcTransform
103  (
104  rotation.component(vector::X),
105  rotation.component(vector::Y),
106  rotation.component(vector::Z)
107  );
108 }
109 
110 
112 (
113  const dictionary& dict,
114  const UList<vector>& points
115 )
116 :
118 {}
119 
120 
121 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
122 
124 {
125  return (R_ & v);
126 }
127 
128 
130 {
131  return (Rtr_ & v);
132 }
133 
134 
136 (
137  const vectorField& vf
138 ) const
139 {
141  return tmp<vectorField>(nullptr);
142 }
143 
144 
146 (
147  const vectorField& vf
148 ) const
149 {
151  return tmp<vectorField>(nullptr);
152 }
153 
154 
156 (
158 ) const
159 {
161  return tmp<tensorField>(nullptr);
162 }
163 
164 
166 (
167  const vector& p,
168  const tensor& t
169 ) const
170 {
171  return (R_ & t & Rtr_);
172 }
173 
174 
177 (
178  const vectorField& vf
179 ) const
180 {
181  tmp<symmTensorField> tfld(new symmTensorField(vf.size()));
182  symmTensorField& fld = tfld.ref();
183 
184  forAll(fld, i)
185  {
186  fld[i] = transformVectorDiagTensor(R_, vf[i]);
187  }
188  return tfld;
189 }
190 
191 
193 (
194  const vector& p,
195  const vector& v
196 ) const
197 {
198  return transformVectorDiagTensor(R_, v);
199 }
200 
201 
203 {
204  writeEntry(os, "e1", e1());
205  writeEntry(os, "e2", e2());
206  writeEntry(os, "e3", e3());
207 }
208 
209 
210 // ************************************************************************* //
#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:162
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:381
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:346
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.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
addToRunTimeSelectionTable(polyPatch, mergedCyclicPolyPatch, word)
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)
IOerror FatalIOError
Field< symmTensor > symmTensorField
Specialisation of Field<T> for symmTensor.
dimensionedScalar cos(const dimensionedScalar &ds)
const unitConversion unitDegrees
dictionary dict
volScalarField & p
Useful unit conversions.