1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2009-2011 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 "genericPointPatchField.H"
27 #include "pointPatchFieldMapper.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
37 genericPointPatchField<Type>::genericPointPatchField
40 const DimensionedField<Type, pointMesh>& iF
43 calculatedPointPatchField<Type>(p, iF)
47 "genericPointPatchField<Type>::genericPointPatchField"
48 "(const pointPatch& p, const DimensionedField<Type, volMesh>& iF)"
54 genericPointPatchField<Type>::genericPointPatchField
57 const DimensionedField<Type, pointMesh>& iF,
58 const dictionary& dict
61 calculatedPointPatchField<Type>(p, iF, dict),
62 actualTypeName_(dict.lookup("type")),
65 forAllConstIter(dictionary, dict_, iter)
67 if (iter().keyword() != "type")
72 && iter().stream().size()
75 ITstream& is = iter().stream();
83 && firstToken.wordToken() == "nonuniform"
88 if (!fieldToken.isCompound())
93 && fieldToken.labelToken() == 0
106 "genericPointPatchField<Type>::"
107 "genericPointPatchField"
108 "(const pointPatch&, const Field<Type>&, "
109 "const dictionary&)",
111 ) << "\n token following 'nonuniform' "
113 << "\n on patch " << this->patch().name()
115 << this->dimensionedInternalField().name()
117 << this->dimensionedInternalField().objectPath()
118 << exit(FatalIOError);
123 fieldToken.compoundToken().type()
124 == token::Compound<List<scalar> >::typeName
127 scalarField* fPtr = new scalarField;
130 dynamicCast<token::Compound<List<scalar> > >
132 fieldToken.transferCompoundToken()
136 if (fPtr->size() != this->size())
140 "genericPointPatchField<Type>::"
141 "genericPointPatchField"
142 "(const pointPatch&, const Field<Type>&, "
143 "const dictionary&)",
145 ) << "\n size of field " << iter().keyword()
146 << " (" << fPtr->size() << ')'
147 << " is not the same size as the patch ("
148 << this->size() << ')'
149 << "\n on patch " << this->patch().name()
151 << this->dimensionedInternalField().name()
153 << this->dimensionedInternalField().objectPath()
154 << exit(FatalIOError);
157 scalarFields_.insert(iter().keyword(), fPtr);
161 fieldToken.compoundToken().type()
162 == token::Compound<List<vector> >::typeName
165 vectorField* fPtr = new vectorField;
168 dynamicCast<token::Compound<List<vector> > >
170 fieldToken.transferCompoundToken()
174 if (fPtr->size() != this->size())
178 "genericPointPatchField<Type>::"
179 "genericPointPatchField"
180 "(const pointPatch&, const Field<Type>&, "
181 "const dictionary&)",
183 ) << "\n size of field " << iter().keyword()
184 << " (" << fPtr->size() << ')'
185 << " is not the same size as the patch ("
186 << this->size() << ')'
187 << "\n on patch " << this->patch().name()
189 << this->dimensionedInternalField().name()
191 << this->dimensionedInternalField().objectPath()
192 << exit(FatalIOError);
195 vectorFields_.insert(iter().keyword(), fPtr);
199 fieldToken.compoundToken().type()
200 == token::Compound<List<sphericalTensor> >::typeName
203 sphericalTensorField* fPtr = new sphericalTensorField;
208 token::Compound<List<sphericalTensor> >
211 fieldToken.transferCompoundToken()
215 if (fPtr->size() != this->size())
219 "genericPointPatchField<Type>::"
220 "genericPointPatchField"
221 "(const pointPatch&, const Field<Type>&, "
222 "const dictionary&)",
224 ) << "\n size of field " << iter().keyword()
225 << " (" << fPtr->size() << ')'
226 << " is not the same size as the patch ("
227 << this->size() << ')'
228 << "\n on patch " << this->patch().name()
230 << this->dimensionedInternalField().name()
232 << this->dimensionedInternalField().objectPath()
233 << exit(FatalIOError);
236 sphericalTensorFields_.insert(iter().keyword(), fPtr);
240 fieldToken.compoundToken().type()
241 == token::Compound<List<symmTensor> >::typeName
244 symmTensorField* fPtr = new symmTensorField;
249 token::Compound<List<symmTensor> >
252 fieldToken.transferCompoundToken()
256 if (fPtr->size() != this->size())
260 "genericPointPatchField<Type>::"
261 "genericPointPatchField"
262 "(const pointPatch&, const Field<Type>&, "
263 "const dictionary&)",
265 ) << "\n size of field " << iter().keyword()
266 << " (" << fPtr->size() << ')'
267 << " is not the same size as the patch ("
268 << this->size() << ')'
269 << "\n on patch " << this->patch().name()
271 << this->dimensionedInternalField().name()
273 << this->dimensionedInternalField().objectPath()
274 << exit(FatalIOError);
277 symmTensorFields_.insert(iter().keyword(), fPtr);
281 fieldToken.compoundToken().type()
282 == token::Compound<List<tensor> >::typeName
285 tensorField* fPtr = new tensorField;
288 dynamicCast<token::Compound<List<tensor> > >
290 fieldToken.transferCompoundToken()
294 if (fPtr->size() != this->size())
298 "genericPointPatchField<Type>::"
299 "genericPointPatchField"
300 "(const pointPatch&, const Field<Type>&, "
301 "const dictionary&)",
303 ) << "\n size of field " << iter().keyword()
304 << " (" << fPtr->size() << ')'
305 << " is not the same size as the patch ("
306 << this->size() << ')'
307 << "\n on patch " << this->patch().name()
309 << this->dimensionedInternalField().name()
311 << this->dimensionedInternalField().objectPath()
312 << exit(FatalIOError);
315 tensorFields_.insert(iter().keyword(), fPtr);
321 "genericPointPatchField<Type>::"
322 "genericPointPatchField"
323 "(const pointPatch&, const Field<Type>&, "
324 "const dictionary&)",
326 ) << "\n compound " << fieldToken.compoundToken()
328 << "\n on patch " << this->patch().name()
330 << this->dimensionedInternalField().name()
332 << this->dimensionedInternalField().objectPath()
333 << exit(FatalIOError);
343 genericPointPatchField<Type>::genericPointPatchField
345 const genericPointPatchField<Type>& ptf,
347 const DimensionedField<Type, pointMesh>& iF,
348 const pointPatchFieldMapper& mapper
351 calculatedPointPatchField<Type>(ptf, p, iF, mapper),
352 actualTypeName_(ptf.actualTypeName_),
357 HashPtrTable<scalarField>,
365 new scalarField(*iter(), mapper)
371 HashPtrTable<vectorField>,
379 new vectorField(*iter(), mapper)
385 HashPtrTable<sphericalTensorField>,
386 ptf.sphericalTensorFields_,
390 sphericalTensorFields_.insert
393 new sphericalTensorField(*iter(), mapper)
399 HashPtrTable<symmTensorField>,
400 ptf.symmTensorFields_,
404 symmTensorFields_.insert
407 new symmTensorField(*iter(), mapper)
413 HashPtrTable<tensorField>,
421 new tensorField(*iter(), mapper)
428 genericPointPatchField<Type>::genericPointPatchField
430 const genericPointPatchField<Type>& ptf,
431 const DimensionedField<Type, pointMesh>& iF
434 calculatedPointPatchField<Type>(ptf, iF),
435 actualTypeName_(ptf.actualTypeName_),
437 scalarFields_(ptf.scalarFields_),
438 vectorFields_(ptf.vectorFields_),
439 sphericalTensorFields_(ptf.sphericalTensorFields_),
440 symmTensorFields_(ptf.symmTensorFields_),
441 tensorFields_(ptf.tensorFields_)
445 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
448 void genericPointPatchField<Type>::autoMap
450 const pointPatchFieldMapper& m
455 HashPtrTable<scalarField>,
465 HashPtrTable<vectorField>,
475 HashPtrTable<sphericalTensorField>,
476 sphericalTensorFields_,
485 HashPtrTable<symmTensorField>,
495 HashPtrTable<tensorField>,
506 void genericPointPatchField<Type>::rmap
508 const pointPatchField<Type>& ptf,
509 const labelList& addr
512 const genericPointPatchField<Type>& dptf =
513 refCast<const genericPointPatchField<Type> >(ptf);
517 HashPtrTable<scalarField>,
522 HashPtrTable<scalarField>::const_iterator dptfIter =
523 dptf.scalarFields_.find(iter.key());
525 if (dptfIter != scalarFields_.end())
527 iter()->rmap(*dptfIter(), addr);
533 HashPtrTable<vectorField>,
538 HashPtrTable<vectorField>::const_iterator dptfIter =
539 dptf.vectorFields_.find(iter.key());
541 if (dptfIter != vectorFields_.end())
543 iter()->rmap(*dptfIter(), addr);
549 HashPtrTable<sphericalTensorField>,
550 sphericalTensorFields_,
554 HashPtrTable<sphericalTensorField>::const_iterator dptfIter =
555 dptf.sphericalTensorFields_.find(iter.key());
557 if (dptfIter != sphericalTensorFields_.end())
559 iter()->rmap(*dptfIter(), addr);
565 HashPtrTable<symmTensorField>,
570 HashPtrTable<symmTensorField>::const_iterator dptfIter =
571 dptf.symmTensorFields_.find(iter.key());
573 if (dptfIter != symmTensorFields_.end())
575 iter()->rmap(*dptfIter(), addr);
581 HashPtrTable<tensorField>,
586 HashPtrTable<tensorField>::const_iterator dptfIter =
587 dptf.tensorFields_.find(iter.key());
589 if (dptfIter != tensorFields_.end())
591 iter()->rmap(*dptfIter(), addr);
598 void genericPointPatchField<Type>::write(Ostream& os) const
600 os.writeKeyword("type") << actualTypeName_ << token::END_STATEMENT << nl;
602 forAllConstIter(dictionary, dict_, iter)
604 if (iter().keyword() != "type")
609 && iter().stream().size()
610 && iter().stream()[0].isWord()
611 && iter().stream()[0].wordToken() == "nonuniform"
614 if (scalarFields_.found(iter().keyword()))
616 scalarFields_.find(iter().keyword())()
617 ->writeEntry(iter().keyword(), os);
619 else if (vectorFields_.found(iter().keyword()))
621 vectorFields_.find(iter().keyword())()
622 ->writeEntry(iter().keyword(), os);
624 else if (sphericalTensorFields_.found(iter().keyword()))
626 sphericalTensorFields_.find(iter().keyword())()
627 ->writeEntry(iter().keyword(), os);
629 else if (symmTensorFields_.found(iter().keyword()))
631 symmTensorFields_.find(iter().keyword())()
632 ->writeEntry(iter().keyword(), os);
634 else if (tensorFields_.found(iter().keyword()))
636 tensorFields_.find(iter().keyword())()
637 ->writeEntry(iter().keyword(), os);
649 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
651 } // End namespace Foam
653 // ************************************************************************* //