1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, 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"
43 #include "SymmTensor.H"
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 /*---------------------------------------------------------------------------*\
51 Class Tensor Declaration
52 \*---------------------------------------------------------------------------*/
57 public VectorSpace<Tensor<Cmpt>, Cmpt, 9>
62 //- Equivalent type of labels used for valid component indexing
63 typedef Tensor<label> labelType;
70 rank = 2 // Rank of Tensor is 2
74 // Static data members
76 static const char* const typeName;
77 static const char* componentNames[];
79 static const Tensor zero;
80 static const Tensor one;
81 static const Tensor max;
82 static const Tensor min;
85 //- Component labeling enumeration
86 enum components { XX, XY, XZ, YX, YY, YZ, ZX, ZY, ZZ };
94 //- Construct given VectorSpace
95 inline Tensor(const VectorSpace<Tensor<Cmpt>, Cmpt, 9>&);
97 //- Construct given SphericalTensor
98 inline Tensor(const SphericalTensor<Cmpt>&);
100 //- Construct given SymmTensor
101 inline Tensor(const SymmTensor<Cmpt>&);
103 //- Construct given the three vector components
106 const Vector<Cmpt>& x,
107 const Vector<Cmpt>& y,
108 const Vector<Cmpt>& z
111 //- Construct given the nine components
114 const Cmpt txx, const Cmpt txy, const Cmpt txz,
115 const Cmpt tyx, const Cmpt tyy, const Cmpt tyz,
116 const Cmpt tzx, const Cmpt tzy, const Cmpt tzz
119 //- Construct from Istream
127 inline const Cmpt& xx() const;
128 inline const Cmpt& xy() const;
129 inline const Cmpt& xz() const;
130 inline const Cmpt& yx() const;
131 inline const Cmpt& yy() const;
132 inline const Cmpt& yz() const;
133 inline const Cmpt& zx() const;
134 inline const Cmpt& zy() const;
135 inline const Cmpt& zz() const;
147 // Access vector components.
148 // Note: returning const only to find out lhs usage
150 inline const Vector<Cmpt> x() const;
151 inline const Vector<Cmpt> y() const;
152 inline const Vector<Cmpt> z() const;
155 inline Tensor<Cmpt> T() const;
160 //- Assign to a SphericalTensor
161 inline void operator=(const SphericalTensor<Cmpt>&);
163 //- Assign to a SymmTensor
164 inline void operator=(const SymmTensor<Cmpt>&);
169 class typeOfRank<Cmpt, 2>
173 typedef Tensor<Cmpt> type;
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 } // End namespace Foam
181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 // Include inline implementations
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 // ************************************************************************* //