1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 Templated 3D tensor derived from VectorSpace adding construction from
30 9 components, element access using xx(), xy() etc. member functions and
31 the inner-product (dot-product) and outer-product of two Vectors
32 (tensor-product) operators.
37 \*---------------------------------------------------------------------------*/
43 #include "SphericalTensor.H"
44 #include "SymmTensor.H"
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 /*---------------------------------------------------------------------------*\
52 Class Tensor Declaration
53 \*---------------------------------------------------------------------------*/
58 public VectorSpace<Tensor<Cmpt>, Cmpt, 9>
63 //- Equivalent type of labels used for valid component indexing
64 typedef Tensor<label> labelType;
71 rank = 2 // Rank of Tensor is 2
75 // Static data members
77 static const char* const typeName;
78 static const char* componentNames[];
80 static const Tensor zero;
81 static const Tensor one;
82 static const Tensor max;
83 static const Tensor min;
86 //- Component labeling enumeration
87 enum components { XX, XY, XZ, YX, YY, YZ, ZX, ZY, ZZ };
95 //- Construct given VectorSpace
96 inline Tensor(const VectorSpace<Tensor<Cmpt>, Cmpt, 9>&);
98 //- Construct given SphericalTensor
99 inline Tensor(const SphericalTensor<Cmpt>&);
101 //- Construct given SymmTensor
102 inline Tensor(const SymmTensor<Cmpt>&);
104 //- Construct given the three vectors
107 const Vector<Cmpt>& x,
108 const Vector<Cmpt>& y,
109 const Vector<Cmpt>& z
112 //- Construct given the nine components
115 const Cmpt txx, const Cmpt txy, const Cmpt txz,
116 const Cmpt tyx, const Cmpt tyy, const Cmpt tyz,
117 const Cmpt tzx, const Cmpt tzy, const Cmpt tzz
120 //- Construct from Istream
128 inline const Cmpt& xx() const;
129 inline const Cmpt& xy() const;
130 inline const Cmpt& xz() const;
131 inline const Cmpt& yx() const;
132 inline const Cmpt& yy() const;
133 inline const Cmpt& yz() const;
134 inline const Cmpt& zx() const;
135 inline const Cmpt& zy() const;
136 inline const Cmpt& zz() const;
148 // Access vector components.
149 // Note: returning const only to find out lhs usage
151 inline const Vector<Cmpt> x() const;
152 inline const Vector<Cmpt> y() const;
153 inline const Vector<Cmpt> z() const;
156 inline Tensor<Cmpt> T() const;
161 //- Assign to a SphericalTensor
162 inline void operator=(const SphericalTensor<Cmpt>&);
164 //- Assign to a SymmTensor
165 inline void operator=(const SymmTensor<Cmpt>&);
170 class typeOfRank<Cmpt, 2>
174 typedef Tensor<Cmpt> type;
178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 } // End namespace Foam
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 // Include inline implementations
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191 // ************************************************************************* //