From b1d755aca1ddc6a1b095d0e43996b08dd9e10ba0 Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 20 Jun 2016 11:25:38 +0100 Subject: [PATCH] ENH: mapFieldsPar: map (global) constraint patches --- .../preProcessing/mapFieldsPar/MapVolFields.H | 95 ++++++++++++++++++- .../preProcessing/mapFieldsPar/mapFieldsPar.C | 30 +----- src/sampling/meshToMesh/meshToMesh.C | 11 ++- 3 files changed, 102 insertions(+), 34 deletions(-) diff --git a/applications/utilities/preProcessing/mapFieldsPar/MapVolFields.H b/applications/utilities/preProcessing/mapFieldsPar/MapVolFields.H index c365bbddf6..c212b473ec 100644 --- a/applications/utilities/preProcessing/mapFieldsPar/MapVolFields.H +++ b/applications/utilities/preProcessing/mapFieldsPar/MapVolFields.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -35,6 +35,88 @@ License namespace Foam { +template +void evaluateConstraintTypes(GeometricField& fld) +{ + typename GeometricField:: + GeometricBoundaryField& fldBf = fld.boundaryField(); + + if + ( + Pstream::defaultCommsType == Pstream::blocking + || Pstream::defaultCommsType == Pstream::nonBlocking + ) + { + label nReq = Pstream::nRequests(); + + forAll(fldBf, patchi) + { + fvPatchField& tgtField = fldBf[patchi]; + + if + ( + tgtField.type() == tgtField.patch().patch().type() + && polyPatch::constraintType(tgtField.patch().patch().type()) + ) + { + tgtField.initEvaluate(Pstream::defaultCommsType); + } + } + + // Block for any outstanding requests + if + ( + Pstream::parRun() + && Pstream::defaultCommsType == Pstream::nonBlocking + ) + { + Pstream::waitRequests(nReq); + } + + forAll(fldBf, patchi) + { + fvPatchField& tgtField = fldBf[patchi]; + + if + ( + tgtField.type() == tgtField.patch().patch().type() + && polyPatch::constraintType(tgtField.patch().patch().type()) + ) + { + tgtField.evaluate(Pstream::defaultCommsType); + } + } + } + else if (Pstream::defaultCommsType == Pstream::scheduled) + { + const lduSchedule& patchSchedule = + fld.mesh().globalData().patchSchedule(); + + forAll(patchSchedule, patchEvali) + { + label patchi = patchSchedule[patchEvali].patch; + fvPatchField& tgtField = fldBf[patchi]; + + if + ( + tgtField.type() == tgtField.patch().patch().type() + && polyPatch::constraintType(tgtField.patch().patch().type()) + ) + { + if (patchSchedule[patchEvali].init) + { + tgtField.initEvaluate(Pstream::scheduled); + } + else + { + tgtField.evaluate(Pstream::scheduled); + } + } + } + } +} + + template void MapVolFields ( @@ -57,8 +139,6 @@ void MapVolFields if (selectedFields.empty() || selectedFields.found(fieldName)) { - Info<< " interpolating " << fieldName << endl; - const fieldType fieldSource(*fieldIter(), meshSource); IOobject targetIO @@ -71,14 +151,21 @@ void MapVolFields if (targetIO.typeHeaderOk(true)) { + Info<< " interpolating onto existing field " + << fieldName << endl; fieldType fieldTarget(targetIO, meshTarget); interp.mapSrcToTgt(fieldSource, cop, fieldTarget); + evaluateConstraintTypes(fieldTarget); + fieldTarget.write(); } else { + Info<< " creating new field " + << fieldName << endl; + targetIO.readOpt() = IOobject::NO_READ; tmp @@ -86,6 +173,8 @@ void MapVolFields fieldType fieldTarget(targetIO, tfieldTarget); + evaluateConstraintTypes(fieldTarget); + fieldTarget.write(); } } diff --git a/applications/utilities/preProcessing/mapFieldsPar/mapFieldsPar.C b/applications/utilities/preProcessing/mapFieldsPar/mapFieldsPar.C index 515dc66459..fdfdaad1da 100644 --- a/applications/utilities/preProcessing/mapFieldsPar/mapFieldsPar.C +++ b/applications/utilities/preProcessing/mapFieldsPar/mapFieldsPar.C @@ -121,34 +121,6 @@ void mapSubMesh } -wordList addProcessorPatches -( - const fvMesh& meshTarget, - const wordList& cuttingPatches -) -{ - // Add the processor patches to the cutting list - HashSet cuttingPatchTable; - forAll(cuttingPatches, i) - { - cuttingPatchTable.insert(cuttingPatches[i]); - } - - const polyBoundaryMesh& pbm = meshTarget.boundaryMesh(); - - forAll(pbm, patchI) - { - if (isA(pbm[patchI])) - { - const word& patchName = pbm[patchI].name(); - cuttingPatchTable.insert(patchName); - } - } - - return cuttingPatchTable.toc(); -} - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int main(int argc, char *argv[]) @@ -369,7 +341,7 @@ int main(int argc, char *argv[]) meshSource, meshTarget, patchMap, - addProcessorPatches(meshTarget, cuttingPatches), + cuttingPatches, mapMethod, patchMapMethod, subtract, diff --git a/src/sampling/meshToMesh/meshToMesh.C b/src/sampling/meshToMesh/meshToMesh.C index 98d622e00c..3b336ba494 100644 --- a/src/sampling/meshToMesh/meshToMesh.C +++ b/src/sampling/meshToMesh/meshToMesh.C @@ -713,7 +713,11 @@ void Foam::meshToMesh::constructNoCuttingPatches forAll(srcBM, patchI) { const polyPatch& pp = srcBM[patchI]; - if (!polyPatch::constraintType(pp.type())) + + // We want to map all the global patches, including constraint + // patches (since they might have mappable properties, e.g. + // jumpCyclic). We'll fix the value afterwards. + if (!isA(pp)) { srcPatchID.append(pp.index()); @@ -764,7 +768,10 @@ void Foam::meshToMesh::constructFromCuttingPatches const polyPatch& srcPatch = srcRegion_.boundaryMesh()[srcPatchName]; - if (!polyPatch::constraintType(srcPatch.type())) + // We want to map all the global patches, including constraint + // patches (since they might have mappable properties, e.g. + // jumpCyclic). We'll fix the value afterwards. + if (!isA(srcPatch)) { const polyPatch& tgtPatch = tgtRegion_.boundaryMesh()[tgtPatchName];