1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
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 "pointPatchField.H"
28 #include "pointMesh.H"
29 #include "dictionary.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 pointPatchField<Type>::pointPatchField
42 const DimensionedField<Type, pointMesh>& iF
48 patchType_(word::null)
53 pointPatchField<Type>::pointPatchField
56 const DimensionedField<Type, pointMesh>& iF,
57 const dictionary& dict
63 patchType_(dict.lookupOrDefault<word>("patchType", word::null))
68 pointPatchField<Type>::pointPatchField
70 const pointPatchField<Type>& ptf
74 internalField_(ptf.internalField_),
76 patchType_(ptf.patchType_)
81 pointPatchField<Type>::pointPatchField
83 const pointPatchField<Type>& ptf,
84 const DimensionedField<Type, pointMesh>& iF
90 patchType_(ptf.patchType_)
94 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
97 const objectRegistry& pointPatchField<Type>::db() const
99 return patch_.boundaryMesh().mesh()();
104 void pointPatchField<Type>::write(Ostream& os) const
106 os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
108 if (patchType_.size())
110 os.writeKeyword("patchType") << patchType_
111 << token::END_STATEMENT << nl;
117 tmp<Field<Type> > pointPatchField<Type>::patchInternalField() const
119 return patchInternalField(internalField());
124 template<class Type1>
125 tmp<Field<Type1> > pointPatchField<Type>::patchInternalField
127 const Field<Type1>& iF
131 if (iF.size() != internalField().size())
135 "tmp<Field<Type1> > pointPatchField<"
137 "patchInternalField(const Field<Type1>& iF) const"
138 ) << "given internal field does not correspond to the mesh. "
139 << "Field size: " << iF.size()
140 << " mesh size: " << internalField().size()
141 << abort(FatalError);
145 const labelList& meshPoints = patch().meshPoints();
147 tmp<Field<Type1> > tvalues(new Field<Type1>(meshPoints.size()));
148 Field<Type1>& values = tvalues();
150 forAll (meshPoints, pointI)
152 values[pointI] = iF[meshPoints[pointI]];
160 template<class Type1>
161 void pointPatchField<Type>::addToInternalField
164 const Field<Type1>& pF
168 if (iF.size() != internalField().size())
172 "void pointPatchField<Type>::"
173 "addToInternalField("
174 "Field<Type1>& iF, const Field<Type1>& iF) const"
175 ) << "given internal field does not correspond to the mesh. "
176 << "Field size: " << iF.size()
177 << " mesh size: " << internalField().size()
178 << abort(FatalError);
181 if (pF.size() != size())
185 "void pointPatchField<Type>::"
186 "addToInternalField("
187 "Field<Type1>& iF, const Field<Type1>& iF) const"
188 ) << "given patch field does not correspond to the mesh. "
189 << "Field size: " << pF.size()
190 << " mesh size: " << size()
191 << abort(FatalError);
194 // Get the addressing
195 const labelList& mp = patch().meshPoints();
199 iF[mp[pointI]] += pF[pointI];
205 template<class Type1>
206 void pointPatchField<Type>::setInInternalField
209 const Field<Type1>& pF,
210 const labelList& meshPoints
214 if (iF.size() != internalField().size())
218 "void pointPatchField<Type>::"
219 "setInInternalField("
220 "Field<Type1>& iF, const Field<Type1>& iF) const"
221 ) << "given internal field does not correspond to the mesh. "
222 << "Field size: " << iF.size()
223 << " mesh size: " << internalField().size()
224 << abort(FatalError);
227 if (pF.size() != meshPoints.size())
231 "void pointPatchField<Type>::"
232 "setInInternalField("
233 "Field<Type1>& iF, const Field<Type1>& iF) const"
234 ) << "given patch field does not correspond to the meshPoints. "
235 << "Field size: " << pF.size()
236 << " meshPoints size: " << size()
237 << abort(FatalError);
240 forAll (meshPoints, pointI)
242 iF[meshPoints[pointI]] = pF[pointI];
248 template<class Type1>
249 void pointPatchField<Type>::setInInternalField
252 const Field<Type1>& pF
255 setInInternalField(iF, pF, patch().meshPoints());
260 void pointPatchField<Type>::evaluate(const Pstream::commsTypes)
271 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
277 const pointPatchField<Type>& ptf
282 os.check("Ostream& operator<<(Ostream&, const pointPatchField<Type>&)");
288 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
290 } // End namespace Foam
292 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
294 #include "newPointPatchField.C"
296 // ************************************************************************* //