vectorTensorTransformI.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) 2011-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 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
31 :
32  t_(Zero),
33  R_(sphericalTensor::I),
34  hasR_(false)
35 {}
36 
37 
39 (
40  const vector& t,
41  const tensor& R,
42  bool hasR
43 )
44 :
45  t_(t),
46  R_(R),
47  hasR_(hasR)
48 {}
49 
50 
52 :
53  t_(t),
54  R_(sphericalTensor::I),
55  hasR_(false)
56 {}
57 
58 
60 :
61  t_(Zero),
62  R_(R),
63  hasR_(true)
64 {}
65 
66 
67 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
68 
70 {
71  return t_;
72 }
73 
74 
76 {
77  return R_;
78 }
79 
80 
82 {
83  return hasR_;
84 }
85 
86 
88 {
89  return t_;
90 }
91 
92 
94 {
95  // Assume that non-const access to R changes it from I, so set
96  // hasR to true
97 
98  hasR_ = true;
99 
100  return R_;
101 }
102 
103 
105 (
106  const vector& v
107 ) const
108 {
109  if (hasR_)
110  {
111  return t() + (R() & v);
112  }
113  else
114  {
115  return t() + v;
116  }
117 }
118 
119 
121 (
122  const pointField& pts
123 ) const
124 {
125  tmp<pointField> tfld;
126 
127  if (hasR_)
128  {
129  tfld = t() + (R() & pts);
130  }
131  else
132  {
133  tfld = t() + pts;
134  }
135  return tfld();
136 }
137 
138 
140 (
141  const vector& v
142 ) const
143 {
144  if (hasR_)
145  {
146  return (R().T() & (v - t()));
147  }
148  else
149  {
150  return v - t();
151  }
152 }
153 
154 
156 (
157  const pointField& pts
158 ) const
159 {
160  tmp<pointField> tfld;
161 
162  if (hasR_)
163  {
164  tfld = (R().T() & (pts - t()));
165  }
166  else
167  {
168  tfld = pts - t();
169  }
170  return tfld();
171 }
172 
173 
174 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
175 
176 inline void Foam::vectorTensorTransform::operator=
177 (
179 )
180 {
181  t_ = tr.t_;
182  R_ = tr.R_;
183  hasR_ = tr.hasR_;
184 }
185 
186 
187 inline void Foam::vectorTensorTransform::operator&=
188 (
190 )
191 {
192  t_ += tr.t_;
193  R_ = tr.R_ & R_;
194 
195  // If either of the two objects has hasR_ as true, then inherit
196  // it, otherwise, these should both be I tensors.
197  hasR_ = tr.hasR_ || hasR_;
198 }
199 
200 
202 {
203  t_ = t;
204 }
205 
206 
208 {
209  t_ += t;
210 }
211 
212 
214 {
215  t_ -= t;
216 }
217 
218 
220 {
221  hasR_ = true;
222 
223  R_ = R;
224 }
225 
226 
228 {
229  hasR_ = true;
230 
231  R_ = R & R_;
232 }
233 
234 
235 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
236 
238 {
239  return vectorTensorTransform(-tr.t(), tr.R().T(), tr.hasR());
240 }
241 
242 
243 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
244 
245 inline bool Foam::operator==
246 (
247  const vectorTensorTransform& tr1,
248  const vectorTensorTransform& tr2
249 )
250 {
251  return (tr1.t() == tr2.t() && tr1.R() == tr2.R());
252 }
253 
254 
255 inline bool Foam::operator!=
256 (
257  const vectorTensorTransform& tr1,
258  const vectorTensorTransform& tr2
259 )
260 {
261  return !operator==(tr1, tr2);
262 }
263 
264 
265 inline Foam::vectorTensorTransform Foam::operator+
266 (
267  const vectorTensorTransform& tr,
268  const vector& t
269 )
270 {
271  return vectorTensorTransform(tr.t() + t, tr.R(), tr.hasR());
272 }
273 
274 
275 inline Foam::vectorTensorTransform Foam::operator+
276 (
277  const vector& t,
279 )
280 {
281  return vectorTensorTransform(t + tr.t(), tr.R(), tr.hasR());
282 }
283 
284 
285 inline Foam::vectorTensorTransform Foam::operator-
286 (
287  const vectorTensorTransform& tr,
288  const vector& t
289 )
290 {
291  return vectorTensorTransform(tr.t() - t, tr.R(), tr.hasR());
292 }
293 
294 
295 inline Foam::vectorTensorTransform Foam::operator&
296 (
297  const vectorTensorTransform& tr1,
298  const vectorTensorTransform& tr2
299 )
300 {
301  return vectorTensorTransform
302  (
303  tr1.t() + tr2.t(),
304  tr1.R() & tr2.R(),
305  (tr1.hasR() || tr2.hasR())
306  );
307 }
308 
309 
310 // ************************************************************************* //
Foam::Tensor< scalar >
Foam::vectorTensorTransform::invTransformPosition
vector invTransformPosition(const vector &v) const
Inverse transform the given position.
Definition: vectorTensorTransformI.H:140
Foam::vectorTensorTransform::vectorTensorTransform
vectorTensorTransform()
Construct null.
Definition: vectorTensorTransformI.H:30
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
Foam::Zero
static constexpr const zero Zero
Global zero.
Definition: zero.H:128
Foam::vectorTensorTransform::operator=
void operator=(const vectorTensorTransform &)
Definition: vectorTensorTransformI.H:177
Foam::dimensioned::T
dimensioned< Type > T() const
Return transpose.
Definition: dimensionedSphericalTensor.C:38
Foam::vectorTensorTransform::operator&=
void operator&=(const vectorTensorTransform &)
Definition: vectorTensorTransformI.H:188
R
#define R(A, B, C, D, E, F, K, M)
Foam::Field< vector >
Foam::operator==
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
Foam::inv
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
Definition: dimensionedSphericalTensor.C:73
Foam::vectorTensorTransform::operator+=
void operator+=(const vector &)
Definition: vectorTensorTransformI.H:207
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:58
Foam::vectorTensorTransform::t
const vector & t() const
Definition: vectorTensorTransformI.H:69
Foam::SphericalTensor< scalar >
Foam::vectorTensorTransform::hasR
bool hasR() const
Definition: vectorTensorTransformI.H:81
Foam::vectorTensorTransform::operator-=
void operator-=(const vector &)
Definition: vectorTensorTransformI.H:213
Foam::vectorTensorTransform::transformPosition
vector transformPosition(const vector &v) const
Transform the given position.
Definition: vectorTensorTransformI.H:105
Foam::Vector< scalar >
Foam::vectorTensorTransform
Vector-tensor class used to perform translations and rotations in 3D space.
Definition: vectorTensorTransform.H:63
Foam::vectorTensorTransform::R
const tensor & R() const
Definition: vectorTensorTransformI.H:75
Foam::tr
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
Definition: dimensionedSphericalTensor.C:51
Foam::I
static const Identity< scalar > I
Definition: Identity.H:95