Loading...
Searching...
No Matches
symmTransform.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 OpenFOAM Foundation
9 Copyright (C) 2023-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
27InNamespace
28 Foam
29
30Description
31 3D symmetric tensor transformation operations.
32
33\*---------------------------------------------------------------------------*/
34
35#ifndef Foam_symmTransform_H
36#define Foam_symmTransform_H
37
38#include "transform.H"
39
40// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41
42namespace Foam
43{
44
45// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47//- No-op rotational transform for base types
48template<class T>
49constexpr std::enable_if_t<std::is_arithmetic_v<T>, T>
50transform(const symmTensor&, const T val)
51{
52 return val;
53}
54
55
56//- No-op rotational transform for spherical tensor
57template<class Cmpt>
59(
60 const symmTensor&,
61 const SphericalTensor<Cmpt>& val
62)
63{
64 return val;
65}
66
67
68//- Use rotational tensor to transform a vector
69// Same as (rot & v)
70template<class Cmpt>
71inline Vector<Cmpt> transform(const symmTensor& tt, const Vector<Cmpt>& v)
73 return tt & v;
74}
75
76
77//- Use rotational tensor to transform a tensor.
78// Same as (rot & input & rot.T())
79template<class Cmpt>
80inline Tensor<Cmpt> transform(const symmTensor& stt, const Tensor<Cmpt>& t)
81{
82 return Tensor<Cmpt>
83 (
84 // xx:
85 (stt.xx()*t.xx() + stt.xy()*t.yx() + stt.xz()*t.zx())*stt.xx()
86 + (stt.xx()*t.xy() + stt.xy()*t.yy() + stt.xz()*t.zy())*stt.xy()
87 + (stt.xx()*t.xz() + stt.xy()*t.yz() + stt.xz()*t.zz())*stt.xz(),
88
89 // xy:
90 (stt.xx()*t.xx() + stt.xy()*t.yx() + stt.xz()*t.zx())*stt.xy()
91 + (stt.xx()*t.xy() + stt.xy()*t.yy() + stt.xz()*t.zy())*stt.yy()
92 + (stt.xx()*t.xz() + stt.xy()*t.yz() + stt.xz()*t.zz())*stt.yz(),
93
94 // xz:
95 (stt.xx()*t.xx() + stt.xy()*t.yx() + stt.xz()*t.zx())*stt.xz()
96 + (stt.xx()*t.xy() + stt.xy()*t.yy() + stt.xz()*t.zy())*stt.yz()
97 + (stt.xx()*t.xz() + stt.xy()*t.yz() + stt.xz()*t.zz())*stt.zz(),
98
99 // yx:
100 (stt.xy()*t.xx() + stt.yy()*t.yx() + stt.yz()*t.zx())*stt.xx()
101 + (stt.xy()*t.xy() + stt.yy()*t.yy() + stt.yz()*t.zy())*stt.xy()
102 + (stt.xy()*t.xz() + stt.yy()*t.yz() + stt.yz()*t.zz())*stt.xz(),
103
104 // yy:
105 (stt.xy()*t.xx() + stt.yy()*t.yx() + stt.yz()*t.zx())*stt.xy()
106 + (stt.xy()*t.xy() + stt.yy()*t.yy() + stt.yz()*t.zy())*stt.yy()
107 + (stt.xy()*t.xz() + stt.yy()*t.yz() + stt.yz()*t.zz())*stt.yz(),
108
109 // yz:
110 (stt.xy()*t.xx() + stt.yy()*t.yx() + stt.yz()*t.zx())*stt.xz()
111 + (stt.xy()*t.xy() + stt.yy()*t.yy() + stt.yz()*t.zy())*stt.yz()
112 + (stt.xy()*t.xz() + stt.yy()*t.yz() + stt.yz()*t.zz())*stt.zz(),
113
114 // zx:
115 (stt.xz()*t.xx() + stt.yz()*t.yx() + stt.zz()*t.zx())*stt.xx()
116 + (stt.xz()*t.xy() + stt.yz()*t.yy() + stt.zz()*t.zy())*stt.xy()
117 + (stt.xz()*t.xz() + stt.yz()*t.yz() + stt.zz()*t.zz())*stt.xz(),
118
119 // zy:
120 (stt.xz()*t.xx() + stt.yz()*t.yx() + stt.zz()*t.zx())*stt.xy()
121 + (stt.xz()*t.xy() + stt.yz()*t.yy() + stt.zz()*t.zy())*stt.yy()
122 + (stt.xz()*t.xz() + stt.yz()*t.yz() + stt.zz()*t.zz())*stt.yz(),
123
124 // zz:
125 (stt.xz()*t.xx() + stt.yz()*t.yx() + stt.zz()*t.zx())*stt.xz()
126 + (stt.xz()*t.xy() + stt.yz()*t.yy() + stt.zz()*t.zy())*stt.yz()
127 + (stt.xz()*t.xz() + stt.yz()*t.yz() + stt.zz()*t.zz())*stt.zz()
128 );
129}
130
131
132//- Use rotational tensor to transform a symmTensor
133// Same as (rot & input & rot.T())
134template<class Cmpt>
135inline SymmTensor<Cmpt> transform
136(
137 const symmTensor& stt,
138 const SymmTensor<Cmpt>& st
139)
140{
141 return SymmTensor<Cmpt>
143 // xx:
144 (stt.xx()*st.xx() + stt.xy()*st.xy() + stt.xz()*st.xz())*stt.xx()
145 + (stt.xx()*st.xy() + stt.xy()*st.yy() + stt.xz()*st.yz())*stt.xy()
146 + (stt.xx()*st.xz() + stt.xy()*st.yz() + stt.xz()*st.zz())*stt.xz(),
147
148 // xy:
149 (stt.xx()*st.xx() + stt.xy()*st.xy() + stt.xz()*st.xz())*stt.xy()
150 + (stt.xx()*st.xy() + stt.xy()*st.yy() + stt.xz()*st.yz())*stt.yy()
151 + (stt.xx()*st.xz() + stt.xy()*st.yz() + stt.xz()*st.zz())*stt.yz(),
152
153 // xz:
154 (stt.xx()*st.xx() + stt.xy()*st.xy() + stt.xz()*st.xz())*stt.xz()
155 + (stt.xx()*st.xy() + stt.xy()*st.yy() + stt.xz()*st.yz())*stt.yz()
156 + (stt.xx()*st.xz() + stt.xy()*st.yz() + stt.xz()*st.zz())*stt.zz(),
157
158 // yy:
159 (stt.xy()*st.xx() + stt.yy()*st.xy() + stt.yz()*st.xz())*stt.xy()
160 + (stt.xy()*st.xy() + stt.yy()*st.yy() + stt.yz()*st.yz())*stt.yy()
161 + (stt.xy()*st.xz() + stt.yy()*st.yz() + stt.yz()*st.zz())*stt.yz(),
162
163 // yz:
164 (stt.xy()*st.xx() + stt.yy()*st.xy() + stt.yz()*st.xz())*stt.xz()
165 + (stt.xy()*st.xy() + stt.yy()*st.yy() + stt.yz()*st.yz())*stt.yz()
166 + (stt.xy()*st.xz() + stt.yy()*st.yz() + stt.yz()*st.zz())*stt.zz(),
167
168 // zz:
169 (stt.xz()*st.xx() + stt.yz()*st.xy() + stt.zz()*st.xz())*stt.xz()
170 + (stt.xz()*st.xy() + stt.yz()*st.yy() + stt.zz()*st.yz())*stt.yz()
171 + (stt.xz()*st.xz() + stt.yz()*st.yz() + stt.zz()*st.zz())*stt.zz()
172 );
173}
174
175
176// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177
178template<>
180{
181 return sph(st);
182}
183
184
185template<>
187{
188 return st;
189}
190
191
192template<>
194{
195 return st;
196}
197
198
199// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201} // End namespace Foam
202
203// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204
205#endif
206
207// ************************************************************************* //
A templated (3 x 3) diagonal tensor of objects of <T>, effectively containing 1 element,...
A templated (3 x 3) symmetric tensor of objects of <T>, effectively containing 6 elements,...
Definition SymmTensor.H:53
const Cmpt & yy() const noexcept
Definition SymmTensor.H:154
const Cmpt & xx() const noexcept
Definition SymmTensor.H:150
const Cmpt & yz() const noexcept
Definition SymmTensor.H:155
const Cmpt & zz() const noexcept
Definition SymmTensor.H:158
const Cmpt & xy() const noexcept
Definition SymmTensor.H:151
const Cmpt & xz() const noexcept
Definition SymmTensor.H:152
A templated (3 x 3) tensor of objects of <T> derived from MatrixSpace.
Definition Tensor.H:60
const Cmpt & yy() const noexcept
Definition Tensor.H:197
const Cmpt & zy() const noexcept
Definition Tensor.H:200
const Cmpt & yx() const noexcept
Definition Tensor.H:196
const Cmpt & xx() const noexcept
Definition Tensor.H:193
const Cmpt & yz() const noexcept
Definition Tensor.H:198
const Cmpt & zz() const noexcept
Definition Tensor.H:201
const Cmpt & xy() const noexcept
Definition Tensor.H:194
const Cmpt & xz() const noexcept
Definition Tensor.H:195
const Cmpt & zx() const noexcept
Definition Tensor.H:199
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
Definition Vector.H:61
Namespace for OpenFOAM.
sphericalTensor transformMask< sphericalTensor >(const symmTensor &st)
refinementData transform(const tensor &, const refinementData val)
No-op rotational transform for base types.
Tensor< scalar > tensor
Definition symmTensor.H:57
tensor transformMask< tensor >(const symmTensor &st)
SphericalTensor< Cmpt > sph(const DiagTensor< Cmpt > &dt)
Return the spherical part of a DiagTensor as a SphericalTensor.
symmTensor transformMask< symmTensor >(const symmTensor &st)
SphericalTensor< scalar > sphericalTensor
SphericalTensor of scalars, i.e. SphericalTensor<scalar>.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
SymmTensor< scalar > symmTensor
SymmTensor of scalars, i.e. SymmTensor<scalar>.
Definition symmTensor.H:55
3D tensor transformation operations.