From a0a19c7f3898add49eb75ae51900134d32eb9127 Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Thu, 19 Apr 2018 09:05:29 +0100 Subject: [PATCH] fvcAverage and fvcReconstruct: Return zero for 0-D cases fvcAverage and fvcReconstruct both do divisions or inverses of surface summed fields. A single-cell zero-dimension case, has no genuine faces on which to sum, so surface sums are identically zero. This change detects this situation and returns a zero value instead of failing due to a divide by zero. This allows the multiphase test cases to be reduced to just one cell. --- src/finiteVolume/finiteVolume/fvc/fvcAverage.C | 10 ++++++++-- src/finiteVolume/finiteVolume/fvc/fvcReconstruct.C | 12 ++++++++++-- .../binaryBreakup/system/blockMeshDict | 2 +- .../breakup/system/blockMeshDict | 2 +- .../coalescence/system/blockMeshDict | 2 +- .../system/blockMeshDict | 2 +- .../drift/system/blockMeshDict | 2 +- .../negativeDrift/system/blockMeshDict | 2 +- 8 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/finiteVolume/finiteVolume/fvc/fvcAverage.C b/src/finiteVolume/finiteVolume/fvc/fvcAverage.C index 2df82a88e6..e6e8233284 100644 --- a/src/finiteVolume/finiteVolume/fvc/fvcAverage.C +++ b/src/finiteVolume/finiteVolume/fvc/fvcAverage.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -62,9 +62,15 @@ average IOobject::NO_WRITE ), mesh, - ssf.dimensions() + dimensioned("0", ssf.dimensions(), Zero) ) ); + + if (!mesh.nGeometricD()) + { + return taverage; + } + GeometricField& av = taverage.ref(); av.primitiveFieldRef() = diff --git a/src/finiteVolume/finiteVolume/fvc/fvcReconstruct.C b/src/finiteVolume/finiteVolume/fvc/fvcReconstruct.C index 32c8a51dda..01dd173f2b 100644 --- a/src/finiteVolume/finiteVolume/fvc/fvcReconstruct.C +++ b/src/finiteVolume/finiteVolume/fvc/fvcReconstruct.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -73,11 +73,19 @@ reconstruct IOobject::NO_READ, IOobject::NO_WRITE ), - inv(surfaceSum(SfHat*mesh.Sf()))&surfaceSum(SfHat*ssf), + mesh, + dimensioned("0", ssf.dimensions()/dimArea, Zero), extrapolatedCalculatedFvPatchField::typeName ) ); + if (!mesh.nGeometricD()) + { + return treconField; + } + + treconField.ref() = inv(surfaceSum(SfHat*mesh.Sf()))&surfaceSum(SfHat*ssf), + treconField.ref().correctBoundaryConditions(); return treconField; diff --git a/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/binaryBreakup/system/blockMeshDict b/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/binaryBreakup/system/blockMeshDict index c925e3542d..a3d67d42eb 100644 --- a/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/binaryBreakup/system/blockMeshDict +++ b/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/binaryBreakup/system/blockMeshDict @@ -30,7 +30,7 @@ vertices blocks ( - hex (0 1 2 3 4 5 6 7) (1 2 1) simpleGrading (1 1 1) + hex (0 1 2 3 4 5 6 7) (1 1 1) simpleGrading (1 1 1) ); edges diff --git a/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/breakup/system/blockMeshDict b/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/breakup/system/blockMeshDict index c925e3542d..a3d67d42eb 100644 --- a/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/breakup/system/blockMeshDict +++ b/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/breakup/system/blockMeshDict @@ -30,7 +30,7 @@ vertices blocks ( - hex (0 1 2 3 4 5 6 7) (1 2 1) simpleGrading (1 1 1) + hex (0 1 2 3 4 5 6 7) (1 1 1) simpleGrading (1 1 1) ); edges diff --git a/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/coalescence/system/blockMeshDict b/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/coalescence/system/blockMeshDict index c925e3542d..a3d67d42eb 100644 --- a/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/coalescence/system/blockMeshDict +++ b/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/coalescence/system/blockMeshDict @@ -30,7 +30,7 @@ vertices blocks ( - hex (0 1 2 3 4 5 6 7) (1 2 1) simpleGrading (1 1 1) + hex (0 1 2 3 4 5 6 7) (1 1 1) simpleGrading (1 1 1) ); edges diff --git a/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/simultaneousCoalescenceAndBreakup/system/blockMeshDict b/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/simultaneousCoalescenceAndBreakup/system/blockMeshDict index c925e3542d..a3d67d42eb 100644 --- a/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/simultaneousCoalescenceAndBreakup/system/blockMeshDict +++ b/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/simultaneousCoalescenceAndBreakup/system/blockMeshDict @@ -30,7 +30,7 @@ vertices blocks ( - hex (0 1 2 3 4 5 6 7) (1 2 1) simpleGrading (1 1 1) + hex (0 1 2 3 4 5 6 7) (1 1 1) simpleGrading (1 1 1) ); edges diff --git a/test/multiphase/reactingTwoPhaseEulerFoam/populationBalanceModeling/drift/system/blockMeshDict b/test/multiphase/reactingTwoPhaseEulerFoam/populationBalanceModeling/drift/system/blockMeshDict index 9ef4f21b14..0014cbf999 100644 --- a/test/multiphase/reactingTwoPhaseEulerFoam/populationBalanceModeling/drift/system/blockMeshDict +++ b/test/multiphase/reactingTwoPhaseEulerFoam/populationBalanceModeling/drift/system/blockMeshDict @@ -30,7 +30,7 @@ vertices blocks ( - hex (0 1 2 3 4 5 6 7) (1 2 1) simpleGrading (1 1 1) + hex (0 1 2 3 4 5 6 7) (1 1 1) simpleGrading (1 1 1) ); edges diff --git a/test/multiphase/reactingTwoPhaseEulerFoam/populationBalanceModeling/negativeDrift/system/blockMeshDict b/test/multiphase/reactingTwoPhaseEulerFoam/populationBalanceModeling/negativeDrift/system/blockMeshDict index 9ef4f21b14..0014cbf999 100644 --- a/test/multiphase/reactingTwoPhaseEulerFoam/populationBalanceModeling/negativeDrift/system/blockMeshDict +++ b/test/multiphase/reactingTwoPhaseEulerFoam/populationBalanceModeling/negativeDrift/system/blockMeshDict @@ -30,7 +30,7 @@ vertices blocks ( - hex (0 1 2 3 4 5 6 7) (1 2 1) simpleGrading (1 1 1) + hex (0 1 2 3 4 5 6 7) (1 1 1) simpleGrading (1 1 1) ); edges