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-2023 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 "fvPatchFieldMapper.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", 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 fvPatchFieldMapper& 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_.boundaryMesh().mesh();
134 }
135 
136 
137 template<class Type>
139 {
140  if (&patch_ != &(ptf.patch_))
141  {
143  << "different patches for fvsPatchField<Type>s"
144  << abort(FatalError);
145  }
146 }
147 
148 
149 template<class Type>
151 (
152  const fvsPatchField<Type>& ptf,
153  const fvPatchFieldMapper& mapper
154 )
155 {
156  mapper(*this, ptf);
157 }
158 
159 
160 template<class Type>
162 {
163  Field<Type>::reset(ptf);
164 }
165 
166 
167 template<class Type>
169 {
170  writeEntry(os, "type", type());
171 
172  if (overridesConstraint())
173  {
174  writeEntry(os, "patchType", patch().type());
175  }
176 }
177 
178 
179 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
180 
181 template<class Type>
183 (
184  const UList<Type>& ul
185 )
186 {
188 }
189 
190 
191 template<class Type>
193 (
194  const fvsPatchField<Type>& ptf
195 )
196 {
197  check(ptf);
199 }
200 
201 
202 template<class Type>
204 (
205  const fvsPatchField<Type>& ptf
206 )
207 {
208  check(ptf);
210 }
211 
212 
213 template<class Type>
215 (
216  const fvsPatchField<Type>& ptf
217 )
218 {
219  check(ptf);
221 }
222 
223 
224 template<class Type>
226 (
227  const fvsPatchField<scalar>& ptf
228 )
229 {
230  if (&patch_ != &ptf.patch())
231  {
233  << "incompatible patches for patch fields"
234  << abort(FatalError);
235  }
236 
238 }
239 
240 
241 template<class Type>
243 (
244  const fvsPatchField<scalar>& ptf
245 )
246 {
247  if (&patch_ != &ptf.patch())
248  {
250  << abort(FatalError);
251  }
252 
254 }
255 
256 
257 template<class Type>
259 (
260  const Field<Type>& tf
261 )
262 {
264 }
265 
266 
267 template<class Type>
269 (
270  const Field<Type>& tf
271 )
272 {
274 }
275 
276 
277 template<class Type>
279 (
280  const scalarField& tf
281 )
282 {
284 }
285 
286 
287 template<class Type>
289 (
290  const scalarField& tf
291 )
292 {
294 }
295 
296 
297 template<class Type>
299 (
300  const Type& t
301 )
302 {
304 }
305 
306 
307 template<class Type>
309 (
310  const Type& t
311 )
312 {
314 }
315 
316 
317 template<class Type>
319 (
320  const Type& t
321 )
322 {
324 }
325 
326 
327 template<class Type>
329 (
330  const scalar s
331 )
332 {
334 }
335 
336 
337 template<class Type>
339 (
340  const scalar s
341 )
342 {
344 }
345 
346 
347 template<class Type>
349 (
350  const fvsPatchField<Type>& ptf
351 )
352 {
354 }
355 
356 
357 template<class Type>
359 (
360  const Field<Type>& tf
361 )
362 {
364 }
365 
366 
367 template<class Type>
369 (
370  const Type& t
371 )
372 {
374 }
375 
376 
377 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
378 
379 template<class Type>
381 {
382  ptf.write(os);
383 
384  os.check("Ostream& operator<<(Ostream&, const fvsPatchField<Type>&");
385 
386  return os;
387 }
388 
389 
390 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
391 
392 #include "fvsPatchFieldNew.C"
393 
394 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Pre-declare SubField and related Field type.
Definition: Field.H:82
void operator=(const Field< Type > &)
Definition: Field.C:526
void operator+=(const UList< Type > &)
Definition: Field.C:631
void operator-=(const UList< Type > &)
Definition: Field.C:632
void operator*=(const UList< scalar > &)
Definition: Field.C:633
void operator/=(const UList< scalar > &)
Definition: Field.C:634
void reset(const Field< Type > &)
Reset the field values to the given field.
Definition: Field.C:432
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:160
Foam::fvPatchFieldMapper.
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:82
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.
void check(const fvsPatchField< Type > &) const
Check fvsPatchField<Type> against given fvsPatchField<Type>
const fvPatch & patch() const
Return patch.
virtual void map(const fvsPatchField< Type > &, const fvPatchFieldMapper &)
Map the given fvsPatchField onto this fvsPatchField.
Registry of regIOobjects.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:318
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
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
error FatalError
Ostream & operator<<(Ostream &, const ensightPart &)
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