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-2018 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  inline void operator&=(const vectorTensorTransform&);
169 
170  inline void operator=(const vector&);
171  inline void operator+=(const vector&);
172  inline void operator-=(const vector&);
173 
174  inline void operator=(const tensor&);
175  inline void operator&=(const tensor&);
176 
177 
178  // IOstream operators
179 
181 
182  friend Ostream& operator<<(Ostream& os, const vectorTensorTransform&);
183 };
184 
185 
186 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
187 
188 //- Return the inverse of the given vectorTensorTransform
190 
191 
192 //- Return a string representation of a vectorTensorTransform
194 
195 
196 //- Data associated with vectorTensorTransform type are contiguous
197 template<>
198 inline bool contiguous<vectorTensorTransform>() {return true;}
199 
200 //- Template specialisations
201 template<>
203 template<>
205 template<>
207 const;
208 
209 
210 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
211 
212 inline bool operator==
213 (
214  const vectorTensorTransform& tr1,
215  const vectorTensorTransform& tr2
216 );
217 
218 
219 inline bool operator!=
220 (
221  const vectorTensorTransform& tr1,
222  const vectorTensorTransform& tr2
223 
224 );
225 
226 
227 inline vectorTensorTransform operator+
228 (
229  const vectorTensorTransform& tr,
230  const vector& t
231 );
232 
233 
234 inline vectorTensorTransform operator+
235 (
236  const vector& t,
238 );
239 
240 
241 inline vectorTensorTransform operator-
242 (
243  const vectorTensorTransform& tr,
244  const vector& t
245 );
246 
247 
248 inline vectorTensorTransform operator&
249 (
250  const vectorTensorTransform& tr1,
251  const vectorTensorTransform& tr2
252 );
253 
254 
255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
256 
257 } // End namespace Foam
258 
259 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
260 
261 #include "vectorTensorTransformI.H"
262 
263 #ifdef NoRepository
265 #endif
266 
267 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
268 
269 #endif
270 
271 // ************************************************************************* //
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.
void operator=(const vectorTensorTransform &)
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
volScalarField & C
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 &)