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  Copyright (C) 2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 Class
28  Foam::vectorTensorTransform
29 
30 Description
31  Vector-tensor class used to perform translations and rotations in
32  3D space.
33 
34 SourceFiles
35  vectorTensorTransformI.H
36  vectorTensorTransform.C
37  vectorTensorTransformTemplates.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef vectorTensorTransform_H
42 #define vectorTensorTransform_H
43 
44 #include "tensor.H"
45 #include "word.H"
46 #include "contiguous.H"
47 #include "pointField.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 // Forward Declarations
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
83 
84  static const char* const typeName;
85 
86  static const vectorTensorTransform zero;
87 
88  static const vectorTensorTransform I;
89 
90 
91  // Generated Methods
92 
93  //- Copy construct
95 
96  //- Copy assignment
98  operator=(const vectorTensorTransform&) = default;
99 
100 
101  // Constructors
102 
103  //- Default construct - no translation, identity rotation.
104  inline vectorTensorTransform();
105 
106  //- Construct given a translation vector, rotation tensor and
107  //- hasR bool
108  inline vectorTensorTransform
109  (
110  const vector& t,
111  const tensor& R,
112  bool hasR = true
113  );
114 
115  //- Construct a pure translation vectorTensorTransform given a
116  //- translation vector
117  inline explicit vectorTensorTransform(const vector& t);
118 
119  //- Construct a pure rotation vectorTensorTransform given a
120  //- rotation tensor
121  inline explicit vectorTensorTransform(const tensor& R);
122 
123  //- Construct from Istream
124  explicit vectorTensorTransform(Istream&);
125 
126 
127  // Member Functions
128 
129  // Access
130 
131  inline const vector& t() const;
132 
133  inline const tensor& R() const;
134 
135  inline bool hasR() const;
136 
137 
138  // Edit
139 
140  inline vector& t();
141 
142  inline tensor& R();
143 
144 
145  // Transform
146 
147  //- Transform the given position
148  inline vector transformPosition(const vector& v) const;
149 
150  //- Transform the given pointField
151  inline pointField transformPosition(const pointField& pts) const;
152 
153  //- Inverse transform the given position
154  inline vector invTransformPosition(const vector& v) const;
155 
156  //- Inverse transform the given pointField
157  inline pointField invTransformPosition(const pointField& pts) const;
158 
159  //- Transform the given field
160  template<class Type>
161  tmp<Field<Type>> transform(const Field<Type>&) const;
162 
163 
164  // Member Operators
165 
166  inline void operator&=(const vectorTensorTransform&);
167 
168  //- Assign translation
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 // * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
186 
187 //- Contiguous data for vectorTensorTransform
188 template<> struct is_contiguous<vectorTensorTransform> : std::true_type {};
189 
190 
191 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
192 
193 //- Return the inverse of the given vectorTensorTransform
195 
196 //- Return a string representation of a vectorTensorTransform
198 
199 //- Template specialisations
200 template<>
202 
203 template<>
205 
206 template<>
208 const;
209 
210 
211 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
212 
213 inline bool operator==
214 (
215  const vectorTensorTransform& tr1,
216  const vectorTensorTransform& tr2
217 );
218 
219 
220 inline bool operator!=
221 (
222  const vectorTensorTransform& tr1,
223  const vectorTensorTransform& tr2
224 
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 vector& t,
239 );
240 
241 
242 inline vectorTensorTransform operator-
243 (
244  const vectorTensorTransform& tr,
245  const vector& t
246 );
247 
248 
249 inline vectorTensorTransform operator&
250 (
251  const vectorTensorTransform& tr1,
252  const vectorTensorTransform& tr2
253 );
254 
255 
256 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
257 
258 } // End namespace Foam
259 
260 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
261 
262 #include "vectorTensorTransformI.H"
263 
264 #ifdef NoRepository
266 #endif
267 
268 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
269 
270 #endif
271 
272 // ************************************************************************* //
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()
Default construct - no translation, identity rotation.
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::vectorTensorTransform::operator=
vectorTensorTransform & operator=(const vectorTensorTransform &)=default
Copy assignment.
Foam::operator>>
Istream & operator>>(Istream &, directionInfo &)
Definition: directionInfo.C:230
vectorTensorTransformI.H
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:177
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
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:196
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:202
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::is_contiguous
A template class to specify that a data type can be considered as being contiguous in memory.
Definition: contiguous.H:75