Loading...
Searching...
No Matches
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-2025 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::vectorTensorTransform
29
30Description
31 Vector-tensor class used to perform translations and rotations in
32 3D space.
33
34SourceFiles
35 vectorTensorTransformI.H
36 vectorTensorTransform.C
37 vectorTensorTransform.txx
38
39\*---------------------------------------------------------------------------*/
40
41#ifndef Foam_vectorTensorTransform_H
42#define Foam_vectorTensorTransform_H
43
44#include "tensor.H"
45#include "word.H"
46#include "contiguous.H"
47#include "pointField.H"
48
49// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50
51namespace Foam
52{
53
54// Forward Declarations
58
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
80public:
81
82 // Static Data
83
84 static const char* const typeName;
85
87
89
91 // Generated Methods
92
93 //- Copy construct
95
96 //- Copy assignment
99
100
101 // Constructors
102
103 //- Default construct - no translation, identity rotation.
105
106 //- Construct given a translation vector, rotation tensor and
107 //- hasR bool
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
125
126
127 // Member Functions
128
129 // Access
130
131 //- True if it has a non-identity rotation tensor
132 bool hasR() const noexcept { return hasR_; }
133
134 //- The translation vector
135 const vector& t() const noexcept { return t_; }
136
137 //- The (forward) rotation tensor
138 const tensor& R() const noexcept { return R_; }
139
140
141 // Edit
142
143 //- Non-const access to the translation vector
144 vector& t() noexcept { return t_; }
145
146 //- Non-const access to the rotation tensor. Sets hasR = true
147 inline tensor& R() noexcept;
148
149 //- Test for identity rotation and set hasR accordingly
150 void checkRotation(const scalar tol = ROOTVSMALL);
151
152
153 // Transform
154
155 //- Transform the given position
156 inline vector transformPosition(const vector& v) const;
157
158 //- Transform the given field of points
159 inline pointField transformPosition(const pointField& pts) const;
161 //- Inplace transform the given points
162 inline void transformPositionList(UList<point>& pts) const;
163
164 //- Inverse transform the given position
165 inline vector invTransformPosition(const vector& v) const;
166
167 //- Inverse transform the given field of points
169
170 //- Inplace inverse transform the given points
171 inline void invTransformPositionList(UList<point>& pts) const;
172
173 //- Transform the given field
174 template<class Type>
175 tmp<Field<Type>> transform(const Field<Type>& fld) const;
176
177 //- Inplace transform the given field
178 template<class Type>
179 void transformList(UList<Type>& fld) const;
180
181
182 // Member Operators
183
184 inline void operator&=(const vectorTensorTransform&);
185
186 //- Assign translation
187 inline void operator=(const vector&);
188 inline void operator+=(const vector&);
189 inline void operator-=(const vector&);
190
191 inline void operator=(const tensor&);
192 inline void operator&=(const tensor&);
193
194
195 // IOstream Operators
196
197 friend Istream& operator>>(Istream& is, vectorTensorTransform&);
198
199 friend Ostream& operator<<(Ostream& os, const vectorTensorTransform&);
200};
201
202
203// * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
204
205//- Contiguous data for vectorTensorTransform
206template<> struct is_contiguous<vectorTensorTransform> : std::true_type {};
207
208
209// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
210
211//- Return the inverse of the given vectorTensorTransform
213
214//- Return a string representation of a vectorTensorTransform
216
217// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
218
219inline bool operator==
220(
221 const vectorTensorTransform& tr1,
222 const vectorTensorTransform& tr2
224
225
226inline bool operator!=
227(
228 const vectorTensorTransform& tr1,
229 const vectorTensorTransform& tr2
230
231);
232
233
234inline vectorTensorTransform operator+
235(
237 const vector& t
238);
239
240
241inline vectorTensorTransform operator+
242(
243 const vector& t,
246
247
248inline vectorTensorTransform operator-
249(
251 const vector& t
252);
253
255inline vectorTensorTransform operator&
256(
257 const vectorTensorTransform& tr1,
258 const vectorTensorTransform& tr2
259);
260
261
262// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
263
264} // End namespace Foam
265
266// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
267
269
270#ifdef NoRepository
271 #include "vectorTensorTransform.txx"
272#endif
273
274// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
275
276#endif
277
278// ************************************************************************* //
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Graphite solid properties.
Definition C.H:49
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition UList.H:89
Tensor of scalars, i.e. Tensor<scalar>.
A class for managing temporary objects.
Definition tmp.H:75
Vector-tensor class used to perform translations and rotations in 3D space.
void checkRotation(const scalar tol=ROOTVSMALL)
Test for identity rotation and set hasR accordingly.
void transformPositionList(UList< point > &pts) const
Inplace transform the given points.
vector & t() noexcept
Non-const access to the translation vector.
vectorTensorTransform & operator=(const vectorTensorTransform &)=default
Copy assignment.
const tensor & R() const noexcept
The (forward) rotation tensor.
const vector & t() const noexcept
The translation vector.
tmp< Field< Type > > transform(const Field< Type > &fld) const
Transform the given field.
void invTransformPositionList(UList< point > &pts) const
Inplace inverse transform the given points.
static const vectorTensorTransform I
static const vectorTensorTransform zero
vectorTensorTransform(const vectorTensorTransform &)=default
Copy construct.
void transformList(UList< Type > &fld) const
Inplace transform the given field.
vector invTransformPosition(const vector &v) const
Inverse transform the given position.
vectorTensorTransform()
Default construct - no translation, identity rotation.
vector transformPosition(const vector &v) const
Transform the given position.
static const char *const typeName
bool hasR() const noexcept
True if it has a non-identity rotation tensor.
A class for handling words, derived from Foam::string.
Definition word.H:66
OBJstream os(runTime.globalPath()/outputName)
auto & name
Namespace for OpenFOAM.
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
Tensor< scalar > tensor
Definition symmTensor.H:57
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
Istream & operator>>(Istream &, directionInfo &)
vector point
Point is a vector.
Definition point.H:37
const direction noexcept
Definition scalarImpl.H:265
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
vectorField pointField
pointField is a vectorField.
Vector< scalar > vector
Definition vector.H:57
const pointField & pts
A template class to specify that a data type can be considered as being contiguous in memory.
Definition contiguous.H:70