/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-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 "mappedFixedInternalValueFvPatchField.H" #include "IndirectList.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template Foam::mappedFixedInternalValueFvPatchField:: mappedFixedInternalValueFvPatchField ( const fvPatch& p, const DimensionedField& iF ) : mappedFixedValueFvPatchField(p, iF) {} template Foam::mappedFixedInternalValueFvPatchField:: mappedFixedInternalValueFvPatchField ( const mappedFixedInternalValueFvPatchField& ptf, const fvPatch& p, const DimensionedField& iF, const fvPatchFieldMapper& mapper ) : mappedFixedValueFvPatchField(ptf, p, iF, mapper) {} template Foam::mappedFixedInternalValueFvPatchField:: mappedFixedInternalValueFvPatchField ( const fvPatch& p, const DimensionedField& iF, const dictionary& dict ) : mappedFixedValueFvPatchField(p, iF, dict) {} template Foam::mappedFixedInternalValueFvPatchField:: mappedFixedInternalValueFvPatchField ( const mappedFixedInternalValueFvPatchField& ptf ) : mappedFixedValueFvPatchField(ptf) {} template Foam::mappedFixedInternalValueFvPatchField:: mappedFixedInternalValueFvPatchField ( const mappedFixedInternalValueFvPatchField& ptf, const DimensionedField& iF ) : mappedFixedValueFvPatchField(ptf, iF) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template void Foam::mappedFixedInternalValueFvPatchField::updateCoeffs() { typedef GeometricField FieldType; if (this->updated()) { return; } // Since we're inside initEvaluate/evaluate there might be processor // comms underway. Change the tag we use. const int oldTag = UPstream::incrMsgType(); // Retrieve the neighbour values and assign to this patch boundary field mappedFixedValueFvPatchField::updateCoeffs(); // Get the coupling information from the mappedPatchBase const mappedPatchBase& mpp = refCast(this->patch().patch()); const fvMesh& nbrMesh = refCast(mpp.sampleMesh()); Field nbrIntFld; switch (mpp.mode()) { case mappedPatchBase::NEARESTCELL: { FatalErrorInFunction << "Cannot apply " << mappedPatchBase::sampleModeNames_ [ mappedPatchBase::NEARESTCELL ] << " mapping mode for patch " << this->patch().name() << exit(FatalError); break; } case mappedPatchBase::NEARESTPATCHFACE: case mappedPatchBase::NEARESTPATCHFACEAMI: { const label samplePatchi = mpp.samplePolyPatch().index(); const fvPatchField& nbrPatchField = this->sampleField().boundaryField()[samplePatchi]; nbrIntFld = nbrPatchField.patchInternalField(); mpp.distribute(nbrIntFld); break; } case mappedPatchBase::NEARESTFACE: { Field allValues(nbrMesh.nFaces(), Zero); const FieldType& nbrField = this->sampleField(); forAll(nbrField.boundaryField(), patchi) { const fvPatchField& pf = nbrField.boundaryField()[patchi]; const Field pif(pf.patchInternalField()); label faceStart = pf.patch().start(); forAll(pf, facei) { allValues[faceStart++] = pif[facei]; } } mpp.distribute(allValues); nbrIntFld.transfer(allValues); break; } default: { FatalErrorInFunction << "Unknown sampling mode: " << mpp.mode() << abort(FatalError); } } UPstream::msgType(oldTag); // Restore tag // Assign to (this) patch internal field its neighbour values Field& intFld = const_cast&>(this->primitiveField()); UIndirectList(intFld, this->patch().faceCells()) = nbrIntFld; } template void Foam::mappedFixedInternalValueFvPatchField::write ( Ostream& os ) const { mappedFixedValueFvPatchField::write(os); } // ************************************************************************* //