fvsPatchField.C
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-2024 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 \*---------------------------------------------------------------------------*/
25 
26 #include "IOobject.H"
27 #include "dictionary.H"
28 #include "fvMesh.H"
29 #include "fieldMapper.H"
30 #include "surfaceMesh.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
34 template<class Type>
36 (
37  const fvPatch& p,
39 )
40 :
41  Field<Type>(p.size()),
42  patch_(p),
43  internalField_(iF)
44 {}
45 
46 
47 template<class Type>
49 (
50  const fvPatch& p,
52  const Field<Type>& f
53 )
54 :
55  Field<Type>(f),
56  patch_(p),
57  internalField_(iF)
58 {}
59 
60 
61 template<class Type>
63 (
64  const fvPatch& p,
66  const dictionary& dict,
67  const bool valueRequired
68 )
69 :
70  Field<Type>(p.size()),
71  patch_(p),
72  internalField_(iF)
73 {
74  if (valueRequired)
75  {
76  if (dict.found("value"))
77  {
79  (
80  Field<Type>("value", iF.dimensions(), dict, p.size())
81  );
82  }
83  else
84  {
86  (
87  dict
88  ) << "essential value entry not provided"
89  << exit(FatalIOError);
90  }
91  }
92 }
93 
94 
95 template<class Type>
97 (
98  const fvsPatchField<Type>& ptf,
99  const fvPatch& p,
101  const fieldMapper& mapper,
102  const bool mappingRequired
103 )
104 :
105  Field<Type>(p.size()),
106  patch_(p),
107  internalField_(iF)
108 {
109  if (mappingRequired)
110  {
111  mapper(*this, ptf);
112  }
113 }
114 
115 
116 template<class Type>
118 (
119  const fvsPatchField<Type>& ptf,
121 )
122 :
123  Field<Type>(ptf),
124  patch_(ptf.patch_),
125  internalField_(iF)
126 {}
127 
128 
129 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
130 
131 template<class Type>
133 {
134  return patch_.boundaryMesh().mesh();
135 }
136 
137 
138 template<class Type>
140 {
141  if (&patch_ != &(ptf.patch_))
142  {
144  << "different patches for fvsPatchField<Type>s"
145  << abort(FatalError);
146  }
147 }
148 
149 
150 template<class Type>
152 (
153  const fvsPatchField<Type>& ptf,
154  const fieldMapper& mapper
155 )
156 {
157  mapper(*this, ptf);
158 }
159 
160 
161 template<class Type>
163 {
164  Field<Type>::reset(ptf);
165 }
166 
167 
168 template<class Type>
170 {
171  writeEntry(os, "type", type());
172 
173  if (overridesConstraint())
174  {
175  writeEntry(os, "patchType", patch().type());
176  }
177 }
178 
179 
180 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
181 
182 template<class Type>
184 (
185  const UList<Type>& ul
186 )
187 {
189 }
190 
191 
192 template<class Type>
194 (
195  const fvsPatchField<Type>& ptf
196 )
197 {
198  check(ptf);
200 }
201 
202 
203 template<class Type>
205 (
206  const fvsPatchField<Type>& ptf
207 )
208 {
209  check(ptf);
211 }
212 
213 
214 template<class Type>
216 (
217  const fvsPatchField<Type>& ptf
218 )
219 {
220  check(ptf);
222 }
223 
224 
225 template<class Type>
227 (
228  const fvsPatchField<scalar>& ptf
229 )
230 {
231  if (&patch_ != &ptf.patch())
232  {
234  << "incompatible patches for patch fields"
235  << abort(FatalError);
236  }
237 
239 }
240 
241 
242 template<class Type>
244 (
245  const fvsPatchField<scalar>& ptf
246 )
247 {
248  if (&patch_ != &ptf.patch())
249  {
251  << abort(FatalError);
252  }
253 
255 }
256 
257 
258 template<class Type>
260 (
261  const Field<Type>& tf
262 )
263 {
265 }
266 
267 
268 template<class Type>
270 (
271  const Field<Type>& tf
272 )
273 {
275 }
276 
277 
278 template<class Type>
280 (
281  const scalarField& tf
282 )
283 {
285 }
286 
287 
288 template<class Type>
290 (
291  const scalarField& tf
292 )
293 {
295 }
296 
297 
298 template<class Type>
300 (
301  const Type& t
302 )
303 {
305 }
306 
307 
308 template<class Type>
310 (
311  const Type& t
312 )
313 {
315 }
316 
317 
318 template<class Type>
320 (
321  const Type& t
322 )
323 {
325 }
326 
327 
328 template<class Type>
330 (
331  const scalar s
332 )
333 {
335 }
336 
337 
338 template<class Type>
340 (
341  const scalar s
342 )
343 {
345 }
346 
347 
348 template<class Type>
350 (
351  const fvsPatchField<Type>& ptf
352 )
353 {
355 }
356 
357 
358 template<class Type>
360 (
361  const Field<Type>& tf
362 )
363 {
365 }
366 
367 
368 template<class Type>
370 (
371  const Type& t
372 )
373 {
375 }
376 
377 
378 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
379 
380 template<class Type>
382 {
383  ptf.write(os);
384 
385  os.check("Ostream& operator<<(Ostream&, const fvsPatchField<Type>&");
386 
387  return os;
388 }
389 
390 
391 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
392 
393 #include "fvsPatchFieldNew.C"
394 
395 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const dimensionSet & dimensions() const
Return dimensions.
Pre-declare SubField and related Field type.
Definition: Field.H:83
void operator=(const Field< Type > &)
Definition: Field.C:550
void operator+=(const UList< Type > &)
Definition: Field.C:655
void operator-=(const UList< Type > &)
Definition: Field.C:656
void operator*=(const UList< scalar > &)
Definition: Field.C:657
void operator/=(const UList< scalar > &)
Definition: Field.C:658
void reset(const Field< Type > &)
Reset the field values to the given field.
Definition: Field.C:456
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:92
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Abstract base class for field mapping.
Definition: fieldMapper.H:48
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:83
virtual void write(Ostream &) const
Write.
virtual void reset(const fvsPatchField< Type > &)
Reset the fvsPatchField to the given fvsPatchField.
fvsPatchField(const fvPatch &, const DimensionedField< Type, surfaceMesh > &)
Construct from patch and internal field.
Definition: fvsPatchField.C:36
const objectRegistry & db() const
Return local objectRegistry.
virtual void map(const fvsPatchField< Type > &, const fieldMapper &)
Map the given fvsPatchField onto this fvsPatchField.
void check(const fvsPatchField< Type > &) const
Check fvsPatchField<Type> against given fvsPatchField<Type>
const fvPatch & patch() const
Return patch.
Registry of regIOobjects.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:346
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
const tensorField & tf
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
errorManip< error > abort(error &err)
Definition: errorManip.H:131
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
IOerror FatalIOError
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)
error FatalError
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
labelList f(nPoints)
dictionary dict
volScalarField & p