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-2022 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 :
42  Field<Type>(p.size()),
43  internalField_(iF)
44 {}
45 
46 
47 template<class Type>
49 (
50  const faPatch& p,
52  const Field<Type>& f
53 )
54 :
56  Field<Type>(f),
57  internalField_(iF)
58 {}
59 
60 
61 template<class Type>
63 (
64  const faPatchField<Type>& ptf,
65  const faPatch& p,
67  const faPatchFieldMapper& mapper
68 )
69 :
70  faPatchFieldBase(ptf, p),
71  Field<Type>(ptf, mapper),
72  internalField_(iF)
73 {}
74 
75 
76 template<class Type>
78 (
79  const faPatch& p,
81  const dictionary& dict,
82  const bool valueRequired
83 )
84 :
86  Field<Type>(p.size()),
87  internalField_(iF)
88 {
90 
91  const auto* hasValue = dict.findEntry("value", keyType::LITERAL);
92 
93  if (hasValue)
94  {
95  Field<Type>::assign(*hasValue, p.size());
96  }
97  else
98  {
100  }
101 }
102 
103 
104 template<class Type>
106 (
107  const faPatchField<Type>& ptf
108 )
109 :
110  faPatchFieldBase(ptf),
111  Field<Type>(ptf),
112  internalField_(ptf.internalField_)
113 {}
114 
115 
116 template<class Type>
118 (
119  const faPatchField<Type>& ptf,
121 )
122 :
123  faPatchFieldBase(ptf),
124  Field<Type>(ptf),
125  internalField_(iF)
126 {}
127 
128 
129 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
130 
131 template<class Type>
133 {
134  // Note: Lookup fields from the field DB rather than the mesh
135  return internalField_.db();
136 }
137 
138 
139 template<class Type>
141 {
143 }
144 
145 
146 template<class Type>
148 {
149  return (*this - patchInternalField())*patch().deltaCoeffs();
150 }
151 
152 
153 template<class Type>
156 {
157  return patch().patchInternalField(internalField_);
158 }
159 
160 
161 template<class Type>
163 {
165 }
166 
167 
168 template<class Type>
170 (
171  const faPatchField<Type>& ptf,
172  const labelList& addr
173 )
174 {
175  Field<Type>::rmap(ptf, addr);
176 }
177 
178 
179 template<class Type>
181 {
183 }
184 
185 
186 template<class Type>
188 {
189  if (!updated())
190  {
191  updateCoeffs();
192  }
193 
195 }
196 
197 
198 template<class Type>
199 void Foam::faPatchField<Type>::write(Ostream& os) const
200 {
201  os.writeEntry("type", type());
202 
203  if (!patchType().empty())
204  {
205  os.writeEntry("patchType", patchType());
206  }
207 }
208 
209 
210 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
211 
212 template<class Type>
214 (
215  const UList<Type>& ul
216 )
217 {
219 }
220 
221 
222 template<class Type>
224 (
225  const faPatchField<Type>& ptf
226 )
227 {
230 }
231 
232 
233 template<class Type>
235 (
236  const faPatchField<Type>& ptf
237 )
238 {
241 }
242 
243 
244 template<class Type>
246 (
247  const faPatchField<Type>& ptf
248 )
249 {
252 }
253 
254 
255 template<class Type>
257 (
258  const faPatchField<scalar>& ptf
259 )
260 {
263 }
264 
265 
266 template<class Type>
268 (
269  const faPatchField<scalar>& ptf
270 )
271 {
274 }
275 
276 
277 template<class Type>
279 (
280  const Field<Type>& tf
281 )
282 {
284 }
285 
286 
287 template<class Type>
289 (
290  const Field<Type>& tf
291 )
292 {
294 }
295 
296 
297 template<class Type>
299 (
300  const scalarField& tf
301 )
302 {
304 }
305 
306 
307 template<class Type>
309 (
310  const scalarField& tf
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 Type& t
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 scalar s
351 )
352 {
354 }
355 
356 
357 template<class Type>
359 (
360  const scalar s
361 )
362 {
364 }
365 
366 
367 template<class Type>
369 (
370  const faPatchField<Type>& ptf
371 )
372 {
374 }
375 
376 
377 template<class Type>
379 (
380  const Field<Type>& tf
381 )
382 {
384 }
385 
386 
387 template<class Type>
389 (
390  const Type& t
391 )
392 {
394 }
395 
396 
397 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
398 
399 template<class Type>
400 Foam::Ostream& Foam::operator<<(Ostream& os, const faPatchField<Type>& ptf)
401 {
402  ptf.write(os);
403 
405 
406  return os;
407 }
408 
409 
410 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
411 
412 #include "faPatchFieldNew.C"
413 
414 // ************************************************************************* //
virtual void autoMap(const faPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: faPatchField.C:155
dictionary dict
void operator-=(const UList< Type > &)
Definition: Field.C:724
void check(const faPatchField< Type > &) const
Check faPatchField<Type> against given faPatchField<Type>
Definition: faPatchField.C:133
commsTypes
Types of communications.
Definition: UPstream.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:120
virtual tmp< Field< Type > > snGrad() const
Return patch-normal gradient.
Definition: faPatchField.C:140
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:45
Template invariant parts for faPatchField.
Definition: faPatchField.H:74
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:312
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
Definition: areaFieldsFwd.H:56
virtual void write(Ostream &) const
Write.
Definition: faPatchField.C:192
void setUpdated(bool state) noexcept
Set updated state.
Definition: faPatchField.H:113
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: POSIX.C:752
Generic templated field type.
Definition: Field.H:61
const objectRegistry & db() const noexcept
Return the local objectRegistry.
Definition: IOobject.C:441
String literal.
Definition: keyType.H:82
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:55
OBJstream os(runTime.globalPath()/outputName)
#define FUNCTION_NAME
void operator=(const Field< Type > &)
Copy assignment.
Definition: Field.C:671
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition: faPatch.H:72
labelList f(nPoints)
virtual tmp< Field< Type > > patchInternalField() const
Return internal field next to patch as patch field.
Definition: faPatchField.C:148
void checkPatch(const faPatchFieldBase &rhs) const
Check that patches are identical.
void assign(const entry &e, const label len)
Assign from a dictionary (primitive) entry.
Definition: Field.C:195
void autoMap(const FieldMapper &map, const bool applyFlip=true)
Map from self.
Definition: Field.C:433
virtual void rmap(const faPatchField< Type > &, const labelList &)
Reverse map the given faPatchField onto this faPatchField.
Definition: faPatchField.C:163
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field, sets Updated to false.
Definition: faPatchField.C:180
void rmap(const UList< Type > &mapF, const labelUList &mapAddressing)
1 to 1 reverse-map from the given field
Definition: Field.C:496
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: faPatchField.C:173
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
const std::string patch
OpenFOAM patch number as a std::string.
const objectRegistry & db() const
Return local objectRegistry.
Definition: faPatchField.C:125
void operator+=(const UList< Type > &)
Definition: Field.C:723
volScalarField & p
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Registry of regIOobjects.
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))
A FieldMapper for finite-area patch fields.
void operator/=(const UList< scalar > &)
Definition: Field.C:726
void operator*=(const UList< scalar > &)
Definition: Field.C:725
faPatchField(const faPatch &, const DimensionedField< Type, areaMesh > &)
Construct from patch and internal field.
Definition: faPatchField.C:29
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:157