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 | Copyright (C) 2011-2015 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "symmTensorField.H"
27 #include "transformField.H"
28 
29 #define TEMPLATE
30 #include "FieldFunctionsM.C"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 
37 // * * * * * * * * * * * * * * * global functions * * * * * * * * * * * * * //
38 
41 
50 
51 void inv(Field<symmTensor>& tf, const UList<symmTensor>& tf1)
52 {
53  if (tf.empty())
54  {
55  return;
56  }
57 
58  scalar scale = magSqr(tf1[0]);
59  Vector<bool> removeCmpts
60  (
61  magSqr(tf1[0].xx())/scale < SMALL,
62  magSqr(tf1[0].yy())/scale < SMALL,
63  magSqr(tf1[0].zz())/scale < SMALL
64  );
65 
66  if (removeCmpts.x() || removeCmpts.y() || removeCmpts.z())
67  {
68  symmTensorField tf1Plus(tf1);
69 
70  if (removeCmpts.x())
71  {
72  tf1Plus += symmTensor(1,0,0,0,0,0);
73  }
74 
75  if (removeCmpts.y())
76  {
77  tf1Plus += symmTensor(0,0,0,1,0,0);
78  }
79 
80  if (removeCmpts.z())
81  {
82  tf1Plus += symmTensor(0,0,0,0,0,1);
83  }
84 
86 
87  if (removeCmpts.x())
88  {
89  tf -= symmTensor(1,0,0,0,0,0);
90  }
91 
92  if (removeCmpts.y())
93  {
94  tf -= symmTensor(0,0,0,1,0,0);
95  }
96 
97  if (removeCmpts.z())
98  {
99  tf -= symmTensor(0,0,0,0,0,1);
100  }
101  }
102  else
103  {
105  }
106 }
107 
109 {
110  tmp<symmTensorField> result(new symmTensorField(tf.size()));
111  inv(result(), tf);
112  return result;
113 }
114 
116 {
118  inv(tRes(), tf());
120  return tRes;
121 }
122 
123 
124 template<>
125 tmp<Field<symmTensor> > transformFieldMask<symmTensor>
126 (
127  const tensorField& tf
128 )
129 {
130  return symm(tf);
131 }
132 
133 template<>
134 tmp<Field<symmTensor> > transformFieldMask<symmTensor>
135 (
136  const tmp<tensorField>& ttf
137 )
138 {
140  ttf.clear();
141  return ret;
142 }
143 
144 
145 template<>
146 tmp<Field<symmTensor> > transformFieldMask<symmTensor>
147 (
148  const symmTensorField& stf
149 )
150 {
151  return stf;
152 }
153 
154 template<>
155 tmp<Field<symmTensor> > transformFieldMask<symmTensor>
156 (
157  const tmp<symmTensorField>& tstf
158 )
159 {
160  return tstf;
161 }
162 
163 
164 // * * * * * * * * * * * * * * * global operators * * * * * * * * * * * * * //
165 
167 
170 
171 
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 
174 } // End namespace Foam
175 
176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177 
178 #include "undefFieldFunctionsM.H"
179 
180 // ************************************************************************* //
BINARY_OPERATOR
#define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc)
Definition: DimensionedFieldFunctionsM.C:417
Foam::symm
dimensionedSymmTensor symm(const dimensionedSymmTensor &dt)
Definition: dimensionedSymmTensor.C:82
Foam::sphericalTensor
SphericalTensor< scalar > sphericalTensor
SphericalTensor of scalars.
Definition: sphericalTensor.H:48
Foam::SymmTensor< scalar >
Foam::transformFieldMask< symmTensor >
tmp< Field< symmTensor > > transformFieldMask< symmTensor >(const tensorField &tf)
Definition: symmTensorField.C:126
UNARY_FUNCTION
#define UNARY_FUNCTION(ReturnType, Type1, Func, Dfunc)
Definition: DimensionedFieldFunctionsM.C:30
Foam::reuseTmp::clear
static void clear(const tmp< Field< Type1 > > &tf1)
Definition: FieldReuseFunctions.H:46
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::tensor
Tensor< scalar > tensor
Tensor of scalars.
Definition: tensor.H:51
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:875
BINARY_TYPE_OPERATOR
#define BINARY_TYPE_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc)
Definition: DimensionedFieldFunctionsM.C:684
undefFieldFunctionsM.H
Foam::dev2
dimensionedSymmTensor dev2(const dimensionedSymmTensor &dt)
Definition: dimensionedSymmTensor.C:115
Foam::innerSqr
dimensionedSymmTensor innerSqr(const dimensionedSymmTensor &dt)
Definition: dimensionedSymmTensor.C:60
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:112
Foam::symmTensorField
Field< symmTensor > symmTensorField
Specialisation of Field<T> for symmTensor.
Definition: primitiveFieldsFwd.H:51
tf
const tensorField & tf
Definition: getPatchFieldTensor.H:36
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::inv
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
Definition: dimensionedSphericalTensor.C:71
Foam::reuseTmp::New
static tmp< Field< TypeR > > New(const tmp< Field< Type1 > > &tf1)
Definition: FieldReuseFunctions.H:41
Foam::symmTensor
SymmTensor< scalar > symmTensor
SymmTensor of scalars.
Definition: symmTensor.H:48
Foam::sph
SphericalTensor< Cmpt > sph(const DiagTensor< Cmpt > &dt)
Return the spherical part of a diagonal tensor.
Definition: DiagTensorI.H:281
Foam::Vector::x
const Cmpt & x() const
Definition: VectorI.H:65
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::Vector::z
const Cmpt & z() const
Definition: VectorI.H:77
Foam::cof
dimensionedSymmTensor cof(const dimensionedSymmTensor &dt)
Definition: dimensionedSymmTensor.C:137
Foam::vector
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:49
UNARY_OPERATOR
#define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc, Dfunc)
Definition: DimensionedFieldFunctionsM.C:86
Foam::Vector
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
Definition: Vector.H:57
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:60
FieldFunctionsM.C
Foam::Vector::y
const Cmpt & y() const
Definition: VectorI.H:71
Foam::tr
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
Definition: dimensionedSphericalTensor.C:49
Foam::det
dimensionedScalar det(const dimensionedSphericalTensor &dt)
Definition: dimensionedSphericalTensor.C:60
Foam::hdual
void hdual(pointPatchField< vector > &, const pointPatchField< tensor > &)
Definition: pointPatchFieldFunctions.H:248
Foam::tmp::clear
void clear() const
If object pointer points to valid object:
Definition: tmpI.H:172
Foam::twoSymm
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
Definition: dimensionedSymmTensor.C:93
Foam::magSqr
dimensioned< scalar > magSqr(const dimensioned< Type > &)
Foam::dev
dimensionedSymmTensor dev(const dimensionedSymmTensor &dt)
Definition: dimensionedSymmTensor.C:104