vectorTensorTransformI.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) 2011-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 // * * * * * * * * * * * * * * * * 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_ & R_;
181 
182  // If either of the two objects has hasR_ as true, then inherit
183  // it, otherwise, these should both be I tensors.
184  hasR_ = tr.hasR_ || hasR_;
185 }
186 
187 
189 {
190  t_ = t;
191 }
192 
193 
195 {
196  t_ += t;
197 }
198 
199 
201 {
202  t_ -= t;
203 }
204 
205 
207 {
208  hasR_ = true;
209 
210  R_ = R;
211 }
212 
213 
215 {
216  hasR_ = true;
217 
218  R_ = R & R_;
219 }
220 
221 
222 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
223 
225 {
226  return vectorTensorTransform(-tr.t(), tr.R().T(), tr.hasR());
227 }
228 
229 
230 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
231 
232 inline bool Foam::operator==
233 (
234  const vectorTensorTransform& tr1,
235  const vectorTensorTransform& tr2
236 )
237 {
238  return (tr1.t() == tr2.t() && tr1.R() == tr2.R());
239 }
240 
241 
242 inline bool Foam::operator!=
243 (
244  const vectorTensorTransform& tr1,
245  const vectorTensorTransform& tr2
246 )
247 {
248  return !operator==(tr1, tr2);
249 }
250 
251 
252 inline Foam::vectorTensorTransform Foam::operator+
253 (
254  const vectorTensorTransform& tr,
255  const vector& t
256 )
257 {
258  return vectorTensorTransform(tr.t() + t, tr.R(), tr.hasR());
259 }
260 
261 
262 inline Foam::vectorTensorTransform Foam::operator+
263 (
264  const vector& t,
266 )
267 {
268  return vectorTensorTransform(t + tr.t(), tr.R(), tr.hasR());
269 }
270 
271 
272 inline Foam::vectorTensorTransform Foam::operator-
273 (
274  const vectorTensorTransform& tr,
275  const vector& t
276 )
277 {
278  return vectorTensorTransform(tr.t() - t, tr.R(), tr.hasR());
279 }
280 
281 
282 inline Foam::vectorTensorTransform Foam::operator&
283 (
284  const vectorTensorTransform& tr1,
285  const vectorTensorTransform& tr2
286 )
287 {
288  return vectorTensorTransform
289  (
290  tr1.t() + tr2.t(),
291  tr1.R() & tr2.R(),
292  (tr1.hasR() || tr2.hasR())
293  );
294 }
295 
296 
297 // ************************************************************************* //
Vector-tensor class used to perform translations and rotations in 3D space.
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
Tensor< Cmpt > T() const
Return transpose.
Definition: TensorI.H:321
vector invTransformPosition(const vector &v) const
Inverse transform the given position.
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.
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:97
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
static const vectorTensorTransform I
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
A class for managing temporary objects.
Definition: PtrList.H:53
vector transformPosition(const vector &v) const
Transform the given position.
void operator &=(const vectorTensorTransform &)