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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::FieldField
29
30Description
31 A field of fields is a PtrList of fields with reference counting.
32
33SourceFiles
34 FieldField.C
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef Foam_FieldField_H
39#define Foam_FieldField_H
40
41#include "tmp.H"
42#include "PtrList.H"
43#include "scalar.H"
44#include "direction.H"
45#include "VectorSpace.H"
46
47// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48
49namespace Foam
50{
51
52// Forward Declarations
53
54template<template<class> class Field, class Type>
55class FieldField;
56
57template<template<class> class Field, class Type>
58Ostream& operator<<
59(
60 Ostream&,
61 const FieldField<Field, Type>&
62);
63
64template<template<class> class Field, class Type>
65Ostream& operator<<
66(
67 Ostream&,
68 const tmp<FieldField<Field, Type>>&
69);
70
71
72/*---------------------------------------------------------------------------*\
73 Class FieldField Declaration
74\*---------------------------------------------------------------------------*/
75
76template<template<class> class Field, class Type>
77class FieldField
78:
79 public refCount,
80 public PtrList<Field<Type>>
81{
82
83public:
84
85 //- Component type
86 typedef typename pTraits<Type>::cmptType cmptType;
87
88
89 // Constructors
90
91 //- Construct null
92 // Used for temporary fields which are initialised after construction
93 constexpr FieldField() noexcept;
94
95 //- Construct given size
96 // Used for temporary fields which are initialised after construction
97 explicit FieldField(const label size);
98
99 //- Clone construct with new type
100 FieldField(const word& type, const FieldField<Field, Type>& ff);
101
102 //- Copy construct, cloning each element
103 FieldField(const FieldField<Field, Type>& ff);
104
105 //- Move construct
106 FieldField(FieldField<Field, Type>&& ff);
107
108 //- Construct as copy or re-use as specified.
109 FieldField(FieldField<Field, Type>& ff, bool reuse);
110
111 //- Copy construct from PtrList
112 FieldField(const PtrList<Field<Type>>& list);
113
114 //- Move construct from PtrList
115 FieldField(PtrList<Field<Type>>&& list);
116
117 //- Move/copy construct from tmp<FieldField>
118 FieldField(const tmp<FieldField<Field, Type>>& tf);
119
120 //- Construct from Istream
121 FieldField(Istream& is);
122
123 //- Clone
124 tmp<FieldField<Field, Type>> clone() const;
125
126 //- Return a pointer to a new calculatedFvPatchFieldField created on
127 // freestore without setting patchField values
128 template<class Type2>
130 (
131 const FieldField<Field, Type2>& ff
132 );
133
134
135 // Member Functions
136
137 //- Negate this field. See notes in Field
138 void negate();
139
140 //- Normalise this field. See notes in Field
141 void normalise();
142
143 //- Return a component field of the field
145
146 //- Replace a component field of the field
147 void replace(const direction, const FieldField<Field, cmptType>&);
148
149 //- Replace a component field of the field
150 void replace(const direction, const cmptType&);
151
152 //- Return the field transpose (only defined for second rank tensors)
153 tmp<FieldField<Field, Type>> T() const;
154
155
156 // Member operators
157
158 //- Copy assignment
159 void operator=(const FieldField<Field, Type>&);
160
161 //- Move assignment
162 void operator=(FieldField<Field, Type>&&);
163
164 //- Move or clone assignment
165 void operator=(const tmp<FieldField<Field, Type>>&);
166
167 //- Assign uniform value
168 void operator=(const Type& val);
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
191 friend Ostream& operator<< <Field, Type>
192 (
193 Ostream&,
194 const FieldField<Field, Type>&
195 );
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
211#include "FieldFieldFunctions.H"
212
213#ifdef NoRepository
214 #include "FieldField.C"
215#endif
216
217// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218
219#endif
220
221// ************************************************************************* //
A field of fields is a PtrList of fields with reference counting.
Definition: FieldField.H:80
tmp< FieldField< Field, Type > > T() const
Return the field transpose (only defined for second rank tensors)
Definition: FieldField.C:286
constexpr FieldField() noexcept
Construct null.
Definition: FieldField.C:108
tmp< FieldField< Field, Type > > clone() const
Clone.
Definition: FieldField.C:189
static tmp< FieldField< Field, Type > > NewCalculatedType(const FieldField< Field, Type2 > &ff)
Return a pointer to a new calculatedFvPatchFieldField created on.
Definition: FieldField.C:198
void replace(const direction, const FieldField< Field, cmptType > &)
Replace a component field of the field.
Definition: FieldField.C:259
pTraits< Type >::cmptType cmptType
Component type.
Definition: FieldField.H:85
void negate()
Negate this field. See notes in Field.
Definition: FieldField.C:219
void normalise()
Normalise this field. See notes in Field.
Definition: FieldField.C:229
friend Ostream & operator(Ostream &, const FieldField< Field, Type > &)
tmp< FieldField< Field, cmptType > > component(const direction) const
Return a component field of the field.
Definition: FieldField.C:241
Generic templated field type.
Definition: Field.H:82
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
label size() const noexcept
The number of elements in the list.
Definition: UPtrListI.H:106
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:66
Reference counter for various OpenFOAM components.
Definition: refCount.H:51
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
Direction is an 8-bit unsigned integer type used to represent Cartesian directions,...
Namespace for OpenFOAM.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:598
uint8_t direction
Definition: direction.H:56
const direction noexcept
Definition: Scalar.H:223