FreeFOAM The Cross-Platform CFD Toolkit
SphericalTensorI_.H
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 <OpenFOAM/Vector_.H>
27 
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
30 namespace Foam
31 {
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
35 // Construct null
36 template <class Cmpt>
38 {}
39 
40 
41 // Construct given VectorSpace
42 template <class Cmpt>
44 (
45  const VectorSpace<SphericalTensor<Cmpt>, Cmpt, 1>& vs
46 )
47 :
49 {}
50 
51 
52 // Construct given three Cmpts
53 template <class Cmpt>
55 {
56  this->v_[II] = stii;
57 }
58 
59 
60 // Construct from Istream
61 template <class Cmpt>
63 :
64  VectorSpace<SphericalTensor<Cmpt>, Cmpt, 1>(is)
65 {}
66 
67 
68 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
69 
70 template <class Cmpt>
71 inline const Cmpt& SphericalTensor<Cmpt>::ii() const
72 {
73  return this->v_[II];
74 }
75 
76 
77 template <class Cmpt>
79 {
80  return this->v_[II];
81 }
82 
83 
84 template <class Cmpt>
86 {
87  return *this;
88 }
89 
90 
91 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
92 
93 //- Inner-product between two spherical tensors
94 template <class Cmpt>
97 {
98  return SphericalTensor<Cmpt>(st1.ii()*st2.ii());
99 }
100 
101 
102 //- Inner-product between a spherical tensor and a vector
103 template <class Cmpt>
104 inline Vector<Cmpt>
106 {
107  return Vector<Cmpt>
108  (
109  st.ii()*v.x(),
110  st.ii()*v.y(),
111  st.ii()*v.z()
112  );
113 }
114 
115 
116 //- Inner-product between a vector and a spherical tensor
117 template <class Cmpt>
118 inline Vector<Cmpt>
120 {
121  return Vector<Cmpt>
122  (
123  v.x()*st.ii(),
124  v.y()*st.ii(),
125  v.z()*st.ii()
126  );
127 }
128 
129 
130 //- Double-dot-product between a spherical tensor and a spherical tensor
131 template <class Cmpt>
132 inline Cmpt
134 {
135  return 3*st1.ii()*st2.ii();
136 }
137 
138 
139 //- Division of a scalar by a sphericalTensor
140 template <class Cmpt>
141 inline SphericalTensor<Cmpt>
142 operator/(const scalar s, const SphericalTensor<Cmpt>& st)
143 {
144  return SphericalTensor<Cmpt>(s/st.ii());
145 }
146 
147 
148 template <class Cmpt>
149 inline Cmpt magSqr(const SphericalTensor<Cmpt>& st)
150 {
151  return 3*magSqr(st.ii());
152 }
153 
154 
155 //- Return the trace of a spherical tensor
156 template <class Cmpt>
157 inline Cmpt tr(const SphericalTensor<Cmpt>& st)
158 {
159  return 3*st.ii();
160 }
161 
162 
163 //- Return the spherical part of a spherical tensor, i.e. itself
164 template <class Cmpt>
166 {
167  return st;
168 }
169 
170 
171 //- Return the determinant of a spherical tensor
172 template <class Cmpt>
173 inline Cmpt det(const SphericalTensor<Cmpt>& st)
174 {
175  return st.ii()*st.ii()*st.ii();
176 }
177 
178 
179 //- Return the inverse of a spherical tensor
180 template <class Cmpt>
182 {
183  return SphericalTensor<Cmpt>(1.0/st.ii());
184 }
185 
186 
187 template<class Cmpt>
188 class outerProduct<SphericalTensor<Cmpt>, Cmpt>
189 {
190 public:
191 
193 };
194 
195 template<class Cmpt>
196 class outerProduct<Cmpt, SphericalTensor<Cmpt> >
197 {
198 public:
199 
201 };
202 
203 
204 template<class Cmpt>
206 {
207 public:
208 
210 };
211 
212 
213 template<class Cmpt>
214 class innerProduct<SphericalTensor<Cmpt>, Vector<Cmpt> >
215 {
216 public:
217 
219 };
220 
221 template<class Cmpt>
222 class innerProduct<Vector<Cmpt>, SphericalTensor<Cmpt> >
223 {
224 public:
225 
227 };
228 
229 
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231 
232 } // End namespace Foam
233 
234 // ************************ vim: set sw=4 sts=4 et: ************************ //