CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (https://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   Time-average of a patch (wallHeatFlux) (https://www.cfd-online.com/Forums/openfoam-post-processing/167061-time-average-patch-wallheatflux.html)

milabvieira February 22, 2016 19:17

Time-average of a patch (wallHeatFlux)
 
Dear Foamers,

I would like to know if someone could help me to get the time-average of a variable defined on the patches (in my case, wallHeatFlux), by using the fieldAverage function?

The fieldAverage works well when I define it (in the controlDict) for Temperature of Velocity, which are internal fields (fieldI, according to the .C document).

Nevertheless, I am interested in obtaining the average on time of the wallHeatFlux (that are calculated over the patches), so when writing this variable inside the fields brackets, I get an error informing that I don't have the wallHeatFlux database, but I have that file with my results from the previous time-step.

If someone knows how to modify the libfunctionObjects.so to a libfunctionObjectsCustom.so (for instance), so that I could time-average the wallHeatFlux exactly as it is done to the Temperature field, I will be very glad to receive your suggestions.

Thank you very much for your help.

Camila

wyldckat March 28, 2016 16:11

1 Attachment(s)
Greetings Camila,

Please find in attachment the case "hotRoom_wallHeatFlux.tar.gz", tested on OpenFOAM 3.0.x, but the case set-up can be used as a basis for other versions.

The case was modified from "heatTransfer/buoyantPimpleFoam/hotRoom" and the following steps were added:
  1. Added in Allrun the following two lines:
    Code:

    runApplication wallHeatFlux
    runApplication execFlowFunctionObjects -noFlow -dict system/execDict

  2. The file "system/execDict" has the function object for the field averaging over time, namely:
    Code:

    functions
    {
        fieldAverage1
        {
            type            fieldAverage;
            functionObjectLibs ("libfieldFunctionObjects.so");
            enabled        true;
            outputControl      timeStep;
            outputInterval      1;
            resetOnRestart  false;
            resetOnOutput  false;

            fields
            (
                wallHeatFlux
                {
                    mean        on;
                    prime2Mean  on;
                    base        time;
                }
            );
        }
    }

This is a quick solution that I could come up with, but this averaging is only taking into account the time snapshots that were saved. It's not exactly what you wanted, but as I said, it's a quick fix.




If you need this done during the simulation, then the following source code folders can be used as a basis:
  • "$FOAM_SRC/postProcessing/functionObjects/utilities/wallShearStress"
  • "$FOAM_APP/utilities/postProcessing/wall/wallHeatFlux"
Best regards,
Bruno

ruedanestor April 29, 2016 05:57

Thank you Bruno, it works perfectly.

It used to work a bit different in OF 2.1, more like:

patchAverage -latestTime wallHeatFlux <patch_here>

What was the change between versions so we now have to include it in an external dictionary?

Nestor,

wyldckat May 1, 2016 20:03

Hi Nestor,

patchAverage still exists in OpenFOAM 3.0 and it should still work. But the original question was about the "fieldAverage" function object, so I replied to that specific question. And honestly, I didn't remember about patchAverage.

Best regards,
Bruno

svramana December 21, 2018 00:37

Quote:

Originally Posted by wyldckat (Post 592016)
Greetings Camila,

Please find in attachment the case "hotRoom_wallHeatFlux.tar.gz", tested on OpenFOAM 3.0.x, but the case set-up can be used as a basis for other versions.

The case was modified from "heatTransfer/buoyantPimpleFoam/hotRoom" and the following steps were added:
  1. Added in Allrun the following two lines:
    Code:

    runApplication wallHeatFlux
    runApplication execFlowFunctionObjects -noFlow -dict system/execDict

  2. The file "system/execDict" has the function object for the field averaging over time, namely:
    Code:

    functions
    {
        fieldAverage1
        {
            type            fieldAverage;
            functionObjectLibs ("libfieldFunctionObjects.so");
            enabled        true;
            outputControl      timeStep;
            outputInterval      1;
            resetOnRestart  false;
            resetOnOutput  false;

            fields
            (
                wallHeatFlux
                {
                    mean        on;
                    prime2Mean  on;
                    base        time;
                }
            );
        }
    }

This is a quick solution that I could come up with, but this averaging is only taking into account the time snapshots that were saved. It's not exactly what you wanted, but as I said, it's a quick fix.




If you need this done during the simulation, then the following source code folders can be used as a basis:
  • "$FOAM_SRC/postProcessing/functionObjects/utilities/wallShearStress"
  • "$FOAM_APP/utilities/postProcessing/wall/wallHeatFlux"
Best regards,
Bruno

Hi Bruno,
you have explained very well for averaging the wallHeatFlux for the time directories we have saved. But I want to take average while simulation is running. How can do this ? I'm using OF-4.1.

wyldckat December 22, 2018 11:24

Quote:

Originally Posted by svramana (Post 719783)
Hi Bruno,
you have explained very well for averaging the wallHeatFlux for the time directories we have saved. But I want to take average while simulation is running. How can do this ? I'm using OF-4.1.

Quick answer: I'm sorry to say that wallHeatFlux was not yet a function object in OpenFOAM 4.1, it was only available as an application: https://github.com/OpenFOAM/OpenFOAM...wallHeatFlux.C - if you really want to do this, you will have to upgrade to OpenFOAM 5 or newer. Either that, or try to compile the function object from OpenFOAM 5 with OpenFOAM 4... for which I don't have time right now explain how.

svramana December 23, 2018 04:10

Thank you Sir.
I'll try out this. Time average of WallHeatFlux is must for me.

svramana January 15, 2019 08:35

Calculation of wrong heat flux using wallHeatFlux utiity
 
1 Attachment(s)
Hi everyone,
I'm simulating heat transfer problem for compressible flow over cylinder using buoyantPimpleFoam. I want to calculate Nusslet number over cylinder, for that I'm taking time average of wall heat flux with help of wallHeatFlux utility available in OF5.0.
But problem is that I'm getting wrong values of heat flux as shown in attached picture. Value must be highest at stagnation point as boundary layer is thickeness is lowest there and then it should gradually decrease as BL thickeness increase. But I'm getting results opposite to it.
I'm not able to figure out what is wrong with my simulation or it is bug. Can someone help me please ?

In figure stagnation point is along plane.
Attachment 67776
Thanks

wyldckat January 20, 2019 17:10

Quick answer: Not enough information to try and deduce what the problem is. Please follow the instructions given at: https://www.cfd-online.com/Forums/op...-get-help.html

My best guess is that the non-uniform boundary mesh is giving you problems in discretizing the heat transfer. If the adjacent cells near the walls have different thicknesses along the surface of those walls, that will give you disproportionate energy and temperature values, given that it's calculating in function of the volume of the cell.

svramana January 23, 2019 08:58

4 Attachment(s)
Hello Bruno sir,
Thank you for reply.
Adjacent mesh near to wall have uniform thickness along the surface but are non uniform in radial direction, but I don't think this could be a problem. For reference I have attached picture of mesh near cylinder.
In the graph we can see that, heat flux is initially increasing and then decreasing whereas, it must continuously decrease from stagnation point onward fir the reason stated in my previous post.
Still I'm struggling to figure out the reason.

Attachment 67934 Attachment 67935

If you have time please have look at Attachment 67992. Please use Allrun script for case initialisation, I'm using buoyantPimpleFoam solver.

I have tried with extracting a temperature of first cell from wall using plot over intersection filter in paraview. Then I subtracted this from wall temperature and divided difference with cell centre distance from wall to get gradient.
i.e grad = (T - T_wall) / dy, where dy is first cell centre distance from wall.
Then used this gradient to calculate Nusslet number = (grad * L) / (T_wall - T_inf), where L is characteristic length and T_inf is free stream temperature.
This way I'm getting exact curve what I want, i.e. matching with experimental data. But not getting with OF utility. I think problem is with snGrad() calculation in OF.
Following picture shows comparison of both the curves.
Attachment 67994


Thank you.

svramana February 21, 2019 12:22

Hi all
Still I'm struggling for the answer. Can any one give some hint please ?

schuyler February 21, 2019 13:06

How refined is your mesh at the stagnation point? It is possible you do not have enough refinement. The cell Reynolds number requirement for high-speed compressible flows is ReCell<5.

Since you get the right answer using a manual calculation though, I think you may be right about the utility. Something you could try: (1) Use a different version of OpenFOAM, (2) Calculate just the wall gradient of T using the grad() command, and see how that works.

svramana February 22, 2019 09:11

Hi Schuyler,
Thank you for reply.
My mesh resolution near wall is such that y+ < 1. As per your suggestion
(1) I was using OF4.x but I want to take time average of heat flux to calculate average Nusselt number, for which wallHeatFlux must be functionObject, which is not available in OF4. So I installed OF5 and later I tried with OF6 also, but got same results.
(2) Before using wallHeatFlux utility, I was using grad() to calculate Nusselt number but the solution was not correct.

I want to confirm whether I'm using correct formula or not.
The way I'm calculating Nusselt number is Nu = ( q * D) / ( alphaEff * rho * Cp * (Tw - Tinf) )
Where,
q = Heat flux
alphaEff = Effective thermal diffusivity
D = Characteristic length, which is dia in this case
rho = density
Cp = Specific heat capacity
Tw = Wall Temperature
Tinf = Inlet Temperature.

Is this a Correct way ?

Thank you

machao February 26, 2019 22:54

Quote:

Originally Posted by svramana (Post 721999)
Hi everyone,
I'm simulating heat transfer problem for compressible flow over cylinder using buoyantPimpleFoam. I want to calculate Nusslet number over cylinder, for that I'm taking time average of wall heat flux with help of wallHeatFlux utility available in OF5.0.
But problem is that I'm getting wrong values of heat flux as shown in attached picture. Value must be highest at stagnation point as boundary layer is thickeness is lowest there and then it should gradually decrease as BL thickeness increase. But I'm getting results opposite to it.
I'm not able to figure out what is wrong with my simulation or it is bug. Can someone help me please ?

In figure stagnation point is along plane.
Attachment 67776
Thanks

Dear svramana

I wonder how you take time average of wall heat flux with help of wallHeatFlux utility available in OF5.0.I want to obtain the average field of wallshearstress.Could you give me some suggestions?

Thanks

svramana February 27, 2019 13:18

Hi machao,
I'm taking time average of wallHeatFlux, whether you want time average or surface average?
If you want to take time average, in controlDict you have to call functionObject 'wallShearStress' before you call functionObject 'fieldAverage'. Then again call 'wallShearStress' in field average. This is shown below
Code:

functions
{
  wallShearStress
  {
      type wallShearStress;
      libs ("libfieldFunctionObjects.so");
      patches ("*.wall");
      enabled true;
      timeStart 1; //time from which you want to start averaging
      timeEnd 2; // End time for averaging
      outputControl writeTime;
      resetOnOutput false;
  }

  fieldAverage1
  {
      type fieldAverage;
      libs ("libfieldFunctionObjects.so");
      enabled true;
      timeStart 1; //same as above
      timeEnd 2; // same as above
      outputControl writeTime;
      resetOnOutput false;

      fields
      (
        wallShearStress
        {
            mean on;
            prime2Mean on;
            base time;
        }
      );
  }
}

Thanks

wyldckat February 27, 2019 20:05

Quote:

Originally Posted by svramana (Post 725651)
I want to confirm whether I'm using correct formula or not.
The way I'm calculating Nusselt number is Nu = ( q * D) / ( alphaEff * rho * Cp * (Tw - Tinf) )
Where,
q = Heat flux
alphaEff = Effective thermal diffusivity
D = Characteristic length, which is dia in this case
rho = density
Cp = Specific heat capacity
Tw = Wall Temperature
Tinf = Inlet Temperature.

Is this a Correct way ?

Thank you

Quick answer: Questions about Nusselt number calculations with OpenFOAM have been asked several times here on the OpenFOAM forums... after a quick search online, start reading from post #3 on this thread: https://www.cfd-online.com/Forums/op...tml#post659713

svramana February 28, 2019 02:03

Thank you sir for reply,
I have seen that post and have tried that way also, but actual question was about post #10 of this thread. I have tried different possible ways but I didn't got the correct answer yet.

Thank you


All times are GMT -4. The time now is 07:17.