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

Calculate flux across surface

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree10Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 19, 2016, 17:56
Default Calculate flux across surface
  #1
Senior Member
 
Thomas Oliveira
Join Date: Apr 2015
Posts: 114
Rep Power: 12
t.oliveira is on a distinguished road
Dear all,

I have got the simulation results for the velocity field along time.

Now I need to compute the integral of U over a plane (that is not a patch) defined by its basePoint and normalVector.

I have exhausted all the possibilities I could imagine using execFlowFunctionObjects and swak4Foam.

Could you please shed some light on how to do it?

Thanks,

Thomas
t.oliveira is offline   Reply With Quote

Old   January 20, 2016, 05:16
Default
  #2
Senior Member
 
Tom Fahner
Join Date: Mar 2009
Location: Breda, Netherlands
Posts: 640
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
I think this should it be possible with ParaView?
tomf is offline   Reply With Quote

Old   January 20, 2016, 07:04
Default
  #3
Senior Member
 
Thomas Oliveira
Join Date: Apr 2015
Posts: 114
Rep Power: 12
t.oliveira is on a distinguished road
Quote:
Originally Posted by tomf View Post
I think this should it be possible with ParaView?
It probably is. However, AFAIK, the workflow through ParaView is not scalable to many timesteps. Moreover, I would like to repeat that for a series of numerical experiments.
t.oliveira is offline   Reply With Quote

Old   January 20, 2016, 08:05
Default
  #4
Senior Member
 
Tom Fahner
Join Date: Mar 2009
Location: Breda, Netherlands
Posts: 640
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
Maybe sample could work, probably still requires ParaView, but this may reduce the workload:
Use sample to generate vtk file for each time step only with U variable > Optionally use the foamSequenceVTKFiles script to rename the files in sequenced order > start ParaView > Open the sequenced files > integrateVariables > save Data (all time steps).

This may need some additional work to get everything in one file. I do not know about current OpenFOAM tools that do this right now. If anyone does, feel free to comment.

Regards,
Tom
tomf is offline   Reply With Quote

Old   January 20, 2016, 11:44
Default
  #5
Senior Member
 
Thomas Oliveira
Join Date: Apr 2015
Posts: 114
Rep Power: 12
t.oliveira is on a distinguished road
Quote:
Originally Posted by t.oliveira View Post
I need to compute the integral of U over a plane defined by its basePoint and normalVector. Could you please shed some light on how to do it?
Use the following function object:

Code:
functions
{
    flux
    {
        type            faceSource;
        functionObjectLibs ("libfieldFunctionObjects.so");

        enabled         true;
        outputControl   outputTime;
        surfaceFormat   off;

        // Output to log&file (true) or to file only
        log             true;
        // Output field values as well
        valueOutput     true;
        // Type of source: patch/faceZone/sampledSurface
        source          sampledSurface;        
        //// if sampledSurface: dictionary with a sampledSurface
        //// Note: will not sample surface fields.
        sampledSurfaceDict
        {           
            type            plane;
            basePoint       (8.1e-4 0 0);
            normalVector    (1 0 0);
            interpolate       false;
        }
        operation       areaNormalIntegrate;
        fields
        (
            U
        );
    }
}
I saved it in a file called system/integrateOnSurfaceDict, instead of writing it on the bottom of controlDict, just to keep it more organised.

Use it executing:

Code:
execFlowFunctionObjects -dict system/integrateOnSurfaceDict -noFlow
To find out this solution, I started looking some examples on /src/postProcessing/functionObjects. It is a good starting point.

I tried also using cuttingPlane instead of plane, and interpolate true, and got slightly different results. If I put the plane over a patch, the usage of plane and interpolate false gave the same result as running
Code:
patchIntegrate U <patchName>
Best wishes,

Thomas
t.oliveira is offline   Reply With Quote

Old   January 20, 2016, 11:46
Default
  #6
Senior Member
 
