From 2d96fc5011de6cc5027aef78f4de646d3ca48daa Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Tue, 26 Jul 2016 12:05:15 +0100 Subject: [PATCH] BUG: mapFields function object - evaluate constraint patches after mapping. Fixes #190 --- .../utilities/mapFields/mapFields.H | 7 ++ .../utilities/mapFields/mapFieldsTemplates.C | 88 +++++++++++++++++++ 2 files changed, 95 insertions(+) diff --git a/src/postProcessing/functionObjects/utilities/mapFields/mapFields.H b/src/postProcessing/functionObjects/utilities/mapFields/mapFields.H index 80c2ebe119..9343616cfe 100644 --- a/src/postProcessing/functionObjects/utilities/mapFields/mapFields.H +++ b/src/postProcessing/functionObjects/utilities/mapFields/mapFields.H @@ -122,6 +122,13 @@ class mapFieldsFO //- Helper function to create the mesh-to-mesh interpolation void createInterpolation(const dictionary& dict); + //- Helper function to evaluate constraint patches after mapping + template + void evaluateConstraintTypes + ( + GeometricField& fld + ) const; + //- Helper function to interpolate and write the fied template bool writeFieldType() const; diff --git a/src/postProcessing/functionObjects/utilities/mapFields/mapFieldsTemplates.C b/src/postProcessing/functionObjects/utilities/mapFields/mapFieldsTemplates.C index de269ea867..dd1086049b 100644 --- a/src/postProcessing/functionObjects/utilities/mapFields/mapFieldsTemplates.C +++ b/src/postProcessing/functionObjects/utilities/mapFields/mapFieldsTemplates.C @@ -25,6 +25,91 @@ License #include "meshToMesh.H" +template +void Foam::mapFieldsFO::evaluateConstraintTypes +( + GeometricField& fld +) const +{ + 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 bool Foam::mapFieldsFO::writeFieldType() const { @@ -53,6 +138,9 @@ bool Foam::mapFieldsFO::writeFieldType() const if (log_) Info<< ": interpolated"; FieldType fieldMapRegion(mapRegionIO, tfieldMapRegion); + + evaluateConstraintTypes(fieldMapRegion); + fieldMapRegion.write(); if (log_) Info<< " and written" << nl;