initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / fields / pointPatchFields / basic / value / valuePointPatchField.C
blobc694e96fb42905351a1eab40e92bf856b5fbe2c1
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 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 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 "valuePointPatchField.H"
28 #include "pointPatchFieldMapper.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 namespace Foam
35 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
37 template<class Type>
38 void valuePointPatchField<Type>::checkFieldSize() const
40     if (size() != this->patch().size())
41     {
42         FatalErrorIn
43         (
44             "void valuePointPatchField<Type>::checkField() const"
45         )   << "field does not correspond to patch. " << endl
46             << "Field size: " << size() << " patch size: "
47             << this->patch().size()
48             << abort(FatalError);
49     }
53 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
55 template<class Type>
56 valuePointPatchField<Type>::valuePointPatchField
58     const pointPatch& p,
59     const DimensionedField<Type, pointMesh>& iF
62     pointPatchField<Type>(p, iF),
63     Field<Type>(p.size())
67 template<class Type>
68 valuePointPatchField<Type>::valuePointPatchField
70     const pointPatch& p,
71     const DimensionedField<Type, pointMesh>& iF,
72     const dictionary& dict,
73     const bool valueRequired
76     pointPatchField<Type>(p, iF, dict),
77     Field<Type>(p.size())
79     if (dict.found("value"))
80     {
81         Field<Type>::operator=
82         (
83             Field<Type>("value", dict, p.size())
84         );
85     }
86     else if (!valueRequired)
87     {
88         Field<Type>::operator=(pTraits<Type>::zero);
89     }
90     else
91     {
92         FatalIOErrorIn
93         (
94             "pointPatchField<Type>::pointPatchField"
95             "("
96             "const fvPatch& p,"
97             "const DimensionedField<Type, pointMesh>& iF,"
98             "const dictionary& dict,"
99             "const bool valueRequired"
100             ")",
101             dict
102         )   << "Essential entry 'value' missing"
103             << exit(FatalIOError);
104     }
108 template<class Type>
109 valuePointPatchField<Type>::valuePointPatchField
111     const valuePointPatchField<Type>& ptf,
112     const pointPatch& p,
113     const DimensionedField<Type, pointMesh>& iF,
114     const pointPatchFieldMapper& mapper
117     pointPatchField<Type>(p, iF),
118     Field<Type>(ptf, mapper)
122 template<class Type>
123 valuePointPatchField<Type>::valuePointPatchField
125     const valuePointPatchField<Type>& ptf,
126     const DimensionedField<Type, pointMesh>& iF
129     pointPatchField<Type>(ptf, iF),
130     Field<Type>(ptf)
134 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
136 template<class Type>
137 void valuePointPatchField<Type>::autoMap
139     const pointPatchFieldMapper& m
142     Field<Type>::autoMap(m);
146 template<class Type>
147 void valuePointPatchField<Type>::rmap
149     const pointPatchField<Type>& ptf,
150     const labelList& addr
153     Field<Type>::rmap
154     (
155         refCast<const valuePointPatchField<Type> >
156         (
157             ptf
158         ),
159         addr
160     );
164 template<class Type>
165 void valuePointPatchField<Type>::updateCoeffs()
167     if (this->updated())
168     {
169         return;
170     }
172     // Get internal field to insert values into
173     Field<Type>& iF = const_cast<Field<Type>&>(this->internalField());
175     setInInternalField(iF, *this);
177     pointPatchField<Type>::updateCoeffs();
181 template<class Type>
182 void valuePointPatchField<Type>::evaluate(const Pstream::commsTypes)
184     // Get internal field to insert values into
185     Field<Type>& iF = const_cast<Field<Type>&>(this->internalField());
187     setInInternalField(iF, *this);
189     pointPatchField<Type>::evaluate();
193 template<class Type>
194 void valuePointPatchField<Type>::write(Ostream& os) const
196     pointPatchField<Type>::write(os);
197     this->writeEntry("value", os);
201 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
203 template<class Type>
204 void valuePointPatchField<Type>::operator=
206     const valuePointPatchField<Type>& ptf
209     Field<Type>::operator=(ptf);
213 template<class Type>
214 void valuePointPatchField<Type>::operator=
216     const pointPatchField<Type>& ptf
219     Field<Type>::operator=(ptf.patchInternalField());
223 template<class Type>
224 void valuePointPatchField<Type>::operator=
226     const Field<Type>& tf
229     Field<Type>::operator=(tf);
233 template<class Type>
234 void valuePointPatchField<Type>::operator=
236     const Type& t
239     Field<Type>::operator=(t);
243 // Force an assignment
244 template<class Type>
245 void valuePointPatchField<Type>::operator==
247     const valuePointPatchField<Type>& ptf
250     Field<Type>::operator=(ptf);
254 template<class Type>
255 void valuePointPatchField<Type>::operator==
257     const pointPatchField<Type>& ptf
260     Field<Type>::operator=(ptf.patchInternalField());
264 template<class Type>
265 void valuePointPatchField<Type>::operator==
267     const Field<Type>& tf
270     Field<Type>::operator=(tf);
274 template<class Type>
275 void valuePointPatchField<Type>::operator==
277     const Type& t
280     Field<Type>::operator=(t);
284 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
286 } // End namespace Foam
288 // ************************************************************************* //