/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . \*---------------------------------------------------------------------------*/ #include "genericPointPatchField.H" #include "pointPatchFieldMapper.H" // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template Foam::genericPointPatchField::genericPointPatchField ( const pointPatch& p, const DimensionedField& iF ) : calculatedPointPatchField(p, iF) { NotImplemented; } template Foam::genericPointPatchField::genericPointPatchField ( const pointPatch& p, const DimensionedField& iF, const dictionary& dict ) : calculatedPointPatchField(p, iF, dict), actualTypeName_(dict.lookup("type")), dict_(dict) { forAllConstIter(dictionary, dict_, iter) { if (iter().keyword() != "type") { if ( iter().isStream() && iter().stream().size() ) { ITstream& is = iter().stream(); // Read first token token firstToken(is); if ( firstToken.isWord() && firstToken.wordToken() == "nonuniform" ) { token fieldToken(is); if (!fieldToken.isCompound()) { if ( fieldToken.isLabel() && fieldToken.labelToken() == 0 ) { scalarFields_.insert ( iter().keyword(), new scalarField(0) ); } else { FatalIOErrorInFunction ( dict ) << "\n token following 'nonuniform' " "is not a compound" << "\n on patch " << this->patch().name() << " of field " << this->dimensionedInternalField().name() << " in file " << this->dimensionedInternalField().objectPath() << exit(FatalIOError); } } else if ( fieldToken.compoundToken().type() == token::Compound>::typeName ) { scalarField* fPtr = new scalarField; fPtr->transfer ( dynamicCast>> ( fieldToken.transferCompoundToken(is) ) ); if (fPtr->size() != this->size()) { FatalIOErrorInFunction ( dict ) << "\n size of field " << iter().keyword() << " (" << fPtr->size() << ')' << " is not the same size as the patch (" << this->size() << ')' << "\n on patch " << this->patch().name() << " of field " << this->dimensionedInternalField().name() << " in file " << this->dimensionedInternalField().objectPath() << exit(FatalIOError); } scalarFields_.insert(iter().keyword(), fPtr); } else if ( fieldToken.compoundToken().type() == token::Compound>::typeName ) { vectorField* fPtr = new vectorField; fPtr->transfer ( dynamicCast>> ( fieldToken.transferCompoundToken(is) ) ); if (fPtr->size() != this->size()) { FatalIOErrorInFunction ( dict ) << "\n size of field " << iter().keyword() << " (" << fPtr->size() << ')' << " is not the same size as the patch (" << this->size() << ')' << "\n on patch " << this->patch().name() << " of field " << this->dimensionedInternalField().name() << " in file " << this->dimensionedInternalField().objectPath() << exit(FatalIOError); } vectorFields_.insert(iter().keyword(), fPtr); } else if ( fieldToken.compoundToken().type() == token::Compound>::typeName ) { sphericalTensorField* fPtr = new sphericalTensorField; fPtr->transfer ( dynamicCast < token::Compound> > ( fieldToken.transferCompoundToken(is) ) ); if (fPtr->size() != this->size()) { FatalIOErrorInFunction ( dict ) << "\n size of field " << iter().keyword() << " (" << fPtr->size() << ')' << " is not the same size as the patch (" << this->size() << ')' << "\n on patch " << this->patch().name() << " of field " << this->dimensionedInternalField().name() << " in file " << this->dimensionedInternalField().objectPath() << exit(FatalIOError); } sphericalTensorFields_.insert(iter().keyword(), fPtr); } else if ( fieldToken.compoundToken().type() == token::Compound>::typeName ) { symmTensorField* fPtr = new symmTensorField; fPtr->transfer ( dynamicCast < token::Compound> > ( fieldToken.transferCompoundToken(is) ) ); if (fPtr->size() != this->size()) { FatalIOErrorInFunction ( dict ) << "\n size of field " << iter().keyword() << " (" << fPtr->size() << ')' << " is not the same size as the patch (" << this->size() << ')' << "\n on patch " << this->patch().name() << " of field " << this->dimensionedInternalField().name() << " in file " << this->dimensionedInternalField().objectPath() << exit(FatalIOError); } symmTensorFields_.insert(iter().keyword(), fPtr); } else if ( fieldToken.compoundToken().type() == token::Compound>::typeName ) { tensorField* fPtr = new tensorField; fPtr->transfer ( dynamicCast>> ( fieldToken.transferCompoundToken(is) ) ); if (fPtr->size() != this->size()) { FatalIOErrorInFunction ( dict ) << "\n size of field " << iter().keyword() << " (" << fPtr->size() << ')' << " is not the same size as the patch (" << this->size() << ')' << "\n on patch " << this->patch().name() << " of field " << this->dimensionedInternalField().name() << " in file " << this->dimensionedInternalField().objectPath() << exit(FatalIOError); } tensorFields_.insert(iter().keyword(), fPtr); } else { FatalIOErrorInFunction ( dict ) << "\n compound " << fieldToken.compoundToken() << " not supported" << "\n on patch " << this->patch().name() << " of field " << this->dimensionedInternalField().name() << " in file " << this->dimensionedInternalField().objectPath() << exit(FatalIOError); } } } } } } template Foam::genericPointPatchField::genericPointPatchField ( const genericPointPatchField& ptf, const pointPatch& p, const DimensionedField& iF, const pointPatchFieldMapper& mapper ) : calculatedPointPatchField(ptf, p, iF, mapper), actualTypeName_(ptf.actualTypeName_), dict_(ptf.dict_) { forAllConstIter ( HashPtrTable, ptf.scalarFields_, iter ) { scalarFields_.insert ( iter.key(), new scalarField(*iter(), mapper) ); } forAllConstIter ( HashPtrTable, ptf.vectorFields_, iter ) { vectorFields_.insert ( iter.key(), new vectorField(*iter(), mapper) ); } forAllConstIter ( HashPtrTable, ptf.sphericalTensorFields_, iter ) { sphericalTensorFields_.insert ( iter.key(), new sphericalTensorField(*iter(), mapper) ); } forAllConstIter ( HashPtrTable, ptf.symmTensorFields_, iter ) { symmTensorFields_.insert ( iter.key(), new symmTensorField(*iter(), mapper) ); } forAllConstIter ( HashPtrTable, ptf.tensorFields_, iter ) { tensorFields_.insert ( iter.key(), new tensorField(*iter(), mapper) ); } } template Foam::genericPointPatchField::genericPointPatchField ( const genericPointPatchField& ptf, const DimensionedField& iF ) : calculatedPointPatchField(ptf, iF), actualTypeName_(ptf.actualTypeName_), dict_(ptf.dict_), scalarFields_(ptf.scalarFields_), vectorFields_(ptf.vectorFields_), sphericalTensorFields_(ptf.sphericalTensorFields_), symmTensorFields_(ptf.symmTensorFields_), tensorFields_(ptf.tensorFields_) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template void Foam::genericPointPatchField::autoMap ( const pointPatchFieldMapper& m ) { forAllIter ( HashPtrTable, scalarFields_, iter ) { iter()->autoMap(m); } forAllIter ( HashPtrTable, vectorFields_, iter ) { iter()->autoMap(m); } forAllIter ( HashPtrTable, sphericalTensorFields_, iter ) { iter()->autoMap(m); } forAllIter ( HashPtrTable, symmTensorFields_, iter ) { iter()->autoMap(m); } forAllIter ( HashPtrTable, tensorFields_, iter ) { iter()->autoMap(m); } } template void Foam::genericPointPatchField::rmap ( const pointPatchField& ptf, const labelList& addr ) { const genericPointPatchField& dptf = refCast>(ptf); forAllIter ( HashPtrTable, scalarFields_, iter ) { HashPtrTable::const_iterator dptfIter = dptf.scalarFields_.find(iter.key()); if (dptfIter != scalarFields_.end()) { iter()->rmap(*dptfIter(), addr); } } forAllIter ( HashPtrTable, vectorFields_, iter ) { HashPtrTable::const_iterator dptfIter = dptf.vectorFields_.find(iter.key()); if (dptfIter != vectorFields_.end()) { iter()->rmap(*dptfIter(), addr); } } forAllIter ( HashPtrTable, sphericalTensorFields_, iter ) { HashPtrTable::const_iterator dptfIter = dptf.sphericalTensorFields_.find(iter.key()); if (dptfIter != sphericalTensorFields_.end()) { iter()->rmap(*dptfIter(), addr); } } forAllIter ( HashPtrTable, symmTensorFields_, iter ) { HashPtrTable::const_iterator dptfIter = dptf.symmTensorFields_.find(iter.key()); if (dptfIter != symmTensorFields_.end()) { iter()->rmap(*dptfIter(), addr); } } forAllIter ( HashPtrTable, tensorFields_, iter ) { HashPtrTable::const_iterator dptfIter = dptf.tensorFields_.find(iter.key()); if (dptfIter != tensorFields_.end()) { iter()->rmap(*dptfIter(), addr); } } } template void Foam::genericPointPatchField::write(Ostream& os) const { os.writeKeyword("type") << actualTypeName_ << token::END_STATEMENT << nl; forAllConstIter(dictionary, dict_, iter) { if (iter().keyword() != "type") { if ( iter().isStream() && iter().stream().size() && iter().stream()[0].isWord() && iter().stream()[0].wordToken() == "nonuniform" ) { if (scalarFields_.found(iter().keyword())) { scalarFields_.find(iter().keyword())() ->writeEntry(iter().keyword(), os); } else if (vectorFields_.found(iter().keyword())) { vectorFields_.find(iter().keyword())() ->writeEntry(iter().keyword(), os); } else if (sphericalTensorFields_.found(iter().keyword())) { sphericalTensorFields_.find(iter().keyword())() ->writeEntry(iter().keyword(), os); } else if (symmTensorFields_.found(iter().keyword())) { symmTensorFields_.find(iter().keyword())() ->writeEntry(iter().keyword(), os); } else if (tensorFields_.found(iter().keyword())) { tensorFields_.find(iter().keyword())() ->writeEntry(iter().keyword(), os); } } else { iter().write(os); } } } } // ************************************************************************* //