/*---------------------------------------------------------------------------*\ ========= | \\ / 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 "pointPatchField.H" #include "pointMesh.H" #include "dictionary.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template Foam::pointPatchField::pointPatchField ( const pointPatch& p, const DimensionedField& iF ) : patch_(p), internalField_(iF), updated_(false), patchType_(word::null) {} template Foam::pointPatchField::pointPatchField ( const pointPatch& p, const DimensionedField& iF, const dictionary& dict ) : patch_(p), internalField_(iF), updated_(false), patchType_(dict.lookupOrDefault("patchType", word::null)) {} template Foam::pointPatchField::pointPatchField ( const pointPatchField& ptf, const pointPatch& p, const DimensionedField& iF, const pointPatchFieldMapper& ) : patch_(p), internalField_(iF), updated_(false), patchType_(ptf.patchType_) {} template Foam::pointPatchField::pointPatchField ( const pointPatchField& ptf ) : patch_(ptf.patch_), internalField_(ptf.internalField_), updated_(false), patchType_(ptf.patchType_) {} template Foam::pointPatchField::pointPatchField ( const pointPatchField& ptf, const DimensionedField& iF ) : patch_(ptf.patch_), internalField_(iF), updated_(false), patchType_(ptf.patchType_) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template const Foam::objectRegistry& Foam::pointPatchField::db() const { return patch_.boundaryMesh().mesh()(); } template void Foam::pointPatchField::write(Ostream& os) const { os.writeKeyword("type") << type() << token::END_STATEMENT << nl; if (patchType_.size()) { os.writeKeyword("patchType") << patchType_ << token::END_STATEMENT << nl; } } template Foam::tmp> Foam::pointPatchField::patchInternalField() const { return patchInternalField(primitiveField()); } template template Foam::tmp> Foam::pointPatchField::patchInternalField ( const Field& iF, const labelList& meshPoints ) const { // Check size if (iF.size() != primitiveField().size()) { FatalErrorInFunction << "given internal field does not correspond to the mesh. " << "Field size: " << iF.size() << " mesh size: " << primitiveField().size() << abort(FatalError); } return tmp>(new Field(iF, meshPoints)); } template template Foam::tmp> Foam::pointPatchField::patchInternalField ( const Field& iF ) const { return patchInternalField(iF, patch().meshPoints()); } template template void Foam::pointPatchField::addToInternalField ( Field& iF, const Field& pF ) const { // Check size if (iF.size() != primitiveField().size()) { FatalErrorInFunction << "given internal field does not correspond to the mesh. " << "Field size: " << iF.size() << " mesh size: " << primitiveField().size() << abort(FatalError); } if (pF.size() != size()) { FatalErrorInFunction << "given patch field does not correspond to the mesh. " << "Field size: " << pF.size() << " mesh size: " << size() << abort(FatalError); } // Get the addressing const labelList& mp = patch().meshPoints(); forAll(mp, pointi) { iF[mp[pointi]] += pF[pointi]; } } template template void Foam::pointPatchField::addToInternalField ( Field& iF, const Field& pF, const labelList& points ) const { // Check size if (iF.size() != primitiveField().size()) { FatalErrorInFunction << "given internal field does not correspond to the mesh. " << "Field size: " << iF.size() << " mesh size: " << primitiveField().size() << abort(FatalError); } if (pF.size() != size()) { FatalErrorInFunction << "given patch field does not correspond to the mesh. " << "Field size: " << pF.size() << " mesh size: " << size() << abort(FatalError); } // Get the addressing const labelList& mp = patch().meshPoints(); forAll(points, i) { label pointi = points[i]; iF[mp[pointi]] += pF[pointi]; } } template template void Foam::pointPatchField::setInInternalField ( Field& iF, const Field& pF, const labelList& meshPoints ) const { // Check size if (iF.size() != primitiveField().size()) { FatalErrorInFunction << "given internal field does not correspond to the mesh. " << "Field size: " << iF.size() << " mesh size: " << primitiveField().size() << abort(FatalError); } if (pF.size() != meshPoints.size()) { FatalErrorInFunction << "given patch field does not correspond to the meshPoints. " << "Field size: " << pF.size() << " meshPoints size: " << size() << abort(FatalError); } forAll(meshPoints, pointi) { iF[meshPoints[pointi]] = pF[pointi]; } } template template void Foam::pointPatchField::setInInternalField ( Field& iF, const Field& pF ) const { setInInternalField(iF, pF, patch().meshPoints()); } template void Foam::pointPatchField::evaluate(const Pstream::commsTypes) { if (!updated_) { updateCoeffs(); } updated_ = false; } // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // template Foam::Ostream& Foam::operator<< ( Ostream& os, const pointPatchField& ptf ) { ptf.write(os); os.check("Ostream& operator<<(Ostream&, const pointPatchField&)"); return os; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #include "pointPatchFieldNew.C" // ************************************************************************* //