FieldField.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2020 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  //- Copy constructor
103 
104  //- Move constructor
106 
107  //- Construct as copy or re-use as specified.
108  FieldField(FieldField<Field, Type>&, bool reuse);
109 
110  //- Construct as copy of a PtrList<Field, Type>
111  FieldField(const PtrList<Field<Type>>&);
112 
113  //- Construct as copy of tmp<FieldField>
115 
116  //- Construct from Istream
118 
119  //- Clone
121 
122  //- Return a pointer to a new calculatedFvPatchFieldField created on
123  // freestore without setting patchField values
124  template<class Type2>
126  (
128  );
129 
130 
131  // Member Functions
132 
133  //- Negate this field
134  void negate();
135 
136  //- Return a component field of the field
138 
139  //- Replace a component field of the field
140  void replace(const direction, const FieldField<Field, cmptType>&);
141 
142  //- Replace a component field of the field
143  void replace(const direction, const cmptType&);
144 
145  //- Return the field transpose (only defined for second rank tensors)
147 
148 
149  // Member Operators
150 
151  void operator=(const FieldField<Field, Type>&);
153  void operator=(const tmp<FieldField<Field, Type>>&);
154  void operator=(const Type&);
155 
156  void operator+=(const FieldField<Field, Type>&);
157  void operator+=(const tmp<FieldField<Field, Type>>&);
158 
159  void operator-=(const FieldField<Field, Type>&);
160  void operator-=(const tmp<FieldField<Field, Type>>&);
161 
164 
167 
168  void operator+=(const Type&);
169  void operator-=(const Type&);
170 
171  void operator*=(const scalar&);
172  void operator/=(const scalar&);
173 
174 
175  // IOstream Operators
176 
177  friend Ostream& operator<< <Field, Type>
178  (
179  Ostream&,
181  );
182 
183  friend Ostream& operator<< <Field, Type>
184  (
185  Ostream&,
187  );
188 };
189 
190 
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 
193 } // End namespace Foam
194 
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 
197 #include "FieldFieldFunctions.H"
198 
199 #ifdef NoRepository
200  #include "FieldField.C"
201 #endif
202 
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204 
205 #endif
206 
207 // ************************************************************************* //
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:290
void negate()
Negate this field.
Definition: FieldField.C:218
Pre-declare SubField and related Field type.
Definition: Field.H:56
A class for handling words, derived from string.
Definition: word.H:59
void operator*=(const FieldField< Field, scalar > &)
Definition: FieldField.C:379
static tmp< FieldField< Field, Type > > NewCalculatedType(const FieldField< Field, Type2 > &ff)
Return a pointer to a new calculatedFvPatchFieldField created on.
Definition: FieldField.C:197
void operator+=(const FieldField< Field, Type > &)
Definition: FieldField.C:377
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
void operator/=(const FieldField< Field, scalar > &)
Definition: FieldField.C:380
tmp< FieldField< Field, cmptType > > component(const direction) const
Return a component field of the field.
Definition: FieldField.C:230
void replace(const direction, const FieldField< Field, cmptType > &)
Replace a component field of the field.
Definition: FieldField.C:248
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:70
tmp< FieldField< Field, Type > > T() const
Return the field transpose (only defined for second rank tensors)
Definition: FieldField.C:275
void operator-=(const FieldField< Field, Type > &)
Definition: FieldField.C:378
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:188
const FieldField< fvPatchField, Type > & ff(const FieldField< fvPatchField, Type > &bf)
Namespace for OpenFOAM.