From e4d89daf5de85f31c98012102c7dea2e29351ff2 Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Fri, 10 May 2019 12:00:54 +0100 Subject: [PATCH] coupledFvPatches: Prevent crashes when operating on processor cases --- .../cyclicAMI/cyclicAMIFvPatchField.C | 11 +++++++++-- .../cyclicAMI/cyclicAMIFvsPatchField.C | 18 ++---------------- .../constraint/cyclicAMI/cyclicAMIFvPatch.C | 7 +++++-- .../cyclicAMIPointPatch/cyclicAMIPointPatch.C | 14 +++++++++++++- .../cyclicAMIPointPatch/cyclicAMIPointPatch.H | 5 ++++- .../cyclicAMIPointPatchField.C | 9 ++++++++- .../cyclicAMIPointPatchField.H | 6 +++++- 7 files changed, 46 insertions(+), 24 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C index ab7e19aa1d..dab70f35ee 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C @@ -63,9 +63,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 58579fbc7c..8312c573c3 100644 --- a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicAMI/cyclicAMIFvsPatchField.C +++ b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicAMI/cyclicAMIFvsPatchField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -114,21 +114,7 @@ Foam::cyclicAMIFvsPatchField::cyclicAMIFvsPatchField template bool Foam::cyclicAMIFvsPatchField::coupled() const { - if - ( - Pstream::parRun() - || ( - this->cyclicAMIPatch_.size() - && this->cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().size() - ) - ) - { - return true; - } - else - { - 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 ad5f02da5a..2b0a9ba1ec 100644 --- a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.C +++ b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -26,6 +26,7 @@ License #include "cyclicAMIFvPatch.H" #include "addToRunTimeSelectionTable.H" #include "fvMesh.H" +#include "Time.H" #include "transform.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -103,7 +104,9 @@ void Foam::cyclicAMIFvPatch::makeWeights(scalarField& w) const 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 b224b65b8f..516bbe6cc0 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatch/cyclicAMIPointPatch.C +++ b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatch/cyclicAMIPointPatch.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,6 +25,8 @@ License #include "cyclicAMIPointPatch.H" #include "pointBoundaryMesh.H" +#include "pointMesh.H" +#include "Time.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -96,4 +98,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 84fc7f28f4..b93db8bf89 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatch/cyclicAMIPointPatch.H +++ b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatch/cyclicAMIPointPatch.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -112,6 +112,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 b97936324f..1c88b2b926 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatchField/cyclicAMIPointPatchField.C +++ b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatchField/cyclicAMIPointPatchField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -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 a8b3d57019..0e2d3ea464 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatchField/cyclicAMIPointPatchField.H +++ b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatchField/cyclicAMIPointPatchField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -208,6 +208,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 (