faPatchField.C
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) 2016-2017 Wikki Ltd
9  Copyright (C) 2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "faPatchField.H"
30 #include "faPatchFieldMapper.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
34 template<class Type>
36 (
37  const faPatch& p,
39 )
40 :
41  Field<Type>(p.size()),
42  patch_(p),
43  internalField_(iF),
44  updated_(false),
45  patchType_(word::null)
46 {}
47 
48 
49 template<class Type>
51 (
52  const faPatch& p,
54  const Field<Type>& f
55 )
56 :
57  Field<Type>(f),
58  patch_(p),
59  internalField_(iF),
60  updated_(false),
61  patchType_(word::null)
62 {}
63 
64 
65 template<class Type>
67 (
68  const faPatchField<Type>& ptf,
69  const faPatch& p,
71  const faPatchFieldMapper& mapper
72 )
73 :
74  Field<Type>(ptf, mapper),
75  patch_(p),
76  internalField_(iF),
77  updated_(false),
78  patchType_(word::null)
79 {}
80 
81 
82 template<class Type>
84 (
85  const faPatch& p,
87  const dictionary& dict
88 )
89 :
90  Field<Type>(p.size()),
91  patch_(p),
92  internalField_(iF),
93  updated_(false),
94  patchType_(dict.getOrDefault<word>("patchType", word::null))
95 {
96  if (dict.found("value"))
97  {
99  (
100  Field<Type>("value", dict, p.size())
101  );
102  }
103  else
104  {
106  }
107 }
108 
109 
110 template<class Type>
112 (
113  const faPatchField<Type>& ptf
114 )
115 :
116  Field<Type>(ptf),
117  patch_(ptf.patch_),
118  internalField_(ptf.internalField_),
119  updated_(false),
120  patchType_(ptf.patchType_)
121 {}
122 
123 
124 template<class Type>
126 (
127  const faPatchField<Type>& ptf,
129 )
130 :
131  Field<Type>(ptf),
132  patch_(ptf.patch_),
133  internalField_(iF),
134  updated_(false),
135  patchType_(ptf.patchType_)
136 {}
137 
138 
139 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
140 
141 template<class Type>
143 {
144  // Note: Lookup fields from the field DB rather than the mesh
145  return internalField_.db();
146 }
147 
148 
149 template<class Type>
151 {
152  if (&patch_ != &(ptf.patch_))
153  {
155  << "different patches for faPatchField<Type>s"
156  << abort(FatalError);
157  }
158 }
159 
160 
161 template<class Type>
163 {
164  return (*this - patchInternalField())*patch_.deltaCoeffs();
165 }
166 
167 
168 template<class Type>
171 {
172  return patch_.patchInternalField(internalField_);
173 }
174 
175 
176 template<class Type>
178 {
180 }
181 
182 
183 template<class Type>
185 (
186  const faPatchField<Type>& ptf,
187  const labelList& addr
188 )
189 {
190  Field<Type>::rmap(ptf, addr);
191 }
192 
193 
194 template<class Type>
196 {
197  if (!updated_)
198  {
199  updateCoeffs();
200  }
201 
202  updated_ = false;
203 }
204 
205 
206 template<class Type>
208 {
209  os.writeEntry("type", type());
210 
211  if (patchType_.size())
212  {
213  os.writeEntry("patchType", patchType_);
214  }
215 }
216 
217 
218 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
219 
220 template<class Type>
222 (
223  const UList<Type>& ul
224 )
225 {
227 }
228 
229 
230 template<class Type>
232 (
233  const faPatchField<Type>& ptf
234 )
235 {
236  check(ptf);
238 }
239 
240 
241 template<class Type>
243 (
244  const faPatchField<Type>& ptf
245 )
246 {
247  check(ptf);
249 }
250 
251 
252 template<class Type>
254 (
255  const faPatchField<Type>& ptf
256 )
257 {
258  check(ptf);
260 }
261 
262 
263 template<class Type>
265 (
266  const faPatchField<scalar>& ptf
267 )
268 {
269  if (&patch_ != &ptf.patch())
270  {
272  << "incompatible patches for patch fields"
273  << abort(FatalError);
274  }
275 
277 }
278 
279 
280 template<class Type>
282 (
283  const faPatchField<scalar>& ptf
284 )
285 {
286  if (&patch_ != &ptf.patch())
287  {
289  << " incompatible patches for patch fields"
290  << abort(FatalError);
291  }
292 
294 }
295 
296 
297 template<class Type>
299 (
300  const Field<Type>& tf
301 )
302 {
304 }
305 
306 
307 template<class Type>
309 (
310  const Field<Type>& tf
311 )
312 {
314 }
315 
316 
317 template<class Type>
319 (
320  const scalarField& tf
321 )
322 {
324 }
325 
326 
327 template<class Type>
329 (
330  const scalarField& tf
331 )
332 {
334 }
335 
336 
337 template<class Type>
339 (
340  const Type& t
341 )
342 {
344 }
345 
346 
347 template<class Type>
349 (
350  const Type& t
351 )
352 {
354 }
355 
356 
357 template<class Type>
359 (
360  const Type& t
361 )
362 {
364 }
365 
366 
367 template<class Type>
369 (
370  const scalar s
371 )
372 {
374 }
375 
376 
377 template<class Type>
379 (
380  const scalar s
381 )
382 {
384 }
385 
386 
387 template<class Type>
389 (
390  const faPatchField<Type>& ptf
391 )
392 {
394 }
395 
396 
397 template<class Type>
399 (
400  const Field<Type>& tf
401 )
402 {
404 }
405 
406 
407 template<class Type>
409 (
410  const Type& t
411 )
412 {
414 }
415 
416 
417 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
418 
419 template<class Type>
421 {
422  ptf.write(os);
423 
424  os.check(FUNCTION_NAME);
425 
426  return os;
427 }
428 
429 
430 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
431 
432 #include "faPatchFieldNew.C"
433 
434 // ************************************************************************* //
Foam::faPatchField::faPatchField
faPatchField(const faPatch &, const DimensionedField< Type, areaMesh > &)
Construct from patch and internal field.
Definition: faPatchField.C:36
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::faPatchField
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
Definition: areaFieldsFwd.H:50
Foam::faPatchField::write
virtual void write(Ostream &) const
Write.
Definition: faPatchField.C:207
Foam::faPatchField::snGrad
virtual tmp< Field< Type > > snGrad() const
Return patch-normal gradient.
Definition: faPatchField.C:162
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
s
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Definition: gmvOutputSpray.H:25
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::faPatchField::check
void check(const faPatchField< Type > &) const
Check faPatchField<Type> against given faPatchField<Type>
Definition: faPatchField.C:150
faPatchFieldNew.C
faPatchField.H
Foam::faPatchFieldMapper
Definition: faPatchFieldMapper.H:44
Foam::faPatchField::autoMap
virtual void autoMap(const faPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: faPatchField.C:177
faPatchFieldMapper.H
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::check
static void check(const int retVal, const char *what)
Definition: ptscotchDecomp.C:80
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::faPatchField::patchInternalField
virtual tmp< Field< Type > > patchInternalField() const
Return internal field next to patch as patch field.
Definition: faPatchField.C:170
Foam::faPatchField::evaluate
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field, sets Updated to false.
Definition: faPatchField.C:195
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:69
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
f
labelList f(nPoints)
Foam::List< label >
Foam::pTraits
A traits class, which is primarily used for primitives.
Definition: pTraits.H:56
Foam::UList< Type >
Foam::faPatchField::db
const objectRegistry & db() const
Return local objectRegistry.
Definition: faPatchField.C:142
Foam::faPatchField::rmap
virtual void rmap(const faPatchField< Type > &, const labelList &)
Reverse map the given faPatchField onto this faPatchField.
Definition: faPatchField.C:185
FUNCTION_NAME
#define FUNCTION_NAME
Definition: messageStream.H:295
Foam::roots::type
type
Types of root.
Definition: Roots.H:54
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::faPatch
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition: faPatch.H:69
Foam::faPatchField::patch
const faPatch & patch() const
Return patch.
Definition: faPatchField.H:279
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54
Foam::IOobject::db
const objectRegistry & db() const noexcept
Return the local objectRegistry.
Definition: IOobject.C:487