1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
28 #include "dictionary.H"
30 #include "fvPatchFieldMapper.H"
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35 Foam::fvPatchField<Type>::fvPatchField
38 const DimensionedField<Type, volMesh>& iF
41 Field<Type>(p.size()),
45 patchType_(word::null)
50 Foam::fvPatchField<Type>::fvPatchField
53 const DimensionedField<Type, volMesh>& iF,
61 patchType_(word::null)
66 Foam::fvPatchField<Type>::fvPatchField
68 const fvPatchField<Type>& ptf,
70 const DimensionedField<Type, volMesh>& iF,
71 const fvPatchFieldMapper& mapper
74 Field<Type>(ptf, mapper),
78 patchType_(ptf.patchType_)
83 Foam::fvPatchField<Type>::fvPatchField
86 const DimensionedField<Type, volMesh>& iF,
87 const dictionary& dict,
88 const bool valueRequired
91 Field<Type>(p.size()),
95 patchType_(dict.lookupOrDefault<word>("patchType", word::null))
97 if (dict.found("value"))
99 fvPatchField<Type>::operator=
101 Field<Type>("value", dict, p.size())
104 else if (!valueRequired)
106 fvPatchField<Type>::operator=(pTraits<Type>::zero);
112 "fvPatchField<Type>::fvPatchField"
115 "const DimensionedField<Type, volMesh>& iF,"
116 "const dictionary& dict,"
117 "const bool valueRequired"
120 ) << "Essential entry 'value' missing"
121 << exit(FatalIOError);
127 Foam::fvPatchField<Type>::fvPatchField
129 const fvPatchField<Type>& ptf
134 internalField_(ptf.internalField_),
136 patchType_(ptf.patchType_)
141 Foam::fvPatchField<Type>::fvPatchField
143 const fvPatchField<Type>& ptf,
144 const DimensionedField<Type, volMesh>& iF
151 patchType_(ptf.patchType_)
155 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
158 const Foam::objectRegistry& Foam::fvPatchField<Type>::db() const
160 return patch_.boundaryMesh().mesh();
165 void Foam::fvPatchField<Type>::check(const fvPatchField<Type>& ptf) const
167 if (&patch_ != &(ptf.patch_))
169 FatalErrorIn("PatchField<Type>::check(const fvPatchField<Type>&)")
170 << "different patches for fvPatchField<Type>s"
171 << abort(FatalError);
176 // Return gradient at boundary
178 Foam::tmp<Foam::Field<Type> > Foam::fvPatchField<Type>::snGrad() const
180 return (*this - patchInternalField())*patch_.deltaCoeffs();
184 // Return internal field next to patch as patch field
186 Foam::tmp<Foam::Field<Type> >
187 Foam::fvPatchField<Type>::patchInternalField() const
189 return patch_.patchInternalField(internalField_);
194 void Foam::fvPatchField<Type>::autoMap
196 const fvPatchFieldMapper& m
199 Field<Type>::autoMap(m);
204 void Foam::fvPatchField<Type>::rmap
206 const fvPatchField<Type>& ptf,
207 const labelList& addr
210 Field<Type>::rmap(ptf, addr);
215 void Foam::fvPatchField<Type>::evaluate(const Pstream::commsTypes)
227 void Foam::fvPatchField<Type>::manipulateMatrix(fvMatrix<Type>& matrix)
234 void Foam::fvPatchField<Type>::write(Ostream& os) const
236 os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
238 if (patchType_.size())
240 os.writeKeyword("patchType") << patchType_
241 << token::END_STATEMENT << nl;
247 template<class EntryType>
248 void Foam::fvPatchField<Type>::writeEntryIfDifferent
251 const word& entryName,
252 const EntryType& value1,
253 const EntryType& value2
256 if (value1 != value2)
258 os.writeKeyword(entryName) << value2 << token::END_STATEMENT << nl;
263 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
266 void Foam::fvPatchField<Type>::operator=
268 const UList<Type>& ul
271 Field<Type>::operator=(ul);
276 void Foam::fvPatchField<Type>::operator=
278 const fvPatchField<Type>& ptf
282 Field<Type>::operator=(ptf);
287 void Foam::fvPatchField<Type>::operator+=
289 const fvPatchField<Type>& ptf
293 Field<Type>::operator+=(ptf);
298 void Foam::fvPatchField<Type>::operator-=
300 const fvPatchField<Type>& ptf
304 Field<Type>::operator-=(ptf);
309 void Foam::fvPatchField<Type>::operator*=
311 const fvPatchField<scalar>& ptf
314 if (&patch_ != &ptf.patch())
318 "PatchField<Type>::operator*=(const fvPatchField<scalar>& ptf)"
319 ) << "incompatible patches for patch fields"
320 << abort(FatalError);
323 Field<Type>::operator*=(ptf);
328 void Foam::fvPatchField<Type>::operator/=
330 const fvPatchField<scalar>& ptf
333 if (&patch_ != &ptf.patch())
337 "PatchField<Type>::operator/=(const fvPatchField<scalar>& ptf)"
338 ) << " incompatible patches for patch fields"
339 << abort(FatalError);
342 Field<Type>::operator/=(ptf);
347 void Foam::fvPatchField<Type>::operator+=
349 const Field<Type>& tf
352 Field<Type>::operator+=(tf);
357 void Foam::fvPatchField<Type>::operator-=
359 const Field<Type>& tf
362 Field<Type>::operator-=(tf);
367 void Foam::fvPatchField<Type>::operator*=
369 const scalarField& tf
372 Field<Type>::operator*=(tf);
377 void Foam::fvPatchField<Type>::operator/=
379 const scalarField& tf
382 Field<Type>::operator/=(tf);
387 void Foam::fvPatchField<Type>::operator=
392 Field<Type>::operator=(t);
397 void Foam::fvPatchField<Type>::operator+=
402 Field<Type>::operator+=(t);
407 void Foam::fvPatchField<Type>::operator-=
412 Field<Type>::operator-=(t);
417 void Foam::fvPatchField<Type>::operator*=
422 Field<Type>::operator*=(s);
427 void Foam::fvPatchField<Type>::operator/=
432 Field<Type>::operator/=(s);
436 // Force an assignment, overriding fixedValue status
438 void Foam::fvPatchField<Type>::operator==
440 const fvPatchField<Type>& ptf
443 Field<Type>::operator=(ptf);
448 void Foam::fvPatchField<Type>::operator==
450 const Field<Type>& tf
453 Field<Type>::operator=(tf);
458 void Foam::fvPatchField<Type>::operator==
463 Field<Type>::operator=(t);
467 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
470 Foam::Ostream& Foam::operator<<(Ostream& os, const fvPatchField<Type>& ptf)
474 os.check("Ostream& operator<<(Ostream&, const fvPatchField<Type>&");
480 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
482 # include "newFvPatchField.C"
484 // ************************************************************************* //