spatialTransformI.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "transform.H"
29 
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 
32 Foam::tensor Foam::spatialTransform::Erx() const
33 {
34  return E_ & *r_;
35 }
36 
37 
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 
41 :
42  E_(tensor::I),
43  r_(Zero)
44 {}
45 
46 
48 (
49  const tensor& E,
50  const vector& r
51 )
52 :
53  E_(E),
54  r_(r)
55 {}
56 
57 
59 :
60  E_(is),
61  r_(is)
62 {}
63 
64 
66 :
67  X_(X)
68 {}
69 
70 
72 :
73  X_(X)
74 {}
75 
76 
77 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
78 
79 inline const Foam::tensor& Foam::spatialTransform::E() const
80 {
81  return E_;
82 }
83 
85 {
86  return E_;
87 }
88 
89 inline const Foam::vector& Foam::spatialTransform::r() const
90 {
91  return r_;
92 }
93 
95 {
96  return r_;
97 }
98 
99 
101 {
102  return transpose(*this);
103 }
104 
105 
107 {
108  return spatialTransform(E_.T(), -(E_ & r_));
109 }
110 
111 
112 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
115 {
116  return dual(*this);
117 }
118 
119 
120 inline Foam::spatialTransform::operator spatialTensor() const
121 {
122  return spatialTensor
123  (
124  E_, Zero,
125  -Erx(), E_
126  );
127 }
128 
129 
131 {
132  E_ &= X.E_;
133  r_ = X.r_ + (r_ & X.E_);
134 }
135 
136 
137 inline Foam::spatialTransform Foam::spatialTransform::operator&
138 (
139  const spatialTransform& X
140 ) const
141 {
142  return spatialTransform(E_ & X.E_, X.r_ + (r_ & X.E_));
143 }
144 
145 
146 inline Foam::spatialVector Foam::spatialTransform::operator&
147 (
148  const spatialVector& v
149 ) const
150 {
151  return spatialVector
152  (
153  E_ & v.w(),
154  E_ & (v.l() - (r_ ^ v.w()))
155  );
156 }
157 
158 
159 inline Foam::spatialVector Foam::spatialTransform::operator&&
160 (
161  const spatialVector& v
162 ) const
163 {
164  return spatialVector
165  (
166  E_ & v.w(),
167  E_ & (v.l() - r_)
168  );
169 }
170 
171 
173 (
174  const vector& p
175 ) const
176 {
177  return E_ & (p - r_);
178 }
179 
180 
181 inline Foam::spatialTransform::transpose::operator spatialTensor() const
182 {
183  return spatialTensor
184  (
185  X_.E().T(), -X_.Erx().T(),
186  Zero, X_.E().T()
187  );
188 }
189 
190 
191 inline Foam::spatialVector Foam::spatialTransform::transpose::operator&
192 (
193  const spatialVector& f
194 ) const
195 {
196  vector ETfl(X_.E().T() & f.l());
197 
198  return spatialVector
199  (
200  (X_.E().T() & f.w()) + (X_.r() ^ ETfl),
201  ETfl
202  );
203 }
204 
205 
206 inline Foam::spatialTransform::dual::operator spatialTensor() const
207 {
208  return spatialTensor
209  (
210  X_.E(), -X_.Erx(),
211  Zero, X_.E()
212  );
213 }
214 
215 
216 inline Foam::spatialVector Foam::spatialTransform::dual::operator&
217 (
218  const spatialVector& f
219 ) const
220 {
221  return spatialVector
222  (
223  X_.E() & (f.w() - (X_.r() ^ f.l())),
224  X_.E() & f.l()
225  );
226 }
227 
228 
229 // * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * * //
230 
232 {
233  is >> X.E() >> X.r();
234  return is;
235 }
236 
237 
238 inline Foam::Ostream& Foam::operator<<
239 (
240  Foam::Ostream& os,
241  const spatialTransform& X
242 )
243 {
244  os << X.E() << token::SPACE << X.r();
245  return os;
246 }
247 
248 
249 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
250 
251 namespace Foam
252 {
253 
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 
256 //- Rotational spatial transformation tensor about the x-axis by omega radians
257 inline spatialTransform Xrx(const scalar& omega)
258 {
259  return spatialTransform(Rx(omega), Zero);
260 }
261 
262 //- Rotational spatial transformation tensor about the y-axis by omega radians
263 inline spatialTransform Xry(const scalar& omega)
264 {
265  return spatialTransform(Ry(omega), Zero);
266 }
267 
268 //- Rotational spatial transformation tensor about the z-axis by omega radians
269 inline spatialTransform Xrz(const scalar& omega)
270 {
271  return spatialTransform(Rz(omega), Zero);
272 }
273 
274 //- Rotational spatial transformation tensor about axis a by omega radians
275 inline spatialTransform Xr(const vector& a, const scalar omega)
276 {
277  return spatialTransform(Ra(a, omega), Zero);
278 }
279 
280 //- Translational spatial transformation tensor for translation r
281 inline spatialTransform Xt(const vector& r)
282 {
283  return spatialTransform(tensor::I, r);
284 }
285 
286 
287 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
288 
289 } // End namespace Foam
290 
291 // ************************************************************************* //
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
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:46
tensor Rz(const scalar omega)
Rotational transformation tensor about the z-axis by omega radians.
Definition: transform.H:115
spatialTransform Xry(const scalar &omega)
Rotational spatial transformation tensor about the y-axis by omega radians.
static const Identity< scalar > I
Definition: Identity.H:100
SpatialVector< scalar > spatialVector
SpatialVector of scalars.
Definition: spatialVector.H:46
3D tensor transformation operations.
Istream & operator>>(Istream &, directionInfo &)
Space [isspace].
Definition: token.H:131
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.
Vector< scalar > vector
Definition: vector.H:57
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:56
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
OBJstream os(runTime.globalPath()/outputName)
labelList f(nPoints)
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:99
Wrapper-class to provide dual functions and operators.
const tensor & E() const
Return the rotation tensor.
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:131
volScalarField & p
Tensor of scalars, i.e. Tensor<scalar>.
tensor Rx(const scalar omega)
Rotational transformation tensor about the x-axis by omega radians.
Definition: transform.H:83
spatialTransform()
Construct null.
spatialTransform inv() const
Return the inverse transformation tensor: X^-1.
Namespace for OpenFOAM.
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127