CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Post-Processing

faceZoneAverage function object does not work with field U,p etc.

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 13, 2021, 16:52
Default faceZoneAverage function object does not work with field U,p etc.
  #1
New Member
 
Join Date: Aug 2021
Posts: 11
Rep Power: 4
Daniel_C is on a distinguished road
Since OpenFOAM V8 it should be possible to have the field values processed on a faceZone.

If I add a function file in the system directory in this way e.g. :

Code:
/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  9
     \\/     M anipulation  |
-------------------------------------------------------------------------------
Description
    Calculates the average values of fields on a faceZone.

\*---------------------------------------------------------------------------*/

        type            surfaceFieldValue;
        libs            ("libfieldFunctionObjects.so");
        writeControl    timeStep;
        writeInterval   1;
        log             yes;
        writeTotalArea  no;
        writeFields     no;
        regionType      faceZone;
        name            my_facezone;
        operation       areaAverage;
	fields  
	(
	    U
	);

// ************************************************************************* //
and additionally include the function in controlDict via "#includeFunc my_function" entry, OpenFoam V9 throws an exception during solver initialization:

Quote:
surfaceFieldValue my_function: faceZone(my_facezone):
Unable to process internal faces for volume field U
The same is true for other scalars (p for example), except for phi. When taking phi as a field variable, everything is fine. Also, the function faceZoneFlowRate works with phi.

Seems there is something I missed? Can anyone give me a hint, what I am doing wrong?

Regards

Daniel
Daniel_C is offline   Reply With Quote

Old   October 14, 2021, 08:58
Default
  #2
Senior Member
 
Tom Fahner
Join Date: Mar 2009
Location: Breda, Netherlands
Posts: 634
Rep Power: 32
tomf will become famous soon enoughtomf will become famous soon enough
Send a message via MSN to tomf Send a message via Skype™ to tomf
Hi Daniel,

I once had a similar issue:

This is caused by the fact that the field values (U, p, etc.) are stored on the cell center. phi however is stored at the faces as it is the flux through the face.

You can use another functionObject first to interpolate the fields to the faces and afterwards you can use the surfaceFieldValue functionObject.

Have a look at the online documentation.

Hope it helps.
Cheers,
Tom
tomf is offline   Reply With Quote

Old   October 15, 2021, 18:51
Thumbs up
  #3
New Member
 
Join Date: Aug 2021
Posts: 11
Rep Power: 4
Daniel_C is on a distinguished road
Thank you Tom!

That worked for the field U in that way:

1. added the function my_surfaceInterpolate to interpolate field U to surface field UInterp

2. defined faceZoneAverage inline with name of faceZone und newly created field UInterp

That works for p in the same fashion. Great so far!

Code:
functions
{
    my_surfaceInterpolate
    {
     type        surfaceInterpolate;
     libs        ("libfieldFunctionObjects.so");
     fields      ((U UInterp)); 
     executeControl  timeStep;
     writeControl    writeTime;   
    }

    #includeFunc faceZoneAverage(name=my_faceZone, UInterp)

}
But, this doesn't work with the magnitude of U, because it calculates a constant average magnitude of 0 m/s for all time steps. It should not be zero, because there is definitely air flowing through the faceZone.

Here is what I have done:

Code:
    #includeFunc  mag(U)

    surfaceInterpolate1
    {
     type        surfaceInterpolate;
     libs        ("libfieldFunctionObjects.so");
     fields      ((mag(U) magUInterp)); 
     executeControl  timeStep;
     writeControl    writeTime;   
    }

    #includeFunc faceZoneAverage(name=my_faceZone, magUInterp)

Any ideas?


Regards

Daniel
Daniel_C is offline   Reply With Quote

Old   October 15, 2021, 19:09
Thumbs up Problem solved!
  #4
New Member
 
Join Date: Aug 2021
Posts: 11
Rep Power: 4
Daniel_C is on a distinguished road
My fault,

had something to do with the write control settings. The field was written every 500 time steps.

So I got the right values from time step 500 onwards.

It works just as Tom stated. Problem solved!
Daniel_C is offline   Reply With Quote

Reply


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
whats the cause of error? immortality OpenFOAM Running, Solving & CFD 13 March 24, 2021 07:15
How to create a function object in OpenFoam that runs properly ? mkhm OpenFOAM Programming & Development 1 October 20, 2018 16:16
is internalField(U) equivalent to zeroGradient? immortality OpenFOAM Running, Solving & CFD 7 March 29, 2013 01:27
Problem with compile the setParabolicInlet ivanyao OpenFOAM Running, Solving & CFD 6 September 5, 2008 20:50
Droplet Evaporation Christian Main CFD Forum 2 February 27, 2007 06:27


All times are GMT -4. The time now is 22:58.