tensorFieldField.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) 2011 OpenFOAM Foundation
9  Copyright (C) 2019-2023 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "tensorFieldField.H"
30 
31 #define TEMPLATE template<template<class> class Field>
32 #include "FieldFieldFunctionsM.C"
33 
34 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
35 
36 template<template<class> class Field, class Cmpt>
37 void Foam::zip
38 (
39  FieldField<Field, Tensor<Cmpt>>& result,
40  const FieldField<Field, Cmpt>& xx,
41  const FieldField<Field, Cmpt>& xy,
42  const FieldField<Field, Cmpt>& xz,
43  const FieldField<Field, Cmpt>& yx,
44  const FieldField<Field, Cmpt>& yy,
45  const FieldField<Field, Cmpt>& yz,
46  const FieldField<Field, Cmpt>& zx,
47  const FieldField<Field, Cmpt>& zy,
48  const FieldField<Field, Cmpt>& zz
49 )
50 {
51  forAll(result, i)
52  {
53  Foam::zip
54  (
55  result[i],
56  xx[i], xy[i], xz[i],
57  yx[i], yy[i], yz[i],
58  zx[i], zy[i], zz[i]
59  );
60  }
61 }
62 
63 
64 template<template<class> class Field, class Cmpt>
65 void Foam::unzip
66 (
67  const FieldField<Field, Tensor<Cmpt>>& input,
68  FieldField<Field, Cmpt>& xx,
69  FieldField<Field, Cmpt>& xy,
70  FieldField<Field, Cmpt>& xz,
71  FieldField<Field, Cmpt>& yx,
72  FieldField<Field, Cmpt>& yy,
73  FieldField<Field, Cmpt>& yz,
74  FieldField<Field, Cmpt>& zx,
75  FieldField<Field, Cmpt>& zy,
76  FieldField<Field, Cmpt>& zz
77 )
78 {
79  forAll(input, i)
80  {
82  (
83  input[i],
84  xx[i], xy[i], xz[i],
85  yx[i], yy[i], yz[i],
86  zx[i], zy[i], zz[i]
87  );
88  }
89 }
90 
91 
92 template<template<class> class Field, class Cmpt>
93 void Foam::zipRows
94 (
95  FieldField<Field, Tensor<Cmpt>>& result,
96  const FieldField<Field, Vector<Cmpt>>& x,
97  const FieldField<Field, Vector<Cmpt>>& y,
98  const FieldField<Field, Vector<Cmpt>>& z
99 )
100 {
101  forAll(result, i)
102  {
103  Foam::zipRows(result[i], x[i], y[i], z[i]);
104  }
105 }
106 
107 
108 template<template<class> class Field, class Cmpt>
109 void Foam::zipCols
110 (
111  FieldField<Field, Tensor<Cmpt>>& result,
112  const FieldField<Field, Vector<Cmpt>>& x,
113  const FieldField<Field, Vector<Cmpt>>& y,
114  const FieldField<Field, Vector<Cmpt>>& z
115 )
116 {
117  forAll(result, i)
118  {
119  Foam::zipCols(result[i], x[i], y[i], z[i]);
120  }
121 }
122 
123 
124 template<template<class> class Field, class Cmpt>
125 void Foam::unzipRows
126 (
127  const FieldField<Field, Tensor<Cmpt>>& input,
128  FieldField<Field, Vector<Cmpt>>& x,
129  FieldField<Field, Vector<Cmpt>>& y,
130  FieldField<Field, Vector<Cmpt>>& z
131 )
132 {
133  forAll(input, i)
134  {
135  Foam::unzipRows(input[i], x[i], y[i], z[i]);
136  }
137 }
138 
139 
140 template<template<class> class Field, class Cmpt>
141 void Foam::unzipCols
142 (
143  const FieldField<Field, Tensor<Cmpt>>& input,
144  FieldField<Field, Vector<Cmpt>>& x,
145  FieldField<Field, Vector<Cmpt>>& y,
146  FieldField<Field, Vector<Cmpt>>& z
147 )
148 {
149  forAll(input, i)
150  {
151  Foam::unzipCols(input[i], x[i], y[i], z[i]);
152  }
153 }
154 
155 
156 template<template<class> class Field, class Cmpt>
157 void Foam::unzipRow
158 (
159  const FieldField<Field, Tensor<Cmpt>>& input,
160  const direction idx,
161  FieldField<Field, Vector<Cmpt>>& result
162 )
163 {
164  forAll(input, i)
165  {
166  Foam::unzipRow(input[i], idx, result[i]);
167  }
168 }
169 
170 
171 template<template<class> class Field, class Cmpt>
172 void Foam::unzipCol
173 (
174  const FieldField<Field, Tensor<Cmpt>>& input,
175  const direction idx,
176  FieldField<Field, Vector<Cmpt>>& result
177 )
178 {
179  forAll(input, i)
180  {
181  Foam::unzipCol(input[i], idx, result[i]);
182  }
183 }
184 
185 
186 template<template<class> class Field, class Cmpt>
187 void Foam::unzipDiag
188 (
189  const FieldField<Field, Tensor<Cmpt>>& input,
190  FieldField<Field, Vector<Cmpt>>& result
191 )
192 {
193  forAll(input, i)
194  {
195  Foam::unzipDiag(input[i], result[i]);
196  }
197 }
198 
199 
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 
202 namespace Foam
203 {
204 
205 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
206 
207 UNARY_FUNCTION(scalar, tensor, tr)
216 UNARY_FUNCTION(scalar, tensor, det)
219 
222 
223 
224 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
225 
228 
231 
232 
233 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
234 
235 } // End namespace Foam
236 
237 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
238 
239 #include "undefFieldFunctionsM.H"
240 
241 // ************************************************************************* //
#define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc)
void divide(DimensionedField< Type, GeoMesh > &result, const DimensionedField< Type, GeoMesh > &f1, const DimensionedField< scalar, GeoMesh > &f2)
uint8_t direction
Definition: direction.H:46
Specialisation of FieldField<T> for tensor.
void unzipCols(const FieldField< Field, SymmTensor< Cmpt >> &input, FieldField< Field, Vector< Cmpt >> &x, FieldField< Field, Vector< Cmpt >> &y, FieldField< Field, Vector< Cmpt >> &z)
Extract symmTensor field field columns.
#define UNARY_FUNCTION(ReturnType, Type1, Func, Dfunc)
dimensionedTensor skew(const dimensionedTensor &dt)
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
void zip(FieldField< Field, SphericalTensor< Cmpt >> &result, const FieldField< Field, Cmpt > &ii)
Zip together sphericalTensor field field from components.
void zipCols(FieldField< Field, SymmTensor< Cmpt >> &result, const FieldField< Field, Vector< Cmpt >> &x, const FieldField< Field, Vector< Cmpt >> &y, const FieldField< Field, Vector< Cmpt >> &z)
Zip together symmTensor field from column components.
Tensor< scalar > tensor
Definition: symmTensor.H:57
void unzipRow(const FieldField< Field, SymmTensor< Cmpt >> &input, const direction idx, FieldField< Field, Vector< Cmpt >> &result)
Extract a symmTensor field field row (x,y,z) == (0,1,2)
SymmTensor< Cmpt > devSymm(const SymmTensor< Cmpt > &st)
Return the deviatoric part of the symmetric part of a SymmTensor.
Definition: SymmTensorI.H:481
dimensionedScalar det(const dimensionedSphericalTensor &dt)
SphericalTensor< Cmpt > sph(const DiagTensor< Cmpt > &dt)
Return the spherical part of a DiagTensor as a SphericalTensor.
Definition: DiagTensorI.H:110
void unzipRows(const FieldField< Field, SymmTensor< Cmpt >> &input, FieldField< Field, Vector< Cmpt >> &x, FieldField< Field, Vector< Cmpt >> &y, FieldField< Field, Vector< Cmpt >> &z)
Extract symmTensor field field rows.
void zipRows(FieldField< Field, SymmTensor< Cmpt >> &result, const FieldField< Field, Vector< Cmpt >> &x, const FieldField< Field, Vector< Cmpt >> &y, const FieldField< Field, Vector< Cmpt >> &z)
Zip together symmTensor field field from row components.
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
A field of fields is a PtrList of fields with reference counting.
Definition: FieldField.H:51
dimensionedTensor eigenVectors(const dimensionedSymmTensor &dt)
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
void unzip(const FieldField< Field, SphericalTensor< Cmpt >> &input, FieldField< Field, Cmpt > &ii)
Unzip sphericalTensor field field into components.
void unzipDiag(const FieldField< Field, SymmTensor< Cmpt >> &input, FieldField< Field, Vector< Cmpt >> &result)
Extract a symmTensor field field diagonal.
scalar y
dimensionedSymmTensor dev(const dimensionedSymmTensor &dt)
Generic templated field type.
Definition: Field.H:62
SymmTensor< scalar > symmTensor
SymmTensor of scalars, i.e. SymmTensor<scalar>.
Definition: symmTensor.H:55
static Istream & input(Istream &is, IntRange< T > &range)
Definition: IntRanges.C:33
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
Vector< scalar > vector
Definition: vector.H:57
void hdual(pointPatchField< vector > &, const pointPatchField< tensor > &)
void unzipCol(const FieldField< Field, SymmTensor< Cmpt >> &input, const direction idx, FieldField< Field, Vector< Cmpt >> &result)
Extract a symmTensor field field column (x,y,z) == (0,1,2)
dimensionedSymmTensor dev2(const dimensionedSymmTensor &dt)
dimensionedSymmTensor symm(const dimensionedSymmTensor &dt)
dimensionedVector eigenValues(const dimensionedSymmTensor &dt)
#define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc, Dfunc)
SphericalTensor< scalar > sphericalTensor
SphericalTensor of scalars, i.e. SphericalTensor<scalar>.
A templated (3 x 3) tensor of objects of <T> derived from MatrixSpace.
Definition: complexI.H:266
#define BINARY_TYPE_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc)
dimensionedSymmTensor cof(const dimensionedSymmTensor &dt)
Namespace for OpenFOAM.
SymmTensor< Cmpt > devTwoSymm(const SymmTensor< Cmpt > &st)
Return the deviatoric part of twice the symmetric part of a SymmTensor.
Definition: SymmTensorI.H:491