SphericalTensor2DI.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2020 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 "Vector2D.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 template<class Cmpt>
35 :
37 {}
38 
39 
40 template<class Cmpt>
42 (
43  const VectorSpace<SphericalTensor2D<Cmpt>, Cmpt, 1>& vs
44 )
45 :
47 {}
48 
49 
50 template<class Cmpt>
52 {
53  this->v_[II] = stii;
54 }
55 
56 
57 template<class Cmpt>
59 :
60  SphericalTensor2D::vsType(is)
61 {}
62 
63 
64 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
65 
66 namespace Foam
67 {
68 
69 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
70 
71 //- Return the trace of a SphericalTensor2D
72 template<class Cmpt>
73 inline Cmpt tr(const SphericalTensor2D<Cmpt>& st)
74 {
75  return 2*st.ii();
76 }
77 
78 
79 //- Return the spherical part of a SphericalTensor2D, i.e. itself
80 template<class Cmpt>
82 {
83  return st;
84 }
85 
86 
87 //- Return the determinant of a SphericalTensor2D
88 template<class Cmpt>
89 inline Cmpt det(const SphericalTensor2D<Cmpt>& st)
90 {
91  return st.ii()*st.ii();
92 }
93 
94 
95 //- Return the inverse of a SphericalTensor2D
96 template<class Cmpt>
97 inline SphericalTensor2D<Cmpt> inv(const SphericalTensor2D<Cmpt>& st)
98 {
99  #ifdef FULLDEBUG
100  if (mag(st.ii()) < VSMALL)
101  {
103  << "SphericalTensor2D is not invertible due to zero determinant:"
104  << "det(SphericalTensor2D) = " << det(st)
105  << abort(FatalError);
106  }
107  #endif
108 
109  return SphericalTensor2D<Cmpt>(1/st.ii());
110 }
111 
112 
113 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
114 
115 //- Division of a Cmpt by a SphericalTensor2D
116 template<class Cmpt>
117 inline SphericalTensor2D<Cmpt>
118 operator/(const Cmpt s, const SphericalTensor2D<Cmpt>& st)
119 {
120  #ifdef FULLDEBUG
121  if (mag(st.ii()) < VSMALL)
122  {
124  << "Cmpt = " << s
125  << " is not divisible due to a zero element in SphericalTensor2D:"
126  << "SphericalTensor2D = " << st
127  << abort(FatalError);
128  }
129  #endif
130 
131  return SphericalTensor2D<Cmpt>(s/st.ii());
132 }
133 
134 
135 //- Division of a SphericalTensor2D by a Cmpt
136 template<class Cmpt>
137 inline SphericalTensor2D<Cmpt>
138 operator/(const SphericalTensor2D<Cmpt>& st, const Cmpt s)
139 {
140  #ifdef FULLDEBUG
141  if (mag(s) < VSMALL)
142  {
144  << "SphericalTensor2D = " << st
145  << " is not divisible due to a zero value in Cmpt:"
146  << "Cmpt = " << s
147  << abort(FatalError);
148  }
149  #endif
150 
151  return SphericalTensor2D<Cmpt>(st.ii()/s);
152 }
153 
154 
155 //- Inner-product of a SphericalTensor2D and a SphericalTensor2D
156 template<class Cmpt>
157 inline SphericalTensor2D<Cmpt>
158 operator&
159 (
160  const SphericalTensor2D<Cmpt>& st1,
161  const SphericalTensor2D<Cmpt>& st2
162 )
163 {
164  return SphericalTensor2D<Cmpt>(st1.ii()*st2.ii());
165 }
167 
168 //- Inner-product of a SphericalTensor2D and a Vector2D
169 template<class Cmpt>
170 inline Vector2D<Cmpt>
172 {
173  return Vector2D<Cmpt>
174  (
175  st.ii()*v.x(),
176  st.ii()*v.y()
177  );
178 }
179 
181 //- Inner-product of a Vector2D and a SphericalTensor2D
182 template<class Cmpt>
183 inline Vector2D<Cmpt>
185 {
186  return Vector2D<Cmpt>
187  (
188  v.x()*st.ii(),
189  v.y()*st.ii()
190  );
191 }
192 
193 
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 template<class Cmpt>
197 class outerProduct<SphericalTensor2D<Cmpt>, Cmpt>
198 {
199 public:
200 
202 };
203 
204 template<class Cmpt>
205 class outerProduct<Cmpt, SphericalTensor2D<Cmpt>>
206 {
207 public:
210 };
211 
213 template<class Cmpt>
215 {
216 public:
217 
219 };
221 
222 template<class Cmpt>
223 class innerProduct<SphericalTensor2D<Cmpt>, Vector2D<Cmpt>>
224 {
225 public:
226 
227  typedef Vector2D<Cmpt> type;
228 };
230 template<class Cmpt>
231 class innerProduct<Vector2D<Cmpt>, SphericalTensor2D<Cmpt>>
232 {
233 public:
235  typedef Vector2D<Cmpt> type;
236 };
237 
239 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
240 
241 } // End namespace Foam
243 // ************************************************************************* //
SphericalTensor2D()=default
Default construct.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
const Cmpt & y() const noexcept
Access to the vector y component.
Definition: Vector2D.H:132
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:578
const Cmpt & ii() const noexcept
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
Templated vector space.
Definition: VectorSpace.H:52
dimensionedScalar operator/(const scalar s1, const dimensionedScalar &ds2)
typeOfRank< typename pTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank) >::type type
Definition: products.H:118
dimensionedScalar det(const dimensionedSphericalTensor &dt)
SphericalTensor< Cmpt > sph(const DiagTensor< Cmpt > &dt)
Return the spherical part of a DiagTensor as a SphericalTensor.
Definition: DiagTensorI.H:87
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
errorManip< error > abort(error &err)
Definition: errorManip.H:139
const Cmpt & x() const noexcept
Access to the vector x component.
Definition: Vector2D.H:127
A templated (2 x 2) diagonal tensor of objects of <T>, effectively containing 1 element, derived from VectorSpace.
tmp< GeometricField< Type, faPatchField, areaMesh > > operator &(const faMatrix< Type > &, const DimensionedField< Type, areaMesh > &)
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:58
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Templated 2D Vector derived from VectorSpace adding construction from 2 components, element access using x() and y() member functions and the inner-product (dot-product).
Definition: Vector2D.H:51
typeOfRank< typename pTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank) - 2 >::type type
Definition: products.H:155
Namespace for OpenFOAM.
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:157