initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / fields / Fields / DynamicField / DynamicField.H
blob1b9915d5730da34d75fca1c2680911217c1fd1cb
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::DynamicField
28 Description
29     Dynamically sized Field. WIP.
31 SourceFiles
32     DynamicField.C
34 \*---------------------------------------------------------------------------*/
36 #ifndef DynamicField_H
37 #define DynamicField_H
39 #include "Field.H"
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 namespace Foam
46 // Forward declaration of friend functions and operators
48 template<class Type>
49 class DynamicField;
51 template<class Type>
52 Ostream& operator<<(Ostream&, const DynamicField<Type>&);
54 template<class Type>
55 Ostream& operator<<(Ostream&, const tmp<DynamicField<Type> >&);
57 template<class Type>
58 Istream& operator>>(Istream&, DynamicField<Type>&);
61 /*---------------------------------------------------------------------------*\
62                            Class DynamicField Declaration
63 \*---------------------------------------------------------------------------*/
65 template<class Type>
66 class DynamicField
68     public Field<Type>
71     // Private data
73         //- The capacity (allocated size) of the underlying field.
74         label capacity_;
77         //- Construct given size and initial value
78         DynamicField(const label, const Type&);
80         //- Construct as copy of tmp<DynamicField>
81 #       ifdef ConstructFromTmp
82         DynamicField(const tmp<DynamicField<Type> >&);
83 #       endif
85         //- Construct from a dictionary entry
86         DynamicField(const word&, const dictionary&, const label);
88 public:
90     // Static data members
92         static const char* const typeName;
95     // Static Member Functions
97         //- Return a null field
98         inline static const DynamicField<Type>& null()
99         {
100             return *reinterpret_cast< DynamicField<Type>* >(0);
101         }
104     // Constructors
106         //- Construct null
107         //  Used for temporary fields which are initialised after construction
108         DynamicField();
110         //- Construct given size
111         //  Used for temporary fields which are initialised after construction
112         explicit inline DynamicField(const label);
114         //- Construct as copy of a UList\<Type\>
115         explicit inline DynamicField(const UList<Type>&);
117         //- Construct by transferring the List contents
118         explicit inline DynamicField(const Xfer<List<Type> >&);
120         //- Construct by 1 to 1 mapping from the given field
121         inline DynamicField
122         (
123             const UList<Type>& mapF,
124             const labelList& mapAddressing
125         );
127         //- Construct by interpolative mapping from the given field
128         inline DynamicField
129         (
130             const UList<Type>& mapF,
131             const labelListList& mapAddressing,
132             const scalarListList& weights
133         );
135         //- Construct by mapping from the given field
136         inline DynamicField
137         (
138             const UList<Type>& mapF,
139             const FieldMapper& map
140         );
142         //- Construct as copy
143         inline DynamicField(const DynamicField<Type>&);
145         //- Construct as copy or re-use as specified.
146         inline DynamicField(DynamicField<Type>&, bool reUse);
148         //- Construct by transferring the Field contents
149         inline DynamicField(const Xfer<DynamicField<Type> >&);
151         //- Construct from Istream
152         inline DynamicField(Istream&);
154         //- Clone
155         tmp<DynamicField<Type> > clone() const;
158     // Member Functions
160         //- Size of the underlying storage.
161         inline label capacity() const;
163         //- Append an element at the end of the list
164         inline void append(const Type&);
166         //- Alter the addressed list size.
167         //  New space will be allocated if required.
168         //  Use this to resize the list prior to using the operator[] for
169         //  setting values (as per List usage).
170         void setSize(const label nElem);
172     // Member operators
174         inline void operator=(const DynamicField<Type>&);
175         inline void operator=(const UList<Type>&);
176         inline void operator=(const tmp<DynamicField<Type> >&);
178         //- Return element of Field.
179         inline Type& operator[](const label i);
181         //- Return element of constant Field.
182         inline const Type& operator[](const label) const;
184     // IOstream operators
186         friend Ostream& operator<< <Type>
187         (Ostream&, const DynamicField<Type>&);
189         friend Ostream& operator<< <Type>
190         (Ostream&, const tmp<DynamicField<Type> >&);
192         friend Istream& operator>> <Type>
193         (Istream&, DynamicField<Type>&);
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199 } // End namespace Foam
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 #include "DynamicFieldI.H"
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 #ifdef NoRepository
208 #   include "DynamicField.C"
209 #endif
211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
213 #endif
215 // ************************************************************************* //