BUG: incorrect boundary type for expressions variables (fixes #1889)

- had calculated boundaries (default) for the evaluated variables,
  which meant they retained their initialized values (usually Zero).

  This normally goes unnoticed, since the boundary values are largely
  irrelevant in the volField expressions. However, when applying
  functions that balk at a zero value - eg, log() - this raises a
  floating point exception.

  These boundary should be zeroGradient, since the evaluated variables
  correspond to the internalField only. Could continue to use
  calculated, but then need to set the calculated boundary values from
  the patch internal field manually.
This commit is contained in:
Mark Olesen
2020-10-23 09:34:07 +02:00
parent 3e4d9e15c0
commit 9dc4f76b03

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2010-2018 Bernhard Gschaider <bgschaid@hfd-research.com>
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -261,7 +261,14 @@ Foam::tmp<GeomField> Foam::expressions::fvExprDriver::getOrReadFieldImpl
tfield.reset
(
GeomField::New(name, meshRef, dimensioned<Type>(Zero))
GeomField::New
(
name,
meshRef,
dimensioned<Type>(Zero),
// Patch is zeroGradient (volFields) or calculated (other)
defaultBoundaryType(GeomField::null())
)
);
GeomField& fld = tfield.ref();