Loading...
Searching...
No Matches
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 Copyright (C) 2025 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30
33 t_(Zero),
34 R_(sphericalTensor::I),
35 hasR_(false)
36{}
37
38
40(
41 const vector& t,
42 const tensor& R,
43 bool hasR
44)
46 t_(t),
47 R_(R),
48 hasR_(hasR)
49{}
50
51
54 t_(t),
55 R_(sphericalTensor::I),
56 hasR_(false)
57{}
58
59
61:
62 t_(Zero),
63 R_(R),
64 hasR_(true)
65{}
66
67
68// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
69
71{
72 // Assume that non-const access to R changes it from I, so set
73 // hasR to true
74 hasR_ = true;
75
76 return R_;
77}
78
79
81(
82 const vector& v
83) const
84{
85 if (hasR_)
86 {
87 return t() + (R() & v);
88 }
89 else
90 {
91 return t() + v;
92 }
93}
94
95
97(
98 const pointField& pts
99) const
100{
101 tmp<pointField> tfld;
102
103 if (hasR_)
104 {
105 tfld = t() + (R() & pts);
106 }
107 else
109 tfld = t() + pts;
110 }
111 return tfld();
112}
113
114
116(
117 UList<point>& pts
118) const
119{
120 if (hasR_)
121 {
122 for (auto& p : pts)
123 {
124 p = t() + (R() & p);
125 }
126 }
127 else
128 {
129 for (auto& p : pts)
131 p += t();
132 }
133 }
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
166 tfld = pts - t();
167 }
168 return tfld();
169}
170
171
173(
174 UList<point>& pts
175) const
176{
177 if (hasR_)
178 {
179 const auto rot = R().T();
180
181 for (auto& p : pts)
182 {
183 p = (rot & (p - t()));
184 }
185 }
186 else
187 {
188 for (auto& p : pts)
189 {
190 p -= t();
192 }
193}
194
195
196// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
197
198inline void Foam::vectorTensorTransform::operator&=
199(
201)
202{
203 t_ += tr.t_;
204 R_ = tr.R_ & R_;
206 // If either of the two objects has hasR_ as true, then inherit
207 // it, otherwise, these should both be I tensors.
208 hasR_ = tr.hasR_ || hasR_;
209}
210
213{
214 t_ = t;
215}
216
219{
220 t_ += t;
221}
222
225{
226 t_ -= t;
227}
228
229
232 hasR_ = true;
233
234 R_ = R;
235}
236
237
239{
240 hasR_ = true;
242 R_ = R & R_;
243}
244
245
246// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
247
248inline Foam::vectorTensorTransform Foam::inv(const vectorTensorTransform& tr)
250 return vectorTensorTransform(-tr.t(), tr.R().T(), tr.hasR());
251}
252
253
254// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
255
256inline bool Foam::operator==
257(
258 const vectorTensorTransform& tr1,
260)
261{
262 return (tr1.t() == tr2.t() && tr1.R() == tr2.R());
263}
264
265
266inline bool Foam::operator!=
267(
268 const vectorTensorTransform& tr1,
270)
271{
272 return !operator==(tr1, tr2);
273}
274
275
276inline Foam::vectorTensorTransform Foam::operator+
277(
278 const vectorTensorTransform& tr,
279 const vector& t
280)
281{
282 return vectorTensorTransform(tr.t() + t, tr.R(), tr.hasR());
283}
284
285
286inline Foam::vectorTensorTransform Foam::operator+
287(
288 const vector& t,
290)
291{
292 return vectorTensorTransform(t + tr.t(), tr.R(), tr.hasR());
293}
294
295
296inline Foam::vectorTensorTransform Foam::operator-
297(
298 const vectorTensorTransform& tr,
299 const vector& t
300)
301{
302 return vectorTensorTransform(tr.t() - t, tr.R(), tr.hasR());
303}
304
305
306inline Foam::vectorTensorTransform Foam::operator&
307(
308 const vectorTensorTransform& tr1,
309 const vectorTensorTransform& tr2
310)
311{
312 return vectorTensorTransform
313 (
314 tr1.t() + tr2.t(),
315 tr1.R() & tr2.R(),
316 (tr1.hasR() || tr2.hasR())
317 );
318}
319
320
321// ************************************************************************* //
#define R(A, B, C, D, E, F, K, M)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition UList.H:89
A class for managing temporary objects.
Definition tmp.H:75
Vector-tensor class used to perform translations and rotations in 3D space.
void transformPositionList(UList< point > &pts) const
Inplace transform the given points.
vectorTensorTransform & operator=(const vectorTensorTransform &)=default
Copy assignment.
const tensor & R() const noexcept
The (forward) rotation tensor.
const vector & t() const noexcept
The translation vector.
void invTransformPositionList(UList< point > &pts) const
Inplace inverse transform the given points.
static const vectorTensorTransform I
vectorTensorTransform(const vectorTensorTransform &)=default
Copy construct.
vector invTransformPosition(const vector &v) const
Inverse transform the given position.
vectorTensorTransform()
Default construct - no translation, identity rotation.
vector transformPosition(const vector &v) const
Transform the given position.
bool hasR() const noexcept
True if it has a non-identity rotation tensor.
void operator&=(const vectorTensorTransform &)
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
volScalarField & p
const volScalarField & T
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
Tensor< scalar > tensor
Definition symmTensor.H:57
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
const direction noexcept
Definition scalarImpl.H:265
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
vectorField pointField
pointField is a vectorField.
Vector< scalar > vector
Definition vector.H:57
SphericalTensor< scalar > sphericalTensor
SphericalTensor of scalars, i.e. SphericalTensor<scalar>.
const pointField & pts