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-2026 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 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 template<class Type>
35 (
36  const fvPatch& p,
38 )
39 :
40  Field<Type>(p.size()),
41  patch_(p),
42  internalField_(iF)
43 {}
44 
45 
46 template<class Type>
48 (
49  const fvPatch& p,
51  const Field<Type>& f
52 )
53 :
54  Field<Type>(f),
55  patch_(p),
56  internalField_(iF)
57 {}
58 
59 
60 template<class Type>
62 (
63  const fvPatch& p,
65  const dictionary& dict,
66  const bool valueRequired
67 )
68 :
69  Field<Type>(p.size()),
70  patch_(p),
71  internalField_(iF)
72 {
73  if (valueRequired)
74  {
75  if (dict.found("value"))
76  {
78  (
79  Field<Type>("value", iF.dimensions(), dict, p.size())
80  );
81  }
82  else
83  {
85  (
86  dict
87  ) << "essential value entry not provided"
88  << exit(FatalIOError);
89  }
90  }
91 }
92 
93 
94 template<class Type>
96 (
97  const fvsPatchField<Type>& ptf,
98  const fvPatch& p,
100  const fieldMapper& mapper,
101  const bool mappingRequired
102 )
103 :
104  Field<Type>(p.size()),
105  patch_(p),
106  internalField_(iF)
107 {
108  if (mappingRequired)
109  {
110  mapper(*this, ptf);
111  }
112 }
113 
114 
115 template<class Type>
117 (
118  const fvsPatchField<Type>& ptf,
120 )
121 :
122  Field<Type>(ptf),
123  patch_(ptf.patch_),
124  internalField_(iF)
125 {}
126 
127 
128 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
129 
130 template<class Type>
132 {
133  return patch_.mesh();
134 }
135 
136 
137 template<class Type>
139 {
140  return patch_.time();
141 }
142 
143 
144 template<class Type>
146 {
147  if (&patch_ != &(ptf.patch_))
148  {
150  << "different patches for fvsPatchField<Type>s"
151  << abort(FatalError);
152  }
153 }
154 
155 
156 template<class Type>
158 (
159  const fvsPatchField<Type>& ptf,
160  const fieldMapper& mapper
161 )
162 {
163  mapper(*this, ptf);
164 }
165 
166 
167 template<class Type>
169 {
170  Field<Type>::reset(ptf);
171 }
172 
173 
174 template<class Type>
176 {
177  writeEntry(os, "type", type());
178 
179  if (overridesConstraint())
180  {
181  writeEntry(os, "patchType", patch().type());
182  }
183 }
184 
185 
186 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
187 
188 template<class Type>
190 (
191  const UList<Type>& ul
192 )
193 {
195 }
196 
197 
198 template<class Type>
200 (
201  const fvsPatchField<Type>& ptf
202 )
203 {
204  check(ptf);
206 }
207 
208 
209 template<class Type>
211 (
212  const fvsPatchField<Type>& ptf
213 )
214 {
215  check(ptf);
217 }
218 
219 
220 template<class Type>
222 (
223  const fvsPatchField<Type>& ptf
224 )
225 {
226  check(ptf);
228 }
229 
230 
231 template<class Type>
233 (
234  const fvsPatchField<scalar>& ptf
235 )
236 {
237  if (&patch_ != &ptf.patch())
238  {
240  << "incompatible patches for patch fields"
241  << abort(FatalError);
242  }
243 
245 }
246 
247 
248 template<class Type>
250 (
251  const fvsPatchField<scalar>& ptf
252 )
253 {
254  if (&patch_ != &ptf.patch())
255  {
257  << abort(FatalError);
258  }
259 
261 }
262 
263 
264 template<class Type>
266 (
267  const Field<Type>& tf
268 )
269 {
271 }
272 
273 
274 template<class Type>
276 (
277  const Field<Type>& tf
278 )
279 {
281 }
282 
283 
284 template<class Type>
286 (
287  const scalarField& tf
288 )
289 {
291 }
292 
293 
294 template<class Type>
296 (
297  const scalarField& tf
298 )
299 {
301 }
302 
303 
304 template<class Type>
306 (
307  const Type& t
308 )
309 {
311 }
312 
313 
314 template<class Type>
316 (
317  const Type& t
318 )
319 {
321 }
322 
323 
324 template<class Type>
326 (
327  const Type& t
328 )
329 {
331 }
332 
333 
334 template<class Type>
336 (
337  const scalar s
338 )
339 {
341 }
342 
343 
344 template<class Type>
346 (
347  const scalar s
348 )
349 {
351 }
352 
353 
354 template<class Type>
356 (
357  const fvsPatchField<Type>& ptf
358 )
359 {
361 }
362 
363 
364 template<class Type>
366 (
367  const Field<Type>& tf
368 )
369 {
371 }
372 
373 
374 template<class Type>
376 (
377  const Type& t
378 )
379 {
381 }
382 
383 
384 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
385 
386 template<class Type>
388 {
389  ptf.write(os);
390 
391  os.check("Ostream& operator<<(Ostream&, const fvsPatchField<Type>&");
392 
393  return os;
394 }
395 
396 
397 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
398 
399 #include "fvsPatchFieldNew.C"
400 
401 // ************************************************************************* //
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:557
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:108
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
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:58
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:86
const Time & time() const
Return time.
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:35
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.
const Time & time() const
Return time.
#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(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), lagrangian::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
IOerror FatalIOError
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)
error FatalError
void writeEntry(Ostream &os, const word &key, const DimensionedFieldFunction< DimensionedFieldType > &f)
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