ENH: Extended API to allow results to be accessed outside of class

This commit is contained in:
andy
2012-11-20 18:06:15 +00:00
parent ea774d8a97
commit d07327202e
5 changed files with 22 additions and 3 deletions

View File

@ -177,6 +177,9 @@ bool Foam::fieldValues::cellSource::writeValues(const word& fieldName)
{ {
Type result = processValues(values, V, weightField); Type result = processValues(values, V, weightField);
// add to result dictionary, over-writing any previous entry
resultDict_.add(fieldName, result, true);
if (valueOutput_) if (valueOutput_)
{ {
IOField<Type> IOField<Type>

View File

@ -291,6 +291,9 @@ bool Foam::fieldValues::faceSource::writeValues(const word& fieldName)
{ {
Type result = processValues(values, Sf, weightField); Type result = processValues(values, Sf, weightField);
// add to result dictionary, over-writing any previous entry
resultDict_.add(fieldName, result, true);
file()<< tab << result; file()<< tab << result;
if (log_) if (log_)

View File

@ -92,7 +92,8 @@ Foam::fieldValue::fieldValue
log_(false), log_(false),
sourceName_(dict.lookupOrDefault<word>("sourceName", "sampledSurface")), sourceName_(dict.lookupOrDefault<word>("sourceName", "sampledSurface")),
fields_(dict.lookup("fields")), fields_(dict.lookup("fields")),
valueOutput_(dict.lookup("valueOutput")) valueOutput_(dict.lookup("valueOutput")),
resultDict_(fileName("name"), dictionary::null)
{ {
// Only active if obr is an fvMesh // Only active if obr is an fvMesh
if (isA<fvMesh>(obr_)) if (isA<fvMesh>(obr_))

View File

@ -42,6 +42,7 @@ SourceFiles
#include "Switch.H" #include "Switch.H"
#include "pointFieldFwd.H" #include "pointFieldFwd.H"
#include "OFstream.H" #include "OFstream.H"
#include "dictionary.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -49,7 +50,6 @@ namespace Foam
{ {
// Forward declaration of classes // Forward declaration of classes
class dictionary;
class objectRegistry; class objectRegistry;
class fvMesh; class fvMesh;
class mapPolyMesh; class mapPolyMesh;
@ -88,6 +88,9 @@ protected:
//- Output field values flag //- Output field values flag
Switch valueOutput_; Switch valueOutput_;
//- Results dictionary for external access of results
dictionary resultDict_;
// Functions to be over-ridden from IOoutputFilter class // Functions to be over-ridden from IOoutputFilter class
@ -147,6 +150,9 @@ public:
//- Helper function to return the reference to the mesh //- Helper function to return the reference to the mesh
inline const fvMesh& mesh() const; inline const fvMesh& mesh() const;
//- Return access to the latest set of results
inline const dictionary& resultDict() const;
// Function object functions // Function object functions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -75,4 +75,10 @@ inline const Foam::fvMesh& Foam::fieldValue::mesh() const
} }
inline const Foam::dictionary& Foam::fieldValue::resultDict() const
{
return resultDict_;
}
// ************************************************************************* // // ************************************************************************* //