OpenFOAM logo
The Open Source CFD Toolbox
  Programmer’s C++ Doxygen OpenCFD Solutions Contact OpenFOAM

SymmTensor.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2007 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     SymmTensor
00027 
00028 Description
00029     Templated 3D symmetric tensor derived from VectorSpace adding construction
00030     from 6 components, element access using xx(), xy() etc. member functions
00031     and the inner-product (dot-product) and outer-product of two Vectors
00032     (tensor-product) operators.
00033 
00034 SourceFiles
00035     SymmTensorI.H
00036 
00037 \*---------------------------------------------------------------------------*/
00038 
00039 #ifndef SymmTensor_H
00040 #define SymmTensor_H
00041 
00042 #include "VectorSpace.H"
00043 #include "SphericalTensor.H"
00044 
00045 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00046 
00047 namespace Foam
00048 {
00049 
00050 /*---------------------------------------------------------------------------*\
00051                            Class SymmTensor Declaration
00052 \*---------------------------------------------------------------------------*/
00053 
00054 template <class Cmpt>
00055 class SymmTensor
00056 :
00057     public VectorSpace<SymmTensor<Cmpt>, Cmpt, 6>
00058 {
00059 
00060 public:
00061 
00062     //- Equivalent type of labels used for valid component indexing
00063     typedef SymmTensor<label> labelType;
00064 
00065 
00066     // Member constants
00067 
00068         enum
00069         {
00070             rank = 2 // Rank of SymmTensor is 2
00071         };
00072 
00073 
00074     // Static data members
00075 
00076         static const char* const typeName;
00077         static const char* componentNames[];
00078 
00079         static const SymmTensor zero;
00080         static const SymmTensor one;
00081 
00082 
00083     //- Component labeling enumeration
00084     enum components { XX, XY, XZ, YY, YZ, ZZ };
00085 
00086 
00087     // Constructors
00088 
00089         //- Construct null
00090         inline SymmTensor();
00091 
00092         //- Construct given VectorSpace
00093         inline SymmTensor(const VectorSpace<SymmTensor<Cmpt>, Cmpt, 6>&);
00094 
00095         //- Construct given SphericalTensor
00096         inline SymmTensor(const SphericalTensor<Cmpt>&);
00097 
00098         //- Construct given the nine components
00099         inline SymmTensor
00100         (
00101             const Cmpt txx, const Cmpt txy, const Cmpt txz,
00102                             const Cmpt tyy, const Cmpt tyz,
00103                                             const Cmpt tzz
00104         );
00105 
00106         //- Construct from Istream
00107         SymmTensor(Istream&);
00108 
00109 
00110     // Member Functions
00111 
00112         // Access
00113 
00114             inline const Cmpt& xx() const;
00115             inline const Cmpt& xy() const;
00116             inline const Cmpt& xz() const;
00117             inline const Cmpt& yy() const;
00118             inline const Cmpt& yz() const;
00119             inline const Cmpt& zz() const;
00120 
00121             inline Cmpt& xx();
00122             inline Cmpt& xy();
00123             inline Cmpt& xz();
00124             inline Cmpt& yy();
00125             inline Cmpt& yz();
00126             inline Cmpt& zz();
00127 
00128         //- Transpose
00129         inline const SymmTensor<Cmpt>& T() const;
00130 
00131 
00132     // Member Operators
00133 
00134         //- Construct given SphericalTensor
00135         inline void operator=(const SphericalTensor<Cmpt>&);
00136 };
00137 
00138 
00139 template<class Cmpt>
00140 class symmTypeOfRank<Cmpt, 2>
00141 {
00142 public:
00143 
00144     typedef SymmTensor<Cmpt> type;
00145 };
00146 
00147 
00148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00149 
00150 } // End namespace Foam
00151 
00152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00153 
00154 // Include inline implementations
00155 #include "SymmTensorI.H"
00156 
00157 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00158 
00159 #endif
00160 
00161 // ************************************************************************* //
Copyright © 2000-2007 OpenCFD Ltd