FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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"
28 
29 #define TEMPLATE
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 
37 // * * * * * * * * * * * * * * * global functions * * * * * * * * * * * * * //
38 
40 
49 
50 void inv(Field<symmTensor>& tf, const UList<symmTensor>& tf1)
51 {
52  if (tf.empty())
53  {
54  return;
55  }
56 
57  scalar scale = magSqr(tf1[0]);
58  Vector<bool> removeCmpts
59  (
60  magSqr(tf1[0].xx())/scale < SMALL,
61  magSqr(tf1[0].yy())/scale < SMALL,
62  magSqr(tf1[0].zz())/scale < SMALL
63  );
64 
65  if (removeCmpts.x() || removeCmpts.y() || removeCmpts.z())
66  {
67  symmTensorField tf1Plus(tf1);
68 
69  if (removeCmpts.x())
70  {
71  tf1Plus += symmTensor(1,0,0,0,0,0);
72  }
73 
74  if (removeCmpts.y())
75  {
76  tf1Plus += symmTensor(0,0,0,1,0,0);
77  }
78 
79  if (removeCmpts.z())
80  {
81  tf1Plus += symmTensor(0,0,0,0,0,1);
82  }
83 
85 
86  if (removeCmpts.x())
87  {
88  tf -= symmTensor(1,0,0,0,0,0);
89  }
90 
91  if (removeCmpts.y())
92  {
93  tf -= symmTensor(0,0,0,1,0,0);
94  }
95 
96  if (removeCmpts.z())
97  {
98  tf -= symmTensor(0,0,0,0,0,1);
99  }
100  }
101  else
102  {
104  }
105 }
106 
108 {
109  tmp<symmTensorField> result(new symmTensorField(tf.size()));
110  inv(result(), tf);
111  return result;
112 }
113 
115 {
117  inv(tRes(), tf());
119  return tRes;
120 }
121 
122 
123 template<>
124 tmp<Field<symmTensor> > transformFieldMask<symmTensor>
125 (
126  const tensorField& tf
127 )
128 {
129  return symm(tf);
130 }
131 
132 template<>
133 tmp<Field<symmTensor> > transformFieldMask<symmTensor>
134 (
135  const tmp<tensorField>& ttf
136 )
137 {
139  ttf.clear();
140  return ret;
141 }
142 
143 
144 template<>
145 tmp<Field<symmTensor> > transformFieldMask<symmTensor>
146 (
147  const symmTensorField& stf
148 )
149 {
150  return stf;
151 }
152 
153 template<>
154 tmp<Field<symmTensor> > transformFieldMask<symmTensor>
155 (
156  const tmp<symmTensorField>& tstf
157 )
158 {
159  return tstf;
160 }
161 
162 
163 // * * * * * * * * * * * * * * * global operators * * * * * * * * * * * * * //
164 
166 
167 BINARY_OPERATOR(tensor, symmTensor, symmTensor, &, dot)
168 BINARY_TYPE_OPERATOR(tensor, symmTensor, symmTensor, &, dot)
169 
170 
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 
173 } // End namespace Foam
174 
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 
178 
179 // ************************ vim: set sw=4 sts=4 et: ************************ //