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 "genericPointPatchField.H"
28 #include "pointPatchFieldMapper.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
38 genericPointPatchField<Type>::genericPointPatchField
41 const DimensionedField<Type, pointMesh>& iF
44 calculatedPointPatchField<Type>(p, iF)
48 "genericPointPatchField<Type>::genericPointPatchField"
49 "(const pointPatch& p, const DimensionedField<Type, volMesh>& iF)"
55 genericPointPatchField<Type>::genericPointPatchField
58 const DimensionedField<Type, pointMesh>& iF,
59 const dictionary& dict
62 calculatedPointPatchField<Type>(p, iF, dict),
63 actualTypeName_(dict.lookup("type")),
68 dictionary::const_iterator iter = dict_.begin();
73 if (iter().keyword() != "type")
78 && iter().stream().size()
81 ITstream& is = iter().stream();
89 && firstToken.wordToken() == "nonuniform"
94 if (!fieldToken.isCompound())
99 && fieldToken.labelToken() == 0
112 "genericPointPatchField<Type>::"
113 "genericPointPatchField"
114 "(const pointPatch&, const Field<Type>&, "
115 "const dictionary&)",
117 ) << "\n token following 'nonuniform' "
119 << "\n on patch " << this->patch().name()
121 << this->dimensionedInternalField().name()
123 << this->dimensionedInternalField().objectPath()
124 << exit(FatalIOError);
129 fieldToken.compoundToken().type()
130 == token::Compound<List<scalar> >::typeName
133 scalarField* fPtr = new scalarField;
136 dynamicCast<token::Compound<List<scalar> > >
138 fieldToken.transferCompoundToken()
142 if (fPtr->size() != this->size())
146 "genericPointPatchField<Type>::"
147 "genericPointPatchField"
148 "(const pointPatch&, const Field<Type>&, "
149 "const dictionary&)",
151 ) << "\n size of field " << iter().keyword()
152 << " (" << fPtr->size() << ')'
153 << " is not the same size as the patch ("
154 << this->size() << ')'
155 << "\n on patch " << this->patch().name()
157 << this->dimensionedInternalField().name()
159 << this->dimensionedInternalField().objectPath()
160 << exit(FatalIOError);
163 scalarFields_.insert(iter().keyword(), fPtr);
167 fieldToken.compoundToken().type()
168 == token::Compound<List<vector> >::typeName
171 vectorField* fPtr = new vectorField;
174 dynamicCast<token::Compound<List<vector> > >
176 fieldToken.transferCompoundToken()
180 if (fPtr->size() != this->size())
184 "genericPointPatchField<Type>::"
185 "genericPointPatchField"
186 "(const pointPatch&, const Field<Type>&, "
187 "const dictionary&)",
189 ) << "\n size of field " << iter().keyword()
190 << " (" << fPtr->size() << ')'
191 << " is not the same size as the patch ("
192 << this->size() << ')'
193 << "\n on patch " << this->patch().name()
195 << this->dimensionedInternalField().name()
197 << this->dimensionedInternalField().objectPath()
198 << exit(FatalIOError);
201 vectorFields_.insert(iter().keyword(), fPtr);
205 fieldToken.compoundToken().type()
206 == token::Compound<List<sphericalTensor> >::typeName
209 sphericalTensorField* fPtr = new sphericalTensorField;
214 token::Compound<List<sphericalTensor> >
217 fieldToken.transferCompoundToken()
221 if (fPtr->size() != this->size())
225 "genericPointPatchField<Type>::"
226 "genericPointPatchField"
227 "(const pointPatch&, const Field<Type>&, "
228 "const dictionary&)",
230 ) << "\n size of field " << iter().keyword()
231 << " (" << fPtr->size() << ')'
232 << " is not the same size as the patch ("
233 << this->size() << ')'
234 << "\n on patch " << this->patch().name()
236 << this->dimensionedInternalField().name()
238 << this->dimensionedInternalField().objectPath()
239 << exit(FatalIOError);
242 sphericalTensorFields_.insert(iter().keyword(), fPtr);
246 fieldToken.compoundToken().type()
247 == token::Compound<List<symmTensor> >::typeName
250 symmTensorField* fPtr = new symmTensorField;
255 token::Compound<List<symmTensor> >
258 fieldToken.transferCompoundToken()
262 if (fPtr->size() != this->size())
266 "genericPointPatchField<Type>::"
267 "genericPointPatchField"
268 "(const pointPatch&, const Field<Type>&, "
269 "const dictionary&)",
271 ) << "\n size of field " << iter().keyword()
272 << " (" << fPtr->size() << ')'
273 << " is not the same size as the patch ("
274 << this->size() << ')'
275 << "\n on patch " << this->patch().name()
277 << this->dimensionedInternalField().name()
279 << this->dimensionedInternalField().objectPath()
280 << exit(FatalIOError);
283 symmTensorFields_.insert(iter().keyword(), fPtr);
287 fieldToken.compoundToken().type()
288 == token::Compound<List<tensor> >::typeName
291 tensorField* fPtr = new tensorField;
294 dynamicCast<token::Compound<List<tensor> > >
296 fieldToken.transferCompoundToken()
300 if (fPtr->size() != this->size())
304 "genericPointPatchField<Type>::"
305 "genericPointPatchField"
306 "(const pointPatch&, const Field<Type>&, "
307 "const dictionary&)",
309 ) << "\n size of field " << iter().keyword()
310 << " (" << fPtr->size() << ')'
311 << " is not the same size as the patch ("
312 << this->size() << ')'
313 << "\n on patch " << this->patch().name()
315 << this->dimensionedInternalField().name()
317 << this->dimensionedInternalField().objectPath()
318 << exit(FatalIOError);
321 tensorFields_.insert(iter().keyword(), fPtr);
327 "genericPointPatchField<Type>::"
328 "genericPointPatchField"
329 "(const pointPatch&, const Field<Type>&, "
330 "const dictionary&)",
332 ) << "\n compound " << fieldToken.compoundToken()
334 << "\n on patch " << this->patch().name()
336 << this->dimensionedInternalField().name()
338 << this->dimensionedInternalField().objectPath()
339 << exit(FatalIOError);
349 genericPointPatchField<Type>::genericPointPatchField
351 const genericPointPatchField<Type>& ptf,
353 const DimensionedField<Type, pointMesh>& iF,
354 const pointPatchFieldMapper& mapper
357 calculatedPointPatchField<Type>(ptf, p, iF, mapper),
358 actualTypeName_(ptf.actualTypeName_),
363 HashPtrTable<scalarField>::const_iterator iter =
364 ptf.scalarFields_.begin();
365 iter != ptf.scalarFields_.end();
369 scalarFields_.insert(iter.key(), new scalarField(*iter(), mapper));
374 HashPtrTable<vectorField>::const_iterator iter =
375 ptf.vectorFields_.begin();
376 iter != ptf.vectorFields_.end();
380 vectorFields_.insert(iter.key(), new vectorField(*iter(), mapper));
385 HashPtrTable<sphericalTensorField>::const_iterator iter =
386 ptf.sphericalTensorFields_.begin();
387 iter != ptf.sphericalTensorFields_.end();
391 sphericalTensorFields_.insert
394 new sphericalTensorField(*iter(), mapper)
400 HashPtrTable<symmTensorField>::const_iterator iter =
401 ptf.symmTensorFields_.begin();
402 iter != ptf.symmTensorFields_.end();
406 symmTensorFields_.insert
409 new symmTensorField(*iter(), mapper)
415 HashPtrTable<tensorField>::const_iterator iter =
416 ptf.tensorFields_.begin();
417 iter != ptf.tensorFields_.end();
421 tensorFields_.insert(iter.key(), new tensorField(*iter(), mapper));
427 genericPointPatchField<Type>::genericPointPatchField
429 const genericPointPatchField<Type>& ptf,
430 const DimensionedField<Type, pointMesh>& iF
433 calculatedPointPatchField<Type>(ptf, iF),
434 actualTypeName_(ptf.actualTypeName_),
436 scalarFields_(ptf.scalarFields_),
437 vectorFields_(ptf.vectorFields_),
438 sphericalTensorFields_(ptf.sphericalTensorFields_),
439 symmTensorFields_(ptf.symmTensorFields_),
440 tensorFields_(ptf.tensorFields_)
444 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
447 void genericPointPatchField<Type>::autoMap
449 const pointPatchFieldMapper& m
454 HashPtrTable<scalarField>::iterator iter = scalarFields_.begin();
455 iter != scalarFields_.end();
464 HashPtrTable<vectorField>::iterator iter = vectorFields_.begin();
465 iter != vectorFields_.end();
474 HashPtrTable<sphericalTensorField>::iterator iter =
475 sphericalTensorFields_.begin();
476 iter != sphericalTensorFields_.end();
485 HashPtrTable<symmTensorField>::iterator iter =
486 symmTensorFields_.begin();
487 iter != symmTensorFields_.end();
496 HashPtrTable<tensorField>::iterator iter = tensorFields_.begin();
497 iter != tensorFields_.end();
507 void genericPointPatchField<Type>::rmap
509 const pointPatchField<Type>& ptf,
510 const labelList& addr
513 const genericPointPatchField<Type>& dptf =
514 refCast<const genericPointPatchField<Type> >(ptf);
518 HashPtrTable<scalarField>::iterator iter = scalarFields_.begin();
519 iter != scalarFields_.end();
523 HashPtrTable<scalarField>::const_iterator dptfIter =
524 dptf.scalarFields_.find(iter.key());
526 if (dptfIter != scalarFields_.end())
528 iter()->rmap(*dptfIter(), addr);
534 HashPtrTable<vectorField>::iterator iter = vectorFields_.begin();
535 iter != vectorFields_.end();
539 HashPtrTable<vectorField>::const_iterator dptfIter =
540 dptf.vectorFields_.find(iter.key());
542 if (dptfIter != vectorFields_.end())
544 iter()->rmap(*dptfIter(), addr);
550 HashPtrTable<sphericalTensorField>::iterator iter =
551 sphericalTensorFields_.begin();
552 iter != sphericalTensorFields_.end();
556 HashPtrTable<sphericalTensorField>::const_iterator dptfIter =
557 dptf.sphericalTensorFields_.find(iter.key());
559 if (dptfIter != sphericalTensorFields_.end())
561 iter()->rmap(*dptfIter(), addr);
567 HashPtrTable<symmTensorField>::iterator iter =
568 symmTensorFields_.begin();
569 iter != symmTensorFields_.end();
573 HashPtrTable<symmTensorField>::const_iterator dptfIter =
574 dptf.symmTensorFields_.find(iter.key());
576 if (dptfIter != symmTensorFields_.end())
578 iter()->rmap(*dptfIter(), addr);
584 HashPtrTable<tensorField>::iterator iter = tensorFields_.begin();
585 iter != tensorFields_.end();
589 HashPtrTable<tensorField>::const_iterator dptfIter =
590 dptf.tensorFields_.find(iter.key());
592 if (dptfIter != tensorFields_.end())
594 iter()->rmap(*dptfIter(), addr);
601 void genericPointPatchField<Type>::write(Ostream& os) const
603 os.writeKeyword("type") << actualTypeName_ << token::END_STATEMENT << nl;
607 dictionary::const_iterator iter = dict_.begin();
612 if (iter().keyword() != "type")
617 && iter().stream().size()
618 && iter().stream()[0].isWord()
619 && iter().stream()[0].wordToken() == "nonuniform"
622 if (scalarFields_.found(iter().keyword()))
624 scalarFields_.find(iter().keyword())()
625 ->writeEntry(iter().keyword(), os);
627 else if (vectorFields_.found(iter().keyword()))
629 vectorFields_.find(iter().keyword())()
630 ->writeEntry(iter().keyword(), os);
632 else if (sphericalTensorFields_.found(iter().keyword()))
634 sphericalTensorFields_.find(iter().keyword())()
635 ->writeEntry(iter().keyword(), os);
637 else if (symmTensorFields_.found(iter().keyword()))
639 symmTensorFields_.find(iter().keyword())()
640 ->writeEntry(iter().keyword(), os);
642 else if (tensorFields_.found(iter().keyword()))
644 tensorFields_.find(iter().keyword())()
645 ->writeEntry(iter().keyword(), os);
657 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
659 } // End namespace Foam
661 // ************************************************************************* //