Home
Downloads
Documentation
Installation
User Guide
man-pages
API Documentation
README
Release Notes
Changes
License
Support
SourceForge Project
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
OpenFOAM
fields
Fields
symmTensorField
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
"
27
#include <
OpenFOAM/transformField.H
>
28
29
#define TEMPLATE
30
#include <
OpenFOAM/FieldFunctionsM.C
>
31
32
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33
34
namespace
Foam
35
{
36
37
// * * * * * * * * * * * * * * * global functions * * * * * * * * * * * * * //
38
39
UNARY_FUNCTION
(
symmTensor
,
vector
,
sqr
)
40
41
UNARY_FUNCTION
(scalar,
symmTensor
,
tr
)
42
UNARY_FUNCTION
(
sphericalTensor
,
symmTensor
,
sph
)
43
UNARY_FUNCTION
(
symmTensor
,
symmTensor
,
symm
)
44
UNARY_FUNCTION
(
symmTensor
,
symmTensor
,
twoSymm
)
45
UNARY_FUNCTION
(
symmTensor
,
symmTensor
,
dev
)
46
UNARY_FUNCTION
(
symmTensor
,
symmTensor
,
dev2
)
47
UNARY_FUNCTION
(scalar,
symmTensor
,
det
)
48
UNARY_FUNCTION
(
symmTensor
,
symmTensor
,
cof
)
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
84
TFOR_ALL_F_OP_FUNC_F
(
symmTensor
, tf, =,
inv
,
symmTensor
, tf1Plus)
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
{
103
TFOR_ALL_F_OP_FUNC_F
(
symmTensor
, tf, =,
inv
,
symmTensor
, tf1)
104
}
105
}
106
107
tmp<symmTensorField>
inv
(
const
UList<symmTensor>
&
tf
)
108
{
109
tmp<symmTensorField>
result(
new
symmTensorField
(tf.
size
()));
110
inv
(result(), tf);
111
return
result;
112
}
113
114
tmp<symmTensorField>
inv
(
const
tmp<symmTensorField>
&
tf
)
115
{
116
tmp<symmTensorField>
tRes =
reuseTmp<symmTensor, symmTensor>::New
(tf);
117
inv
(tRes(),
tf
());
118
reuseTmp<symmTensor, symmTensor>::clear
(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
{
138
tmp<Field<symmTensor>
> ret =
transformFieldMask<symmTensor>
(ttf());
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
165
UNARY_OPERATOR
(
vector
,
symmTensor
, *,
hdual
)
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
177
#include <
OpenFOAM/undefFieldFunctionsM.H
>
178
179
// ************************ vim: set sw=4 sts=4 et: ************************ //