SymmTensor.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2025 OpenFOAM Foundation
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 Class
25  Foam::SymmTensor
26 
27 Description
28  Templated 3D symmetric tensor derived from VectorSpace adding construction
29  from 6 components, element access using xx(), xy() etc. member functions
30  and the inner-product (dot-product) and outer-product of two Vectors
31  (tensor-product) operators.
32 
33 SourceFiles
34  SymmTensorI.H
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef SymmTensor_H
39 #define SymmTensor_H
40 
41 #include "VectorSpace.H"
42 #include "SphericalTensor.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class SymmTensor Declaration
51 \*---------------------------------------------------------------------------*/
52 
53 template<class Cmpt>
54 class SymmTensor
55 :
56  public VectorSpace<SymmTensor<Cmpt>, Cmpt, 6>
57 {
58 
59 public:
60 
61  //- Equivalent type of labels used for valid component indexing
63 
64 
65  // Member constants
66 
67  //- Rank of SymmTensor is 2
68  static const direction rank = 2;
69 
70 
71  // Static Data Members
72 
73  static const SymmTensor I;
74 
75 
76  //- Component labeling enumeration
77  enum components { XX, XY, XZ, YY, YZ, ZZ };
78 
79 
80  // Constructors
81 
82  //- Construct null
83  inline SymmTensor();
84 
85  //- Construct initialised to zero
86  inline SymmTensor(const Foam::zero);
87 
88  //- Construct given VectorSpace of the same rank
89  template<class Cmpt2>
90  inline SymmTensor(const VectorSpace<SymmTensor<Cmpt2>, Cmpt2, 6>&);
91 
92  //- Construct given SphericalTensor
93  inline SymmTensor(const SphericalTensor<Cmpt>&);
94 
95  //- Construct given the six components
96  inline SymmTensor
97  (
98  const Cmpt txx, const Cmpt txy, const Cmpt txz,
99  const Cmpt tyy, const Cmpt tyz,
100  const Cmpt tzz
101  );
102 
103  //- Construct from Istream
105 
106 
107  // Member Functions
108 
109  // Access
110 
111  inline const Cmpt& xx() const;
112  inline const Cmpt& xy() const;
113  inline const Cmpt& xz() const;
114  inline const Cmpt& yx() const;
115  inline const Cmpt& yy() const;
116  inline const Cmpt& yz() const;
117  inline const Cmpt& zx() const;
118  inline const Cmpt& zy() const;
119  inline const Cmpt& zz() const;
120 
121  inline Cmpt& xx();
122  inline Cmpt& xy();
123  inline Cmpt& xz();
124  inline Cmpt& yy();
125  inline Cmpt& yz();
126  inline Cmpt& zz();
127 
128  //- Transpose
129  inline const SymmTensor<Cmpt>& T() const;
130 
131 
132  // Member Operators
133 
134  //- Inherit VectorSpace assignment operators
136 
137  //- Assign to given SphericalTensor
138  inline void operator=(const SphericalTensor<Cmpt>&);
139 };
140 
141 
142 template<class Cmpt>
143 class symmTypeOfRank<Cmpt, 2>
144 {
145 public:
146 
147  typedef SymmTensor<Cmpt> type;
148 };
149 
150 
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152 
153 } // End namespace Foam
154 
155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
156 
157 // Include inline implementations
158 #include "SymmTensorI.H"
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 
162 #endif
163 
164 // ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
Templated 3D SphericalTensor derived from VectorSpace adding construction from 1 component,...
Templated 3D symmetric tensor derived from VectorSpace adding construction from 6 components,...
Definition: SymmTensor.H:56
const Cmpt & xx() const
Definition: SymmTensorI.H:87
const Cmpt & yx() const
Definition: SymmTensorI.H:105
static const direction rank
Rank of SymmTensor is 2.
Definition: SymmTensor.H:67
components
Component labeling enumeration.
Definition: SymmTensor.H:76
const Cmpt & yz() const
Definition: SymmTensorI.H:117
static const SymmTensor I
Definition: SymmTensor.H:72
const Cmpt & xz() const
Definition: SymmTensorI.H:99
const Cmpt & zz() const
Definition: SymmTensorI.H:135
const Cmpt & xy() const
Definition: SymmTensorI.H:93
const Cmpt & zx() const
Definition: SymmTensorI.H:123
const Cmpt & zy() const
Definition: SymmTensorI.H:129
const Cmpt & yy() const
Definition: SymmTensorI.H:111
SymmTensor()
Construct null.
Definition: SymmTensorI.H:32
void operator=(const SphericalTensor< Cmpt > &)
Assign to given SphericalTensor.
Definition: SymmTensorI.H:188
SymmTensor< label > labelType
Equivalent type of labels used for valid component indexing.
Definition: SymmTensor.H:61
const SymmTensor< Cmpt > & T() const
Transpose.
Definition: SymmTensorI.H:179
Templated vector space.
Definition: VectorSpace.H:85
friend Ostream & operator(Ostream &, const VectorSpace< Form, Cmpt, Ncmpts > &)
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
Definition: zero.H:50
Namespace for OpenFOAM.
uint8_t direction
Definition: direction.H:45
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488