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