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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::vectorTensorTransform
28 
29 Description
30  Vector-tensor class used to perform translations and rotations in
31  3D space.
32 
33 SourceFiles
34  vectorTensorTransformI.H
35  vectorTensorTransform.C
36  vectorTensorTransformTemplates.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef vectorTensorTransform_H
41 #define vectorTensorTransform_H
42 
43 #include "tensor.H"
44 #include "word.H"
45 #include "contiguous.H"
46 #include "pointField.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 // Forward Declarations
54 
55 class vectorTensorTransform;
56 Istream& operator>>(Istream& is, vectorTensorTransform&);
57 Ostream& operator<<(Ostream& os, const vectorTensorTransform& C);
58 
59 
60 /*---------------------------------------------------------------------------*\
61  Class vectorTensorTransform Declaration
62 \*---------------------------------------------------------------------------*/
63 
65 {
66  // private data
67 
68  //- Translation vector
69  vector t_;
70 
71  //- Rotation tensor
72  tensor R_;
73 
74  //- Recording if the transform has non-identity transform to
75  // allow its calculation to be skipped, which is the majority
76  // of the expected cases
77  bool hasR_;
78 
79 
80 public:
81 
82  // Static data members
83 
84  static const char* const typeName;
85 
86  static const vectorTensorTransform zero;
87 
88  static const vectorTensorTransform I;
89 
90 
91  // Constructors
92 
93  //- Construct null
94  inline vectorTensorTransform();
95 
96  //- Construct given a translation vector, rotation tensor and
97  // hasR bool
99  (
100  const vector& t,
101  const tensor& R,
102  bool hasR = true
103  );
104 
105  //- Construct a pure translation vectorTensorTransform given a
106  // translation vector
107  inline explicit vectorTensorTransform(const vector& t);
108 
109  //- Construct a pure rotation vectorTensorTransform given a
110  // rotation tensor
111  inline explicit vectorTensorTransform(const tensor& R);
112 
113  //- Construct from Istream
115 
116 
117  // Member functions
118 
119  // Access
120 
121  inline const vector& t() const;
122 
123  inline const tensor& R() const;
124 
125  inline bool hasR() const;
126 
127 
128  // Edit
129 
130  inline vector& t();
131 
132  inline tensor& R();
133 
134 
135  // Transform
136 
137  //- Transform the given position
138  inline vector transformPosition(const vector& v) const;
139 
140  //- Transform the given pointField
141  inline pointField transformPosition(const pointField& pts) const;
142 
143  //- Inverse transform the given position
144  inline vector invTransformPosition(const vector& v) const;
145 
146  //- Inverse transform the given pointField
147  inline pointField invTransformPosition(const pointField& pts) const;
148 
149  //- Transform the given field
150  template<class Type>
151  tmp<Field<Type>> transform(const Field<Type>&) const;
152 
153 
154  // Member operators
155 
156  inline void operator=(const vectorTensorTransform&);
157  inline void operator&=(const vectorTensorTransform&);
158 
159  inline void operator=(const vector&);
160  inline void operator+=(const vector&);
161  inline void operator-=(const vector&);
162 
163  inline void operator=(const tensor&);
164  inline void operator&=(const tensor&);
165 
166 
167  // IOstream operators
168 
170 
171  friend Ostream& operator<<(Ostream& os, const vectorTensorTransform&);
172 };
173 
174 
175 // * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
176 
177 //- Contiguous data for vectorTensorTransform
178 template<> struct is_contiguous<vectorTensorTransform> : std::true_type {};
179 
180 
181 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
182 
183 //- Return the inverse of the given vectorTensorTransform
185 
186 //- Return a string representation of a vectorTensorTransform
188 
189 //- Template specialisations
190 template<>
192 
193 template<>
195 
196 template<>
198 const;
199 
200 
201 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
202 
203 inline bool operator==
204 (
205  const vectorTensorTransform& tr1,
206  const vectorTensorTransform& tr2
207 );
208 
209 
210 inline bool operator!=
211 (
212  const vectorTensorTransform& tr1,
213  const vectorTensorTransform& tr2
214 
215 );
216 
217 
218 inline vectorTensorTransform operator+
219 (
220  const vectorTensorTransform& tr,
221  const vector& t
222 );
223 
224 
225 inline vectorTensorTransform operator+
226 (
227  const vector& t,
229 );
230 
231 
232 inline vectorTensorTransform operator-
233 (
234  const vectorTensorTransform& tr,
235  const vector& t
236 );
237 
238 
239 inline vectorTensorTransform operator&
240 (
241  const vectorTensorTransform& tr1,
242  const vectorTensorTransform& tr2
243 );
244 
245 
246 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
247 
248 } // End namespace Foam
249 
250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
251 
252 #include "vectorTensorTransformI.H"
253 
254 #ifdef NoRepository
256 #endif
257 
258 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259 
260 #endif
261 
262 // ************************************************************************* //
Foam::vectorTensorTransform::zero
static const vectorTensorTransform zero
Definition: vectorTensorTransform.H:85
Foam::Tensor< scalar >
Foam::vectorTensorTransform::operator>>
friend Istream & operator>>(Istream &is, vectorTensorTransform &)
Foam::vectorTensorTransform::invTransformPosition
vector invTransformPosition(const vector &v) const
Inverse transform the given position.
Definition: vectorTensorTransformI.H:140
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::vectorTensorTransform::vectorTensorTransform
vectorTensorTransform()
Construct null.
Definition: vectorTensorTransformI.H:30
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
vectorTensorTransformTemplates.C
Foam::vectorTensorTransform::transform
tmp< Field< Type > > transform(const Field< Type > &) const
Transform the given field.
Foam::vectorTensorTransform::operator<<
friend Ostream & operator<<(Ostream &os, const vectorTensorTransform &)
Foam::operator>>
Istream & operator>>(Istream &, directionInfo &)
Definition: directionInfo.C:228
vectorTensorTransformI.H
Foam::vectorTensorTransform::operator=
void operator=(const vectorTensorTransform &)
Definition: vectorTensorTransformI.H:177
Foam::vectorTensorTransform::typeName
static const char *const typeName
Definition: vectorTensorTransform.H:83
tensor.H
C
volScalarField & C
Definition: readThermalProperties.H:102
Foam::vectorTensorTransform::operator&=
void operator&=(const vectorTensorTransform &)
Definition: vectorTensorTransformI.H:188
Foam::Field< vector >
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::inv
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
Definition: dimensionedSphericalTensor.C:73
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
Foam::vectorTensorTransform::operator+=
void operator+=(const vector &)
Definition: vectorTensorTransformI.H:207
Foam::vectorTensorTransform::t
const vector & t() const
Definition: vectorTensorTransformI.H:69
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::vectorTensorTransform::hasR
bool hasR() const
Definition: vectorTensorTransformI.H:81
Foam::vectorTensorTransform::operator-=
void operator-=(const vector &)
Definition: vectorTensorTransformI.H:213
pointField.H
Foam::vectorTensorTransform::transformPosition
vector transformPosition(const vector &v) const
Transform the given position.
Definition: vectorTensorTransformI.H:105
Foam::Vector< scalar >
contiguous.H
Foam::vectorTensorTransform::I
static const vectorTensorTransform I
Definition: vectorTensorTransform.H:87
Foam::vectorTensorTransform
Vector-tensor class used to perform translations and rotations in 3D space.
Definition: vectorTensorTransform.H:63
Foam::vectorTensorTransform::R
const tensor & R() const
Definition: vectorTensorTransformI.H:75
Foam::tr
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
Definition: dimensionedSphericalTensor.C:51
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
word.H
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &)
Definition: boundaryPatch.C:102
Foam::is_contiguous
A template class to specify that a data type can be considered as being contiguous in memory.
Definition: contiguous.H:75