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

Tensor2D.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     Tensor2D
00027 
00028 Description
00029     Templated 2D tensor derived from VectorSpace adding construction from
00030     4 components, element access using xx(), xy(), yx() and yy() member
00031     functions and the iner-product (dot-product) and outer-product of two
00032     Vector2Ds (tensor-product) operators.
00033 
00034 SourceFiles
00035     Tensor2DI.H
00036 
00037 \*---------------------------------------------------------------------------*/
00038 
00039 #ifndef Tensor2D_H
00040 #define Tensor2D_H
00041 
00042 #include "Vector2D.H"
00043 #include "SphericalTensor2D.H"
00044 
00045 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00046 
00047 namespace Foam
00048 {
00049 
00050 /*---------------------------------------------------------------------------*\
00051                            Class Tensor2D Declaration
00052 \*---------------------------------------------------------------------------*/
00053 
00054 template <class Cmpt>
00055 class Tensor2D
00056 :
00057     public VectorSpace<Tensor2D<Cmpt>, Cmpt, 4>
00058 {
00059 
00060 public:
00061 
00062     // Member constants
00063 
00064         enum
00065         {
00066             rank = 2 // Rank of Tensor2D is 2
00067         };
00068 
00069 
00070     // Static data members
00071 
00072         static const char* const typeName;
00073         static const char* componentNames[];
00074 
00075         static const Tensor2D zero;
00076         static const Tensor2D one;
00077 
00078     //- Component labeling enumeration
00079     enum components { XX, XY, YX, YY };
00080 
00081 
00082     // Constructors
00083 
00084         //- Construct null
00085         inline Tensor2D();
00086 
00087         //- Construct given VectorSpace
00088         inline Tensor2D(const VectorSpace<Tensor2D<Cmpt>, Cmpt, 4>&);
00089 
00090         //- Construct given SphericalTensor2D
00091         inline Tensor2D(const SphericalTensor2D<Cmpt>&);
00092 
00093         //- Construct given the nine components
00094         inline Tensor2D
00095         (
00096             const Cmpt txx, const Cmpt txy,
00097             const Cmpt tyx, const Cmpt tyy
00098         );
00099 
00100         //- Construct from Istream
00101         Tensor2D(Istream&);
00102 
00103 
00104     // Member Functions
00105 
00106         // Access
00107 
00108             inline const Vector2D<Cmpt>& x() const;
00109             inline const Vector2D<Cmpt>& y() const;
00110 
00111             inline Vector2D<Cmpt>& x();
00112             inline Vector2D<Cmpt>& y();
00113 
00114             inline const Cmpt& xx() const;
00115             inline const Cmpt& xy() const;
00116             inline const Cmpt& yx() const;
00117             inline const Cmpt& yy() const;
00118 
00119             inline Cmpt& xx();
00120             inline Cmpt& xy();
00121             inline Cmpt& yx();
00122             inline Cmpt& yy();
00123 
00124         //- Transpose
00125         inline Tensor2D<Cmpt> T() const;
00126 
00127 
00128     // Member Operators
00129 
00130         //- Construct given SphericalTensor2D
00131         inline void operator=(const SphericalTensor2D<Cmpt>&);
00132 };
00133 
00134 
00135 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00136 
00137 } // End namespace Foam
00138 
00139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00140 
00141 // Include inline implementations
00142 #include "Tensor2DI.H"
00143 
00144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00145 
00146 #endif
00147 
00148 // ************************************************************************* //
Copyright © 2000-2007 OpenCFD Ltd