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 -------------------------------------------------------------------------------
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 \*---------------------------------------------------------------------------*/
27 
28 #include "coordinateSystem.H"
29 #include "transform.H"
30 
31 // * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
32 
33 namespace 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 // ************************************************************************* //
Foam::Tensor< scalar >
Foam::Vector::x
const Cmpt & x() const
Access to the vector x component.
Definition: VectorI.H:73
Foam::SymmTensor
A templated (3 x 3) symmetric tensor of objects of <T>, effectively containing 6 elements,...
Definition: SymmTensor.H:58
Foam::Tensor::zx
const Cmpt & zx() const
Definition: TensorI.H:194
Foam::transformPrincipal_vector
static symmTensor transformPrincipal_vector(const tensor &tt, const vector &v)
Transform principal.
Definition: coordinateSystemTransform.C:62
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::Tensor::yx
const Cmpt & yx() const
Definition: TensorI.H:173
Foam::transform
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:521
coordinateSystem.H
Foam::Vector::z
const Cmpt & z() const
Access to the vector z component.
Definition: VectorI.H:85
Foam::Tensor::xz
const Cmpt & xz() const
Definition: TensorI.H:166
Foam::Tensor::yz
const Cmpt & yz() const
Definition: TensorI.H:187
Foam::Tensor::zy
const Cmpt & zy() const
Definition: TensorI.H:201
Foam::Tensor::yy
const Cmpt & yy() const
Definition: TensorI.H:180
makeTransform
#define makeTransform(Op, Type)
Definition: coordinateSystemTransform.C:40
Foam::Tensor::zz
const Cmpt & zz() const
Definition: TensorI.H:208
makeCoordinateSystemTransform
#define makeCoordinateSystemTransform(Op, RetType, Type)
Definition: coordinateSystemTransform.C:139
Foam::symmTensor
SymmTensor< scalar > symmTensor
SymmTensor of scalars, i.e. SymmTensor<scalar>.
Definition: symmTensor.H:59
Foam::Tensor::xy
const Cmpt & xy() const
Definition: TensorI.H:159
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::SphericalTensor
A templated (3 x 3) diagonal tensor of objects of <T>, effectively containing 1 element,...
Definition: SphericalTensor.H:57
Foam::Tensor::xx
const Cmpt & xx() const
Definition: TensorI.H:152
Foam::Vector::y
const Cmpt & y() const
Access to the vector y component.
Definition: VectorI.H:79
Foam::Vector< scalar >
Foam::UList
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:103
Foam::invTransform
dimensionSet invTransform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:527
Foam::UIndirectList
A List with indirect addressing.
Definition: faMatrix.H:60
Foam::coordinateSystem::invTransformPoint
point invTransformPoint(const point &global) const
Remove origin offset and inverse transform point.
Definition: coordinateSystem.C:329
transform.H
3D tensor transformation operations.
Foam::coordinateSystem::transformPoint
point transformPoint(const point &localCart) const
Transform point and add origin offset.
Definition: coordinateSystem.C:320