1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 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
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
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 "pointPatchField.H"
27 #include "pointMesh.H"
28 #include "dictionary.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 pointPatchField<Type>::pointPatchField
41 const DimensionedField<Type, pointMesh>& iF
47 patchType_(word::null)
52 pointPatchField<Type>::pointPatchField
55 const DimensionedField<Type, pointMesh>& iF,
56 const dictionary& dict
62 patchType_(dict.lookupOrDefault<word>("patchType", word::null))
67 pointPatchField<Type>::pointPatchField
69 const pointPatchField<Type>& ptf
73 internalField_(ptf.internalField_),
75 patchType_(ptf.patchType_)
80 pointPatchField<Type>::pointPatchField
82 const pointPatchField<Type>& ptf,
83 const DimensionedField<Type, pointMesh>& iF
89 patchType_(ptf.patchType_)
93 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
96 const objectRegistry& pointPatchField<Type>::db() const
98 return patch_.boundaryMesh().mesh()();
103 void pointPatchField<Type>::write(Ostream& os) const
105 os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
107 if (patchType_.size())
109 os.writeKeyword("patchType") << patchType_
110 << token::END_STATEMENT << nl;
116 tmp<Field<Type> > pointPatchField<Type>::patchInternalField() const
118 return patchInternalField(internalField());
123 template<class Type1>
124 tmp<Field<Type1> > pointPatchField<Type>::patchInternalField
126 const Field<Type1>& iF,
127 const labelList& meshPoints
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);
144 return tmp<Field<Type1> >(new Field<Type1>(iF, meshPoints));
149 template<class Type1>
150 tmp<Field<Type1> > pointPatchField<Type>::patchInternalField
152 const Field<Type1>& iF
155 return patchInternalField(iF, patch().meshPoints());
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>::addToInternalField
209 const Field<Type1>& pF,
210 const labelList& points
214 if (iF.size() != internalField().size())
218 "void pointPatchField<Type>::"
219 "addToInternalField("
220 "Field<Type1>& iF, const Field<Type1>& iF, const labelList&) 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() != size())
231 "void pointPatchField<Type>::"
232 "addToInternalField("
233 "Field<Type1>& iF, const Field<Type1>& iF, const labelList&) const"
234 ) << "given patch field does not correspond to the mesh. "
235 << "Field size: " << pF.size()
236 << " mesh size: " << size()
237 << abort(FatalError);
240 // Get the addressing
241 const labelList& mp = patch().meshPoints();
245 label pointI = points[i];
246 iF[mp[pointI]] += pF[pointI];
252 template<class Type1>
253 void pointPatchField<Type>::setInInternalField
256 const Field<Type1>& pF,
257 const labelList& meshPoints
261 if (iF.size() != internalField().size())
265 "void pointPatchField<Type>::"
266 "setInInternalField("
267 "Field<Type1>& iF, const Field<Type1>& iF) const"
268 ) << "given internal field does not correspond to the mesh. "
269 << "Field size: " << iF.size()
270 << " mesh size: " << internalField().size()
271 << abort(FatalError);
274 if (pF.size() != meshPoints.size())
278 "void pointPatchField<Type>::"
279 "setInInternalField("
280 "Field<Type1>& iF, const Field<Type1>& iF) const"
281 ) << "given patch field does not correspond to the meshPoints. "
282 << "Field size: " << pF.size()
283 << " meshPoints size: " << size()
284 << abort(FatalError);
287 forAll(meshPoints, pointI)
289 iF[meshPoints[pointI]] = pF[pointI];
295 template<class Type1>
296 void pointPatchField<Type>::setInInternalField
299 const Field<Type1>& pF
302 setInInternalField(iF, pF, patch().meshPoints());
307 void pointPatchField<Type>::evaluate(const Pstream::commsTypes)
318 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
324 const pointPatchField<Type>& ptf
329 os.check("Ostream& operator<<(Ostream&, const pointPatchField<Type>&)");
335 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
337 } // End namespace Foam
339 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
341 #include "pointPatchFieldNew.C"
343 // ************************************************************************* //