Fix tutorials: coupled/conjugateHeatFoam/conjugateCavity: fix Allrun file
[OpenFOAM-1.6-ext.git] / src / finiteVolume / fields / fvsPatchFields / fvsPatchField / fvsPatchField.C
blob22e4fe0652bcc84d7aec50f1e94fae815bf1f77b
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 namespace Foam
37 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
39 template<class Type>
40 fvsPatchField<Type>::fvsPatchField
42     const fvPatch& p,
43     const DimensionedField<Type, surfaceMesh>& iF
46     Field<Type>(p.size()),
47     patch_(p),
48     internalField_(iF)
52 template<class Type>
53 fvsPatchField<Type>::fvsPatchField
55     const fvPatch& p,
56     const DimensionedField<Type, surfaceMesh>& iF,
57     const Field<Type>& f
60     Field<Type>(f),
61     patch_(p),
62     internalField_(iF)
66 template<class Type>
67 fvsPatchField<Type>::fvsPatchField
69     const fvsPatchField<Type>& ptf,
70     const fvPatch& p,
71     const DimensionedField<Type, surfaceMesh>& iF,
72     const fvPatchFieldMapper& mapper
75     Field<Type>(ptf, mapper),
76     patch_(p),
77     internalField_(iF)
81 template<class Type>
82 fvsPatchField<Type>::fvsPatchField
84     const fvPatch& p,
85     const DimensionedField<Type, surfaceMesh>& iF,
86     const dictionary& dict,
87     const bool valueRequired
90     Field<Type>(p.size()),
91     patch_(p),
92     internalField_(iF)
94     if (dict.found("value"))
95     {
96         fvsPatchField<Type>::operator=
97         (
98             Field<Type>("value", dict, p.size())
99         );
100     }
101     else if (!valueRequired)
102     {
103         fvsPatchField<Type>::operator=(pTraits<Type>::zero);
104     }
105     else
106     {
107         FatalIOErrorIn
108         (
109             "fvsPatchField<Type>::fvsPatchField"
110             "("
111             "const fvPatch& p,"
112             "const DimensionedField<Type, surfaceMesh>& iF,"
113             "const dictionary& dict,"
114             "const bool valueRequired"
115             ")",
116             dict
117         )   << "Essential entry 'value' missing"
118             << exit(FatalIOError);
119     }
123 template<class Type>
124 fvsPatchField<Type>::fvsPatchField
126     const fvsPatchField<Type>& ptf
129     Field<Type>(ptf),
130     patch_(ptf.patch_),
131     internalField_(ptf.internalField_)
135 template<class Type>
136 fvsPatchField<Type>::fvsPatchField
138     const fvsPatchField<Type>& ptf,
139     const DimensionedField<Type, surfaceMesh>& iF
142     Field<Type>(ptf),
143     patch_(ptf.patch_),
144     internalField_(iF)
148 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
150 template<class Type>
151 const objectRegistry& fvsPatchField<Type>::db() const
153     return patch_.boundaryMesh().mesh();
157 template<class Type>
158 void fvsPatchField<Type>::check(const fvsPatchField<Type>& ptf) const
160     if (&patch_ != &(ptf.patch_))
161     {
162         FatalErrorIn("PatchField<Type>::check(const fvsPatchField<Type>&)")
163             << "different patches for fvsPatchField<Type>s"
164             << abort(FatalError);
165     }
169 // Map from self
170 template<class Type>
171 void fvsPatchField<Type>::autoMap
173     const fvPatchFieldMapper& m
176     Field<Type>::autoMap(m);
180 // Reverse-map the given fvsPatchField onto this fvsPatchField
181 template<class Type>
182 void fvsPatchField<Type>::rmap
184     const fvsPatchField<Type>& ptf,
185     const labelList& addr
188     Field<Type>::rmap(ptf, addr);
192 // Write
193 template<class Type>
194 void fvsPatchField<Type>::write(Ostream& os) const
196     os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
200 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
202 template<class Type>
203 void fvsPatchField<Type>::operator=
205     const UList<Type>& ul
208     Field<Type>::operator=(ul);
212 template<class Type>
213 void fvsPatchField<Type>::operator=
215     const fvsPatchField<Type>& ptf
218     check(ptf);
219     Field<Type>::operator=(ptf);
223 template<class Type>
224 void fvsPatchField<Type>::operator+=
226     const fvsPatchField<Type>& ptf
229     check(ptf);
230     Field<Type>::operator+=(ptf);
234 template<class Type>
235 void fvsPatchField<Type>::operator-=
237     const fvsPatchField<Type>& ptf
240     check(ptf);
241     Field<Type>::operator-=(ptf);
245 template<class Type>
246 void fvsPatchField<Type>::operator*=
248     const fvsPatchField<scalar>& ptf
251     if (&patch_ != &ptf.patch())
252     {
253         FatalErrorIn
254         (
255             "PatchField<Type>::operator*=(const fvsPatchField<scalar>& ptf)"
256         )   << "incompatible patches for patch fields"
257             << abort(FatalError);
258     }
260     Field<Type>::operator*=(ptf);
264 template<class Type>
265 void fvsPatchField<Type>::operator/=
267     const fvsPatchField<scalar>& ptf
270     if (&patch_ != &ptf.patch())
271     {
272         FatalErrorIn
273         (
274             "PatchField<Type>::operator/=(const fvsPatchField<scalar>& ptf)"
275         )   << "    incompatible patches for patch fields"
276             << abort(FatalError);
277     }
279     Field<Type>::operator/=(ptf);
283 template<class Type>
284 void fvsPatchField<Type>::operator+=
286     const Field<Type>& tf
289     Field<Type>::operator+=(tf);
293 template<class Type>
294 void fvsPatchField<Type>::operator-=
296     const Field<Type>& tf
299     Field<Type>::operator-=(tf);
303 template<class Type>
304 void fvsPatchField<Type>::operator*=
306     const scalarField& tf
309     Field<Type>::operator*=(tf);
313 template<class Type>
314 void fvsPatchField<Type>::operator/=
316     const scalarField& tf
319     Field<Type>::operator/=(tf);
323 template<class Type>
324 void fvsPatchField<Type>::operator=
326     const Type& t
329     Field<Type>::operator=(t);
333 template<class Type>
334 void fvsPatchField<Type>::operator+=
336     const Type& t
339     Field<Type>::operator+=(t);
343 template<class Type>
344 void fvsPatchField<Type>::operator-=
346     const Type& t
349     Field<Type>::operator-=(t);
353 template<class Type>
354 void fvsPatchField<Type>::operator*=
356     const scalar s
359     Field<Type>::operator*=(s);
363 template<class Type>
364 void fvsPatchField<Type>::operator/=
366     const scalar s
369     Field<Type>::operator/=(s);
373 // Force an assignment, overriding fixedValue status
374 template<class Type>
375 void fvsPatchField<Type>::operator==
377     const fvsPatchField<Type>& ptf
380     Field<Type>::operator=(ptf);
384 template<class Type>
385 void fvsPatchField<Type>::operator==
387     const Field<Type>& tf
390     Field<Type>::operator=(tf);
394 template<class Type>
395 void fvsPatchField<Type>::operator==
397     const Type& t
400     Field<Type>::operator=(t);
404 // * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
406 template<class Type>
407 Ostream& operator<<(Ostream& os, const fvsPatchField<Type>& ptf)
409     ptf.write(os);
411     os.check("Ostream& operator<<(Ostream&, const fvsPatchField<Type>&");
413     return os;
417 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
419 } // End namespace Foam
421 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
423 #   include "newFvsPatchField.C"
425 // ************************************************************************* //