View Issue Details

IDProjectCategoryView StatusLast Update
0002339OpenFOAMBugpublic2016-11-19 21:54
ReporterTomF Assigned Tohenry  
PrioritynormalSeverityfeatureReproducibilityalways
Status resolvedResolutionfixed 
PlatformGNU/LinuxOSOtherOS Version(please specify)
Fixed in Versiondev 
Summary0002339: Not all foamCalc functionality is available from postProcess
DescriptionUp to version 3.0.x it was possible to use a simple command line expression to add or subtract fields, e.g. to get the temperature in degrees Celsius as:

foamCalc addSubtract T subtract -value 273.15 -resultName TC

Or similarly to subtract fields to compute differences:

foamCalc addSubtract T subtract -field TNew -resultName TDelta

The old interpolate and magGrad also seem to be missing.

Steps To ReproduceRun postProcess -func addSubtract T subtract -value 273.15 -resultName TC
in a case where the temperature field is available and it will give an error.
TagsNo tags attached.

Activities

henry

2016-11-18 09:52

manager   ~0007237

This functionality is provided by the fieldValueDelta functionObject:

Description
    Provides a differencing option between two 'field value' function objects.

    Example of function object specification:
    \verbatim
    fieldValueDelta1
    {
        type fieldValueDelta;
        libs ("libfieldFunctionObjects.so");
        operation subtract;

        fieldValue1
        {
            ...
        }
        fieldValue2
        {
            ...
        }
    }
    \endverbatim

Usage
    \table
        Property | Description | Required | Default value
        type | type name: fieldValueDelta | yes |
    \endtable

    The \c operation is one of:
    \plaintable
       add | add
       subtract | subtract
       min | minimum
       max | maximum
       average | average
    \endplaintable

TomF

2016-11-18 10:08

reporter   ~0007238

Thank you Henry for the fast response. I tried to use this, but when I add this to my controlDict:

    addSubtract
    {
        type fieldValueDelta;
        libs ("libfieldFunctionObjects.so");
        operation subtract;

        fieldValue1
        {
            TMean;
        }
        fieldValue2
        {
            T;
        }
    }
I get the error:
keyword region1 is undefined in dictionary" ./system/controlDict.functions.addSubtract"
file: ./system/controlDict.functions.addSubtract at line 231.

    From function const Foam::dictionary& Foam::dictionary::subDict(const Foam::word&) const
    in file db/dictionary/dictionary.C at line 642.

So I added (after the type declaration):
        region1 all;
and now I get a new error:
Attempt to return primitive entry ITstream : /home/tom/Projecten/TNO/DataCenters/CFD/engine/testAutoSetup/system/controlDict.functions.addSubtract.region1, line 0, IOstream: Version 2.0, format ASCII, line 0, OPENED, GOOD
    primitiveEntry 'region1' comprises
 as a sub-dictionary

    From function virtual const Foam::dictionary& Foam::primitiveEntry::dict() const
    in file db/dictionary/primitiveEntry/primitiveEntry.C at line 189.

So I understand it requires something for region1, but I have no idea what to provide there.

TomF

2016-11-18 10:56

reporter   ~0007239

I managed to get the functionObject to not give an error by using:

    addSubtract
    {
        type fieldValueDelta;
        libs ("libfieldFunctionObjects.so");
        operation subtract;

        region1
        {
            regionType all;
            type volRegion;
            fields (TMean);
            writeFields true;
            operation none;
        }
        region2
        {
            regionType all;
            type volRegion;
            fields (T);
            writeFields true;
            operation none;
        }
    }

So from the original documentation the "fieldValue1" should be replaced with "region1" although I think it would make more sense if the code itself is modified such that it needs fieldValue1 and fieldValue2.

The problem however is still there that I want to use some functionObject to subtract two volScalarFields, like the foamCalc utility used to do and not their max/min/average/CoV/sum/sumMag/volAverage/volIntegrate/weightedAverage/weightedVolAverage.

henry

2016-11-18 12:11

manager   ~0007240

OK, you will either need to write a field functionObject which performs the subtraction in the manner you require or you could use the more flexible approach of the codedFunctionObject which is convenient if the processing you need is case-specific.

TomF

2016-11-18 12:58

reporter   ~0007241

Ok, thanks alot.

I will have a look at this when I have some more time available. In the mean time I can use the workaround of using the version 3.0.x for the post processing.

henry

2016-11-18 22:25

manager   ~0007243

I have prototyped a 'subtract' field functionObject:

OpenFOAM-dev commit 028956e79cbecef1537ee98adfba521a31941569

I will refactor it a bit to make it easier to create similar functionObjects.

henry

2016-11-18 22:28

manager   ~0007244

> The old interpolate and magGrad also seem to be missing.

Which form of interpolation do you need? A 'surfaceInterpolate' functionObject is provided.

'magGrad' is not needed specifically because 'mag' and 'grad' are both provided and 'mag' can be applied to the result of 'grad'.

TomF

2016-11-19 21:17

reporter   ~0007247

Thank you for the subtract functionObject! Just tested it on the hotRoom tutorial and It looks like something I can use indeed.

> Which form of interpolation do you need? A 'surfaceInterpolate' functionObject is provided.

I do not need the interpolation. I just thought from the list that was provided by the old foamCalc and the new postProcess that there was no interpolation option in the postProcess like there was no subtraction and wanted to point that out. If it was not relevant please forget about this.

> 'magGrad' is not needed specifically because 'mag' and 'grad' are both provided and 'mag' can be applied to the result of 'grad'.

Thanks for the clarification.

henry

2016-11-19 21:53

manager   ~0007248

I have just added the 'add' functionObject.

henry

2016-11-19 21:54

manager   ~0007249

Resolved by
commit 028956e79cbecef1537ee98adfba521a31941569
commit 56919a444203751717a4ece05d44cc8716787ca1

Issue History

Date Modified Username Field Change
2016-11-18 09:41 TomF New Issue
2016-11-18 09:52 henry Note Added: 0007237
2016-11-18 10:08 TomF Note Added: 0007238
2016-11-18 10:56 TomF Note Added: 0007239
2016-11-18 12:11 henry Note Added: 0007240
2016-11-18 12:58 TomF Note Added: 0007241
2016-11-18 22:25 henry Note Added: 0007243
2016-11-18 22:28 henry Note Added: 0007244
2016-11-19 21:17 TomF Note Added: 0007247
2016-11-19 21:53 henry Note Added: 0007248
2016-11-19 21:54 henry Assigned To => henry
2016-11-19 21:54 henry Status new => resolved
2016-11-19 21:54 henry Resolution open => fixed
2016-11-19 21:54 henry Fixed in Version => dev
2016-11-19 21:54 henry Note Added: 0007249