Thomas Oliveira
Join Date: Apr 2015
Posts: 114
Rep Power: 12
t.oliveira is on a distinguished road
Quote:
Originally Posted by tomf View Post
start ParaView > Open the sequenced files > integrateVariables > save Data (all time steps)
Thank you, Tom!
t.oliveira is offline   Reply With Quote

Old   January 21, 2016, 03:23
Default
  #7
Senior Member
 
Tom Fahner
Join Date: Mar 2009
Location: Breda, Netherlands
Posts: 640
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
Thank you for pointing out the sampledSurface option, was not aware of that. I thought only patches and faceZones were possible.
tomf is offline   Reply With Quote

Old   October 1, 2016, 09:14
Default
  #8
Senior Member
 
A. Min
Join Date: Mar 2015
Posts: 305
Rep Power: 12
alimea is on a distinguished road
Quote:
Originally Posted by t.oliveira View Post
Use the following function object:

Code:
functions
{
    flux
    {
        type            faceSource;
        functionObjectLibs ("libfieldFunctionObjects.so");

        enabled         true;
        outputControl   outputTime;
        surfaceFormat   off;

        // Output to log&file (true) or to file only
        log             true;
        // Output field values as well
        valueOutput     true;
        // Type of source: patch/faceZone/sampledSurface
        source          sampledSurface;        
        //// if sampledSurface: dictionary with a sampledSurface
        //// Note: will not sample surface fields.
        sampledSurfaceDict
        {           
            type            plane;
            basePoint       (8.1e-4 0 0);
            normalVector    (1 0 0);
            interpolate       false;
        }
        operation       areaNormalIntegrate;
        fields
        (
            U
        );
    }
}
I saved it in a file called system/integrateOnSurfaceDict, instead of writing it on the bottom of controlDict, just to keep it more organised.

Use it executing:

Code:
execFlowFunctionObjects -dict system/integrateOnSurfaceDict -noFlow
To find out this solution, I started looking some examples on /src/postProcessing/functionObjects. It is a good starting point.

I tried also using cuttingPlane instead of plane, and interpolate true, and got slightly different results. If I put the plane over a patch, the usage of plane and interpolate false gave the same result as running
Code:
patchIntegrate U <patchName>
Best wishes,

Thomas
Hi
I want to calculate the heat flux over a plane. I have computed gradT before that. Is your code appropriate for my goal?
What about calculation of flux over a cylinder perimeter?
Thanks
alimea is offline   Reply With Quote

Old   June 27, 2018, 06:13
Default
  #9
Senior Member
 
Thomas Oliveira
Join Date: Apr 2015
Posts: 114
Rep Power: 12
t.oliveira is on a distinguished road
Quote:
Originally Posted by t.oliveira View Post
Use the following function object:
[...]
Use it executing:
[...]
This is an updated version that works with OpenFOAM 5.x:

Code:
functions
{
    flux
    {
        functionObjectLibs ("libfieldFunctionObjects.so");
        type             surfaceFieldValue;

        enabled          true;
        writeControl     outputTime;
        writeInterval    1;
        writeFields      false;

        name myName;

        // regionType: patch/faceZone/sampledSurface
        regionType sampledSurface;

        sampledSurfaceDict
        {
            type                  plane;
            planeType             pointAndNormal;
            pointAndNormalDict
            {
                point  (0.1 0 0);
                normal (1 0 0);
            };
            interpolate false;
        }

        // Operation: areaAverage/sum/weightedAverage/...
        operation    areaNormalIntegrate;
        fields
        (
            U
        );
    }
}
Use it executing:

Code:
postProcess -fields "(U)" -dict system/integrateOnSurfaceDict
Best wishes,

Thomas
cdunn6754 and hnsxmh like this.
t.oliveira is offline   Reply With Quote

Old   July 18, 2018, 14:49
Default
  #10
New Member
 
Clint
Join Date: Sep 2015
Posts: 10
Rep Power: 10
cdunn6754 is on a distinguished road
There is no 'flux' function in my installation. I checked the other versions and it's not there either. Is that something that you made?

