tensorField.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-2016 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 "tensorField.H"
30 #include "transformField.H"
31 
32 #define TEMPLATE
33 #include "FieldFunctionsM.C"
34 
35 
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 
38 namespace Foam
39 {
40 
41 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
42 
43 UNARY_FUNCTION(scalar, tensor, tr)
52 UNARY_FUNCTION(scalar, tensor, det)
54 
55 void inv(Field<tensor>& result, const UList<tensor>& f1)
56 {
57  // With 'failsafe' invert
58  // std::transform
59  TFOR_ALL_F_OP_F_FUNC(tensor, result, =, tensor, f1, safeInv)
60 }
61 
63 {
64  auto tres = tmp<tensorField>::New(tf.size());
65  inv(tres.ref(), tf);
66  return tres;
67 }
68 
69 tmp<tensorField> inv(const tmp<tensorField>& tf)
70 {
71  auto tres = New(tf);
72  inv(tres.ref(), tf());
73  tf.clear();
74  return tres;
75 }
76 
78 
81 
82 
83 template<>
85 (
86  const symmTensorField& stf
87 )
88 {
89  auto tres = tmp<tensorField>::New(stf.size());
90  auto& res = tres.ref();
91  TFOR_ALL_F_OP_F(tensor, res, =, symmTensor, stf)
92  return tres;
93 }
94 
95 template<>
96 tmp<Field<tensor>> transformFieldMask<tensor>
97 (
98  const tmp<symmTensorField>& tstf
99 )
100 {
101  tmp<Field<tensor>> ret = transformFieldMask<tensor>(tstf());
102  tstf.clear();
103  return ret;
104 }
105 
106 
107 // * * * * * * * * * * * * * * * global operators * * * * * * * * * * * * * //
108 
111 
114 
115 
116 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
117 
118 } // End namespace Foam
119 
120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
121 
122 #include "undefFieldFunctionsM.H"
123 
124 // ************************************************************************* //
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
#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)
#define UNARY_FUNCTION(ReturnType, Type1, Func, Dfunc)
dimensionedTensor skew(const dimensionedTensor &dt)
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
#define TFOR_ALL_F_OP_F_FUNC(typeF1, f1, OP, typeF2, f2, FUNC)
Definition: FieldM.H:170
Tensor< scalar > tensor
Definition: symmTensor.H:57
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
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
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
dimensionedTensor eigenVectors(const dimensionedSymmTensor &dt)
tmp< Field< Type1 > > transformFieldMask(const Field< Type2 > &fld)
Spatial transformation functions for primitive fields.
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
symmTensor pinv(const symmTensor &st)
Return inverse of a given symmTensor, and fall back to pseudo-inverse if the symmTensor is singular...
Definition: symmTensor.C:334
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
Definition: tmp.H:206
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
Vector< scalar > vector
Definition: vector.H:57
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:105
void hdual(pointPatchField< vector > &, const pointPatchField< tensor > &)
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
dimensionedSymmTensor dev2(const dimensionedSymmTensor &dt)
dimensionedSymmTensor symm(const dimensionedSymmTensor &dt)
tmp< Field< tensor > > transformFieldMask< tensor >(const symmTensorField &)
Definition: tensorField.C:78
dimensionedVector eigenValues(const dimensionedSymmTensor &dt)
#define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc, Dfunc)
SphericalTensor< scalar > sphericalTensor
SphericalTensor of scalars, i.e. SphericalTensor<scalar>.
#define TFOR_ALL_F_OP_F(typeF1, f1, OP, typeF2, f2)
Definition: FieldM.H:458
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Tensor of scalars, i.e. Tensor<scalar>.
#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