Fix tutorials: coupled/conjugateHeatFoam/conjugateCavity: fix Allrun file
[OpenFOAM-1.6-ext.git] / src / finiteVolume / fields / fvPatchFields / fvPatchField / fvPatchField.C
blobaab884b4afb1d6caae185ab60d70f44b6328d87a
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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 \*---------------------------------------------------------------------------*/
27 #include "IOobject.H"
28 #include "dictionary.H"
29 #include "fvMesh.H"
30 #include "fvPatchFieldMapper.H"
32 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
34 template<class Type>
35 Foam::fvPatchField<Type>::fvPatchField
37     const fvPatch& p,
38     const DimensionedField<Type, volMesh>& iF
41     Field<Type>(p.size()),
42     patch_(p),
43     internalField_(iF),
44     updated_(false),
45     patchType_(word::null)
49 template<class Type>
50 Foam::fvPatchField<Type>::fvPatchField
52     const fvPatch& p,
53     const DimensionedField<Type, volMesh>& iF,
54     const Field<Type>& f
57     Field<Type>(f),
58     patch_(p),
59     internalField_(iF),
60     updated_(false),
61     patchType_(word::null)
65 template<class Type>
66 Foam::fvPatchField<Type>::fvPatchField
68     const fvPatchField<Type>& ptf,
69     const fvPatch& p,
70     const DimensionedField<Type, volMesh>& iF,
71     const fvPatchFieldMapper& mapper
74     Field<Type>(ptf, mapper),
75     patch_(p),
76     internalField_(iF),
77     updated_(false),
78     patchType_(ptf.patchType_)
82 template<class Type>
83 Foam::fvPatchField<Type>::fvPatchField
85     const fvPatch& p,
86     const DimensionedField<Type, volMesh>& iF,
87     const dictionary& dict,
88     const bool valueRequired
91     Field<Type>(p.size()),
92     patch_(p),
93     internalField_(iF),
94     updated_(false),
95     patchType_(dict.lookupOrDefault<word>("patchType", word::null))
97     if (dict.found("value"))
98     {
99         fvPatchField<Type>::operator=
100         (
101             Field<Type>("value", dict, p.size())
102         );
103     }
104     else if (!valueRequired)
105     {
106         fvPatchField<Type>::operator=(pTraits<Type>::zero);
107     }
108     else
109     {
110         FatalIOErrorIn
111         (
112             "fvPatchField<Type>::fvPatchField"
113             "("
114             "const fvPatch& p,"
115             "const DimensionedField<Type, volMesh>& iF,"
116             "const dictionary& dict,"
117             "const bool valueRequired"
118             ")",
119             dict
120         )   << "Essential entry 'value' missing"
121             << exit(FatalIOError);
122     }
126 template<class Type>
127 Foam::fvPatchField<Type>::fvPatchField
129     const fvPatchField<Type>& ptf
132     Field<Type>(ptf),
133     patch_(ptf.patch_),
134     internalField_(ptf.internalField_),
135     updated_(false),
136     patchType_(ptf.patchType_)
140 template<class Type>
141 Foam::fvPatchField<Type>::fvPatchField
143     const fvPatchField<Type>& ptf,
144     const DimensionedField<Type, volMesh>& iF
147     Field<Type>(ptf),
148     patch_(ptf.patch_),
149     internalField_(iF),
150     updated_(false),
151     patchType_(ptf.patchType_)
155 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
157 template<class Type>
158 const Foam::objectRegistry& Foam::fvPatchField<Type>::db() const
160     return patch_.boundaryMesh().mesh();
164 template<class Type>
165 void Foam::fvPatchField<Type>::check(const fvPatchField<Type>& ptf) const
167     if (&patch_ != &(ptf.patch_))
168     {
169         FatalErrorIn("PatchField<Type>::check(const fvPatchField<Type>&)")
170             << "different patches for fvPatchField<Type>s"
171             << abort(FatalError);
172     }
176 // Return gradient at boundary
177 template<class Type>
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
185 template<class Type>
186 Foam::tmp<Foam::Field<Type> >
187 Foam::fvPatchField<Type>::patchInternalField() const
189     return patch_.patchInternalField(internalField_);
193 template<class Type>
194 void Foam::fvPatchField<Type>::autoMap
196     const fvPatchFieldMapper& m
199     Field<Type>::autoMap(m);
203 template<class Type>
204 void Foam::fvPatchField<Type>::rmap
206     const fvPatchField<Type>& ptf,
207     const labelList& addr
210     Field<Type>::rmap(ptf, addr);
214 template<class Type>
215 void Foam::fvPatchField<Type>::evaluate(const Pstream::commsTypes)
217     if (!updated_)
218     {
219         updateCoeffs();
220     }
222     updated_ = false;
226 template<class Type>
227 void Foam::fvPatchField<Type>::manipulateMatrix(fvMatrix<Type>& matrix)
229     // do nothing
233 template<class Type>
234 void Foam::fvPatchField<Type>::write(Ostream& os) const
236     os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
238     if (patchType_.size())
239     {
240         os.writeKeyword("patchType") << patchType_
241             << token::END_STATEMENT << nl;
242     }
246 template<class Type>
247 template<class EntryType>
248 void Foam::fvPatchField<Type>::writeEntryIfDifferent
250     Ostream& os,
251     const word& entryName,
252     const EntryType& value1,
253     const EntryType& value2
254 ) const
256     if (value1 != value2)
257     {
258         os.writeKeyword(entryName) << value2 << token::END_STATEMENT << nl;
259     }
263 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
265 template<class Type>
266 void Foam::fvPatchField<Type>::operator=
268     const UList<Type>& ul
271     Field<Type>::operator=(ul);
275 template<class Type>
276 void Foam::fvPatchField<Type>::operator=
278     const fvPatchField<Type>& ptf
281     check(ptf);
282     Field<Type>::operator=(ptf);
286 template<class Type>
287 void Foam::fvPatchField<Type>::operator+=
289     const fvPatchField<Type>& ptf
292     check(ptf);
293     Field<Type>::operator+=(ptf);
297 template<class Type>
298 void Foam::fvPatchField<Type>::operator-=
300     const fvPatchField<Type>& ptf
303     check(ptf);
304     Field<Type>::operator-=(ptf);
308 template<class Type>
309 void Foam::fvPatchField<Type>::operator*=
311     const fvPatchField<scalar>& ptf
314     if (&patch_ != &ptf.patch())
315     {
316         FatalErrorIn
317         (
318             "PatchField<Type>::operator*=(const fvPatchField<scalar>& ptf)"
319         )   << "incompatible patches for patch fields"
320             << abort(FatalError);
321     }
323     Field<Type>::operator*=(ptf);
327 template<class Type>
328 void Foam::fvPatchField<Type>::operator/=
330     const fvPatchField<scalar>& ptf
333     if (&patch_ != &ptf.patch())
334     {
335         FatalErrorIn
336         (
337             "PatchField<Type>::operator/=(const fvPatchField<scalar>& ptf)"
338         )   << "    incompatible patches for patch fields"
339             << abort(FatalError);
340     }
342     Field<Type>::operator/=(ptf);
346 template<class Type>
347 void Foam::fvPatchField<Type>::operator+=
349     const Field<Type>& tf
352     Field<Type>::operator+=(tf);
356 template<class Type>
357 void Foam::fvPatchField<Type>::operator-=
359     const Field<Type>& tf
362     Field<Type>::operator-=(tf);
366 template<class Type>
367 void Foam::fvPatchField<Type>::operator*=
369     const scalarField& tf
372     Field<Type>::operator*=(tf);
376 template<class Type>
377 void Foam::fvPatchField<Type>::operator/=
379     const scalarField& tf
382     Field<Type>::operator/=(tf);
386 template<class Type>
387 void Foam::fvPatchField<Type>::operator=
389     const Type& t
392     Field<Type>::operator=(t);
396 template<class Type>
397 void Foam::fvPatchField<Type>::operator+=
399     const Type& t
402     Field<Type>::operator+=(t);
406 template<class Type>
407 void Foam::fvPatchField<Type>::operator-=
409     const Type& t
412     Field<Type>::operator-=(t);
416 template<class Type>
417 void Foam::fvPatchField<Type>::operator*=
419     const scalar s
422     Field<Type>::operator*=(s);
426 template<class Type>
427 void Foam::fvPatchField<Type>::operator/=
429     const scalar s
432     Field<Type>::operator/=(s);
436 // Force an assignment, overriding fixedValue status
437 template<class Type>
438 void Foam::fvPatchField<Type>::operator==
440     const fvPatchField<Type>& ptf
443     Field<Type>::operator=(ptf);
447 template<class Type>
448 void Foam::fvPatchField<Type>::operator==
450     const Field<Type>& tf
453     Field<Type>::operator=(tf);
457 template<class Type>
458 void Foam::fvPatchField<Type>::operator==
460     const Type& t
463     Field<Type>::operator=(t);
467 // * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
469 template<class Type>
470 Foam::Ostream& Foam::operator<<(Ostream& os, const fvPatchField<Type>& ptf)
472     ptf.write(os);
474     os.check("Ostream& operator<<(Ostream&, const fvPatchField<Type>&");
476     return os;
480 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
482 #   include "newFvPatchField.C"
484 // ************************************************************************* //