From d07327202e8c74402919adaac052e6a730065877 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 20 Nov 2012 18:06:15 +0000 Subject: [PATCH] ENH: Extended API to allow results to be accessed outside of class --- .../field/fieldValues/cellSource/cellSourceTemplates.C | 3 +++ .../field/fieldValues/faceSource/faceSourceTemplates.C | 3 +++ .../field/fieldValues/fieldValue/fieldValue.C | 3 ++- .../field/fieldValues/fieldValue/fieldValue.H | 8 +++++++- .../field/fieldValues/fieldValue/fieldValueI.H | 8 +++++++- 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceTemplates.C b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceTemplates.C index ab59cf13b8..bdeccc6dd0 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceTemplates.C +++ b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceTemplates.C @@ -177,6 +177,9 @@ bool Foam::fieldValues::cellSource::writeValues(const word& fieldName) { Type result = processValues(values, V, weightField); + // add to result dictionary, over-writing any previous entry + resultDict_.add(fieldName, result, true); + if (valueOutput_) { IOField diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C index 4092bf4400..a82f489036 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C @@ -291,6 +291,9 @@ bool Foam::fieldValues::faceSource::writeValues(const word& fieldName) { Type result = processValues(values, Sf, weightField); + // add to result dictionary, over-writing any previous entry + resultDict_.add(fieldName, result, true); + file()<< tab << result; if (log_) diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.C b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.C index cc2aeb0423..731eadc0c1 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.C +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.C @@ -92,7 +92,8 @@ Foam::fieldValue::fieldValue log_(false), sourceName_(dict.lookupOrDefault("sourceName", "sampledSurface")), fields_(dict.lookup("fields")), - valueOutput_(dict.lookup("valueOutput")) + valueOutput_(dict.lookup("valueOutput")), + resultDict_(fileName("name"), dictionary::null) { // Only active if obr is an fvMesh if (isA(obr_)) diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.H b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.H index 8e52e3ee45..0a91671f72 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.H +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.H @@ -42,6 +42,7 @@ SourceFiles #include "Switch.H" #include "pointFieldFwd.H" #include "OFstream.H" +#include "dictionary.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -49,7 +50,6 @@ namespace Foam { // Forward declaration of classes -class dictionary; class objectRegistry; class fvMesh; class mapPolyMesh; @@ -88,6 +88,9 @@ protected: //- Output field values flag Switch valueOutput_; + //- Results dictionary for external access of results + dictionary resultDict_; + // Functions to be over-ridden from IOoutputFilter class @@ -147,6 +150,9 @@ public: //- Helper function to return the reference to the mesh inline const fvMesh& mesh() const; + //- Return access to the latest set of results + inline const dictionary& resultDict() const; + // Function object functions diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueI.H b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueI.H index c29a7b918a..cd6b8ad181 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueI.H +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -75,4 +75,10 @@ inline const Foam::fvMesh& Foam::fieldValue::mesh() const } +inline const Foam::dictionary& Foam::fieldValue::resultDict() const +{ + return resultDict_; +} + + // ************************************************************************* //