From 1bce1e44c44929fd0a210d587d1a0c3d881585ee Mon Sep 17 00:00:00 2001
From: Andrew Heather <>
Date: Fri, 7 Jun 2024 12:36:24 +0100
Subject: [PATCH] ENH: propellerInfo - updated to work in postProcess mode.
 Fixes #2588

---
 .../forces/propellerInfo/propellerInfo.C      | 26 ++++++++++++++-----
 .../forces/propellerInfo/propellerInfo.H      |  8 +++++-
 2 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/src/functionObjects/forces/propellerInfo/propellerInfo.C b/src/functionObjects/forces/propellerInfo/propellerInfo.C
index c6ed2737dd6..b080d929a36 100644
--- a/src/functionObjects/forces/propellerInfo/propellerInfo.C
+++ b/src/functionObjects/forces/propellerInfo/propellerInfo.C
@@ -5,7 +5,7 @@
     \\  /    A nd           | www.openfoam.com
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
-    Copyright (C) 2021-2022 OpenCFD Ltd.
+    Copyright (C) 2021-2024 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -808,6 +808,7 @@ Foam::functionObjects::propellerInfo::propellerInfo
 )
 :
     forces(name, runTime, dict, false),
+    dict_(dict),
     radius_(0),
     URefPtr_(nullptr),
     rotationMode_(rotationMode::SPECIFIED),
@@ -827,7 +828,8 @@ Foam::functionObjects::propellerInfo::propellerInfo
     interpolationScheme_("cell"),
     wakeFilePtr_(nullptr),
     axialWakeFilePtr_(nullptr),
-    nanValue_(pTraits<scalar>::min)
+    nanValue_(pTraits<scalar>::min),
+    initialised_(false)
 {
     if (readFields)
     {
@@ -855,21 +857,18 @@ bool Foam::functionObjects::propellerInfo::read(const dictionary& dict)
 {
     if (forces::read(dict))
     {
+        dict_ = dict;
+
         radius_ = dict.getScalar("radius");
         URefPtr_.reset(Function1<scalar>::New("URef", dict, &mesh_));
         rotationMode_ = rotationModeNames_.get("rotationMode", dict);
 
-        // Must be set before setting the surface
-        setCoordinateSystem(dict);
-
         writePropellerPerformance_ =
             dict.get<bool>("writePropellerPerformance");
 
         writeWakeFields_ = dict.get<bool>("writeWakeFields");
         if (writeWakeFields_)
         {
-            setSampleDiskSurface(dict);
-
             dict.readIfPresent("interpolationScheme", interpolationScheme_);
 
             dict.readIfPresent("nanValue", nanValue_);
@@ -884,6 +883,19 @@ bool Foam::functionObjects::propellerInfo::read(const dictionary& dict)
 
 bool Foam::functionObjects::propellerInfo::execute()
 {
+    if (!initialised_)
+    {
+        // Must be set before setting the surface
+        setCoordinateSystem(dict_);
+
+        if (writeWakeFields_)
+        {
+            setSampleDiskSurface(dict_);
+        }
+
+        initialised_ = true;
+    }
+
     calcForcesMoments();
 
     createFiles();
diff --git a/src/functionObjects/forces/propellerInfo/propellerInfo.H b/src/functionObjects/forces/propellerInfo/propellerInfo.H
index dfd464f0f81..ad34bbbdac3 100644
--- a/src/functionObjects/forces/propellerInfo/propellerInfo.H
+++ b/src/functionObjects/forces/propellerInfo/propellerInfo.H
@@ -5,7 +5,7 @@
     \\  /    A nd           | www.openfoam.com
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
-    Copyright (C) 2021 OpenCFD Ltd.
+    Copyright (C) 2021-2024 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -205,6 +205,9 @@ protected:
 
     // Protected data
 
+        //- Copy of dictionary used during construction
+        dictionary dict_;
+
         //- Propeller radius
         scalar radius_;
 
@@ -271,6 +274,9 @@ protected:
             //- scalar::min
             scalar nanValue_;
 
+            //- Initialised flag
+            bool initialised_;
+
 
     // Protected Member Functions
 
-- 
GitLab