diff --git a/src/finiteVolume/fields/fvPatchFields/derived/mappedFixedInternalValue/mappedFixedInternalValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/mappedFixedInternalValue/mappedFixedInternalValueFvPatchField.C index 326adefd74..819f39ecfb 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/mappedFixedInternalValue/mappedFixedInternalValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/mappedFixedInternalValue/mappedFixedInternalValueFvPatchField.C @@ -114,20 +114,67 @@ void Foam::mappedFixedInternalValueFvPatchField::updateCoeffs() const mappedPatchBase& mpp = refCast(this->patch().patch()); const fvMesh& nbrMesh = refCast(mpp.sampleMesh()); - const label samplePatchI = mpp.samplePolyPatch().index(); - const fvPatch& nbrPatch = nbrMesh.boundary()[samplePatchI]; + Field nbrIntFld; - // Retrieve the neighbour field - const fvPatchField& nbrField = - nbrPatch.template lookupPatchField - ( - this->dimensionedInternalField().name() - ); + switch (mpp.mode()) + { + case mappedPatchBase::NEARESTCELL: + { + FatalErrorIn + ( + "void mappedFixedValueFvPatchField::updateCoeffs()" + ) << "Cannot apply " + << mappedPatchBase::sampleModeNames_ + [ + mappedPatchBase::NEARESTCELL + ] + << " mapping mode for patch " << this->patch().name() + << exit(FatalError); - // Retrieve the neighbour patch internal field - Field nbrIntFld(nbrField.patchInternalField()); - mpp.distribute(nbrIntFld); + break; + } + case mappedPatchBase::NEARESTPATCHFACE: + { + 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(), pTraits::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: + { + FatalErrorIn("mappedFixedValueFvPatchField::updateCoeffs()") + << "Unknown sampling mode: " << mpp.mode() + << abort(FatalError); + } + } // Restore tag UPstream::msgType() = oldTag;