transformField.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-2021 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 
26 #include "transformField.H"
27 #include "FieldM.H"
28 #include "diagTensor.H"
29 
30 // * * * * * * * * * * * * * * * global functions * * * * * * * * * * * * * //
31 
33 (
34  vectorField& rtf,
35  const spatialTransform& tr,
36  const vectorField& tf
37 )
38 {
39  forAll(rtf, i)
40  {
41  rtf[i] = tr.transformPoint(tf[i]);
42  }
43 }
44 
45 
47 (
48  const spatialTransform& tr,
49  const vectorField& tf
50 )
51 {
52  tmp<vectorField > tranf(new vectorField(tf.size()));
53  transformPoints(tranf.ref(), tr, tf);
54  return tranf;
55 }
56 
57 
59 (
60  const spatialTransform& tr,
61  const tmp<vectorField>& ttf
62 )
63 {
64  tmp<vectorField > tranf = New(ttf);
65  transformPoints(tranf.ref(), tr, ttf());
66  ttf.clear();
67  return tranf;
68 }
69 
70 
71 void Foam::transform
72 (
73  vectorField& rtf,
74  const quaternion& q,
75  const vectorField& tf
76 )
77 {
78  const tensor t = q.R();
80 }
81 
82 
84 (
85  const quaternion& q,
86  const vectorField& tf
87 )
88 {
89  tmp<vectorField > tranf(new vectorField(tf.size()));
90  transform(tranf.ref(), q, tf);
91  return tranf;
92 }
93 
94 
96 (
97  const quaternion& q,
98  const tmp<vectorField>& ttf
99 )
100 {
101  tmp<vectorField > tranf = New(ttf);
102  transform(tranf.ref(), q, ttf());
103  ttf.clear();
104  return tranf;
105 }
106 
107 
109 (
110  vectorField& rtf,
111  const septernion& tr,
112  const vectorField& tf
113 )
114 {
115  const vector T = tr.t();
116 
117  // Check if any translation
118  if (mag(T) > vSmall)
119  {
120  TFOR_ALL_F_OP_F_OP_S(vector, rtf, =, vector, tf, -, vector, T);
121  }
122  else
123  {
124  rtf = tf;
125  }
126 
127  // Check if any rotation
128  if (mag(tr.r().R() - I) > small)
129  {
130  transform(rtf, tr.r(), rtf);
131  }
132 }
133 
134 
136 (
137  const septernion& tr,
138  const vectorField& tf
139 )
140 {
141  tmp<vectorField > tranf(new vectorField(tf.size()));
142  transformPoints(tranf.ref(), tr, tf);
143  return tranf;
144 }
145 
146 
148 (
149  const septernion& tr,
150  const tmp<vectorField>& ttf
151 )
152 {
153  tmp<vectorField > tranf = New(ttf);
154  transformPoints(tranf.ref(), tr, ttf());
155  ttf.clear();
156  return tranf;
157 }
158 
159 
160 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
tensor R() const
The rotation tensor corresponding the quaternion.
Definition: quaternionI.H:323
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
void clear() const
If object pointer points to valid object:
Definition: tmpI.H:237
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
vector transformPoint(const vector &p) const
Transform position p.
volVectorField vectorField(fieldObject, mesh)
Septernion class used to perform translations and rotations in 3D space.
Definition: septernion.H:65
const tensorField & tf
Spatial transformation functions for primitive fields.
static const Identity< scalar > I
Definition: Identity.H:93
Quaternion class used to perform rotations in 3D space.
Definition: quaternion.H:60
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
#define TFOR_ALL_F_OP_FUNC_S_F(typeF1, f1, OP, FUNC, typeS, s, typeF2, f2)
Definition: FieldM.H:210
const volScalarField & T
void transformPoints(vectorField &, const spatialTransform &, const vectorField &)
Transform given vectorField of coordinates with the given spatialTransform.
const vector & t() const
Definition: septernionI.H:58
dimensioned< scalar > mag(const dimensioned< Type > &)
Compact representation of the Plücker spatial transformation tensor in terms of the rotation tensor E...
const quaternion & r() const
Definition: septernionI.H:64
A class for managing temporary objects.
Definition: PtrList.H:53
High performance macro functions for Field<Type> algebra. These expand using either array element acc...
#define TFOR_ALL_F_OP_F_OP_S(typeF1, f1, OP1, typeF2, f2, OP2, typeS, s)
Definition: FieldM.H:295
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:483