From b42db6cee56207c93001cae52a6d353551691251 Mon Sep 17 00:00:00 2001 From: Darrin Stephens Date: Sat, 29 Aug 2020 21:24:51 +1000 Subject: [PATCH] BUG: reconstructPar: prevent crashes when operating on processor cases (#1143) From OpenFOAM Foundation https://github.com/OpenFOAM/OpenFOAM-dev/commit/e4d89daf5de85f31c98012102c7dea2e29351ff2 The main issue here was that reconstructPar is serial but coupled() in cyclicAMIFvPatch.C could return true if both sides of the patch was present (this->size() && neighbFvPatch().size()). However, this would result in an evaluate call in cyclicAMIFvPatchField. This would only work if both sides were completely contained on the same processor. The change in logic prevents coupled() from returning true when called in serial for a decomposed case. Signed-off-by: Kutalmis Bercin --- .../constraint/cyclicAMI/cyclicAMIFvPatchField.C | 11 +++++++++-- .../constraint/cyclicAMI/cyclicAMIFvsPatchField.C | 14 +------------- .../constraint/cyclicAMI/cyclicAMIFvPatch.C | 5 ++++- .../cyclicAMIPointPatch/cyclicAMIPointPatch.C | 12 ++++++++++++ .../cyclicAMIPointPatch/cyclicAMIPointPatch.H | 3 +++ .../cyclicAMIPointPatchField.C | 7 +++++++ .../cyclicAMIPointPatchField.H | 4 ++++ 7 files changed, 40 insertions(+), 16 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C index 047a0b01f7..eb3053dd88 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C @@ -64,9 +64,16 @@ Foam::cyclicAMIFvPatchField::cyclicAMIFvPatchField << exit(FatalIOError); } - if (!dict.found("value") && this->coupled()) + if (!dict.found("value")) { - this->evaluate(Pstream::commsTypes::blocking); + if (this->coupled()) + { + this->evaluate(Pstream::commsTypes::blocking); + } + else + { + fvPatchField::operator=(this->patchInternalField()); + } } } diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicAMI/cyclicAMIFvsPatchField.C b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicAMI/cyclicAMIFvsPatchField.C index bd4d9f4c1f..5a22b8cb08 100644 --- a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicAMI/cyclicAMIFvsPatchField.C +++ b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicAMI/cyclicAMIFvsPatchField.C @@ -115,19 +115,7 @@ Foam::cyclicAMIFvsPatchField::cyclicAMIFvsPatchField template bool Foam::cyclicAMIFvsPatchField::coupled() const { - if - ( - Pstream::parRun() - || ( - this->cyclicAMIPatch_.size() - && this->cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().size() - ) - ) - { - return true; - } - - return false; + return cyclicAMIPatch_.coupled(); } diff --git a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.C b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.C index 73398e753e..b338fb7b5e 100644 --- a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.C +++ b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.C @@ -29,6 +29,7 @@ License #include "cyclicAMIFvPatch.H" #include "addToRunTimeSelectionTable.H" #include "fvMesh.H" +#include "Time.H" #include "transform.H" #include "surfaceFields.H" @@ -52,7 +53,9 @@ namespace Foam bool Foam::cyclicAMIFvPatch::coupled() const { - return Pstream::parRun() || (this->size() && neighbFvPatch().size()); + return + Pstream::parRun() + || !this->boundaryMesh().mesh().time().processorCase(); } diff --git a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatch/cyclicAMIPointPatch.C b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatch/cyclicAMIPointPatch.C index 58803883f7..f4cecf6275 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatch/cyclicAMIPointPatch.C +++ b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatch/cyclicAMIPointPatch.C @@ -27,6 +27,8 @@ License #include "cyclicAMIPointPatch.H" #include "pointBoundaryMesh.H" +#include "pointMesh.H" +#include "Time.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -105,4 +107,14 @@ Foam::cyclicAMIPointPatch::~cyclicAMIPointPatch() {} +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::cyclicAMIPointPatch::coupled() const +{ + return + Pstream::parRun() + || !this->boundaryMesh().mesh().mesh().time().processorCase(); +} + + // ************************************************************************* // diff --git a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatch/cyclicAMIPointPatch.H b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatch/cyclicAMIPointPatch.H index cb7a7ab6a8..d501091c84 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatch/cyclicAMIPointPatch.H +++ b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatch/cyclicAMIPointPatch.H @@ -114,6 +114,9 @@ public: // Member Functions + //- Return true if this patch field is coupled + virtual bool coupled() const; + //- Return the constraint type this pointPatch implements. virtual const word& constraintType() const { diff --git a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatchField/cyclicAMIPointPatchField.C b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatchField/cyclicAMIPointPatchField.C index b9608c1115..0b4de45961 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatchField/cyclicAMIPointPatchField.C +++ b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatchField/cyclicAMIPointPatchField.C @@ -111,6 +111,13 @@ Foam::cyclicAMIPointPatchField::cyclicAMIPointPatchField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +template +bool Foam::cyclicAMIPointPatchField::coupled() const +{ + return cyclicAMIPatch_.coupled(); +} + + template void Foam::cyclicAMIPointPatchField::swapAddSeparated ( diff --git a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatchField/cyclicAMIPointPatchField.H b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatchField/cyclicAMIPointPatchField.H index 42830aba13..87fbaf5a8e 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatchField/cyclicAMIPointPatchField.H +++ b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatchField/cyclicAMIPointPatchField.H @@ -211,6 +211,10 @@ public: // Evaluation functions + //- Return true if coupled. Note that the underlying patch + //- is not coupled() - the points don't align. + virtual bool coupled() const; + //- Evaluate the patch field virtual void evaluate (