spatialTransformI.H
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) 2016-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 
26 #include "transform.H"
27 
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29 
30 Foam::tensor Foam::spatialTransform::Erx() const
31 {
32  return E_ & *r_;
33 }
34 
35 
36 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
37 
39 :
40  E_(tensor::I),
41  r_(Zero)
42 {}
43 
44 
46 (
47  const tensor& E,
48  const vector& r
49 )
50 :
51  E_(E),
52  r_(r)
53 {}
54 
55 
57 :
58  E_(is),
59  r_(is)
60 {}
61 
62 
64 :
65  X_(X)
66 {}
67 
68 
70 :
71  X_(X)
72 {}
73 
74 
75 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
76 
78 {
79  return E_;
80 }
81 
83 {
84  return E_;
85 }
86 
88 {
89  return r_;
90 }
91 
93 {
94  return r_;
95 }
96 
97 
99 {
100  return transpose(*this);
101 }
102 
103 
105 {
106  return spatialTransform(E_.T(), -(E_ & r_));
107 }
108 
109 
110 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
111 
113 {
114  return dual(*this);
115 }
116 
117 
118 inline Foam::spatialTransform::operator spatialTensor() const
119 {
120  return spatialTensor
121  (
122  E_, Zero,
123  -Erx(), E_
124  );
125 }
126 
127 
129 {
130  E_ &= X.E_;
131  r_ = X.r_ + (r_ & X.E_);
132 }
133 
134 
135 inline Foam::spatialTransform Foam::spatialTransform::operator&
136 (
137  const spatialTransform& X
138 ) const
139 {
140  return spatialTransform(E_ & X.E_, X.r_ + (r_ & X.E_));
141 }
142 
143 
144 inline Foam::spatialVector Foam::spatialTransform::operator&
145 (
146  const spatialVector& v
147 ) const
148 {
149  return spatialVector
150  (
151  E_ & v.w(),
152  E_ & (v.l() - (r_ ^ v.w()))
153  );
154 }
155 
156 
157 inline Foam::spatialVector Foam::spatialTransform::operator&&
158 (
159  const spatialVector& v
160 ) const
161 {
162  return spatialVector
163  (
164  E_ & v.w(),
165  E_ & (v.l() - r_)
166  );
167 }
168 
169 
171 (
172  const vector& p
173 ) const
174 {
175  return E_ & (p - r_);
176 }
177 
178 
179 inline Foam::spatialTransform::transpose::operator spatialTensor() const
180 {
181  return spatialTensor
182  (
183  X_.E().T(), -X_.Erx().T(),
184  Zero, X_.E().T()
185  );
186 }
187 
188 
189 inline Foam::spatialVector Foam::spatialTransform::transpose::operator&
190 (
191  const spatialVector& f
192 ) const
193 {
194  vector ETfl(X_.E().T() & f.l());
195 
196  return spatialVector
197  (
198  (X_.E().T() & f.w()) + (X_.r() ^ ETfl),
199  ETfl
200  );
201 }
202 
203 
204 inline Foam::spatialTransform::dual::operator spatialTensor() const
205 {
206  return spatialTensor
207  (
208  X_.E(), -X_.Erx(),
209  Zero, X_.E()
210  );
211 }
212 
213 
214 inline Foam::spatialVector Foam::spatialTransform::dual::operator&
215 (
216  const spatialVector& f
217 ) const
218 {
219  return spatialVector
220  (
221  X_.E() & (f.w() - (X_.r() ^ f.l())),
222  X_.E() & f.l()
223  );
224 }
225 
226 
227 // * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * * //
228 
230 {
231  is >> X.E() >> X.r();
232  return is;
233 }
234 
235 
236 inline Foam::Ostream& Foam::operator<<
237 (
238  Foam::Ostream& os,
239  const spatialTransform& X
240 )
241 {
242  os << X.E() << token::SPACE << X.r();
243  return os;
244 }
245 
246 
247 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
248 
249 namespace Foam
250 {
251 
252 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
253 
254 //- Rotational spatial transformation tensor about the x-axis by omega radians
255 inline spatialTransform Xrx(const scalar& omega)
256 {
257  return spatialTransform(Rx(omega), Zero);
258 }
259 
260 //- Rotational spatial transformation tensor about the x-axis by omega radians
261 inline spatialTransform Xry(const scalar& omega)
262 {
263  return spatialTransform(Ry(omega), Zero);
264 }
265 
266 //- Rotational spatial transformation tensor about the z-axis by omega radians
267 inline spatialTransform Xrz(const scalar& omega)
268 {
269  return spatialTransform(Rz(omega), Zero);
270 }
271 
272 //- Rotational spatial transformation tensor about axis a by omega radians
273 inline spatialTransform Xr(const vector& a, const scalar omega)
274 {
275  return spatialTransform(Ra(a, omega), Zero);
276 }
277 
278 //- Translational spatial transformation tensor for translation r
279 inline spatialTransform Xt(const vector& r)
280 {
281  return spatialTransform(tensor::I, r);
282 }
283 
284 
285 // * * * * * * * * * * * * * * * IOstream Functions * * * * * * * * * * * * //
286 
287 //- Write the spatial transformation as an entry
288 inline void writeEntry(Ostream& os, const spatialTransform& st)
289 {
290  os << st;
291 }
292 
293 
294 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
295 
296 } // End namespace Foam
297 
298 // ************************************************************************* //
spatialTransform Xt(const vector &r)
Translational spatial transformation tensor for translation r.
transpose T() const
Return the transpose transformation tensor ^A{X^*}_B.
spatialTransform Xrx(const scalar &omega)
Rotational spatial transformation tensor about the x-axis by omega radians.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
Tensor< Cmpt > T() const
Return transpose.
Definition: TensorI.H:331
spatialTransform Xrz(const scalar &omega)
Rotational spatial transformation tensor about the z-axis by omega radians.
vector transformPoint(const vector &p) const
Transform position p.
transpose(const spatialTransform &X)
Construct from a spatialTransform.
const vector & r() const
Return the translation vector.
void operator &=(const spatialTransform &X)
Inner-product multiply with a transformation tensor.
SpatialTensor< scalar > spatialTensor
SpatialTensor of scalars.
Definition: spatialTensor.H:47
spatialTransform Xry(const scalar &omega)
Rotational spatial transformation tensor about the x-axis by omega radians.
static const Identity< scalar > I
Definition: Identity.H:93
SpatialVector< scalar > spatialVector
SpatialVector of scalars.
Definition: spatialVector.H:47
3D tensor transformation operations.
Istream & operator>>(Istream &, directionInfo &)
spatialTransform Xr(const vector &a, const scalar omega)
Rotational spatial transformation tensor about axis a by omega radians.
Wrapper-class to provide transpose functions and operators.
static const zero Zero
Definition: zero.H:97
dual operator*() const
Return the dual transformation tensor ^B{X^*}_A.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
static const Tensor I
Definition: Tensor.H:83
labelList f(nPoints)
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
dual(const spatialTransform &X)
Construct from a spatialTransform.
tensor Ry(const scalar &omega)
Rotational transformation tensor about the y-axis by omega radians.
Definition: transform.H:100
Wrapper-class to provide dual functions and operators.
const tensor & E() const
Return the rotation tensor.
tensor Rz(const scalar &omega)
Rotational transformation tensor about the z-axis by omega radians.
Definition: transform.H:114
Compact representation of the Plücker spatial transformation tensor in terms of the rotation tensor E...
tensor Ra(const vector &a, const scalar omega)
Rotational transformation tensor about axis a by omega radians.
Definition: transform.H:128
spatialTransform()
Construct null.
spatialTransform inv() const
Return the inverse transformation tensor: X^-1.
tensor Rx(const scalar &omega)
Rotational transformation tensor about the x-axis by omega radians.
Definition: transform.H:86
Namespace for OpenFOAM.