FreeFOAM The Cross-Platform CFD Toolkit
FieldField.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::FieldField
26 
27 Description
28  Generic field type.
29 
30 SourceFiles
31  FieldField.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef FieldField_H
36 #define FieldField_H
37 
38 #include <OpenFOAM/tmp.H>
39 #include <OpenFOAM/PtrList.H>
40 #include <OpenFOAM/scalar.H>
41 #include <OpenFOAM/direction.H>
42 #include <OpenFOAM/VectorSpace.H>
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 // Forward declaration of friend functions and operators
50 
51 template<template<class> class Field, class Type>
52 class FieldField;
53 
54 template<template<class> class Field, class Type>
55 Ostream& operator<<
56 (
57  Ostream&,
58  const FieldField<Field, Type>&
59 );
60 
61 template<template<class> class Field, class Type>
62 Ostream& operator<<
63 (
64  Ostream&,
65  const tmp<FieldField<Field, Type> >&
66 );
67 
68 
69 /*---------------------------------------------------------------------------*\
70  Class FieldField Declaration
71 \*---------------------------------------------------------------------------*/
72 
73 template<template<class> class Field, class Type>
75 :
76  public refCount,
77  public PtrList<Field<Type> >
78 {
79 
80 public:
81 
82  //- Component type
84 
85 
86  // Constructors
87 
88  //- Construct null
89  // Used for temporary fields which are initialised after construction
90  FieldField();
91 
92  //- Construct given size
93  // Used for temporary fields which are initialised after construction
94  explicit FieldField(const label);
95 
96  //- Construct using the Field sizes from the given FieldField
97  // and the given Field type.
98  // Used for temporary fields which are initialised after construction
99  FieldField(const word&, const FieldField<Field, Type>&);
100 
101  //- Construct as copy
103 
104  //- Construct as copy or re-use as specified.
105  FieldField(FieldField<Field, Type>&, bool reUse);
106 
107  //- Construct as copy of a PtrList<Field, Type>
108  FieldField(const PtrList<Field<Type> >&);
109 
110  //- Construct as copy of tmp<FieldField>
111 # ifdef ConstructFromTmp
113 # endif
114 
115  //- Construct from Istream
117 
118  //- Clone
120 
121  //- Return a pointer to a new calculatedFvPatchFieldField created on
122  // freestore without setting patchField values
123  template<class Type2>
125  (
127  )
128 # ifdef __INTEL_COMPILER
129  {
131  (
132  new FieldField<Field, Type>(ff.size())
133  );
134 
135  forAll(*nffPtr, i)
136  {
137  nffPtr->set(i, Field<Type>::NewCalculatedType(ff[i]).ptr());
138  }
139 
140  return tmp<FieldField<Field, Type> >(nffPtr);
141  }
142 # else
143  ;
144 # endif
145 
146  // Member functions
147 
148  //- Negate this field
149  void negate();
150 
151  //- Return a component field of the field
152  tmp<FieldField<Field, cmptType> > component(const direction) const;
153 
154  //- Replace a component field of the field
155  void replace(const direction, const FieldField<Field, cmptType>&);
156 
157  //- Replace a component field of the field
158  void replace(const direction, const cmptType&);
159 
160  //- Return the field transpose (only defined for second rank tensors)
161  tmp<FieldField<Field, Type> > T() const;
162 
163 
164  // Member operators
165 
166  void operator=(const FieldField<Field, Type>&);
167  void operator=(const tmp<FieldField<Field, Type> >&);
168  void operator=(const Type&);
169 
170  void operator+=(const FieldField<Field, Type>&);
171  void operator+=(const tmp<FieldField<Field, Type> >&);
172 
173  void operator-=(const FieldField<Field, Type>&);
174  void operator-=(const tmp<FieldField<Field, Type> >&);
175 
176  void operator*=(const FieldField<Field, scalar>&);
177  void operator*=(const tmp<FieldField<Field, scalar> >&);
178 
179  void operator/=(const FieldField<Field, scalar>&);
180  void operator/=(const tmp<FieldField<Field, scalar> >&);
181 
182  void operator+=(const Type&);
183  void operator-=(const Type&);
184 
185  void operator*=(const scalar&);
186  void operator/=(const scalar&);
187 
188 
189  // IOstream operators
190 
191  friend Ostream& operator<< <Field, Type>
192  (
193  Ostream&,
194  const FieldField<Field, Type>&
195  );
196 
197  friend Ostream& operator<< <Field, Type>
198  (
199  Ostream&,
200  const tmp<FieldField<Field, Type> >&
201  );
202 };
203 
204 
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206 
207 } // End namespace Foam
208 
209 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 
212 
213 #ifdef NoRepository
214 # include <OpenFOAM/FieldField.C>
215 #endif
216 
217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218 
219 #endif
220 
221 // ************************ vim: set sw=4 sts=4 et: ************************ //