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