From 13152510b3a05bb65f01d3025ca45f005ecc2fb0 Mon Sep 17 00:00:00 2001
From: Andrew Heather <>
Date: Thu, 28 Jan 2021 16:23:11 +0000
Subject: [PATCH] ENH: surfaceFieldValue - set surface output info for run-time
 post-processing

If the 'writeFields' option is set in surfaceFieldValue, e.g.

    surface1
    {
        type        surfaceFieldValue;
        libs        (fieldFunctionObjects);
        operation   none;
        fields      (p);
        regionType  patch;
        name        walls;

        // Create a surface in VTK format
        writeFields yes;
        surfaceFormat vtk;
    }

... the surface can now be used in runTimePostProcessing, e.g.:

    surfaces
    {
        surfaceFieldValueOutput
        {
            type            functionObjectSurface;
            representation  surface;
            liveObject      no;
            field           p;
            colourBy        field;
            range           (0 120000);
            functionObject  surface1;
        }
    }

Note: setting 'liveObject' to 'no' to suppress warnings due to the surface
not being retrieved from the object registry (default = 'yes') - this surface
can [currently] only be read from disk.
---
 .../surfaceFieldValue/surfaceFieldValueTemplates.C        | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C
index 20effe990b4..3ed468dd2c7 100644
--- a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C
+++ b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C
@@ -397,7 +397,13 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues
 
                 surfaceWriterPtr_->nFields() = 1;  // Needed for VTK legacy
 
-                surfaceWriterPtr_->write(fieldName, allValues);
+                fileName outputName =
+                    surfaceWriterPtr_->write(fieldName, allValues);
+
+                // Case-local file name with "<case>" to make relocatable
+                dictionary propsDict;
+                propsDict.add("file", time_.relativePath(outputName, true));
+                this->setProperty(fieldName, propsDict);
 
                 surfaceWriterPtr_->clear();
             }
-- 
GitLab