coordinateSystemTransform.C
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) 2018 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
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\*---------------------------------------------------------------------------*/
27
28#include "coordinateSystem.H"
29#include "transform.H"
30
31// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
32
33namespace Foam
34{
35
36// Resolve templated global functions via local non-templated function.
37// Lambda functions in the caller is a much messier solution.
38
39#undef makeTransform
40#define makeTransform(Op, Type) \
41 static inline Type Op##_##Type(const tensor& tt, const Type& in) \
42 { \
43 return Op(tt, in); \
44 }
45
51
57
58#undef makeTransform
59
60 //- Transform principal.
62 (
63 const tensor& tt,
64 const vector& v
65 )
66 {
67 return symmTensor
68 (
69 tt.xx()*v.x()*tt.xx()
70 + tt.xy()*v.y()*tt.xy()
71 + tt.xz()*v.z()*tt.xz(),
72
73 tt.xx()*v.x()*tt.yx()
74 + tt.xy()*v.y()*tt.yy()
75 + tt.xz()*v.z()*tt.yz(),
76
77 tt.xx()*v.x()*tt.zx()
78 + tt.xy()*v.y()*tt.zy()
79 + tt.xz()*v.z()*tt.zz(),
80
81 tt.yx()*v.x()*tt.yx()
82 + tt.yy()*v.y()*tt.yy()
83 + tt.yz()*v.z()*tt.yz(),
84
85 tt.yx()*v.x()*tt.zx()
86 + tt.yy()*v.y()*tt.zy()
87 + tt.yz()*v.z()*tt.zz(),
88
89 tt.zx()*v.x()*tt.zx()
90 + tt.zy()*v.y()*tt.zy()
91 + tt.zz()*v.z()*tt.zz()
92 );
93 }
94
95} // End namespace Foam
96
97
98// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
99
101(
102 const UList<point>& localCart
103) const
104{
105 return transformPointImpl(localCart);
106}
107
108
110(
111 const pointUIndList& localCart
112) const
113{
114 return transformPointImpl(localCart);
115}
116
117
119(
120 const UList<point>& global
121) const
122{
123 return invTransformPointImpl(global);
124}
125
126
128(
129 const pointUIndList& global
130) const
131{
132 return invTransformPointImpl(global);
133}
134
135
136// Transformations
137
138#undef makeCoordinateSystemTransform
139#define makeCoordinateSystemTransform(Op, RetType, Type) \
140 Foam::RetType Foam::coordinateSystem::Op \
141 ( \
142 const Type& input \
143 ) const \
144 { \
145 return Op##_##Type(rot_, input); \
146 } \
147 \
148 Foam::tmp<Foam::Field<Foam::RetType>> Foam::coordinateSystem::Op \
149 ( \
150 const UList<Type>& input \
151 ) const \
152 { \
153 return manyTimesImpl<RetType>(rot_, input, Op##_##Type); \
154 } \
155 \
156 Foam::RetType Foam::coordinateSystem::Op \
157 ( \
158 const point& global, \
159 const Type& input \
160 ) const \
161 { \
162 return Op##_##Type(this->R(global), input); \
163 } \
164 \
165 Foam::tmp<Foam::Field<Foam::RetType>> Foam::coordinateSystem::Op \
166 ( \
167 const UList<point>& global, \
168 const Type& input \
169 ) const \
170 { \
171 return oneToManyImpl<RetType>(global, input, Op##_##Type); \
172 } \
173 \
174 Foam::tmp<Foam::Field<Foam::RetType>> Foam::coordinateSystem::Op \
175 ( \
176 const pointUIndList& global, \
177 const Type& input \
178 ) const \
179 { \
180 return oneToManyImpl<RetType>(global, input, Op##_##Type); \
181 } \
182 \
183 Foam::tmp<Foam::Field<Foam::RetType>> Foam::coordinateSystem::Op \
184 ( \
185 const UList<point>& global, \
186 const UList<Type>& input \
187 ) const \
188 { \
189 return oneToOneImpl<RetType>(global, input, Op##_##Type); \
190 } \
191 \
192 Foam::tmp<Foam::Field<Foam::RetType>> Foam::coordinateSystem::Op \
193 ( \
194 const pointUIndList& global, \
195 const UList<Type>& input \
196 ) const \
197 { \
198 return oneToOneImpl<RetType>(global, input, Op##_##Type); \
199 }
200
201
203
209
215
216#undef makeCoordinateSystemTransform
217
218
219// ************************************************************************* //
const Cmpt & xx() const
Definition: TensorI.H:153
const Cmpt & yx() const
Definition: TensorI.H:174
const Cmpt & yz() const
Definition: TensorI.H:188
const Cmpt & xz() const
Definition: TensorI.H:167
const Cmpt & zz() const
Definition: TensorI.H:209
const Cmpt & xy() const
Definition: TensorI.H:160
const Cmpt & zx() const
Definition: TensorI.H:195
const Cmpt & zy() const
Definition: TensorI.H:202
const Cmpt & yy() const
Definition: TensorI.H:181
A List with indirect addressing. Like IndirectList but does not store addressing.
Definition: IndirectList.H:79
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:94
const Cmpt & z() const
Access to the vector z component.
Definition: VectorI.H:85
const Cmpt & y() const
Access to the vector y component.
Definition: VectorI.H:79
const Cmpt & x() const
Access to the vector x component.
Definition: VectorI.H:73
point invTransformPoint(const point &global) const
Remove origin offset and inverse transform point.
point transformPoint(const point &localCart) const
Transform point and add origin offset.
tmp< pointField > transformPointImpl(const PointField &localCart) const
Implementation for transformPoint() methods.
A class for managing temporary objects.
Definition: tmp.H:65
#define makeCoordinateSystemTransform(Op, RetType, Type)
#define makeTransform(Op, Type)
Namespace for OpenFOAM.
dimensionSet invTransform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:542
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:536
static symmTensor transformPrincipal_vector(const tensor &tt, const vector &v)
Transform principal.
SymmTensor< scalar > symmTensor
SymmTensor of scalars, i.e. SymmTensor<scalar>.
Definition: symmTensor.H:59
3D tensor transformation operations.