initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / fields / Fields / Field / SubField.H
bloba9930d177d456bec745840528c5322afae4aa052
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::SubField
28 Description
29     SubField is a Field obtained as a section of another Field.
31     Thus it is itself unallocated so that no storage is allocated or
32     deallocated during its use.  To achieve this behaviour, SubField is
33     derived from a SubList rather than a List.
35 SourceFiles
36     SubFieldI.H
38 \*---------------------------------------------------------------------------*/
40 #ifndef SubField_H
41 #define SubField_H
43 #include "SubList.H"
44 #include "Field.H"
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 namespace Foam
51 //- Pre-declare SubField and related Field type
52 template<class Type> class Field;
53 template<class Type> class SubField;
55 /*---------------------------------------------------------------------------*\
56                            Class SubField Declaration
57 \*---------------------------------------------------------------------------*/
59 template<class Type>
60 class SubField
62     public refCount,
63     public SubList<Type>
66 public:
68     //- Component type
69     typedef typename pTraits<Type>::cmptType cmptType;
72     // Constructors
74         //- Construct from a SubList
75         inline SubField(const SubList<Type>&);
77         //- Construct from a UList\<Type\>, using the entire size
78         explicit inline SubField(const UList<Type>&);
80         //- Construct from a UList\<Type\> with a given size
81         inline SubField
82         (
83             const UList<Type>& list,
84             const label subSize
85         );
87         //- Construct from a UList\<Type\> with a given size and start index
88         inline SubField
89         (
90             const UList<Type>& list,
91             const label subSize,
92             const label startIndex
93         );
95         //- Construct as copy
96         inline SubField(const SubField<Type>&);
99     // Member functions
101         //- Return a null SubField
102         static inline const SubField<Type>& null();
104         //- Return a component field of the field
105         inline tmp<Field<cmptType> > component(const direction) const;
107         //- Return the field transpose (only defined for second rank tensors)
108         tmp<Field<Type> > T() const;
111     // Member operators
113         //- Assignment via UList operator. Takes linear time.
114         inline void operator=(const SubField<Type>&);
116         //- Allow cast to a const Field\<Type\>&
117         inline operator const Field<Type>&() const;
121 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
123 } // End namespace Foam
125 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
127 #include "SubFieldI.H"
129 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
131 #endif
133 // ************************************************************************* //