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