CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   how to calculate the volume averaged values in version 4.1 (https://www.cfd-online.com/Forums/openfoam-programming-development/184015-how-calculate-volume-averaged-values-version-4-1-a.html)

6863523 February 20, 2017 12:04

how to calculate the volume averaged values in version 4.1
 
Dear all,
I have used the commands below to calculate the volume averaged values for version 3.0.1 and it works fine for me.
Code:

functions


    functionObjects_all_volAverage
    {
        type            cellSource;
        functionObjectLibs ("libfieldFunctionObjects.so");
        enabled        true;
        outputControl  timeStep;
        outputInterval  2000;
        log            false;
        valueOutput    false;
        source          all;
        sourceName      none;
        operation      volAverage;
        fields
        (
            p
            U
        );
    }

    probes
    {
        // Where to load it from
        functionObjectLibs ( "libsampling.so" );

        type            probes;

        // Name of the directory for probe data
        name            probes;

        // Write at same frequency as fields
        outputControl  timeStep;
        //outputInterval  1;

        // Fields to be probed
        fields
        (

            U
        );

        probeLocations
        (
            ( 0 0.5 0 ) 
            ( 1 0.5 0 )


            ( 0.5 0 0 )

        );
    }

);

I know there is a difference between different versions, and I have found one at https://github.com/OpenFOAM/OpenFOAM...es/controlDict.
and modified as
Code:

functions


    cellObj1
    {
        type            volRegion;
        libs ("libfieldFunctionObjects.so");
        enabled        true;
        writeControl  timeStep;
        writeInterval  2000;
        log            false;
        writeFields    false;
        regionType      cellZone;
        name            0();
        operation      volAverage;
        fields
        (
            p
            U
        );
    }

    probes
    {
        // Where to load it from
        libs ( "libsampling.so" );

        type            probes;

        // Name of the directory for probe data
        name            probes;

        // Write at same frequency as fields
        writeControl  timeStep;
        //outputInterval  1;

        // Fields to be probed
        fields
        (

            U
        );

        probeLocations
        (
            ( 0 0.5 0 ) 
            ( 1 0.5 0 )


            ( 0.5 0 0 )

        );
    }

}

But there is always a problem for me as
Code:

[11] --> FOAM FATAL IO ERROR:
[11] wrong token type - expected word, found on line 0 the label 0
[11]
[11] file: IOstream.functions.cellObj1.name at line 0.
[11]
[11]    From function Foam::Istream& Foam::operator>>(Foam::Istream&, Foam::word&)
[11]    in file primitives/strings/word/wordIO.C at line 74.
[11]
FOAM parallel run exiting
[11]

Thank you in advance.
Best Regards,
Bill

6863523 February 21, 2017 03:50

fieldAverage function in controlDict
 
BTW: I have found the fieldAverage function. I wonder what is the difference between the fieldAverage and the volume average.
Code:

fieldAverage1
    {
    type fieldAverage;
    functionObjectLibs ( "libfieldFunctionObjects.so" );
    enabled true;
    outputControl outputTime;
    outputInterval  100;
    fields
    (
      U
      {
      mean on;
      prime2Mean on;
      base time;
      }

      p
      {
      mean on;
      prime2Mean on;
      base time;
      }
      );
      }

Thank you in advance.
Any suggestion is appreciated.
Best Regards,
Bill

Nathanael3 February 21, 2017 04:33

Hi,

I am working with 1612+ version. Here is a minimal working example to calculate volume averaged value. I tested it over pitzdaily. I works like a charm.

Code:

functions
{
    volumeAverage
    {
        type            volFieldValue;
        libs            ("libfieldFunctionObjects.so");

        log            true;
        writeControl    writeTime;
        writeFields    true;

        regionType      all;
        operation      volAverage;

        fields
        (
            p
            U
        );
    }
}

Best regards,
Nathanaël.

6863523 February 21, 2017 04:45

failed
 
Quote:

Originally Posted by Nathanael3 (Post 637893)
Hi,

I am working with 1612+ version. Here is a minimal working example to calculate volume averaged value. I tested it over pitzdaily. I works like a charm.

Code:

functions
{
    volumeAverage
    {
        type            volFieldValue;
        libs            ("libfieldFunctionObjects.so");

        log            true;
        writeControl    writeTime;
        writeFields    true;

        regionType      all;
        operation      volAverage;

        fields
        (
            p
            U
        );
    }
}

Best regards,
Nathanaël.

Dear Nathanael,
Thank you for the reply.
I have tested the code, but got an error.
Code:

[11] --> FOAM FATAL ERROR:
[11] Unknown function type volFieldValue

