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 -------------------------------------------------------------------------------
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>& 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 
127 template<>
128 tmp<Field<symmTensor>> transformFieldMask<symmTensor>
129 (
130  const tensorField& tf
131 )
132 {
133  return symm(tf);
134 }
135 
136 template<>
137 tmp<Field<symmTensor>> transformFieldMask<symmTensor>
138 (
139  const tmp<tensorField>& ttf
140 )
141 {
143  ttf.clear();
144  return ret;
145 }
146 
147 
148 template<>
149 tmp<Field<symmTensor>> transformFieldMask<symmTensor>
150 (
151  const symmTensorField& stf
152 )
153 {
154  return stf;
155 }
156 
157 template<>
158 tmp<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 // ************************************************************************* //
BINARY_OPERATOR
#define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc)
Definition: DimensionedFieldFunctionsM.C:412
Foam::Vector::x
const Cmpt & x() const
Access to the vector x component.
Definition: VectorI.H:73
Foam::symm
dimensionedSymmTensor symm(const dimensionedSymmTensor &dt)
Definition: dimensionedSymmTensor.C:84
Foam::sphericalTensor
SphericalTensor< scalar > sphericalTensor
SphericalTensor of scalars, i.e. SphericalTensor<scalar>.
Definition: sphericalTensor.H:54
Foam::SymmTensor< scalar >
Foam::transformFieldMask< symmTensor >
tmp< Field< symmTensor > > transformFieldMask< symmTensor >(const tensorField &tf)
Definition: symmTensorField.C:129
UNARY_FUNCTION
#define UNARY_FUNCTION(ReturnType, Type1, Func, Dfunc)
Definition: DimensionedFieldFunctionsM.C:33
Foam::tmp::clear
void clear() const noexcept
Definition: tmpI.H:287
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::dot
void dot(FieldField< Field1, typename innerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Definition: FieldFieldFunctions.C:944
BINARY_TYPE_OPERATOR
#define BINARY_TYPE_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc)
Definition: DimensionedFieldFunctionsM.C:674
undefFieldFunctionsM.H
Foam::dev2
dimensionedSymmTensor dev2(const dimensionedSymmTensor &dt)
Definition: dimensionedSymmTensor.C:117
Foam::innerSqr
dimensionedSymmTensor innerSqr(const dimensionedSymmTensor &dt)
Definition: dimensionedSymmTensor.C:62
Foam::Vector::z
const Cmpt & z() const
Access to the vector z component.
Definition: VectorI.H:85
transformField.H
Spatial transformation functions for primitive fields.
TFOR_ALL_F_OP_FUNC_F
#define TFOR_ALL_F_OP_FUNC_F(typeF1, f1, OP, FUNC, typeF2, f2)
Definition: FieldM.H:116
Foam::magSqr
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:227
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::inv
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
Definition: dimensionedSphericalTensor.C:73
Foam::symmTensor
SymmTensor< scalar > symmTensor
SymmTensor of scalars, i.e. SymmTensor<scalar>.
Definition: symmTensor.H:59
Foam::sph
SphericalTensor< Cmpt > sph(const DiagTensor< Cmpt > &dt)
Return the spherical part of a DiagTensor as a SphericalTensor.
Definition: DiagTensorI.H:130
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::cof
dimensionedSymmTensor cof(const dimensionedSymmTensor &dt)
Definition: dimensionedSymmTensor.C:139
Foam::vector
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:51
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
Foam::Vector::y
const Cmpt & y() const
Access to the vector y component.
Definition: VectorI.H:79
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:51
UNARY_OPERATOR
#define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc, Dfunc)
Definition: DimensionedFieldFunctionsM.C:87
Foam::Vector
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
Definition: Vector.H:62
symmTensorField.H
Foam::UList
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:103
FieldFunctionsM.C
Foam::tmp::New
static tmp< T > New(Args &&... args)
Construct tmp of T with forwarding arguments.
Foam::tr
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
Definition: dimensionedSphericalTensor.C:51
Foam::det
dimensionedScalar det(const dimensionedSphericalTensor &dt)
Definition: dimensionedSphericalTensor.C:62
Foam::UList::size
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
Foam::hdual
void hdual(pointPatchField< vector > &, const pointPatchField< tensor > &)
Definition: pointPatchFieldFunctions.H:273
Foam::twoSymm
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
Definition: dimensionedSymmTensor.C:95
Foam::tensor
Tensor< scalar > tensor
Tensor of scalars, i.e. Tensor<scalar>.
Definition: symmTensor.H:61
Foam::dev
dimensionedSymmTensor dev(const dimensionedSymmTensor &dt)
Definition: dimensionedSymmTensor.C:106