When I run it I get a warning that that function 'flux' doesn't exist.

EDIT:
Really sorry this worked great. I messed up copying your functionObject text.

Last edited by cdunn6754; July 18, 2018 at 14:55. Reason: Original comment is erroneous.
cdunn6754 is offline   Reply With Quote

Old   November 8, 2018, 08:55
Default OpenFoam
  #11
New Member
 
Manaf Muhammed
Join Date: Oct 2018
Posts: 21
Rep Power: 7
manafaero is on a distinguished road
when iam running the script iam getting error

[2] --> FOAM FATAL IO ERROR:
[2] keyword sourceName is undefined in dictionary "IOstream.functions.flux"
[2]
[2] file: IOstream.functions.flux[13]
[13]
[13] --> FOAM FATAL IO ERROR:
from line 0 to line 0.
[2]
[2] From function dictionary::lookupEntry(const word&, bool, bool) const
[2] in file db/dictionary/dictionary.C at line 442.
[2]
FOAM parallel run exiting
[2]
[6]
[6] [8]
[8]
[8] --> FOAM FATAL IO ERROR:
[8] keyword sourceName is undefined in dictionary "IOstream.functions.flux"
[8]
[8] file: IOstream.functions.flux from line 0 to line 0.

please help
manafaero is offline   Reply With Quote

Old   November 8, 2018, 09:03
Default
  #12
Senior Member
 
Thomas Oliveira
Join Date: Apr 2015
Posts: 114
Rep Power: 12
t.oliveira is on a distinguished road
No 'sourceName' was required when I ran it. Did you try providing a sourceName? The syntax for it is similarly to how 'name' is provided.
t.oliveira is offline   Reply With Quote

Old   November 19, 2018, 03:24
Default
  #13
New Member
 
Martin Rønnov Andersen
Join Date: Oct 2018
Location: Aalborg, Denmark
Posts: 10
Rep Power: 7
Skymaas is on a distinguished road
What if one is to find the flux for each cell, at a specific plane? I did get this to work but the output i get is the flux for the entire plane.
Skymaas is offline   Reply With Quote

Old   November 19, 2018, 05:48
Default
  #14
Senior Member
 
Thomas Oliveira
Join Date: Apr 2015
Posts: 114
Rep Power: 12
t.oliveira is on a distinguished road
Dear Martin,


I looked for "areaNormalIntegrate" in OF source code and found the file .src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C.


This may give you a clue on how to do it.


I would first try to replace "operation areaNormalIntegrate;" with operation none;" to see what I get. From the source code, it seems that this operation would write the field.



Kind regards,
Thomas
t.oliveira is offline   Reply With Quote

Old   November 19, 2018, 07:04
Default
  #15
New Member
 
Martin Rønnov Andersen
Join Date: Oct 2018
Location: Aalborg, Denmark
Posts: 10
Rep Power: 7
Skymaas is on a distinguished road
Hey Thomas,
I tried the following code. By doing it this way, i can specify which cells, in the y-direction, i want to extract information from.



Code:
const volVectorField& C = mesh.C();             

forAll(U, celli)
{
   const vector& Ci = C[celli];            
   if (mag(Ci.x() - 0.35) <= 0.003)
       {


       }
}

The only thing i´m able to extract is the velocities. What i need is either the flux or area of each cell - It is a 2D simulation so i would get the area in length.
Can you give me a pointer of how to extract this? I tried mesh.magSf().boundaryField() but it didn´t work.



/Martin
Skymaas is offline   Reply With Quote

Old   November 19, 2018, 08:41
Default
  #16
Senior Member
 
Thomas Oliveira
Join Date: Apr 2015
Posts: 114
Rep Power: 12
t.oliveira is on a distinguished road
Are these faces internal or external? mesh.magSf().boundaryField() gives access to external faces.
t.oliveira is offline   Reply With Quote

