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) 2011-2016 OpenFOAM Foundation
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 "tmp.H"
39 #include "PtrList.H"
40 #include "scalar.H"
41 #include "direction.H"
42 #include "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&,
59 );
60 
61 template<template<class> class Field, class Type>
62 Ostream& operator<<
63 (
64  Ostream&,
66 );
67 
68 
69 /*---------------------------------------------------------------------------*\
70  Class FieldField Declaration
71 \*---------------------------------------------------------------------------*/
72 
73 template<template<class> class Field, class Type>
74 class FieldField
75 :
76  public tmp<FieldField<Field, Type>>::refCount,
77  public PtrList<Field<Type>>
78 {
79 
80 public:
81 
82  //- Component type
83  typedef typename pTraits<Type>::cmptType cmptType;
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  #ifndef NoConstructFromTmp
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 
129 
130  // Member functions
131 
132  //- Negate this field
133  void negate();
134 
135  //- Return a component field of the field
137 
138  //- Replace a component field of the field
139  void replace(const direction, const FieldField<Field, cmptType>&);
140 
141  //- Replace a component field of the field
142  void replace(const direction, const cmptType&);
143 
144  //- Return the field transpose (only defined for second rank tensors)
146 
147 
148  // Member operators
149 
150  void operator=(const FieldField<Field, Type>&);
151  void operator=(const tmp<FieldField<Field, Type>>&);
152  void operator=(const Type&);
153 
154  void operator+=(const FieldField<Field, Type>&);
155  void operator+=(const tmp<FieldField<Field, Type>>&);
156 
157  void operator-=(const FieldField<Field, Type>&);
158  void operator-=(const tmp<FieldField<Field, Type>>&);
159 
162 
165 
166  void operator+=(const Type&);
167  void operator-=(const Type&);
168 
169  void operator*=(const scalar&);
170  void operator/=(const scalar&);
171 
172 
173  // IOstream operators
174 
175  friend Ostream& operator<< <Field, Type>
176  (
177  Ostream&,
179  );
180 
181  friend Ostream& operator<< <Field, Type>
182  (
183  Ostream&,
185  );
186 };
187 
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 } // End namespace Foam
192 
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 
195 #include "FieldFieldFunctions.H"
196 
197 #ifdef NoRepository
198  #include "FieldField.C"
199 #endif
200 
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 
203 #endif
204 
205 // ************************************************************************* //
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Reference counter for various OpenFOAM components.
Definition: refCount.H:49
uint8_t direction
Definition: direction.H:45
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
Generic fieldField type.
Traits class for primitives.
Definition: pTraits.H:50
Generic field type.
Definition: FieldField.H:51
void operator=(const FieldField< Field, Type > &)
Definition: FieldField.C:284
void negate()
Negate this field.
Definition: FieldField.C:212
Pre-declare SubField and related Field type.
Definition: Field.H:57
A class for handling words, derived from string.
Definition: word.H:59
void operator*=(const FieldField< Field, scalar > &)
Definition: FieldField.C:359
static tmp< FieldField< Field, Type > > NewCalculatedType(const FieldField< Field, Type2 > &ff)
Return a pointer to a new calculatedFvPatchFieldField created on.
Definition: FieldField.C:191
void operator+=(const FieldField< Field, Type > &)
Definition: FieldField.C:357
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
void operator/=(const FieldField< Field, scalar > &)
Definition: FieldField.C:360
tmp< FieldField< Field, cmptType > > component(const direction) const
Return a component field of the field.
Definition: FieldField.C:224
void replace(const direction, const FieldField< Field, cmptType > &)
Replace a component field of the field.
Definition: FieldField.C:242
Direction is an 8-bit unsigned integer type used to represent the Cartesian directions etc...
pTraits< Type >::cmptType cmptType
Component type.
Definition: FieldField.H:82
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:63
tmp< FieldField< Field, Type > > T() const
Return the field transpose (only defined for second rank tensors)
Definition: FieldField.C:269
void operator-=(const FieldField< Field, Type > &)
Definition: FieldField.C:358
A class for managing temporary objects.
Definition: PtrList.H:53
FieldField()
Construct null.
Definition: FieldField.C:108
tmp< FieldField< Field, Type > > clone() const
Clone.
Definition: FieldField.C:182
const FieldField< fvPatchField, Type > & ff(const FieldField< fvPatchField, Type > &bf)
Namespace for OpenFOAM.