Then I modified the volFieldValue to volRegion. There is no such error any more.
Thank you.
Best Regards,
Bill

Nathanael3 February 21, 2017 04:53

Hi,

Nice to hear that you found a solution.
The discrepancy may arise from the differences between our OpenFOAM versions.

Best regards,
Nathanaël.

6863523 February 21, 2017 05:09

Quote:

Originally Posted by Nathanael3 (Post 637899)
Hi,

Nice to hear that you found a solution.
The discrepancy may arise from the differences between our OpenFOAM versions.

Best regards,
Nathanaël.

Dear Nathanaël,
Thank you very much for your professional reply. It is really helpful and saved me a lot of time.
I wonder if you have experience with the bash script execution to start the case running.
I have posted the problem here #13-#18
https://www.cfd-online.com/Forums/op...ion-4-1-a.html
Forget about the "functions" problem, because you just solved it:D.
Thank you for your time and kind help.
Best Regards,
Bill

6863523 December 9, 2017 04:22

How to calculate the volume averaged values only in a part of the domain
 
Dear Nathanaël,
I wonder if you have any experience of calculating the volume averaged values only in a part of the domain, say, the values averaged in a 1/3 of the fluid domain?
Thank you in advance.
Best Regards,
Bill

sitajeje January 5, 2018 11:43

volRegion in chtMultiRegionSimpleFoam
 
Dear Foamers,

I cannot excute volRegion in chtMultiRegionSimpleFoam, although this functionObject works fine for pimpleDyMFoam. In the controlDict I wrote almost the same, except field "p" for pimpleDyMFoam and field "T" for chtMultiRegionSimpleFoam.

Code:

functions
{
  volRegion1
    {
        type            volRegion;
        libs              ("libfieldFunctionObjects.so");
        writeFields    true;
        regionType    cellZone;
        name            heater;
        operation      volAverage;
        fields
        (
            T
        );
    }
}

I would appreciate if anyone can help me to execute volRegion in chtMultiRegionSimpleFoam.

Thank you very much in advance!

Best regards,
sitajeje

bineet_aero November 9, 2020 11:14

Quote:

Originally Posted by sitajeje (Post 677056)
Dear Foamers,

I cannot excute volRegion in chtMultiRegionSimpleFoam, although this functionObject works fine for pimpleDyMFoam. In the controlDict I wrote almost the same, except field "p" for pimpleDyMFoam and field "T" for chtMultiRegionSimpleFoam.

Code:

functions
{
  volRegion1
    {
        type            volRegion;
        libs              ("libfieldFunctionObjects.so");
        writeFields    true;
        regionType    cellZone;
        name            heater;
        operation      volAverage;
        fields
        (
            T
        );
    }
}

I would appreciate if anyone can help me to execute volRegion in chtMultiRegionSimpleFoam.

Thank you very much in advance!

Best regards,
sitajeje

Hii i am having similar problem, were you able to solve it ? thanks

Krapf November 15, 2020 10:40

This is working in OpenFOAM 8:
Code:

volAverage
{
    libs              ("libfieldFunctionObjects.so");
    type            volFieldValue;
    operation      volAverage;
    region          fluid;
    fields          (T);
    writeFields    false;
}


Rustralia February 4, 2021 20:03

I have the same issue. Did anyone find a solution?
Quote:

Originally Posted by bineet_aero (Post 787241)
Hii i am having similar problem, were you able to solve it ? thanks


CarCin April 14, 2021 06:30

Quote:

Originally Posted by Krapf (Post 787822)
This is working in OpenFOAM 8:
Code:

volAverage
{
    libs              ("libfieldFunctionObjects.so");
    type            volFieldValue;
    operation      volAverage;
    region          fluid;
    fields          (T);
    writeFields    false;
}


Dear Krapf,

I'm trying to use the same function but it does not work for me in OpenFOAM 8.
I have added the lines you report in my controlDict, like this:

Code:

functions
{
    volAverage
    {
        libs              ("libfieldFunctionObjects.so");
        type            volFieldValue;
        operation    volAverage;
        //region        fluid;
        fields          (T);
        writeFields  false;
    }
}

and then run by typing "pimpleFoam -postProcess -func volFieldValue". The error is the following:

Code:

--> FOAM FATAL IO ERROR:
keyword type is undefined in dictionary "controlDict/functions/volFieldValue"

file: controlDict/functions/volFieldValue from line 6 to line 15.

    From function const Foam::entry& Foam::dictionary::lookupEntry(const Foam::word&, bool, bool) const
    in file db/dictionary/dictionary.C at line 797.


Do you have any suggestion? How do you make it work?
Thank you in advance,
Best
Carlo


All times are GMT -4. The time now is 03:53.