From 9531212f14d7e8cb4e21c9e71db69437dbf21956 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 8 May 2018 09:16:00 +0200 Subject: [PATCH] ENH: disable ensightWrite, vtkWrite function objects in post-process mode - prevents accidental overwrite of runtime conversions. --- .../utilities/ensightWrite/ensightWrite.C | 9 +++++++++ .../utilities/vtkWrite/vtkWrite.C | 9 +++++++++ .../simpleFoam/motorBike/system/ensightWrite | 4 ++-- .../windAroundBuildings/system/controlDict | 1 + .../windAroundBuildings/system/ensightWrite | 18 ++++++++++++++++++ 5 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 tutorials/incompressible/simpleFoam/windAroundBuildings/system/ensightWrite diff --git a/src/functionObjects/utilities/ensightWrite/ensightWrite.C b/src/functionObjects/utilities/ensightWrite/ensightWrite.C index c3b927ff97..d9d0170369 100644 --- a/src/functionObjects/utilities/ensightWrite/ensightWrite.C +++ b/src/functionObjects/utilities/ensightWrite/ensightWrite.C @@ -85,6 +85,15 @@ Foam::functionObjects::ensightWrite::ensightWrite dirName_("ensightWrite"), consecutive_(false) { + if (postProcess) + { + // Disable for post-process mode. + // Emit as FatalError for the try/catch in the caller. + FatalError + << type() << " disabled in post-process mode" + << exit(FatalError); + } + read(dict); } diff --git a/src/functionObjects/utilities/vtkWrite/vtkWrite.C b/src/functionObjects/utilities/vtkWrite/vtkWrite.C index efc490d4c9..f5d28883ca 100644 --- a/src/functionObjects/utilities/vtkWrite/vtkWrite.C +++ b/src/functionObjects/utilities/vtkWrite/vtkWrite.C @@ -56,6 +56,15 @@ Foam::functionObjects::vtkWrite::vtkWrite selectFields_(), dirName_("VTK") { + if (postProcess) + { + // Disable for post-process mode. + // Emit as FatalError for the try/catch in the caller. + FatalError + << type() << " disabled in post-process mode" + << exit(FatalError); + } + read(dict); } diff --git a/tutorials/incompressible/simpleFoam/motorBike/system/ensightWrite b/tutorials/incompressible/simpleFoam/motorBike/system/ensightWrite index 2630bdc3b6..6e609b30d2 100644 --- a/tutorials/incompressible/simpleFoam/motorBike/system/ensightWrite +++ b/tutorials/incompressible/simpleFoam/motorBike/system/ensightWrite @@ -10,8 +10,8 @@ ensightWrite // Fields to output (words or regex) fields (U p "(k|epsilon|omega)"); - writeControl writeTime; - writeInterval 1; + writeControl writeTime; + writeInterval 1; } // ************************************************************************* // diff --git a/tutorials/incompressible/simpleFoam/windAroundBuildings/system/controlDict b/tutorials/incompressible/simpleFoam/windAroundBuildings/system/controlDict index 2f6bf24381..05cc58fa59 100644 --- a/tutorials/incompressible/simpleFoam/windAroundBuildings/system/controlDict +++ b/tutorials/incompressible/simpleFoam/windAroundBuildings/system/controlDict @@ -50,6 +50,7 @@ runTimeModifiable true; functions { + #include "ensightWrite" #include "vtkWrite" } diff --git a/tutorials/incompressible/simpleFoam/windAroundBuildings/system/ensightWrite b/tutorials/incompressible/simpleFoam/windAroundBuildings/system/ensightWrite new file mode 100644 index 0000000000..2345202b8e --- /dev/null +++ b/tutorials/incompressible/simpleFoam/windAroundBuildings/system/ensightWrite @@ -0,0 +1,18 @@ +// -*- C++ -*- +// Minimal example of using the ensight write function object. +// Many more options possible +ensightWrite +{ + type ensightWrite; + libs ("libutilityFunctionObjects.so"); + log true; + + // Fields to output (words or regex) + fields (U p "(k|epsilon|omega)"); + + //- Write more frequent than fields + writeControl timeStep; + writeInterval 5; +} + +// ************************************************************************* //