From fbbbcb4c31a0891d72e97c97a5fa7029346732a3 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Wed, 24 Aug 2011 16:23:45 +0100 Subject: [PATCH] Work-around for strange floating point exception; probably optimisation failure --- .../regionCouple/regionCoupleFvPatchField.C | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/regionCouple/regionCoupleFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/regionCouple/regionCoupleFvPatchField.C index 5ff86f070..33a7d3d7c 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/regionCouple/regionCoupleFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/regionCouple/regionCoupleFvPatchField.C @@ -191,12 +191,16 @@ void regionCoupleFvPatchField::evaluate scalar mOwn = magFOwn[faceI]; scalar mNei = magFNei[faceI]; - scalar den = mOwn - mNei; + scalar den1 = mOwn + mNei; + scalar den2 = mOwn - mNei; - if (mag(den) > SMALL) + // Strange optimisation check: floating point failure if only + // checking for den2. den1 check should not be needed + // HJ, 24/Aug/2011 + if (mag(den1) > SMALL && mag(den2) > SMALL) { - scalar mean = 2.0*mOwn*mNei/(mOwn + mNei); - weights[faceI] = (mean - mNei)/den; + scalar mean = 2.0*mOwn*mNei/den1; + weights[faceI] = (mean - mNei)/den2; } else {