FreeFOAM The Cross-Platform CFD Toolkit
DiagTensor_.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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
19  for more details.
20 
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/>.
23 
24 Class
25  Foam::DiagTensor
26 
27 Description
28  Templated 3D DiagTensor derived from VectorSpace.
29 
30  Adding construction from 3 components, element access using xx(), yy()
31  and zz() member functions and the inner-product (dot-product) and
32  outer-product operators.
33 
34 SourceFiles
35  DiagTensorI.H
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef DiagTensor_H
40 #define DiagTensor_H
41 
42 #include <OpenFOAM/Tensor_.H>
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class DiagTensor Declaration
51 \*---------------------------------------------------------------------------*/
52 
53 template <class Cmpt>
55 :
56  public VectorSpace<DiagTensor<Cmpt>, Cmpt, 3>
57 {
58 
59 public:
60 
61  // Member constants
62 
63  enum
64  {
65  rank = 2 // Rank of DiagTensor is 2
66  };
67 
68 
69  // Static data members
70 
71  static const char* const typeName;
72  static const char* componentNames[];
73  static const DiagTensor zero;
74  static const DiagTensor one;
75  static const DiagTensor max;
76  static const DiagTensor min;
77 
78 
79  //- Component labeling enumeration
80  enum components { XX, YY, ZZ };
81 
82 
83  // Constructors
84 
85  //- Construct null
86  inline DiagTensor();
87 
88  //- Construct given VectorSpace
89  inline DiagTensor(const VectorSpace<DiagTensor<Cmpt>, Cmpt, 3>&);
90 
91  //- Construct given three components
92  inline DiagTensor(const Cmpt& txx, const Cmpt& tyy, const Cmpt& tzz);
93 
94  //- Construct from Istream
95  inline DiagTensor(Istream&);
96 
97 
98  // Member Functions
99 
100  // Access
101 
102  inline const Cmpt& xx() const;
103  inline const Cmpt& yy() const;
104  inline const Cmpt& zz() const;
105 
106  inline Cmpt& xx();
107  inline Cmpt& yy();
108  inline Cmpt& zz();
109 };
110 
111 
112 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
113 
114 } // End namespace Foam
115 
116 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
117 
118 // Include inline implementations
119 #include "DiagTensorI_.H"
120 
121 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
122 
123 #endif
124 
125 // ************************ vim: set sw=4 sts=4 et: ************************ //