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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "faPatchField.H"
29 #include "faPatchFieldMapper.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 template<class Type>
35 (
36  const faPatch& p,
38 )
39 :
40  Field<Type>(p.size()),
41  patch_(p),
42  internalField_(iF),
43  updated_(false),
44  patchType_(word::null)
45 {}
46 
47 
48 template<class Type>
50 (
51  const faPatch& p,
53  const Field<Type>& f
54 )
55 :
56  Field<Type>(f),
57  patch_(p),
58  internalField_(iF),
59  updated_(false),
60  patchType_(word::null)
61 {}
62 
63 
64 template<class Type>
66 (
67  const faPatchField<Type>& ptf,
68  const faPatch& p,
70  const faPatchFieldMapper& mapper
71 )
72 :
73  Field<Type>(ptf, mapper),
74  patch_(p),
75  internalField_(iF),
76  updated_(false),
77  patchType_(word::null)
78 {}
79 
80 
81 template<class Type>
83 (
84  const faPatch& p,
86  const dictionary& dict
87 )
88 :
89  Field<Type>(p.size()),
90  patch_(p),
91  internalField_(iF),
92  updated_(false),
93  patchType_(dict.lookupOrDefault<word>("patchType", word::null))
94 {
95  if (dict.found("value"))
96  {
98  (
99  Field<Type>("value", dict, p.size())
100  );
101  }
102  else
103  {
105  }
106 }
107 
108 
109 template<class Type>
111 (
112  const faPatchField<Type>& ptf
113 )
114 :
115  Field<Type>(ptf),
116  patch_(ptf.patch_),
117  internalField_(ptf.internalField_),
118  updated_(false),
119  patchType_(ptf.patchType_)
120 {}
121 
122 
123 template<class Type>
125 (
126  const faPatchField<Type>& ptf,
128 )
129 :
130  Field<Type>(ptf),
131  patch_(ptf.patch_),
132  internalField_(iF),
133  updated_(false),
134  patchType_(ptf.patchType_)
135 {}
136 
137 
138 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
139 
140 template<class Type>
142 {
143  // Note: Lookup fields from the field DB rather than the mesh
144  return internalField_.db();
145 }
146 
147 
148 template<class Type>
150 {
151  if (&patch_ != &(ptf.patch_))
152  {
154  << "different patches for faPatchField<Type>s"
155  << abort(FatalError);
156  }
157 }
158 
159 
160 template<class Type>
162 {
163  return (*this - patchInternalField())*patch_.deltaCoeffs();
164 }
165 
166 
167 template<class Type>
170 {
171  return patch_.patchInternalField(internalField_);
172 }
173 
174 
175 template<class Type>
177 {
179 }
180 
181 
182 template<class Type>
184 (
185  const faPatchField<Type>& ptf,
186  const labelList& addr
187 )
188 {
189  Field<Type>::rmap(ptf, addr);
190 }
191 
192 
193 template<class Type>
195 {
196  if (!updated_)
197  {
198  updateCoeffs();
199  }
200 
201  updated_ = false;
202 }
203 
204 
205 template<class Type>
207 {
208  os.writeEntry("type", type());
209 
210  if (patchType_.size())
211  {
212  os.writeEntry("patchType", patchType_);
213  }
214 }
215 
216 
217 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
218 
219 template<class Type>
221 (
222  const UList<Type>& ul
223 )
224 {
226 }
227 
228 
229 template<class Type>
231 (
232  const faPatchField<Type>& ptf
233 )
234 {
235  check(ptf);
237 }
238 
239 
240 template<class Type>
242 (
243  const faPatchField<Type>& ptf
244 )
245 {
246  check(ptf);
248 }
249 
250 
251 template<class Type>
253 (
254  const faPatchField<Type>& ptf
255 )
256 {
257  check(ptf);
259 }
260 
261 
262 template<class Type>
264 (
265  const faPatchField<scalar>& ptf
266 )
267 {
268  if (&patch_ != &ptf.patch())
269  {
271  << "incompatible patches for patch fields"
272  << abort(FatalError);
273  }
274 
276 }
277 
278 
279 template<class Type>
281 (
282  const faPatchField<scalar>& ptf
283 )
284 {
285  if (&patch_ != &ptf.patch())
286  {
288  << " incompatible patches for patch fields"
289  << abort(FatalError);
290  }
291 
293 }
294 
295 
296 template<class Type>
298 (
299  const Field<Type>& tf
300 )
301 {
303 }
304 
305 
306 template<class Type>
308 (
309  const Field<Type>& tf
310 )
311 {
313 }
314 
315 
316 template<class Type>
318 (
319  const scalarField& tf
320 )
321 {
323 }
324 
325 
326 template<class Type>
328 (
329  const scalarField& tf
330 )
331 {
333 }
334 
335 
336 template<class Type>
338 (
339  const Type& t
340 )
341 {
343 }
344 
345 
346 template<class Type>
348 (
349  const Type& t
350 )
351 {
353 }
354 
355 
356 template<class Type>
358 (
359  const Type& t
360 )
361 {
363 }
364 
365 
366 template<class Type>
368 (
369  const scalar s
370 )
371 {
373 }
374 
375 
376 template<class Type>
378 (
379  const scalar s
380 )
381 {
383 }
384 
385 
386 template<class Type>
388 (
389  const faPatchField<Type>& ptf
390 )
391 {
393 }
394 
395 
396 template<class Type>
398 (
399  const Field<Type>& tf
400 )
401 {
403 }
404 
405 
406 template<class Type>
408 (
409  const Type& t
410 )
411 {
413 }
414 
415 
416 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
417 
418 template<class Type>
420 {
421  ptf.write(os);
422 
423  os.check(FUNCTION_NAME);
424 
425  return os;
426 }
427 
428 
429 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
430 
431 #include "faPatchFieldNew.C"
432 
433 // ************************************************************************* //
Foam::faPatchField::faPatchField
faPatchField(const faPatch &, const DimensionedField< Type, areaMesh > &)
Construct from patch and internal field.
Definition: faPatchField.C:35
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:206
Foam::faPatchField::snGrad
virtual tmp< Field< Type > > snGrad() const
Return patch-normal gradient.
Definition: faPatchField.C:161
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
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:59
Foam::faPatchField::check
void check(const faPatchField< Type > &) const
Check faPatchField<Type> against given faPatchField<Type>
Definition: faPatchField.C:149
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:176
faPatchFieldMapper.H
Foam::IOobject::db
const objectRegistry & db() const
Return the local objectRegistry.
Definition: IOobject.C:432
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
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:169
Foam::faPatchField::evaluate
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field, sets Updated to false.
Definition: faPatchField.C:194
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:51
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:121
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:137
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:66
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:355
f
labelList f(nPoints)
Foam::List< label >
Foam::pTraits
Traits class for primitives.
Definition: pTraits.H:52
Foam::UList< Type >
Foam::faPatchField::db
const objectRegistry & db() const
Return local objectRegistry.
Definition: faPatchField.C:141
Foam::faPatchField::rmap
virtual void rmap(const faPatchField< Type > &, const labelList &)
Reverse map the given faPatchField onto this faPatchField.
Definition: faPatchField.C:184
FUNCTION_NAME
#define FUNCTION_NAME
Definition: messageStream.H:261
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:219
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:65
Foam::faPatchField::patch
const faPatch & patch() const
Return patch.
Definition: faPatchField.H:281
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &)
Definition: boundaryPatch.C:102
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54