Forward compatibility: flex
[foam-extend-3.2.git] / src / finiteVolume / fields / fvsPatchFields / fvsPatchField / fvsPatchField.C
blobba4af215439127ef8c180782bada23a4a28537aa
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend 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 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  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,
86     const bool valueRequired
89     Field<Type>(p.size()),
90     patch_(p),
91     internalField_(iF)
93     if (dict.found("value"))
94     {
95         fvsPatchField<Type>::operator=
96         (
97             Field<Type>("value", dict, p.size())
98         );
99     }
100     else if (!valueRequired)
101     {
102         fvsPatchField<Type>::operator=(pTraits<Type>::zero);
103     }
104     else
105     {
106         FatalIOErrorIn
107         (
108             "fvsPatchField<Type>::fvsPatchField"
109             "("
110             "const fvPatch& p,"
111             "const DimensionedField<Type, surfaceMesh>& iF,"
112             "const dictionary& dict,"
113             "const bool valueRequired"
114             ")",
115             dict
116         )   << "Essential entry 'value' missing"
117             << exit(FatalIOError);
118     }
122 template<class Type>
123 fvsPatchField<Type>::fvsPatchField
125     const fvsPatchField<Type>& ptf
128     Field<Type>(ptf),
129     patch_(ptf.patch_),
130     internalField_(ptf.internalField_)
134 template<class Type>
135 fvsPatchField<Type>::fvsPatchField
137     const fvsPatchField<Type>& ptf,
138     const DimensionedField<Type, surfaceMesh>& iF
141     Field<Type>(ptf),
142     patch_(ptf.patch_),
143     internalField_(iF)
147 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
149 template<class Type>
150 const objectRegistry& fvsPatchField<Type>::db() const
152     //HR 12.3.10: Lookup fields from the field DB rather than the mesh
153     return internalField_.db();
157 template<class Type>
158 template<class GeometricField, class Type2>
159 const typename GeometricField::PatchFieldType& Foam::fvsPatchField<Type>::lookupPatchField
161     const word& name,
162     const GeometricField*,
163     const Type2*
164 ) const
166     return patch_.patchField<GeometricField, Type2>
167     (
168         internalField_.db().objectRegistry::template lookupObject<GeometricField>(name)
169     );
173 template<class Type>
174 void fvsPatchField<Type>::check(const fvsPatchField<Type>& ptf) const
176     if (&patch_ != &(ptf.patch_))
177     {
178         FatalErrorIn("PatchField<Type>::check(const fvsPatchField<Type>&)")
179             << "different patches for fvsPatchField<Type>s"
180             << abort(FatalError);
181     }
185 template<class Type>
186 void fvsPatchField<Type>::check(const fvPatchField<Type>& ptf) const
188     if (&patch_ != &(ptf.patch()))
189     {
190         FatalErrorIn("PatchField<Type>::check(const fvsPatchField<Type>&)")
191             << "different patches for fvsPatchField<Type>s"
192             << abort(FatalError);
193     }
197 // Map from self
198 template<class Type>
199 void fvsPatchField<Type>::autoMap
201     const fvPatchFieldMapper& m
204     Field<Type>::autoMap(m);
208 // Reverse-map the given fvsPatchField onto this fvsPatchField
209 template<class Type>
210 void fvsPatchField<Type>::rmap
212     const fvsPatchField<Type>& ptf,
213     const labelList& addr
216     Field<Type>::rmap(ptf, addr);
220 // Write
221 template<class Type>
222 void fvsPatchField<Type>::write(Ostream& os) const
224     os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
228 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
230 template<class Type>
231 void fvsPatchField<Type>::operator=
233     const UList<Type>& ul
236     Field<Type>::operator=(ul);
240 template<class Type>
241 void fvsPatchField<Type>::operator=
243     const fvsPatchField<Type>& ptf
246     check(ptf);
247     Field<Type>::operator=(ptf);
251 template<class Type>
252 void fvsPatchField<Type>::operator+=
254     const fvsPatchField<Type>& ptf
257     check(ptf);
258     Field<Type>::operator+=(ptf);
262 template<class Type>
263 void fvsPatchField<Type>::operator-=
265     const fvsPatchField<Type>& ptf
268     check(ptf);
269     Field<Type>::operator-=(ptf);
273 template<class Type>
274 void fvsPatchField<Type>::operator*=
276     const fvsPatchField<scalar>& ptf
279     if (&patch_ != &ptf.patch())
280     {
281         FatalErrorIn
282         (
283             "PatchField<Type>::operator*=(const fvsPatchField<scalar>& ptf)"
284         )   << "incompatible patches for patch fields"
285             << abort(FatalError);
286     }
288     Field<Type>::operator*=(ptf);
292 template<class Type>
293 void fvsPatchField<Type>::operator/=
295     const fvsPatchField<scalar>& ptf
298     if (&patch_ != &ptf.patch())
299     {
300         FatalErrorIn
301         (
302             "PatchField<Type>::operator/=(const fvsPatchField<scalar>& ptf)"
303         )   << "    incompatible patches for patch fields"
304             << abort(FatalError);
305     }
307     Field<Type>::operator/=(ptf);
311 template<class Type>
312 void fvsPatchField<Type>::operator=
314     const fvPatchField<Type>& ptf
317     check(ptf);
318     Field<Type>::operator=(ptf);
322 template<class Type>
323 void fvsPatchField<Type>::operator+=
325     const Field<Type>& tf
328     Field<Type>::operator+=(tf);
332 template<class Type>
333 void fvsPatchField<Type>::operator-=
335     const Field<Type>& tf
338     Field<Type>::operator-=(tf);
342 template<class Type>
343 void fvsPatchField<Type>::operator*=
345     const scalarField& tf
348     Field<Type>::operator*=(tf);
352 template<class Type>
353 void fvsPatchField<Type>::operator/=
355     const scalarField& tf
358     Field<Type>::operator/=(tf);
362 template<class Type>
363 void fvsPatchField<Type>::operator=
365     const Type& t
368     Field<Type>::operator=(t);
372 template<class Type>
373 void fvsPatchField<Type>::operator+=
375     const Type& t
378     Field<Type>::operator+=(t);
382 template<class Type>
383 void fvsPatchField<Type>::operator-=
385     const Type& t
388     Field<Type>::operator-=(t);
392 template<class Type>
393 void fvsPatchField<Type>::operator*=
395     const scalar s
398     Field<Type>::operator*=(s);
402 template<class Type>
403 void fvsPatchField<Type>::operator/=
405     const scalar s
408     Field<Type>::operator/=(s);
412 // Force an assignment, overriding fixedValue status
413 template<class Type>
414 void fvsPatchField<Type>::operator==
416     const fvsPatchField<Type>& ptf
419     Field<Type>::operator=(ptf);
423 template<class Type>
424 void fvsPatchField<Type>::operator==
426     const Field<Type>& tf
429     Field<Type>::operator=(tf);
433 template<class Type>
434 void fvsPatchField<Type>::operator==
436     const Type& t
439     Field<Type>::operator=(t);
443 // * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
445 template<class Type>
446 Ostream& operator<<(Ostream& os, const fvsPatchField<Type>& ptf)
448     ptf.write(os);
450     os.check("Ostream& operator<<(Ostream&, const fvsPatchField<Type>&");
452     return os;
456 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
458 } // End namespace Foam
460 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
462 #   include "newFvsPatchField.C"
464 // ************************************************************************* //