Formatting
[foam-extend-3.2.git] / src / foam / primitives / SymmTensor4thOrder / SymmTensor4thOrderTemplate.H
blob73e6799bdbe748342e6341a3909f7fe490e4d377
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation, either version 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 Class
25     Foam::SymmTensor4thOrder
27 Description
28     Templated 3D symmetric fourth order tensor derived from VectorSpace
29     adding construction from 9 components,
30     element access using xxxx(), xxyy() etc. member functions
31     and double dot product with a second order tensor.
33     It is assumed that the 4th order tensor takes the form (6x6 matrix form):
34     / xxxx xxyy xxzz                \
35     |      yyyy yyzz                |
36     |           zzzz                |
37     |                xyxy           |
38     |                     yzyz      |
39     \                          zxzx /
40     where the tensor is symmetric and unspecified entries are zero.
42 Note:
43     Order is currently hacked due to missing operations on symmetry planes
44     HJ, 29/Oct/2013
46 SourceFiles
47     SymmTensor4thOrderTemplateI.H
49 Author
50     Philip Cardiff UCD
52 \*---------------------------------------------------------------------------*/
54 #ifndef SymmTensor4thOrderTemplate_H
55 #define SymmTensor4thOrderTemplate_H
57 #include "VectorSpace.H"
58 #include "SymmTensorTemplate.H"
60 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
62 namespace Foam
65 /*---------------------------------------------------------------------------*\
66                        Class SymmTensor4thOrder Declaration
67 \*---------------------------------------------------------------------------*/
69 template <class Cmpt>
70 class SymmTensor4thOrder
72     public VectorSpace<SymmTensor4thOrder<Cmpt>, Cmpt, 9>
75 public:
77     //- Equivalent type of labels used for valid component indexing
78     typedef SymmTensor4thOrder<label> labelType;
81     // Member constants
83         enum
84         {
85             rank = 2 // Hacked by PC: Actual rank of SymmTensor4thOrder is 4
86         };
88         //HJ, reconsider and fix.  HJ, 23/Feb/2014
91     // Static data members
93         static const char* const typeName;
94         static const char* componentNames[];
96         static const SymmTensor4thOrder zero;
97         static const SymmTensor4thOrder one;
98         static const SymmTensor4thOrder max;
99         static const SymmTensor4thOrder min;
102         //- Component labeling enumeration
103         enum components
104         {
105             XXXX,
106             XXYY,
107             XXZZ,
108             YYYY,
109             YYZZ,
110             ZZZZ,
111             XYXY,
112             YZYZ,
113             ZXZX
114         };
117     // Constructors
119         //- Construct null
120         inline SymmTensor4thOrder();
122         //- Construct given VectorSpace
123         inline SymmTensor4thOrder
124         (
125             const VectorSpace<SymmTensor4thOrder<Cmpt>, Cmpt, 9>&
126         );
128         //- Construct given SymmTensor (for compilation)
129         inline SymmTensor4thOrder(const SymmTensor<Cmpt>&);
131         //- Construct given the nine components
132         inline SymmTensor4thOrder
133         (
134             const Cmpt txxxx, const Cmpt txxyy, const Cmpt txxzz,
135                               const Cmpt tyyyy, const Cmpt tyyzz,
136                                                 const Cmpt tzzzz,
137             const Cmpt txyxy,
138                               const Cmpt tyzyz,
139                                                 const Cmpt tzxzx
140         );
142         //- Construct from Istream
143         SymmTensor4thOrder(Istream&);
146     // Member Functions
148         // Access
150             inline const Cmpt& xxxx() const;
151             inline const Cmpt& xxyy() const;
152             inline const Cmpt& xxzz() const;
153             inline const Cmpt& yyyy() const;
154             inline const Cmpt& yyzz() const;
155             inline const Cmpt& zzzz() const;
156             inline const Cmpt& xyxy() const;
157             inline const Cmpt& yzyz() const;
158             inline const Cmpt& zxzx() const;
160             inline Cmpt& xxxx();
161             inline Cmpt& xxyy();
162             inline Cmpt& xxzz();
163             inline Cmpt& yyyy();
164             inline Cmpt& yyzz();
165             inline Cmpt& zzzz();
166             inline Cmpt& xyxy();
167             inline Cmpt& yzyz();
168             inline Cmpt& zxzx();
171         //- Assign to a SymmTensor
172         //- maybe I need this to compile
173         inline void operator=(const SymmTensor<Cmpt>&);
177 template<class Cmpt>
178 class typeOfRank<Cmpt, 4>
180 public:
182     typedef SymmTensor4thOrder<Cmpt> type;
186 template<class Cmpt>
187 class symmTypeOfRank<Cmpt, 4>
189 public:
191     typedef SymmTensor4thOrder<Cmpt> type;
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 } // End namespace Foam
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 // Include inline implementations
203 #include "SymmTensor4thOrderTemplateI.H"
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 #endif
209 // ************************************************************************* //