Old   November 20, 2018, 04:31
Default
  #17
New Member
 
Martin Rønnov Andersen
Join Date: Oct 2018
Location: Aalborg, Denmark
Posts: 10
Rep Power: 7
Skymaas is on a distinguished road
It is internal, so that would explain why the mesh.magSf().boundaryField() doesn´t work.
I got it working to some extend. I am able to extract the volume and velocity for each cell, at position x. Now i also want to know the mean velocity at this plane, is there a way to get that?
Skymaas is offline   Reply With Quote

Old   November 20, 2018, 05:17
Default
  #18
Senior Member
 
Thomas Oliveira
Join Date: Apr 2015
Posts: 114
Rep Power: 12
t.oliveira is on a distinguished road
Dear Martin,


It is important to use the forum in a way to make it also helpful for other users that look for a question in the future.


For this, it is better if:
- one starts a new question ("how do I get the flux on each cell on a plane") if this is different from the original one ("Calculate flux across surface");


- one reports what they got/found out. Did you try "operation none;"? What what the result? What did you use for internal faces instead of "mesh.magSf().boundaryField() ".


As for your question, isn't the mean velocity equal to the flux over the area?
t.oliveira is offline   Reply With Quote

Old   November 20, 2018, 05:45
Default
  #19
New Member
 
Martin Rønnov Andersen
Join Date: Oct 2018
Location: Aalborg, Denmark
Posts: 10
Rep Power: 7
Skymaas is on a distinguished road
Hey Thomas,
I actually did open a new thread, but no one responded to it so that is why I asked in this thread. Also, I got the code(posted before the previous) to work, simply by asking for the variable that i want (U[celli], V[celli] ect.)
No, velocity would be the flux multiplied by the area, since flux is velocity over area. I believe i know where you are going with this, but the main problem is how to extract it.
Skymaas is offline   Reply With Quote

Old   May 24, 2019, 11:01
Talking For the Latest Time
  #20
New Member
 
Diego Menezes Pamplona
Join Date: Apr 2019
Posts: 3
Rep Power: 7
dieg01mp is on a distinguished road
Quote:
Originally Posted by t.oliveira View Post
This is an updated version that works with OpenFOAM 5.x:

Code:
functions
{
    flux
    {
        functionObjectLibs ("libfieldFunctionObjects.so");
        type             surfaceFieldValue;

        enabled          true;
        writeControl     outputTime;
        writeInterval    1;
        writeFields      false;

        name myName;

        // regionType: patch/faceZone/sampledSurface
        regionType sampledSurface;

        sampledSurfaceDict
        {
            type                  plane;
            planeType             pointAndNormal;
            pointAndNormalDict
            {
                point  (0.1 0 0);
                normal (1 0 0);
            };
            interpolate false;
        }

        // Operation: areaAverage/sum/weightedAverage/...
        operation    areaNormalIntegrate;
        fields
        (
            U
        );
    }
}
Use it executing:

Code:
postProcess -fields "(U)" -dict system/integrateOnSurfaceDict
Best wishes,

Thomas
I'm actually not using the command for getting the flux for every simulation. Once i'm running various simulations automatically, i just implemented this code on the controlDict file wich actually calculates the flux at the end of every saved iteration. What i want to do is to continue with the code in the controlDict file but to get only the flux for the latest time.
dieg01mp is offline   Reply With Quote

Reply

Tags
flux calculation, integrate

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
How to specify surface flux of a species? ked FLUENT 18 February 15, 2022 15:03
Total heat transf. rate vs Total surface heat flux Renato Sousa FLUENT 1 April 14, 2020 03:27
Symmetry and total surface heat flux CCHunter FLUENT 2 November 8, 2017 04:47
how to Calculate heat flux??? sandip Main CFD Forum 0 December 4, 2009 04:58
Total Heat Transfer Rate & Total Surface Heat Flux Mismatch icaro FLUENT 0 November 24, 2009 07:01


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