FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

SubField.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 Class
00025     Foam::SubField
00026 
00027 Description
00028     SubField is a Field obtained as a section of another Field.
00029 
00030     Thus it is itself unallocated so that no storage is allocated or
00031     deallocated during its use.  To achieve this behaviour, SubField is
00032     derived from a SubList rather than a List.
00033 
00034 SourceFiles
00035     SubFieldI.H
00036 
00037 \*---------------------------------------------------------------------------*/
00038 
00039 #ifndef SubField_H
00040 #define SubField_H
00041 
00042 #include <OpenFOAM/SubList.H>
00043 #include "Field.H"
00044 
00045 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00046 
00047 namespace Foam
00048 {
00049 
00050 //- Pre-declare SubField and related Field type
00051 template<class Type> class Field;
00052 template<class Type> class SubField;
00053 
00054 /*---------------------------------------------------------------------------*\
00055                            Class SubField Declaration
00056 \*---------------------------------------------------------------------------*/
00057 
00058 template<class Type>
00059 class SubField
00060 :
00061     public refCount,
00062     public SubList<Type>
00063 {
00064 
00065 public:
00066 
00067     //- Component type
00068     typedef typename pTraits<Type>::cmptType cmptType;
00069 
00070 
00071     // Constructors
00072 
00073         //- Construct from a SubList
00074         inline SubField(const SubList<Type>&);
00075 
00076         //- Construct from a UList<Type>, using the entire size
00077         explicit inline SubField(const UList<Type>&);
00078 
00079         //- Construct from a UList<Type> with a given size
00080         inline SubField
00081         (
00082             const UList<Type>& list,
00083             const label subSize
00084         );
00085 
00086         //- Construct from a UList<Type> with a given size and start index
00087         inline SubField
00088         (
00089             const UList<Type>& list,
00090             const label subSize,
00091             const label startIndex
00092         );
00093 
00094         //- Construct as copy
00095         inline SubField(const SubField<Type>&);
00096 
00097 
00098     // Member functions
00099 
00100         //- Return a null SubField
00101         static inline const SubField<Type>& null();
00102 
00103         //- Return a component field of the field
00104         inline tmp<Field<cmptType> > component(const direction) const;
00105 
00106         //- Return the field transpose (only defined for second rank tensors)
00107         tmp<Field<Type> > T() const;
00108 
00109 
00110     // Member operators
00111 
00112         //- Assignment via UList operator. Takes linear time.
00113         inline void operator=(const SubField<Type>&);
00114 
00115         //- Allow cast to a const Field<Type>&
00116         inline operator const Field<Type>&() const;
00117 };
00118 
00119 
00120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00121 
00122 } // End namespace Foam
00123 
00124 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00125 
00126 #include "SubFieldI.H"
00127 
00128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00129 
00130 #endif
00131 
00132 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines