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 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
27\*---------------------------------------------------------------------------*/
28
29#include "symmTensorField.H"
30#include "transformField.H"
31
32#define TEMPLATE
33#include "FieldFunctionsM.C"
34
35// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36
37namespace Foam
38{
39
40// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
41
44
53
54void inv(Field<symmTensor>& tf, const UList<symmTensor>& tf1)
55{
56 if (tf.empty())
57 {
58 return;
59 }
60
61 scalar scale = magSqr(tf1[0]);
62 Vector<bool> removeCmpts
63 (
64 magSqr(tf1[0].xx())/scale < SMALL,
65 magSqr(tf1[0].yy())/scale < SMALL,
66 magSqr(tf1[0].zz())/scale < SMALL
67 );
68
69 if (removeCmpts.x() || removeCmpts.y() || removeCmpts.z())
70 {
71 symmTensorField tf1Plus(tf1);
72
73 if (removeCmpts.x())
74 {
75 tf1Plus += symmTensor(1,0,0,0,0,0);
76 }
77
78 if (removeCmpts.y())
79 {
80 tf1Plus += symmTensor(0,0,0,1,0,0);
81 }
82
83 if (removeCmpts.z())
84 {
85 tf1Plus += symmTensor(0,0,0,0,0,1);
86 }
87
89
90 if (removeCmpts.x())
91 {
92 tf -= symmTensor(1,0,0,0,0,0);
93 }
94
95 if (removeCmpts.y())
96 {
97 tf -= symmTensor(0,0,0,1,0,0);
98 }
99
100 if (removeCmpts.z())
101 {
102 tf -= symmTensor(0,0,0,0,0,1);
103 }
104 }
105 else
106 {
108 }
109}
110
112{
113 auto tresult = tmp<symmTensorField>::New(tf.size());
114 inv(tresult.ref(), tf);
115 return tresult;
116}
117
119{
120 tmp<symmTensorField> tresult = New(tf);
121 inv(tresult.ref(), tf());
122 tf.clear();
123 return tresult;
124}
125
126
127template<>
128tmp<Field<symmTensor>> transformFieldMask<symmTensor>
129(
130 const tensorField& tf
131)
132{
133 return symm(tf);
134}
135
136template<>
137tmp<Field<symmTensor>> transformFieldMask<symmTensor>
138(
139 const tmp<tensorField>& ttf
140)
141{
142 tmp<Field<symmTensor>> ret = transformFieldMask<symmTensor>(ttf());
143 ttf.clear();
144 return ret;
145}
146
147
148template<>
149tmp<Field<symmTensor>> transformFieldMask<symmTensor>
150(
151 const symmTensorField& stf
152)
153{
154 return stf;
155}
156
157template<>
158tmp<Field<symmTensor>> transformFieldMask<symmTensor>
159(
160 const tmp<symmTensorField>& tstf
161)
162{
163 return tstf;
164}
165
166
167// * * * * * * * * * * * * * * * global operators * * * * * * * * * * * * * //
168
170
173
174
175// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176
177} // End namespace Foam
178
179// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180
181#include "undefFieldFunctionsM.H"
182
183// ************************************************************************* //
#define BINARY_TYPE_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc)
#define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc, Dfunc)
#define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc)
#define UNARY_FUNCTION(ReturnType, Type1, Func, Dfunc)
#define TFOR_ALL_F_OP_FUNC_F(typeF1, f1, OP, FUNC, typeF2, f2)
Definition: FieldM.H:116
Generic templated field type.
Definition: Field.H:82
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: UList.H:94
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
Definition: Vector.H:65
const Cmpt & z() const
Access to the vector z component.
Definition: VectorI.H:85
const Cmpt & y() const
Access to the vector y component.
Definition: VectorI.H:79
const Cmpt & x() const
Access to the vector x component.
Definition: VectorI.H:73
Tensor of scalars, i.e. Tensor<scalar>.
A class for managing temporary objects.
Definition: tmp.H:65
void clear() const noexcept
Definition: tmpI.H:287
T & ref() const
Definition: tmpI.H:227
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
Namespace for OpenFOAM.
dimensionedSymmTensor dev2(const dimensionedSymmTensor &dt)
dimensionedSymmTensor dev(const dimensionedSymmTensor &dt)
dimensionedScalar det(const dimensionedSphericalTensor &dt)
dimensionedSymmTensor symm(const dimensionedSymmTensor &dt)
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
SphericalTensor< scalar > sphericalTensor
SphericalTensor of scalars, i.e. SphericalTensor<scalar>.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
SymmTensor< scalar > symmTensor
SymmTensor of scalars, i.e. SymmTensor<scalar>.
Definition: symmTensor.H:59
void dot(FieldField< Field1, typename innerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
tmp< Field< symmTensor > > transformFieldMask< symmTensor >(const tensorField &tf)
dimensionedSymmTensor cof(const dimensionedSymmTensor &dt)
void hdual(pointPatchField< vector > &, const pointPatchField< tensor > &)
SphericalTensor< Cmpt > sph(const DiagTensor< Cmpt > &dt)
Return the spherical part of a DiagTensor as a SphericalTensor.
Definition: DiagTensorI.H:130
Field< symmTensor > symmTensorField
Specialisation of Field<T> for symmTensor.
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
dimensionedSymmTensor innerSqr(const dimensionedSymmTensor &dt)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
Spatial transformation functions for primitive fields.