35 #ifndef Foam_transform_H 36 #define Foam_transform_H 40 #include <type_traits> 56 const scalar
s = n1 & n2;
58 const scalar magSqrN3 =
magSqr(n3);
66 + (1 -
s)*
sqr(n3)/magSqrN3
87 const scalar
s =
sin(omega);
88 const scalar
c =
cos(omega);
101 const scalar
s =
sin(omega);
102 const scalar
c =
cos(omega);
113 inline tensor Rz(
const scalar omega)
116 const scalar
c =
cos(omega);
129 const scalar
s =
sin(omega);
130 const scalar
c =
cos(omega);
134 sqr(a.x())*(1 -
c) +
c,
135 a.y()*a.x()*(1 -
c) + a.z()*
s,
136 a.x()*a.z()*(1 -
c) - a.y()*
s,
138 a.x()*a.y()*(1 -
c) - a.z()*
s,
139 sqr(a.y())*(1 -
c) +
c,
140 a.y()*a.z()*(1 -
c) + a.x()*
s,
142 a.x()*a.z()*(1 -
c) + a.y()*
s,
143 a.y()*a.z()*(1 -
c) - a.x()*
s,
144 sqr(a.z())*(1 -
c) +
c 153 constexpr
typename std::enable_if<std::is_arithmetic<T>::value,
T>
::type 174 constexpr
typename std::enable_if<std::is_arithmetic<T>::value,
T>
::type 219 (tt.xx()*t.
xx() + tt.xy()*t.
yx() + tt.xz()*t.
zx())*tt.xx()
220 + (tt.xx()*t.
xy() + tt.xy()*t.
yy() + tt.xz()*t.
zy())*tt.xy()
221 + (tt.xx()*t.
xz() + tt.xy()*t.
yz() + tt.xz()*t.
zz())*tt.xz(),
224 (tt.xx()*t.
xx() + tt.xy()*t.
yx() + tt.xz()*t.
zx())*tt.yx()
225 + (tt.xx()*t.
xy() + tt.xy()*t.
yy() + tt.xz()*t.
zy())*tt.yy()
226 + (tt.xx()*t.
xz() + tt.xy()*t.
yz() + tt.xz()*t.
zz())*tt.yz(),
229 (tt.xx()*t.
xx() + tt.xy()*t.
yx() + tt.xz()*t.
zx())*tt.zx()
230 + (tt.xx()*t.
xy() + tt.xy()*t.
yy() + tt.xz()*t.
zy())*tt.zy()
231 + (tt.xx()*t.
xz() + tt.xy()*t.
yz() + tt.xz()*t.
zz())*tt.zz(),
234 (tt.yx()*t.
xx() + tt.yy()*t.
yx() + tt.yz()*t.
zx())*tt.xx()
235 + (tt.yx()*t.
xy() + tt.yy()*t.
yy() + tt.yz()*t.
zy())*tt.xy()
236 + (tt.yx()*t.
xz() + tt.yy()*t.
yz() + tt.yz()*t.
zz())*tt.xz(),
239 (tt.yx()*t.
xx() + tt.yy()*t.
yx() + tt.yz()*t.
zx())*tt.yx()
240 + (tt.yx()*t.
xy() + tt.yy()*t.
yy() + tt.yz()*t.
zy())*tt.yy()
241 + (tt.yx()*t.
xz() + tt.yy()*t.
yz() + tt.yz()*t.
zz())*tt.yz(),
244 (tt.yx()*t.
xx() + tt.yy()*t.
yx() + tt.yz()*t.
zx())*tt.zx()
245 + (tt.yx()*t.
xy() + tt.yy()*t.
yy() + tt.yz()*t.
zy())*tt.zy()
246 + (tt.yx()*t.
xz() + tt.yy()*t.
yz() + tt.yz()*t.
zz())*tt.zz(),
249 (tt.zx()*t.
xx() + tt.zy()*t.
yx() + tt.zz()*t.
zx())*tt.xx()
250 + (tt.zx()*t.
xy() + tt.zy()*t.
yy() + tt.zz()*t.
zy())*tt.xy()
251 + (tt.zx()*t.
xz() + tt.zy()*t.
yz() + tt.zz()*t.
zz())*tt.xz(),
254 (tt.zx()*t.
xx() + tt.zy()*t.
yx() + tt.zz()*t.
zx())*tt.yx()
255 + (tt.zx()*t.
xy() + tt.zy()*t.
yy() + tt.zz()*t.
zy())*tt.yy()
256 + (tt.zx()*t.
xz() + tt.zy()*t.
yz() + tt.zz()*t.
zz())*tt.yz(),
259 (tt.zx()*t.
xx() + tt.zy()*t.
yx() + tt.zz()*t.
zx())*tt.zx()
260 + (tt.zx()*t.
xy() + tt.zy()*t.
yy() + tt.zz()*t.
zy())*tt.zy()
261 + (tt.zx()*t.
xz() + tt.zy()*t.
yz() + tt.zz()*t.
zz())*tt.zz()
274 (tt.xx()*t.xx() + tt.yx()*t.yx() + tt.zx()*t.zx())*tt.xx()
275 + (tt.xx()*t.xy() + tt.yx()*t.yy() + tt.zx()*t.zy())*tt.yx()
276 + (tt.xx()*t.xz() + tt.yx()*t.yz() + tt.zx()*t.zz())*tt.zx(),
279 (tt.xx()*t.xx() + tt.yx()*t.yx() + tt.zx()*t.zx())*tt.xy()
280 + (tt.xx()*t.xy() + tt.yx()*t.yy() + tt.zx()*t.zy())*tt.yy()
281 + (tt.xx()*t.xz() + tt.yx()*t.yz() + tt.zx()*t.zz())*tt.zy(),
284 (tt.xx()*t.xx() + tt.yx()*t.yx() + tt.zx()*t.zx())*tt.xz()
285 + (tt.xx()*t.xy() + tt.yx()*t.yy() + tt.zx()*t.zy())*tt.yz()
286 + (tt.xx()*t.xz() + tt.yx()*t.yz() + tt.zx()*t.zz())*tt.zz(),
289 (tt.xy()*t.xx() + tt.yy()*t.yx() + tt.zy()*t.zx())*tt.xx()
290 + (tt.xy()*t.xy() + tt.yy()*t.yy() + tt.zy()*t.zy())*tt.yx()
291 + (tt.xy()*t.xz() + tt.yy()*t.yz() + tt.zy()*t.zz())*tt.zx(),
294 (tt.xy()*t.xx() + tt.yy()*t.yx() + tt.zy()*t.zx())*tt.xy()
295 + (tt.xy()*t.xy() + tt.yy()*t.yy() + tt.zy()*t.zy())*tt.yy()
296 + (tt.xy()*t.xz() + tt.yy()*t.yz() + tt.zy()*t.zz())*tt.zy(),
299 (tt.xy()*t.xx() + tt.yy()*t.yx() + tt.zy()*t.zx())*tt.xz()
300 + (tt.xy()*t.xy() + tt.yy()*t.yy() + tt.zy()*t.zy())*tt.yz()
301 + (tt.xy()*t.xz() + tt.yy()*t.yz() + tt.zy()*t.zz())*tt.zz(),
304 (tt.xz()*t.xx() + tt.yz()*t.yx() + tt.zz()*t.zx())*tt.xx()
305 + (tt.xz()*t.xy() + tt.yz()*t.yy() + tt.zz()*t.zy())*tt.yx()
306 + (tt.xz()*t.xz() + tt.yz()*t.yz() + tt.zz()*t.zz())*tt.zx(),
309 (tt.xz()*t.xx() + tt.yz()*t.yx() + tt.zz()*t.zx())*tt.xy()
310 + (tt.xz()*t.xy() + tt.yz()*t.yy() + tt.zz()*t.zy())*tt.yy()
311 + (tt.xz()*t.xz() + tt.yz()*t.yz() + tt.zz()*t.zz())*tt.zy(),
314 (tt.xz()*t.xx() + tt.yz()*t.yx() + tt.zz()*t.zx())*tt.xz()
315 + (tt.xz()*t.xy() + tt.yz()*t.yy() + tt.zz()*t.zy())*tt.yz()
316 + (tt.xz()*t.xz() + tt.yz()*t.yz() + tt.zz()*t.zz())*tt.zz()
324 inline SymmTensor<Cmpt>
transform(
const tensor& tt,
const SymmTensor<Cmpt>& st)
326 return SymmTensor<Cmpt>
329 (tt.xx()*st.xx() + tt.xy()*st.xy() + tt.xz()*st.xz())*tt.xx()
330 + (tt.xx()*st.xy() + tt.xy()*st.yy() + tt.xz()*st.yz())*tt.xy()
331 + (tt.xx()*st.xz() + tt.xy()*st.yz() + tt.xz()*st.zz())*tt.xz(),
334 (tt.xx()*st.xx() + tt.xy()*st.xy() + tt.xz()*st.xz())*tt.yx()
335 + (tt.xx()*st.xy() + tt.xy()*st.yy() + tt.xz()*st.yz())*tt.yy()
336 + (tt.xx()*st.xz() + tt.xy()*st.yz() + tt.xz()*st.zz())*tt.yz(),
339 (tt.xx()*st.xx() + tt.xy()*st.xy() + tt.xz()*st.xz())*tt.zx()
340 + (tt.xx()*st.xy() + tt.xy()*st.yy() + tt.xz()*st.yz())*tt.zy()
341 + (tt.xx()*st.xz() + tt.xy()*st.yz() + tt.xz()*st.zz())*tt.zz(),
344 (tt.yx()*st.xx() + tt.yy()*st.xy() + tt.yz()*st.xz())*tt.yx()
345 + (tt.yx()*st.xy() + tt.yy()*st.yy() + tt.yz()*st.yz())*tt.yy()
346 + (tt.yx()*st.xz() + tt.yy()*st.yz() + tt.yz()*st.zz())*tt.yz(),
349 (tt.yx()*st.xx() + tt.yy()*st.xy() + tt.yz()*st.xz())*tt.zx()
350 + (tt.yx()*st.xy() + tt.yy()*st.yy() + tt.yz()*st.yz())*tt.zy()
351 + (tt.yx()*st.xz() + tt.yy()*st.yz() + tt.yz()*st.zz())*tt.zz(),
354 (tt.zx()*st.xx() + tt.zy()*st.xy() + tt.zz()*st.xz())*tt.zx()
355 + (tt.zx()*st.xy() + tt.zy()*st.yy() + tt.zz()*st.yz())*tt.zy()
356 + (tt.zx()*st.xz() + tt.zy()*st.yz() + tt.zz()*st.zz())*tt.zz()
364 inline SymmTensor<Cmpt>
367 return SymmTensor<Cmpt>
370 (tt.xx()*st.xx() + tt.yx()*st.xy() + tt.zx()*st.xz())*tt.xx()
371 + (tt.xx()*st.xy() + tt.yx()*st.yy() + tt.zx()*st.yz())*tt.yx()
372 + (tt.xx()*st.xz() + tt.yx()*st.yz() + tt.zx()*st.zz())*tt.zx(),
375 (tt.xx()*st.xx() + tt.yx()*st.xy() + tt.zx()*st.xz())*tt.xy()
376 + (tt.xx()*st.xy() + tt.yx()*st.yy() + tt.zx()*st.yz())*tt.yy()
377 + (tt.xx()*st.xz() + tt.yx()*st.yz() + tt.zx()*st.zz())*tt.zy(),
380 (tt.xx()*st.xx() + tt.yx()*st.xy() + tt.zx()*st.xz())*tt.xz()
381 + (tt.xx()*st.xy() + tt.yx()*st.yy() + tt.zx()*st.yz())*tt.yz()
382 + (tt.xx()*st.xz() + tt.yx()*st.yz() + tt.zx()*st.zz())*tt.zz(),
385 (tt.xy()*st.xx() + tt.yy()*st.xy() + tt.zy()*st.xz())*tt.xy()
386 + (tt.xy()*st.xy() + tt.yy()*st.yy() + tt.zy()*st.yz())*tt.yy()
387 + (tt.xy()*st.xz() + tt.yy()*st.yz() + tt.zy()*st.zz())*tt.zy(),
390 (tt.xy()*st.xx() + tt.yy()*st.xy() + tt.zy()*st.xz())*tt.xz()
391 + (tt.xy()*st.xy() + tt.yy()*st.yy() + tt.zy()*st.yz())*tt.yz()
392 + (tt.xy()*st.xz() + tt.yy()*st.yz() + tt.zy()*st.zz())*tt.zz(),
395 (tt.xz()*st.xx() + tt.yz()*st.xy() + tt.zz()*st.xz())*tt.xz()
396 + (tt.xz()*st.xy() + tt.yz()*st.yy() + tt.zz()*st.yz())*tt.yz()
397 + (tt.xz()*st.xz() + tt.yz()*st.yz() + tt.zz()*st.zz())*tt.zz()
404 template<
class Type1,
class Type2>
442 const scalar cos_angle = vec & e0;
443 const scalar sin_angle = vec & e1;
445 if (sin_angle < -SMALL)
dimensionSet invTransform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
scalar pseudoAngle(const vector &e0, const vector &e1, const vector &vec)
Estimate angle of vec in coordinate system (e0, e1, e0^e1).
const Cmpt & yx() const noexcept
dimensionedSymmTensor sqr(const dimensionedVector &dv)
const Cmpt & xy() const noexcept
sphericalTensor transformMask< sphericalTensor >(const symmTensor &st)
tensor rotationTensor(const vector &n1, const vector &n2)
Rotational transformation tensor from vector n1 to n2.
SphericalTensor< Cmpt > sph(const DiagTensor< Cmpt > &dt)
Return the spherical part of a DiagTensor as a SphericalTensor.
tensor Rz(const scalar omega)
Rotational transformation tensor about the z-axis by omega radians.
A templated (3 x 3) diagonal tensor of objects of <T>, effectively containing 1 element, derived from VectorSpace.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
const Cmpt & yz() const noexcept
const Cmpt & xx() const noexcept
const Cmpt & yy() const noexcept
dimensionedScalar cos(const dimensionedScalar &ds)
symmTensor transformMask< symmTensor >(const symmTensor &st)
static const Identity< scalar > I
SymmTensor< scalar > symmTensor
SymmTensor of scalars, i.e. SymmTensor<scalar>.
const Cmpt & zx() const noexcept
constexpr scalar piByTwo(0.5 *M_PI)
Templated 3D Vector derived from VectorSpace adding construction from 3 components, element access using x(), y() and z() member functions and the inner-product (dot-product) and cross-product operators.
dimensionedScalar sin(const dimensionedScalar &ds)
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
const Cmpt & zy() const noexcept
tensor Ry(const scalar omega)
Rotational transformation tensor about the y-axis by omega radians.
Type1 transformMask(const Type2 &t)
const Cmpt & zz() const noexcept
dimensionedSymmTensor symm(const dimensionedSymmTensor &dt)
const dimensionedScalar c
Speed of light in a vacuum.
tensor Ra(const vector &a, const scalar omega)
Rotational transformation tensor about axis a by omega radians.
SphericalTensor< scalar > sphericalTensor
SphericalTensor of scalars, i.e. SphericalTensor<scalar>.
A templated (3 x 3) tensor of objects of <T> derived from MatrixSpace.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Tensor of scalars, i.e. Tensor<scalar>.
const Cmpt & xz() const noexcept
tensor Rx(const scalar omega)
Rotational transformation tensor about the x-axis by omega radians.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)