Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / finiteVolume / fields / fvsPatchFields / fvsPatchField / fvsPatchField.C
blob55c5e6b33dee4b843b246e70fe565c1c66c9e2f7
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2010 OpenCFD Ltd.
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
13     the Free Software Foundation, either version 3 of the License, or
14     (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "IOobject.H"
27 #include "dictionary.H"
28 #include "fvMesh.H"
29 #include "fvPatchFieldMapper.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 namespace Foam
36 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
38 template<class Type>
39 fvsPatchField<Type>::fvsPatchField
41     const fvPatch& p,
42     const DimensionedField<Type, surfaceMesh>& iF
45     Field<Type>(p.size()),
46     patch_(p),
47     internalField_(iF)
51 template<class Type>
52 fvsPatchField<Type>::fvsPatchField
54     const fvPatch& p,
55     const DimensionedField<Type, surfaceMesh>& iF,
56     const Field<Type>& f
59     Field<Type>(f),
60     patch_(p),
61     internalField_(iF)
65 template<class Type>
66 fvsPatchField<Type>::fvsPatchField
68     const fvsPatchField<Type>& ptf,
69     const fvPatch& p,
70     const DimensionedField<Type, surfaceMesh>& iF,
71     const fvPatchFieldMapper& mapper
74     Field<Type>(ptf, mapper),
75     patch_(p),
76     internalField_(iF)
80 template<class Type>
81 fvsPatchField<Type>::fvsPatchField
83     const fvPatch& p,
84     const DimensionedField<Type, surfaceMesh>& iF,
85     const dictionary& dict
88     Field<Type>(p.size()),
89     patch_(p),
90     internalField_(iF)
92     if (dict.found("value"))
93     {
94         fvsPatchField<Type>::operator=
95         (
96             Field<Type>("value", dict, p.size())
97         );
98     }
99     else
100     {
101         fvsPatchField<Type>::operator=(pTraits<Type>::zero);
102     }
106 template<class Type>
107 fvsPatchField<Type>::fvsPatchField
109     const fvsPatchField<Type>& ptf
112     Field<Type>(ptf),
113     patch_(ptf.patch_),
114     internalField_(ptf.internalField_)
118 template<class Type>
119 fvsPatchField<Type>::fvsPatchField
121     const fvsPatchField<Type>& ptf,
122     const DimensionedField<Type, surfaceMesh>& iF
125     Field<Type>(ptf),
126     patch_(ptf.patch_),
127     internalField_(iF)
131 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
133 template<class Type>
134 const objectRegistry& fvsPatchField<Type>::db() const
136     return patch_.boundaryMesh().mesh();
140 template<class Type>
141 void fvsPatchField<Type>::check(const fvsPatchField<Type>& ptf) const
143     if (&patch_ != &(ptf.patch_))
144     {
145         FatalErrorIn("PatchField<Type>::check(const fvsPatchField<Type>&)")
146             << "different patches for fvsPatchField<Type>s"
147             << abort(FatalError);
148     }
152 // Map from self
153 template<class Type>
154 void fvsPatchField<Type>::autoMap
156     const fvPatchFieldMapper& m
159     Field<Type>::autoMap(m);
163 // Reverse-map the given fvsPatchField onto this fvsPatchField
164 template<class Type>
165 void fvsPatchField<Type>::rmap
167     const fvsPatchField<Type>& ptf,
168     const labelList& addr
171     Field<Type>::rmap(ptf, addr);
175 // Write
176 template<class Type>
177 void fvsPatchField<Type>::write(Ostream& os) const
179     os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
183 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
185 template<class Type>
186 void fvsPatchField<Type>::operator=
188     const UList<Type>& ul
191     Field<Type>::operator=(ul);
195 template<class Type>
196 void fvsPatchField<Type>::operator=
198     const fvsPatchField<Type>& ptf
201     check(ptf);
202     Field<Type>::operator=(ptf);
206 template<class Type>
207 void fvsPatchField<Type>::operator+=
209     const fvsPatchField<Type>& ptf
212     check(ptf);
213     Field<Type>::operator+=(ptf);
217 template<class Type>
218 void fvsPatchField<Type>::operator-=
220     const fvsPatchField<Type>& ptf
223     check(ptf);
224     Field<Type>::operator-=(ptf);
228 template<class Type>
229 void fvsPatchField<Type>::operator*=
231     const fvsPatchField<scalar>& ptf
234     if (&patch_ != &ptf.patch())
235     {
236         FatalErrorIn
237         (
238             "PatchField<Type>::operator*=(const fvsPatchField<scalar>& ptf)"
239         )   << "incompatible patches for patch fields"
240             << abort(FatalError);
241     }
243     Field<Type>::operator*=(ptf);
247 template<class Type>
248 void fvsPatchField<Type>::operator/=
250     const fvsPatchField<scalar>& ptf
253     if (&patch_ != &ptf.patch())
254     {
255         FatalErrorIn
256         (
257             "PatchField<Type>::operator/=(const fvsPatchField<scalar>& ptf)"
258         )   << "    incompatible patches for patch fields"
259             << abort(FatalError);
260     }
262     Field<Type>::operator/=(ptf);
266 template<class Type>
267 void fvsPatchField<Type>::operator+=
269     const Field<Type>& tf
272     Field<Type>::operator+=(tf);
276 template<class Type>
277 void fvsPatchField<Type>::operator-=
279     const Field<Type>& tf
282     Field<Type>::operator-=(tf);
286 template<class Type>
287 void fvsPatchField<Type>::operator*=
289     const scalarField& tf
292     Field<Type>::operator*=(tf);
296 template<class Type>
297 void fvsPatchField<Type>::operator/=
299     const scalarField& tf
302     Field<Type>::operator/=(tf);
306 template<class Type>
307 void fvsPatchField<Type>::operator=
309     const Type& t
312     Field<Type>::operator=(t);
316 template<class Type>
317 void fvsPatchField<Type>::operator+=
319     const Type& t
322     Field<Type>::operator+=(t);
326 template<class Type>
327 void fvsPatchField<Type>::operator-=
329     const Type& t
332     Field<Type>::operator-=(t);
336 template<class Type>
337 void fvsPatchField<Type>::operator*=
339     const scalar s
342     Field<Type>::operator*=(s);
346 template<class Type>
347 void fvsPatchField<Type>::operator/=
349     const scalar s
352     Field<Type>::operator/=(s);
356 // Force an assignment, overriding fixedValue status
357 template<class Type>
358 void fvsPatchField<Type>::operator==
360     const fvsPatchField<Type>& ptf
363     Field<Type>::operator=(ptf);
367 template<class Type>
368 void fvsPatchField<Type>::operator==
370     const Field<Type>& tf
373     Field<Type>::operator=(tf);
377 template<class Type>
378 void fvsPatchField<Type>::operator==
380     const Type& t
383     Field<Type>::operator=(t);
387 // * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
389 template<class Type>
390 Ostream& operator<<(Ostream& os, const fvsPatchField<Type>& ptf)
392     ptf.write(os);
394     os.check("Ostream& operator<<(Ostream&, const fvsPatchField<Type>&");
396     return os;
400 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
402 } // End namespace Foam
404 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
406 #   include "fvsPatchFieldNew.C"
408 // ************************************************************************* //