initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / OpenFOAM / fields / Fields / Field / SubField.H
blobf76edbfe6805e8e3f175de9aa60ad01db02673f2
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 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 "Field.H"
44 #include "SubList.H"
45 #include "Field.H"
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 namespace Foam
52 /*---------------------------------------------------------------------------*\
53                            Class SubField Declaration
54 \*---------------------------------------------------------------------------*/
56 template<class Type>
57 class SubField
59     public refCount,
60     public SubList<Type>
63 public:
65     //- Component type
66     typedef typename pTraits<Type>::cmptType cmptType;
69     // Constructors
71         //- Construct from UnallocatedField and SubField size
72         inline SubField
73         (
74             const SubList<Type>& slist
75         );
77         //- Construct from UnallocatedField and SubField size
78         inline SubField
79         (
80             const UList<Type>& list,
81             const label subSize
82         );
84         //- Construct from UnallocatedField, start and end indices
85         inline SubField
86         (
87             const UList<Type>& list,
88             const label subSize,
89             const label startIndex
90         );
92         //- Construct as copy
93         inline SubField
94         (
95             const SubField<Type>& sfield
96         );
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 from 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 // ************************************************************************* //