CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

Mean of a functionObject field

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 2 Post By Yann
  • 1 Post By mcgoldba

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 21, 2021, 00:39
Default Mean of a functionObject field
  #1
New Member
 
Marc
Join Date: Oct 2017
Posts: 11
Rep Power: 9
mcgoldba is on a distinguished road
Hi All,

I would like to get a mean value of a field that is is calculated with a function object. However, this is resulting in a error, I think because the function object field is not initialized at the beginning of the simulation.

For simplicity I have recreated the error with a modified version of the channel935 case. My modified controlDict for this case is as follows:

Code:
/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  6
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "system";
    object      controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application     pimpleFoam;

startFrom       latestTime;

startTime       0;

stopAt          endTime;

endTime         20;

deltaT          0.2;

writeControl    timeStep;

writeInterval   10;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;

functions
{
    fieldAverage1
    {
        type            fieldAverage;
        libs            ("libfieldFunctionObjects.so");
        writeControl    writeTime;

        fields
        (
            U
            {
                mean        on;
                prime2Mean  on;
                base        time;
            }

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

    gradU
    {
        type             grad;
        libs             ("libfieldFunctionObjects.so");
        field            p;
        result           dp;
        writeControl     writeTime;        
    }

}

// ************************************************************************* //
I receive the following error after the second time step

Code:
[0] --> FOAM FATAL ERROR:
[0]
    request for volVectorField dpMean from objectRegistry region0 failed
    available objects of type volVectorField are
5
(
U_0
U
UMean
U_0_0
dp
)
[0]
[0]
[0]     From function const Type& Foam::objectRegistry::lookupObject(const Foam::word&) const [with Type = Foam::
    GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>]
[0]     in file /home/ubuntu/OpenFOAM/OpenFOAM-7/src/OpenFOAM/lnInclude/objectRegistryTemplates.C at line 193.
[0]
FOAM parallel run aborting
Can anyone help with the correct implementation to get the averaged field?
mcgoldba is offline   Reply With Quote

Old   April 21, 2021, 04:44
Default
  #2
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,236
Rep Power: 29
Yann will become famous soon enoughYann will become famous soon enough
Hi Marc,

Have you tried switching the two functions, i.e. calculating dp first, then doing the fieldAverage ?

Yann
mcgoldba and saidc. like this.
Yann is offline   Reply With Quote

Old   April 21, 2021, 10:04
Default
  #3
New Member
 
Marc
Join Date: Oct 2017
Posts: 11
Rep Power: 9
mcgoldba is on a distinguished road
That indeed was the issue. Thank you for the suggestion!

Everything is calculated correctly if I revise the controlDict function order to the following:

Code:
functions
{

    gradp
    {
        type             grad;
        libs             ("libfieldFunctionObjects.so");
        field            p;
        result           dp;
        writeControl     writeTime;        
    }
    
    fieldAverage1
    {
        type            fieldAverage;
        libs            ("libfieldFunctionObjects.so");
        writeControl    writeTime;
        //timeStart       4;       

        fields
        (
            U
            {
                mean        on;
                prime2Mean  on;
                base        time;
            }

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


}
Yann likes this.
mcgoldba is offline   Reply With Quote

Reply

Tags
function objects, mean values


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error: "Source airToporous defined for field h but never used" Utkan OpenFOAM Running, Solving & CFD 2 April 6, 2022 09:23
Cannot find functionObject file residuals vava10 OpenFOAM Pre-Processing 2 November 14, 2020 13:21
Averaging a field created by a functionObject me3840 OpenFOAM Post-Processing 2 October 3, 2018 12:58
potential flows, helmholtz decomposition and other stuffs pigna Main CFD Forum 1 October 26, 2017 09:34
[General] How to create an additional vector with {Field 4, Field 5, Field 6} Bombacar ParaView 1 August 15, 2015 19:05


All times are GMT -4. The time now is 13:01.