diff --git a/src/sampling/meshToMeshInterpolation/meshToMesh/meshToMeshTemplates.C b/src/sampling/meshToMeshInterpolation/meshToMesh/meshToMeshTemplates.C index 10a1c507c4..c5e1f669d6 100644 --- a/src/sampling/meshToMeshInterpolation/meshToMesh/meshToMeshTemplates.C +++ b/src/sampling/meshToMeshInterpolation/meshToMesh/meshToMeshTemplates.C @@ -386,7 +386,7 @@ Foam::meshToMesh::mapSrcToTgt const typename fieldType::GeometricBoundaryField& srcBfld = field.boundaryField(); - wordList patchTypes(tgtBm.size(), calculatedFvPatchField::typeName); + PtrList > tgtPatchFields(tgtBm.size()); // constuct tgt boundary patch types as copy of 'field' boundary types // note: this will provide place holders for fields with additional @@ -396,7 +396,43 @@ Foam::meshToMesh::mapSrcToTgt label srcPatchI = srcPatchID_[i]; label tgtPatchI = tgtPatchID_[i]; - patchTypes[tgtPatchI] = srcBfld[srcPatchI].type(); + if (!tgtPatchFields.set(tgtPatchI)) + { + tgtPatchFields.set + ( + tgtPatchI, + fvPatchField::New + ( + srcBfld[srcPatchI], + tgtMesh.boundary()[tgtPatchI], + DimensionedField::null(), + directFvPatchFieldMapper + ( + labelList(tgtMesh.boundary()[tgtPatchI].size(), -1) + ) + ) + ); + } + } + + // Any unset tgtPatchFields become calculated + forAll(tgtPatchFields, tgtPatchI) + { + if (!tgtPatchFields.set(tgtPatchI)) + { + // Note: use factory New method instead of direct generation of + // calculated so we keep constraints + tgtPatchFields.set + ( + tgtPatchI, + fvPatchField::New + ( + calculatedFvPatchField::typeName, + tgtMesh.boundary()[tgtPatchI], + DimensionedField::null() + ) + ); + } } tmp tresult @@ -412,8 +448,9 @@ Foam::meshToMesh::mapSrcToTgt IOobject::NO_WRITE ), tgtMesh, - dimensioned("0", field.dimensions(), pTraits::zero), - patchTypes + field.dimensions(), + Field(tgtMesh.nCells(), pTraits::zero), + tgtPatchFields ) ); @@ -512,7 +549,7 @@ Foam::meshToMesh::mapTgtToSrc const typename fieldType::GeometricBoundaryField& tgtBfld = field.boundaryField(); - wordList patchTypes(srcBm.size(), calculatedFvPatchField::typeName); + PtrList > srcPatchFields(srcBm.size()); // constuct src boundary patch types as copy of 'field' boundary types // note: this will provide place holders for fields with additional @@ -522,7 +559,43 @@ Foam::meshToMesh::mapTgtToSrc label srcPatchI = srcPatchID_[i]; label tgtPatchI = tgtPatchID_[i]; - patchTypes[srcPatchI] = tgtBfld[tgtPatchI].type(); + if (!srcPatchFields.set(tgtPatchI)) + { + srcPatchFields.set + ( + srcPatchI, + fvPatchField::New + ( + tgtBfld[srcPatchI], + srcMesh.boundary()[tgtPatchI], + DimensionedField::null(), + directFvPatchFieldMapper + ( + labelList(srcMesh.boundary()[srcPatchI].size(), -1) + ) + ) + ); + } + } + + // Any unset srcPatchFields become calculated + forAll(srcPatchFields, srcPatchI) + { + if (!srcPatchFields.set(srcPatchI)) + { + // Note: use factory New method instead of direct generation of + // calculated so we keep constraints + srcPatchFields.set + ( + srcPatchI, + fvPatchField::New + ( + calculatedFvPatchField::typeName, + srcMesh.boundary()[srcPatchI], + DimensionedField::null() + ) + ); + } } tmp tresult @@ -538,8 +611,9 @@ Foam::meshToMesh::mapTgtToSrc IOobject::NO_WRITE ), srcMesh, - dimensioned("0", field.dimensions(), pTraits::zero), - patchTypes + field.dimensions(), + Field(srcMesh.nCells(), pTraits::zero), + srcPatchFields ) );