/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2016 OpenFOAM Foundation ------------------------------------------------------------------------------- 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 "cyclicACMIPointPatchField.H" #include "transformField.H" #include "pointFields.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template Foam::cyclicACMIPointPatchField::cyclicACMIPointPatchField ( const pointPatch& p, const DimensionedField& iF ) : coupledPointPatchField(p, iF), cyclicACMIPatch_(refCast(p)), ppiPtr_(nullptr), nbrPpiPtr_(nullptr) {} template Foam::cyclicACMIPointPatchField::cyclicACMIPointPatchField ( const pointPatch& p, const DimensionedField& iF, const dictionary& dict ) : coupledPointPatchField(p, iF, dict), cyclicACMIPatch_(refCast(p, dict)), ppiPtr_(nullptr), nbrPpiPtr_(nullptr) { if (!isType(p)) { FatalIOErrorInFunction(dict) << "patch " << this->patch().index() << " not cyclicACMI type. " << "Patch type = " << p.type() << exit(FatalIOError); } } template Foam::cyclicACMIPointPatchField::cyclicACMIPointPatchField ( const cyclicACMIPointPatchField& ptf, const pointPatch& p, const DimensionedField& iF, const pointPatchFieldMapper& mapper ) : coupledPointPatchField(ptf, p, iF, mapper), cyclicACMIPatch_(refCast(p)), ppiPtr_(nullptr), nbrPpiPtr_(nullptr) { if (!isType(this->patch())) { FatalErrorInFunction << "Field type does not correspond to patch type for patch " << this->patch().index() << "." << endl << "Field type: " << typeName << endl << "Patch type: " << this->patch().type() << exit(FatalError); } } template Foam::cyclicACMIPointPatchField::cyclicACMIPointPatchField ( const cyclicACMIPointPatchField& ptf, const DimensionedField& iF ) : coupledPointPatchField(ptf, iF), cyclicACMIPatch_(ptf.cyclicACMIPatch_), ppiPtr_(nullptr), nbrPpiPtr_(nullptr) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template void Foam::cyclicACMIPointPatchField::swapAddSeparated ( const Pstream::commsTypes, Field& pField ) const { if (cyclicACMIPatch_.cyclicACMIPatch().owner()) { // We inplace modify pField. To prevent the other side (which gets // evaluated at a later date) using already changed values we do // all swaps on the side that gets evaluated first. // Get neighbouring pointPatch const cyclicACMIPointPatch& nbrPatch = cyclicACMIPatch_.neighbPatch(); // Get neighbouring pointPatchField const GeometricField& fld = refCast> ( this->internalField() ); const cyclicACMIPointPatchField& nbr = refCast> ( fld.boundaryField()[nbrPatch.index()] ); Field ptFld(this->patchInternalField(pField)); Field nbrPtFld(nbr.patchInternalField(pField)); if (doTransform()) { const tensor& forwardT = this->forwardT()[0]; const tensor& reverseT = this->reverseT()[0]; transform(ptFld, reverseT, ptFld); transform(nbrPtFld, forwardT, nbrPtFld); } // convert point field to face field, AMI interpolate, then // face back to point { // add neighbour side contribution to owner Field nbrFcFld(nbrPpi().pointToFaceInterpolate(nbrPtFld)); const cyclicAMIPolyPatch& cami = cyclicACMIPatch_.cyclicACMIPatch(); // interpolate to owner nbrFcFld = cami.interpolate(nbrFcFld); // add to internal field this->addToInternalField ( pField, ppi().faceToPointInterpolate(nbrFcFld)() ); } { // add owner side contribution to neighbour Field fcFld(ppi().pointToFaceInterpolate(ptFld)); const cyclicAMIPolyPatch& cami = cyclicACMIPatch_.cyclicACMIPatch(); // interpolate to neighbour fcFld = cami.neighbPatch().cyclicAMIPolyPatch::interpolate(fcFld); // add to internal field nbr.addToInternalField ( pField, nbrPpi().faceToPointInterpolate(fcFld)() ); } } } // ************************************************************************* //