1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
5 \\ / A nd | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
28 Templated 3D tensor derived from VectorSpace adding construction from
29 9 components, element access using xx(), xy() etc. member functions and
30 the inner-product (dot-product) and outer-product of two Vectors
31 (tensor-product) operators.
36 \*---------------------------------------------------------------------------*/
42 #include "SphericalTensor.H"
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 /*---------------------------------------------------------------------------*\
53 Class Tensor Declaration
54 \*---------------------------------------------------------------------------*/
59 public VectorSpace<Tensor<Cmpt>, Cmpt, 9>
64 //- Equivalent type of labels used for valid component indexing
65 typedef Tensor<label> labelType;
72 rank = 2 // Rank of Tensor is 2
76 // Static data members
78 static const char* const typeName;
79 static const char* componentNames[];
81 static const Tensor zero;
82 static const Tensor one;
83 static const Tensor max;
84 static const Tensor min;
87 //- Component labeling enumeration
88 enum components { XX, XY, XZ, YX, YY, YZ, ZX, ZY, ZZ };
96 //- Construct given VectorSpace
97 inline Tensor(const VectorSpace<Tensor<Cmpt>, Cmpt, 9>&);
99 //- Construct given SphericalTensor
100 inline Tensor(const SphericalTensor<Cmpt>&);
102 //- Construct given SymmTensor
103 inline Tensor(const SymmTensor<Cmpt>&);
105 //- Construct given the three vectors
108 const Vector<Cmpt>& x,
109 const Vector<Cmpt>& y,
110 const Vector<Cmpt>& z
113 //- Construct given the nine components
116 const Cmpt txx, const Cmpt txy, const Cmpt txz,
117 const Cmpt tyx, const Cmpt tyy, const Cmpt tyz,
118 const Cmpt tzx, const Cmpt tzy, const Cmpt tzz
121 //- Construct from Istream
129 inline const Cmpt& xx() const;
130 inline const Cmpt& xy() const;
131 inline const Cmpt& xz() const;
132 inline const Cmpt& yx() const;
133 inline const Cmpt& yy() const;
134 inline const Cmpt& yz() const;
135 inline const Cmpt& zx() const;
136 inline const Cmpt& zy() const;
137 inline const Cmpt& zz() const;
149 // Access vector components.
150 // Note: returning const only to find out lhs usage
152 inline const Vector<Cmpt> x() const;
153 inline const Vector<Cmpt> y() const;
154 inline const Vector<Cmpt> z() const;
156 //- Return (i, j) component. Consistency with VectorN
157 inline const Cmpt& operator()
163 //- Return access to (i, j) component. Consistency with VectorN
164 inline Cmpt& operator()
172 inline Tensor<Cmpt> T() const;
177 //- Assign to a SphericalTensor
178 inline void operator=(const SphericalTensor<Cmpt>&);
180 //- Assign to a SymmTensor
181 inline void operator=(const SymmTensor<Cmpt>&);
186 class typeOfRank<Cmpt, 2>
190 typedef Tensor<Cmpt> type;
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 } // End namespace Foam
198 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200 // Include inline implementations
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 // ************************************************************************* //