FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 Class
00025     Foam::Tensor2D
00026 
00027 Description
00028     Templated 2D tensor derived from VectorSpace adding construction from
00029     4 components, element access using xx(), xy(), yx() and yy() member
00030     functions and the iner-product (dot-product) and outer-product of two
00031     Vector2Ds (tensor-product) operators.
00032 
00033 SourceFiles
00034     Tensor2DI.H
00035 
00036 \*---------------------------------------------------------------------------*/
00037 
00038 #ifndef Tensor2D_H
00039 #define Tensor2D_H
00040 
00041 #include <OpenFOAM/Vector2D_.H>
00042 #include <OpenFOAM/SphericalTensor2D_.H>
00043 
00044 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00045 
00046 namespace Foam
00047 {
00048 
00049 /*---------------------------------------------------------------------------*\
00050                            Class Tensor2D Declaration
00051 \*---------------------------------------------------------------------------*/
00052 
00053 template <class Cmpt>
00054 class Tensor2D
00055 :
00056     public VectorSpace<Tensor2D<Cmpt>, Cmpt, 4>
00057 {
00058 
00059 public:
00060 
00061     // Member constants
00062 
00063         enum
00064         {
00065             rank = 2 // Rank of Tensor2D is 2
00066         };
00067 
00068 
00069     // Static data members
00070 
00071         static const char* const typeName;
00072         static const char* componentNames[];
00073 
00074         static const Tensor2D zero;
00075         static const Tensor2D one;
00076         static const Tensor2D max;
00077         static const Tensor2D min;
00078 
00079 
00080     //- Component labeling enumeration
00081     enum components { XX, XY, YX, YY };
00082 
00083 
00084     // Constructors
00085 
00086         //- Construct null
00087         inline Tensor2D();
00088 
00089         //- Construct given VectorSpace
00090         inline Tensor2D(const VectorSpace<Tensor2D<Cmpt>, Cmpt, 4>&);
00091 
00092         //- Construct given SphericalTensor2D
00093         inline Tensor2D(const SphericalTensor2D<Cmpt>&);
00094 
00095         //- Construct given the two vectors
00096         inline Tensor2D
00097         (
00098             const Vector2D<Cmpt>& x,
00099             const Vector2D<Cmpt>& y
00100         );
00101 
00102         //- Construct given the four components
00103         inline Tensor2D
00104         (
00105             const Cmpt txx, const Cmpt txy,
00106             const Cmpt tyx, const Cmpt tyy
00107         );
00108 
00109         //- Construct from Istream
00110         Tensor2D(Istream&);
00111 
00112 
00113     // Member Functions
00114 
00115         // Access
00116 
00117             inline const Cmpt& xx() const;
00118             inline const Cmpt& xy() const;
00119             inline const Cmpt& yx() const;
00120             inline const Cmpt& yy() const;
00121 
00122             inline Cmpt& xx();
00123             inline Cmpt& xy();
00124             inline Cmpt& yx();
00125             inline Cmpt& yy();
00126 
00127             // Access vector components.
00128             // Note: returning const only to find out lhs usage                                                                                                                                      
00129  
00130             inline const Vector2D<Cmpt> x() const;
00131             inline const Vector2D<Cmpt> y() const;
00132 
00133         //- Transpose
00134         inline Tensor2D<Cmpt> T() const;
00135 
00136 
00137     // Member Operators
00138 
00139         //- Copy SphericalTensor2D
00140         inline void operator=(const SphericalTensor2D<Cmpt>&);
00141 };
00142 
00143 
00144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00145 
00146 } // End namespace Foam
00147 
00148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00149 
00150 // Include inline implementations
00151 #include "Tensor2DI_.H"
00152 
00153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00154 
00155 #endif
00156 
00157 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines