Loading...
Searching...
No Matches
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-2023 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
33template<class Cmpt>
42(
43 const VectorSpace<SphericalTensor2D<Cmpt>, Cmpt, 1>& vs
45:
47{}
48
49
50template<class Cmpt>
52{
53 this->v_[II] = stii;
54}
55
56
57template<class Cmpt>
59:
61{}
62
63
64// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
65
66template<class Cmpt>
67inline Foam::scalar Foam::SphericalTensor2D<Cmpt>::diagSqr() const
68{
69 return 2*Foam::magSqr(this->ii());
70}
71
72
73// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
74
75namespace Foam
76{
78// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
79
80//- Return the trace of a SphericalTensor2D
81template<class Cmpt>
82inline Cmpt tr(const SphericalTensor2D<Cmpt>& st)
83{
84 return 2*st.ii();
85}
86
88//- Return the spherical part of a SphericalTensor2D, i.e. itself
89template<class Cmpt>
91{
92 return st;
93}
94
95
96//- Return the determinant of a SphericalTensor2D
97template<class Cmpt>
98inline Cmpt det(const SphericalTensor2D<Cmpt>& st)
99{
100 return st.ii()*st.ii();
101}
102
103
104//- Return the inverse of a SphericalTensor2D
105template<class Cmpt>
106inline SphericalTensor2D<Cmpt> inv(const SphericalTensor2D<Cmpt>& st)
108 #ifdef FULLDEBUG
109 if (mag(st.ii()) < VSMALL)
110 {
112 << "SphericalTensor2D not invertible, determinant:"
113 << det(st) << " tensor:" << st << nl
114 << abort(FatalError);
115 }
116 #endif
117
118 return SphericalTensor2D<Cmpt>(1/st.ii());
119}
120
121
122// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
123
124//- Division of a Cmpt by a SphericalTensor2D
125template<class Cmpt>
126inline SphericalTensor2D<Cmpt>
127operator/(const Cmpt s, const SphericalTensor2D<Cmpt>& st)
128{
129 #ifdef FULLDEBUG
130 if (mag(st.ii()) < VSMALL)
131 {
133 << "Cmpt = " << s
134 << " is not divisible due to a zero element in SphericalTensor2D:"
135 << "SphericalTensor2D = " << st
136 << abort(FatalError);
137 }
138 #endif
139
140 return SphericalTensor2D<Cmpt>(s/st.ii());
141}
142
143
144//- Division of a SphericalTensor2D by a Cmpt
145template<class Cmpt>
147operator/(const SphericalTensor2D<Cmpt>& st, const Cmpt s)
148{
149 #ifdef FULLDEBUG
150 if (mag(s) < VSMALL)
151 {
153 << "SphericalTensor2D = " << st
154 << " is not divisible due to a zero value in Cmpt:"
155 << "Cmpt = " << s
156 << abort(FatalError);
157 }
158 #endif
159
160 return SphericalTensor2D<Cmpt>(st.ii()/s);
161}
162
163
164//- Inner-product of a SphericalTensor2D and a SphericalTensor2D
165template<class Cmpt>
167operator&
168(
169 const SphericalTensor2D<Cmpt>& st1,
170 const SphericalTensor2D<Cmpt>& st2
171)
172{
173 return SphericalTensor2D<Cmpt>(st1.ii()*st2.ii());
175
176
177//- Inner-product of a SphericalTensor2D and a Vector2D
178template<class Cmpt>
179inline Vector2D<Cmpt>
180operator&(const SphericalTensor2D<Cmpt>& st, const Vector2D<Cmpt>& v)
181{
182 return Vector2D<Cmpt>
183 (
184 st.ii()*v.x(),
185 st.ii()*v.y()
186 );
187}
188
190//- Inner-product of a Vector2D and a SphericalTensor2D
191template<class Cmpt>
192inline Vector2D<Cmpt>
194{
195 return Vector2D<Cmpt>
196 (
197 v.x()*st.ii(),
198 v.y()*st.ii()
199 );
200}
201
202
203// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205template<class Cmpt>
206class outerProduct<SphericalTensor2D<Cmpt>, Cmpt>
207{
208public:
209
211};
212
213template<class Cmpt>
214class outerProduct<Cmpt, SphericalTensor2D<Cmpt>>
215{
216public:
219};
220
222template<class Cmpt>
224{
225public:
226
228};
230
231template<class Cmpt>
232class innerProduct<SphericalTensor2D<Cmpt>, Vector2D<Cmpt>>
233{
234public:
235
236 typedef Vector2D<Cmpt> type;
237};
239template<class Cmpt>
240class innerProduct<Vector2D<Cmpt>, SphericalTensor2D<Cmpt>>
241{
242public:
244 typedef Vector2D<Cmpt> type;
245};
246
248// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
249
250} // End namespace Foam
252// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
A templated (2 x 2) diagonal tensor of objects of <T>, effectively containing 1 element,...
scalar diagSqr() const
The L2-norm squared of the diagonal.
const Cmpt & ii() const noexcept
SphericalTensor2D()=default
Default construct.
Templated 2D Vector derived from VectorSpace adding construction from 2 components,...
Definition Vector2D.H:54
const Cmpt & x() const noexcept
Access to the vector x component.
Definition Vector2D.H:127
const Cmpt & y() const noexcept
Access to the vector y component.
Definition Vector2D.H:132
Templated vector space.
Definition VectorSpace.H:75
static const SphericalTensor2D< Cmpt > zero
VectorSpace< SphericalTensor2D< Cmpt >, Cmpt, Ncmpts > vsType
Definition VectorSpace.H:86
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition zero.H:58
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
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))
Namespace for OpenFOAM.
dimensionedScalar det(const dimensionedSphericalTensor &dt)
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
dimensionedScalar operator/(const scalar s1, const dimensionedScalar &ds2)
tmp< GeometricField< Type, faPatchField, areaMesh > > operator&(const faMatrix< Type > &, const DimensionedField< Type, areaMesh > &)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
errorManip< error > abort(error &err)
Definition errorManip.H:139
SphericalTensor< Cmpt > sph(const DiagTensor< Cmpt > &dt)
Return the spherical part of a DiagTensor as a SphericalTensor.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50