symmTensorField.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 "symmTensorField.H"
30 #include "transformField.H"
31 
32 #define TEMPLATE
33 #include "FieldFunctionsM.C"
34 
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39 
40 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
41 
44 
53 
54 void inv(Field<symmTensor>& result, const UList<symmTensor>& f1)
55 {
56  // With 'failsafe' invert
57  // std::transform
58  TFOR_ALL_F_OP_F_FUNC(symmTensor, result, =, symmTensor, f1, safeInv)
59 }
60 
62 {
63  auto tresult = tmp<symmTensorField>::New(tf.size());
64  inv(tresult.ref(), tf);
65  return tresult;
66 }
67 
68 tmp<symmTensorField> inv(const tmp<symmTensorField>& tf)
69 {
70  tmp<symmTensorField> tresult = New(tf);
71  inv(tresult.ref(), tf());
72  tf.clear();
73  return tresult;
74 }
75 
77 
78 
79 template<>
80 tmp<Field<symmTensor>> transformFieldMask<symmTensor>
81 (
82  const tensorField& tf
83 )
84 {
85  return symm(tf);
86 }
87 
88 template<>
89 tmp<Field<symmTensor>> transformFieldMask<symmTensor>
90 (
91  const tmp<tensorField>& ttf
92 )
93 {
94  tmp<Field<symmTensor>> ret = transformFieldMask<symmTensor>(ttf());
95  ttf.clear();
96  return ret;
97 }
98 
99 
100 template<>
101 tmp<Field<symmTensor>> transformFieldMask<symmTensor>
102 (
103  const symmTensorField& stf
104 )
105 {
106  return stf;
107 }
108 
109 template<>
110 tmp<Field<symmTensor>> transformFieldMask<symmTensor>
111 (
112  const tmp<symmTensorField>& tstf
113 )
114 {
115  return tstf;
116 }
117 
118 
119 // * * * * * * * * * * * * * * * global operators * * * * * * * * * * * * * //
120 
122 
125 
126 
127 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
128 
129 } // End namespace Foam
130 
131 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
132 
133 #include "undefFieldFunctionsM.H"
134 
135 // ************************************************************************* //
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
#define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc)
Field< symmTensor > symmTensorField
Specialisation of Field<T> for symmTensor.
#define UNARY_FUNCTION(ReturnType, Type1, Func, Dfunc)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
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.
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)
void dot(FieldField< Field1, typename innerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
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 > &)
dimensionedSymmTensor innerSqr(const dimensionedSymmTensor &dt)
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
dimensionedSymmTensor dev2(const dimensionedSymmTensor &dt)
dimensionedSymmTensor symm(const dimensionedSymmTensor &dt)
#define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc, Dfunc)
SphericalTensor< scalar > sphericalTensor
SphericalTensor of scalars, i.e. SphericalTensor<scalar>.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
#define BINARY_TYPE_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc)
tmp< Field< symmTensor > > transformFieldMask< symmTensor >(const tensorField &tf)
dimensionedSymmTensor cof(const dimensionedSymmTensor &dt)
Namespace for OpenFOAM.