From b19e767b8f8ee7ef75b59cef23af7765cf32240d Mon Sep 17 00:00:00 2001 From: Andrew Heather <> Date: Tue, 21 Sep 2021 20:48:30 +0100 Subject: [PATCH 01/18] ENH: sampledSets - added min,max,average values to the results dict --- .../sampledSet/sampledSets/sampledSetsTemplates.C | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C b/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C index 6ffb818ed4..82dad524a2 100644 --- a/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C +++ b/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2015-2020 OpenCFD Ltd. + Copyright (C) 2015-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -139,8 +139,17 @@ Foam::fileName Foam::sampledSets::writeSampleFile forAll(masterFields, fieldi) { - valueSetNames[fieldi] = masterFields[fieldi].name(); + const word& fieldName = masterFields[fieldi].name(); + + valueSetNames[fieldi] = fieldName; valueSets[fieldi] = &masterFields[fieldi][setI]; + + // Set results + + setResult("average(" + fieldName + ")", average(*valueSets[fieldi])); + setResult("min(" + fieldName + ")", min(*valueSets[fieldi])); + setResult("max(" + fieldName + ")", max(*valueSets[fieldi])); + setResult("size(" + fieldName + ")", valueSets[fieldi]->size()); } fileName fName From aeef96251ff3c90287ce457e897427984646bbda Mon Sep 17 00:00:00 2001 From: Andrew Heather <> Date: Tue, 21 Sep 2021 20:51:41 +0100 Subject: [PATCH 02/18] ENH: Refactored stateFunctionObject - created new functionObjects::properties class derived from IOdictionary - replaces raw state IOdictionary owned by functionObjectList - state dictionary access/manipulators moved from stateFunctionObject - stateFunctionObject now acts as a light wrapper around functionObjecties::properties - updated dependent code --- src/OpenFOAM/Make/files | 1 + .../functionObjectList/functionObjectList.C | 45 +-- .../functionObjectList/functionObjectList.H | 27 +- .../functionObjectProperties.C | 308 ++++++++++++++++++ .../functionObjectProperties.H | 241 ++++++++++++++ .../functionObjectPropertiesTemplates.C | 163 +++++++++ .../stateFunctionObject/stateFunctionObject.C | 168 ++-------- .../stateFunctionObject/stateFunctionObject.H | 12 +- .../stateFunctionObjectTemplates.C | 73 +---- 9 files changed, 787 insertions(+), 251 deletions(-) create mode 100644 src/OpenFOAM/db/functionObjects/functionObjectProperties/functionObjectProperties.C create mode 100644 src/OpenFOAM/db/functionObjects/functionObjectProperties/functionObjectProperties.H create mode 100644 src/OpenFOAM/db/functionObjects/functionObjectProperties/functionObjectPropertiesTemplates.C diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 79cd748121..47a7a41a0d 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -354,6 +354,7 @@ $(dll)/codedBase/codedBase.C funcObjs = db/functionObjects $(funcObjs)/functionObject/functionObject.C +$(funcObjs)/functionObjectProperties/functionObjectProperties.C $(funcObjs)/functionObjectList/functionObjectList.C $(funcObjs)/stateFunctionObject/stateFunctionObject.C $(funcObjs)/timeFunctionObject/timeFunctionObject.C diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C index 4c39aa2759..8aa4168d6d 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C @@ -97,13 +97,13 @@ namespace Foam // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // -void Foam::functionObjectList::createStateDict() const +void Foam::functionObjectList::createPropertiesDict() const { - // Cannot set the state dictionary on construction since Time has not + // Cannot set the properties dictionary on construction since Time has not // been fully initialised - stateDictPtr_.reset + propsDictPtr_.reset ( - new IOdictionary + new functionObjects::properties ( IOobject ( @@ -412,7 +412,7 @@ Foam::functionObjectList::functionObjectList warnings_(), time_(runTime), parentDict_(parentDict), - stateDictPtr_(nullptr), + propsDictPtr_(nullptr), objectsRegistryPtr_(nullptr), execution_(execution), updated_(false) @@ -509,37 +509,38 @@ Foam::autoPtr Foam::functionObjectList::New Foam::label Foam::functionObjectList::triggerIndex() const { - return stateDict().getOrDefault