vectorTensorTransform.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 Class
25  Foam::vectorTensorTransform
26 
27 Description
28  Vector-tensor class used to perform translations and rotations in
29  3D space.
30 
31 SourceFiles
32  vectorTensorTransformI.H
33  vectorTensorTransform.C
34  vectorTensorTransformTemplates.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef vectorTensorTransform_H
39 #define vectorTensorTransform_H
40 
41 #include "tensor.H"
42 #include "word.H"
43 #include "contiguous.H"
44 #include "pointField.H"
45 #include "transformField.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 // Forward declaration of friend functions and operators
53 
54 class vectorTensorTransform;
55 Istream& operator>>(Istream& is, vectorTensorTransform&);
56 Ostream& operator<<(Ostream& os, const vectorTensorTransform& C);
57 
58 
59 /*---------------------------------------------------------------------------*\
60  Class vectorTensorTransform Declaration
61 \*---------------------------------------------------------------------------*/
62 
64 {
65  // private data
66 
67  //- Translation vector
68  vector t_;
69 
70  //- Rotation tensor
71  tensor R_;
72 
73  //- Recording if the transform has non-identity transform to
74  // allow its calculation to be skipped, which is the majority
75  // of the expected cases
76  bool hasR_;
77 
78 
79 public:
80 
81  // Static Data Members
82 
83  static const char* const typeName;
84 
85  static const vectorTensorTransform zero;
86 
87  static const vectorTensorTransform I;
88 
89 
90  // Constructors
91 
92  //- Construct null
93  inline vectorTensorTransform();
94 
95  //- Construct given a translation vector, rotation tensor and
96  // hasR bool
98  (
99  const vector& t,
100  const tensor& R,
101  bool hasR = true
102  );
103 
104  //- Construct a pure translation vectorTensorTransform given a
105  // translation vector
106  inline explicit vectorTensorTransform(const vector& t);
107 
108  //- Construct a pure rotation vectorTensorTransform given a
109  // rotation tensor
110  inline explicit vectorTensorTransform(const tensor& R);
111 
112  //- Construct from Istream
114 
115 
116  // Member Functions
117 
118  // Access
119 
120  inline const vector& t() const;
121 
122  inline const tensor& R() const;
123 
124  inline bool hasR() const;
125 
126 
127  // Edit
128 
129  inline vector& t();
130 
131  inline tensor& R();
132 
133 
134  // Transform
135 
136  //- Transform the given position
137  inline vector transformPosition(const vector& v) const;
138 
139  //- Transform the given pointField
140  inline pointField transformPosition(const pointField& pts) const;
141 
142  //- Inverse transform the given position
143  inline vector invTransformPosition(const vector& v) const;
144 
145  //- Inverse transform the given pointField
146  inline pointField invTransformPosition(const pointField& pts) const;
147 
148  //- Transform the given type
149  template<class Type>
150  Type transform(const Type&) const;
151 
152  //- Transform the given field
153  template<class Type>
154  tmp<Field<Type>> transform(const Field<Type>&) const;
155 
156  //- Inverse transform the given type
157  template<class Type>
158  Type invTransform(const Type&) const;
159 
160  //- Inverse transform the given field
161  template<class Type>
163 
164 
165  // Member Operators
166 
167  inline void operator&=(const vectorTensorTransform&);
168 
169  inline void operator=(const vector&);
170  inline void operator+=(const vector&);
171  inline void operator-=(const vector&);
172 
173  inline void operator=(const tensor&);
174  inline void operator&=(const tensor&);
175 
176 
177  // IOstream Operators
178 
180 
181  friend Ostream& operator<<(Ostream& os, const vectorTensorTransform&);
182 };
183 
184 
185 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
186 
187 //- Return the inverse of the given vectorTensorTransform
189 
190 
191 //- Return a string representation of a vectorTensorTransform
193 
194 
195 //- Data associated with vectorTensorTransform type are contiguous
196 template<>
197 inline bool contiguous<vectorTensorTransform>() {return true;}
198 
199 //- Template specialisations
200 template<>
202 template<>
204 template<>
206 const;
207 
208 
209 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
210 
211 inline bool operator==
212 (
213  const vectorTensorTransform& tr1,
214  const vectorTensorTransform& tr2
215 );
216 
217 
218 inline bool operator!=
219 (
220  const vectorTensorTransform& tr1,
221  const vectorTensorTransform& tr2
222 
223 );
224 
225 
226 inline vectorTensorTransform operator+
227 (
228  const vectorTensorTransform& tr,
229  const vector& t
230 );
231 
232 
233 inline vectorTensorTransform operator+
234 (
235  const vector& t,
237 );
238 
239 
240 inline vectorTensorTransform operator-
241 (
242  const vectorTensorTransform& tr,
243  const vector& t
244 );
245 
246 
247 inline vectorTensorTransform operator&
248 (
249  const vectorTensorTransform& tr1,
250  const vectorTensorTransform& tr2
251 );
252 
253 
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 
256 } // End namespace Foam
257 
258 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259 
260 #include "vectorTensorTransformI.H"
261 
262 #ifdef NoRepository
264 #endif
265 
266 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
267 
268 #endif
269 
270 // ************************************************************************* //
static const char *const typeName
Vector-tensor class used to perform translations and rotations in 3D space.
Type transform(const Type &) const
Transform the given type.
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
vector invTransformPosition(const vector &v) const
Inverse transform the given position.
Template function to specify if the data of a type are contiguous.
Spatial transformation functions for primitive fields.
A class for handling words, derived from string.
Definition: word.H:59
Type invTransform(const Type &) const
Inverse transform the given type.
Istream & operator>>(Istream &, directionInfo &)
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
static const vectorTensorTransform I
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
bool contiguous< vectorTensorTransform >()
Data associated with vectorTensorTransform type are contiguous.
Ostream & operator<<(Ostream &, const ensightPart &)
static const vectorTensorTransform zero
friend Istream & operator>>(Istream &is, vectorTensorTransform &)
A class for managing temporary objects.
Definition: PtrList.H:53
vector transformPosition(const vector &v) const
Transform the given position.
void operator &=(const vectorTensorTransform &)
Namespace for OpenFOAM.
friend Ostream & operator<<(Ostream &os, const vectorTensorTransform &)