FreeFOAM The Cross-Platform CFD Toolkit
SubField.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::SubField
26 
27 Description
28  SubField is a Field obtained as a section of another Field.
29 
30  Thus it is itself unallocated so that no storage is allocated or
31  deallocated during its use. To achieve this behaviour, SubField is
32  derived from a SubList rather than a List.
33 
34 SourceFiles
35  SubFieldI.H
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef SubField_H
40 #define SubField_H
41 
42 #include <OpenFOAM/SubList.H>
43 #include "Field.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 //- Pre-declare SubField and related Field type
51 template<class Type> class Field;
52 template<class Type> class SubField;
53 
54 /*---------------------------------------------------------------------------*\
55  Class SubField Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 template<class Type>
59 class SubField
60 :
61  public refCount,
62  public SubList<Type>
63 {
64 
65 public:
66 
67  //- Component type
69 
70 
71  // Constructors
72 
73  //- Construct from a SubList
74  inline SubField(const SubList<Type>&);
75 
76  //- Construct from a UList<Type>, using the entire size
77  explicit inline SubField(const UList<Type>&);
78 
79  //- Construct from a UList<Type> with a given size
80  inline SubField
81  (
82  const UList<Type>& list,
83  const label subSize
84  );
85 
86  //- Construct from a UList<Type> with a given size and start index
87  inline SubField
88  (
89  const UList<Type>& list,
90  const label subSize,
91  const label startIndex
92  );
93 
94  //- Construct as copy
95  inline SubField(const SubField<Type>&);
96 
97 
98  // Member functions
99 
100  //- Return a null SubField
101  static inline const SubField<Type>& null();
102 
103  //- Return a component field of the field
104  inline tmp<Field<cmptType> > component(const direction) const;
105 
106  //- Return the field transpose (only defined for second rank tensors)
107  tmp<Field<Type> > T() const;
108 
109 
110  // Member operators
111 
112  //- Assignment via UList operator. Takes linear time.
113  inline void operator=(const SubField<Type>&);
114 
115  //- Allow cast to a const Field<Type>&
116  inline operator const Field<Type>&() const;
117 };
118 
119 
120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
121 
122 } // End namespace Foam
123 
124 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
125 
126 #include "SubFieldI.H"
127 
128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
129 
130 #endif
131 
132 // ************************ vim: set sw=4 sts=4 et: ************************ //