Loading...
Searching...
No Matches
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-2025 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 "Pair.H"
43#include "PtrList.H"
44#include "scalar.H"
45#include "direction.H"
46#include "VectorSpace.H"
47
48// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49
50namespace Foam
51{
52
53// Forward Declarations
54
55template<template<class> class Field, class Type>
56class FieldField;
57
58template<template<class> class Field, class Type>
59Ostream& operator<<
60(
61 Ostream&,
63);
64
65template<template<class> class Field, class Type>
66Ostream& operator<<
67(
68 Ostream&,
70);
71
72
73/*---------------------------------------------------------------------------*\
74 Class FieldField Declaration
75\*---------------------------------------------------------------------------*/
76
77template<template<class> class Field, class Type>
78class FieldField
79:
80 public refCount,
81 public PtrList<Field<Type>>
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 //- Impose lower (floor) clamp on the field values (in-place)
153 void clamp_min(const Type& lower);
154
155 //- Impose lower (floor) clamp on the field values (in-place)
156 void clamp_min(const FieldField<Field, Type>& lower);
157
158 //- Impose upper (ceiling) clamp on the field values (in-place)
159 void clamp_max(const Type& upper);
160
161 //- Impose upper (ceiling) clamp on the field values (in-place)
162 void clamp_max(const FieldField<Field, Type>& upper);
163
164 //- Clamp field values (in-place) to the specified range.
165 // Does not check if range is valid or not.
166 void clamp_range(const Type& lower, const Type& upper);
167
168 //- Clamp field values (in-place) to the specified range.
169 // Does not check if range is valid or not.
170 void clamp_range(const MinMax<Type>& range);
171
172 //- Return the field transpose (only defined for second rank tensors)
173 tmp<FieldField<Field, Type>> T() const;
174
175
176 // Member Operators
177
178 //- Const or non-const access to a field
179 using PtrList<Field<Type>>::operator[];
180
181 //- Const access to a single field element via (fieldi, elemi)
182 inline const Type& operator[](const labelPair& index) const;
183
184 //- Non-const access to a single field element via (fieldi, elemi)
185 inline Type& operator[](const labelPair& index);
186
187 //- Copy assignment
188 void operator=(const FieldField<Field, Type>&);
189
190 //- Move assignment
191 void operator=(FieldField<Field, Type>&&);
192
193 //- Move or clone assignment
194 void operator=(const tmp<FieldField<Field, Type>>&);
195
196 //- Assign uniform value
197 void operator=(const Type& val);
198
199 //- Assign uniform zero
200 void operator=(Foam::zero);
201
202 void operator+=(const FieldField<Field, Type>&);
203 void operator+=(const tmp<FieldField<Field, Type>>&);
204
205 void operator-=(const FieldField<Field, Type>&);
206 void operator-=(const tmp<FieldField<Field, Type>>&);
207
208 void operator*=(const FieldField<Field, scalar>&);
209 void operator*=(const tmp<FieldField<Field, scalar>>&);
210
211 void operator/=(const FieldField<Field, scalar>&);
212 void operator/=(const tmp<FieldField<Field, scalar>>&);
213
214 void operator+=(const Type&);
215 void operator-=(const Type&);
216
217 void operator*=(const scalar&);
218 void operator/=(const scalar&);
219
220
221 // IOstream operators
222
223 friend Ostream& operator<< <Field, Type>
224 (
225 Ostream&,
226 const FieldField<Field, Type>&
227 );
228
229 friend Ostream& operator<< <Field, Type>
230 (
231 Ostream&,
232 const tmp<FieldField<Field, Type>>&
233 );
234};
235
236
237// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
238
239} // End namespace Foam
240
241// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242
243#include "FieldFieldFunctions.H"
244
245#ifdef NoRepository
246 #include "FieldField.C"
247#endif
248
249// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
250
251#endif
252
253// ************************************************************************* //
scalar range
A field of fields is a PtrList of fields with reference counting.
Definition FieldField.H:77
tmp< FieldField< Field, Type > > T() const
Return the field transpose (only defined for second rank tensors).
Definition FieldField.C:366
constexpr FieldField() noexcept
Construct null.
Definition FieldField.C:101
void clamp_range(const Type &lower, const Type &upper)
Clamp field values (in-place) to the specified range.
Definition FieldField.C:336
tmp< FieldField< Field, Type > > clone() const
Clone.
Definition FieldField.C:182
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 clamp_min(const Type &lower)
Impose lower (floor) clamp on the field values (in-place).
Definition FieldField.C:280
void replace(const direction, const FieldField< Field, cmptType > &)
Replace a component field of the field.
Definition FieldField.C:252
pTraits< Type >::cmptType cmptType
Component type.
Definition FieldField.H:83
void negate()
Negate this field. See notes in Field.
Definition FieldField.C:212
void clamp_max(const Type &upper)
Impose upper (ceiling) clamp on the field values (in-place).
Definition FieldField.C:293
void normalise()
Normalise this field. See notes in Field.
Definition FieldField.C:222
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:234
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
A min/max value pair with additional methods. In addition to conveniently storing values,...
Definition MinMax.H:106
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
constexpr PtrList() noexcept
Definition PtrListI.H:29
label size() const noexcept
Definition UPtrListI.H:106
A traits class, which is primarily used for primitives and vector-space.
Definition pTraits.H:64
constexpr refCount() noexcept
Default construct, initializing count to 0.
Definition refCount.H:63
A class for managing temporary objects.
Definition tmp.H:75
A class for handling words, derived from Foam::string.
Definition word.H:66
Direction is an 8-bit unsigned integer type used to represent Cartesian directions,...
Namespace for OpenFOAM.
Pair< label > labelPair
A pair of labels.
Definition Pair.H:54
uint8_t direction
Definition direction.H:49
const direction noexcept
Definition scalarImpl.H:265
A non-counting (dummy) refCount.
Definition refCount.H:55