From 0dd55ebad00f337038e0ee23b9b5576ea7b963ec Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Thu, 27 Jun 2024 13:02:57 +0100 Subject: [PATCH] createNonConformalCouples: Fix writing of non-conformal processor cyclic fields --- .../createNonConformalCouples.C | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/applications/utilities/mesh/manipulation/createNonConformalCouples/createNonConformalCouples.C b/applications/utilities/mesh/manipulation/createNonConformalCouples/createNonConformalCouples.C index 16de5c0bcf..8b9be1d1f7 100644 --- a/applications/utilities/mesh/manipulation/createNonConformalCouples/createNonConformalCouples.C +++ b/applications/utilities/mesh/manipulation/createNonConformalCouples/createNonConformalCouples.C @@ -240,6 +240,51 @@ struct nonConformalCouple }; +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template +void evaluateNonConformalProcessorCyclics(const fvMesh& mesh) +{ + UPtrList> fields(mesh.fields>()); + + forAll(fields, i) + { + const label nReq = Pstream::nRequests(); + + forAll(mesh.boundary(), patchi) + { + typename VolField::Patch& pf = + fields[i].boundaryFieldRef()[patchi]; + + if (isA(pf.patch().patch())) + { + pf.initEvaluate(Pstream::defaultCommsType); + } + } + + if + ( + Pstream::parRun() + && Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking + ) + { + Pstream::waitRequests(nReq); + } + + forAll(mesh.boundary(), patchi) + { + typename VolField::Patch& pf = + fields[i].boundaryFieldRef()[patchi]; + + if (isA(pf.patch().patch())) + { + pf.evaluate(Pstream::defaultCommsType); + } + } + } +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int main(int argc, char *argv[]) @@ -754,6 +799,21 @@ int main(int argc, char *argv[]) } } + // Communicate values across non-conformal processor cyclics so that they + // contain valid values that can be written to disk + if (Pstream::parRun()) + { + forAll(regionMeshes, regioni) + { + const fvMesh& mesh = regionMeshes[regioni]; + + #define EVALUATE_NON_CONFORMAL_PROCESSOR_CYCLICS(Type, nullArg) \ + evaluateNonConformalProcessorCyclics(mesh); + FOR_ALL_FIELD_TYPES(EVALUATE_NON_CONFORMAL_PROCESSOR_CYCLICS) + #undef EVALUATE_NON_CONFORMAL_PROCESSOR_CYCLICS + } + } + // Set the precision of the points data to 10 IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));