diff --git a/src/sampling/meshToMeshInterpolation/meshToMesh/meshToMeshTemplates.C b/src/sampling/meshToMeshInterpolation/meshToMesh/meshToMeshTemplates.C index b5981d522c..5a9926046f 100644 --- a/src/sampling/meshToMeshInterpolation/meshToMesh/meshToMeshTemplates.C +++ b/src/sampling/meshToMeshInterpolation/meshToMesh/meshToMeshTemplates.C @@ -25,6 +25,7 @@ License #include "fvMesh.H" #include "volFields.H" +#include "directFvPatchFieldMapper.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -380,6 +381,32 @@ Foam::meshToMesh::mapSrcToTgt const fvMesh& tgtMesh = static_cast(tgtRegion_); + const typename fieldType::GeometricBoundaryField& bfld = + field.boundaryField(); + + PtrList > patchFields(bfld.size()); + + // constuct tgt boundary patch types as copy of field boundary types + // note: this will provide place holders for fields with additional + // entries, but these values will need to be reset + forAll(bfld, patchI) + { + patchFields.set + ( + patchI, + fvPatchField::New + ( + bfld[patchI], + tgtMesh.boundary()[patchI], + DimensionedField::null(), + directFvPatchFieldMapper + ( + labelList(tgtMesh.boundary()[patchI].size(), -1) + ) + ) + ); + } + tmp tresult ( new fieldType @@ -393,12 +420,9 @@ Foam::meshToMesh::mapSrcToTgt IOobject::NO_WRITE ), tgtMesh, - dimensioned - ( - "zero", - field.dimensions(), - pTraits::zero - ) + field.dimensions(), + Field(tgtMesh.nCells(), pTraits::zero), + patchFields ) ); @@ -493,6 +517,32 @@ Foam::meshToMesh::mapTgtToSrc const fvMesh& srcMesh = static_cast(srcRegion_); + const typename fieldType::GeometricBoundaryField& bfld = + field.boundaryField(); + + PtrList > patchFields(bfld.size()); + + // constuct src boundary patch types as copy of field boundary types + // note: this will provide place holders for fields with additional + // entries, but these values will need to be reset + forAll(bfld, patchI) + { + patchFields.set + ( + patchI, + fvPatchField::New + ( + bfld[patchI], + srcMesh.boundary()[patchI], + DimensionedField::null(), + directFvPatchFieldMapper + ( + labelList(srcMesh.boundary()[patchI].size(), -1) + ) + ) + ); + } + tmp tresult ( new fieldType @@ -506,12 +556,9 @@ Foam::meshToMesh::mapTgtToSrc IOobject::NO_WRITE ), srcMesh, - dimensioned - ( - "zero", - field.dimensions(), - pTraits::zero - ) + field.dimensions(), + Field(srcMesh.nCells(), pTraits::zero), + patchFields ) );