From a7155a7e0a69f651c14fe6630cdecbc0d1c0d72c Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Fri, 21 Oct 2022 09:17:14 +0100 Subject: [PATCH] decomposePar, reconstructPar: Catch decomposition of overridden cyclics Patch fields on cyclic patches which have overridden the cyclic constraint using a "patchType cyclic;" setting cannot be decomposed. OpenFOAM does not have processor variants of jumpCyclic, porousBafflePressure, etc... Using these conditions in a decomposed case requires the cyclic to be constrained to a single processor. This change catches this problem in decomposePar and reconstructPar and raises a fatal error, rather than continuing and silently converting these overridden boundary conditions to a standard processorCyclic patch field. Resolves bug report https://bugs.openfoam.org/view.php?id=3916 --- .../decomposePar/fvFieldDecomposer.H | 3 +- .../fvFieldDecomposerDecomposeFields.C | 33 +++++++++++-------- .../fvFieldReconstructorReconstructFields.C | 18 ++++++++++ .../constraint/cyclic/cyclicTransform.C | 7 ++-- 4 files changed, 40 insertions(+), 21 deletions(-) diff --git a/applications/utilities/parallelProcessing/decomposePar/fvFieldDecomposer.H b/applications/utilities/parallelProcessing/decomposePar/fvFieldDecomposer.H index 8b1ddfc73d..e337554c20 100644 --- a/applications/utilities/parallelProcessing/decomposePar/fvFieldDecomposer.H +++ b/applications/utilities/parallelProcessing/decomposePar/fvFieldDecomposer.H @@ -149,8 +149,7 @@ public: tmp> decomposeField ( - const GeometricField& field, - const bool allowUnknownPatchFields = false + const GeometricField& field ) const; //- Decompose surface field diff --git a/applications/utilities/parallelProcessing/decomposePar/fvFieldDecomposerDecomposeFields.C b/applications/utilities/parallelProcessing/decomposePar/fvFieldDecomposerDecomposeFields.C index 210c00dc88..ad84b9b85c 100644 --- a/applications/utilities/parallelProcessing/decomposePar/fvFieldDecomposerDecomposeFields.C +++ b/applications/utilities/parallelProcessing/decomposePar/fvFieldDecomposerDecomposeFields.C @@ -29,6 +29,7 @@ License #include "processorCyclicFvPatchField.H" #include "processorCyclicFvsPatchField.H" #include "emptyFvPatchFields.H" +#include "stringOps.H" // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -85,8 +86,7 @@ template Foam::tmp> Foam::fvFieldDecomposer::decomposeField ( - const GeometricField& field, - const bool allowUnknownPatchFields + const GeometricField& field ) const { // Create dummy patch fields @@ -153,6 +153,23 @@ Foam::fvFieldDecomposer::decomposeField } else if (isA(procPatch)) { + if (field.boundaryField()[completePatchi].overridesConstraint()) + { + OStringStream str; + str << "\nThe field \"" << field.name() + << "\" on cyclic patch \"" + << field.boundaryField()[completePatchi].patch().name() + << "\" cannot be decomposed as it is not a cyclic " + << "patch field. A \"patchType cyclic;\" setting has " + << "been used to override the cyclic patch type.\n\n" + << "Cyclic patches like this with non-cyclic boundary " + << "conditions should be confined to a single " + << "processor using decomposition constraints."; + FatalErrorInFunction + << stringOps::breakIntoIndentedLines(str.str()).c_str() + << exit(FatalError); + } + const label nbrCompletePatchi = refCast(procPatch) .referPatch().nbrPatchID(); @@ -193,18 +210,6 @@ Foam::fvFieldDecomposer::decomposeField ) ); } - else if (allowUnknownPatchFields) - { - bf.set - ( - procPatchi, - new emptyFvPatchField - ( - procPatch, - resF() - ) - ); - } else { FatalErrorInFunction diff --git a/applications/utilities/parallelProcessing/reconstructPar/fvFieldReconstructorReconstructFields.C b/applications/utilities/parallelProcessing/reconstructPar/fvFieldReconstructorReconstructFields.C index faef572bc3..f32c30bc32 100644 --- a/applications/utilities/parallelProcessing/reconstructPar/fvFieldReconstructorReconstructFields.C +++ b/applications/utilities/parallelProcessing/reconstructPar/fvFieldReconstructorReconstructFields.C @@ -31,6 +31,7 @@ License #include "emptyFvPatchField.H" #include "emptyFvsPatchField.H" #include "processorCyclicFvPatch.H" +#include "stringOps.H" // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -212,6 +213,23 @@ Foam::fvFieldReconstructor::reconstructFvVolumeField ); } + if (patchFields[completePatchi].overridesConstraint()) + { + OStringStream str; + str << "\nThe field \"" << procFields[0].name() + << "\" on cyclic patch \"" + << patchFields[completePatchi].patch().name() + << "\" cannot be reconstructed as it is not a cyclic " + << "patch field. A \"patchType cyclic;\" setting has " + << "been used to override the cyclic patch type.\n\n" + << "Cyclic patches like this with non-cyclic boundary " + << "conditions should be confined to a single " + << "processor using decomposition constraints."; + FatalErrorInFunction + << stringOps::breakIntoIndentedLines(str.str()).c_str() + << exit(FatalError); + } + patchFields[completePatchi].rmap ( procField.boundaryField()[procPatchi], diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicTransform.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicTransform.C index 5b07db9b5e..4133e4eaf6 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicTransform.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicTransform.C @@ -514,9 +514,7 @@ Foam::cyclicTransform::cyclicTransform if (ctrNbrCtrTDistance > lengthScale*matchTolerance) { OStringStream str; - - str << nl - << "Patches " << name << " and " << nbrName << " are potentially " + str << "Patches " << name << " and " << nbrName << " are potentially " << "not geometrically similar enough to be coupled." << nl << nl << "The distance between the transformed centres of these patches " << "is " << ctrNbrCtrTDistance << ", which is greater than the " @@ -529,9 +527,8 @@ Foam::cyclicTransform::cyclicTransform << "is failing, then it might be appropriate to relax the failure " << "criteria by increasing the \"matchTolerance\" setting for " << "these patches in the \"polyMesh/boundary\" file."; - FatalErrorInFunction - << stringOps::breakIntoIndentedLines(str.str(), 80, 4).c_str() + << nl << stringOps::breakIntoIndentedLines(str.str()).c_str() << exit(FatalError); } }