ENH: error handling for empty surfaces in surfaceFieldValue (#2966)

- for workflows with appearing/disappearing patches (for example)
  can specify that empty surfaces should be ignored or warned about
  instead of raising a FatalError.

  Note that this handling is additional to the regular top-level
  "errors" specification. So specifying 'strict' will only actually
  result in a FatalError if the "errors" does not trap errors.

- "ignore" : any empty surfaces are simply ignored and no
  file output (besides the header).

- "warn" : empty surfaces are warned about a few times (10)
  and the file output contains a NaN entry

- "strict" : corresponds to the default behaviour.
  Throws a FatalError if the surface is empty.
  This error may still be caught by the top-level "errors" handling.
This commit is contained in:
Mark Olesen
2023-08-30 16:08:30 +02:00
committed by Andrew Heather
parent ff2abdf1f0
commit 2e3f0811a0
2 changed files with 267 additions and 69 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd.
Copyright (C) 2015-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -88,6 +88,7 @@ Usage
scaleFactor 1.0;
writeArea false;
surfaceFormat none;
empty-surface warn; // default | warn | ignore | strict
// Optional (inherited) entries
...
@ -111,6 +112,7 @@ Usage
writeArea | Write the surface area | bool | no | false
surfaceFormat | Output value format | word <!--
--> | conditional on writeFields | none
empty-surface | Error handling for empty surfaces | enum | no | default
\endtable
The inherited entries are elaborated in:
@ -400,6 +402,9 @@ protected:
//- Optionally write the area of the surfaceFieldValue
bool writeArea_;
//- Handling of empty surfaces (nFaces = 0). Default is Fatal.
error::handlerTypes emptySurfaceError_;
//- Extended selections
wordRes selectionNames_;
@ -412,6 +417,9 @@ protected:
//- Global number of faces
label nFaces_;
//- Number of warnings emitted since the last valid update
unsigned nWarnings_;
// If operating on mesh faces (faceZone, patch)