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/)
-   -   Problem with snGrad() for heat flux. (https://www.cfd-online.com/Forums/openfoam-programming-development/128459-problem-sngrad-heat-flux.html)

SKLee January 13, 2014 05:11

Problem with snGrad() for heat flux.
 
I am simulating the gas laminar flow in straight rectangular channel with rhoCentralFoam (OF-2.2.2), I modified the utility wallHeatFlux and also renamed it to extract the heat flux for laminar flow, and get problem with snGrad() that was used to compute the normal gradient of temperature.

In the code I set

surfaceScalarField heatFlux = (fvc::interpolate(-k))*(fvc::snGrad(T));

then I compile my utility and run it and get the heat fluxes at the surfaces and outlet are zero while it can produce the heat flux at inlet only.

I just check heatFlux = fvc::interpolate(-k) so I have all values (not zero) of k at the surfaces but it I added (fvc::snGrad(T)) to heatFlux I got the results are zero for surface heat flux. This means (fvc::snGrad(T)) produced the value of zero for normal gradient temperature.

What problem I get with snGrad() function. Can anyone help me to get the heat fluxes at the surfaces ?

I use psiThemo model in simulation.

wyldckat February 16, 2014 13:01

Greetings Lee,

I honestly don't know what is the problem you're getting, because I don't get any problem. I'm guessing this is because you didn't share enough information for reproducing the same problem.

I modified the wallHeatFlux utility this way:
  1. Copied the folder "$FOAM_UTILITIES/postProcessing/wall/wallHeatFlux".
  2. Renamed the application in "Make/files".
  3. Changed in the main C file:
    Code:

    surfaceScalarField heatFlux
    (
        fvc::interpolate
        (
            (
                turbulence.valid()
              ? turbulence->alphaEff()()
              : thermo->alpha()
            )
        )*fvc::snGrad(h)
    );

    To this:
    Code:

    volScalarField T
    (
        IOobject
        (
            "T",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        ),
        mesh
    );
       
    surfaceScalarField heatFlux
    (
        fvc::interpolate
        (
            (
                turbulence.valid()
              ? turbulence->alphaEff()()
              : thermo->alpha()
            )
        )*fvc::snGrad(T)
    );

  4. Build it.
  5. Ran in the tutorial case "heatTransfer/buoyantSimpleFoam/hotRoom".
  6. Got results that seemed similar to the original wallHeatFlux.
Best regards,
Bruno

SKLee February 24, 2014 09:09

Hi Bruno,

I modified the wallHeatFLux for laminar case with the rhoCentralFoam solver.

in CreateFields.H
Code:

autoPtr<psiThermo> pThermo
(
    psiThermo::New(mesh)
);
psiThermo& thermo = pThermo();


volScalarField Cp
(
IOobject
(
    "Cp",
    runTime.timeName(),
    mesh
),
  thermo.Cp()
 );

volScalarField mu
(
    IOobject
    (
        "mu",
        runTime.timeName(),
        mesh
    ),
    thermo.mu()
);

and in the wallHeatFluxModifief.C I just change

Code:

volScalarField T
(
    IOobject
    (
        "T",
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ,
        IOobject::NO_WRITE
    ),
    mesh
);
        surfaceScalarField heatFlux
       
(
    fvc::interpolate
    (
        (
              mu*Cp/0.72
            // Pr = 0.72
        )
    )*fvc::snGrad(T)
);

and built it to run. The results show that the heat flux at the wall is zero everywhere. I just try to remove fvc::snGrad(T) and the results is not zero. (i.e. the values of mu*Cp/0.72 shown). That means in my modified code fvc::snGrad(T) does not work (i.e. snGrad(T) = 0).

Could you help me to find out the mistakes ?

Thanks

Best regards,

SK

wyldckat March 2, 2014 07:40

Hi Lee,

This is the problem when people don't share a test case :(

The utility will work if you have walls in your simulation case. Check the contents of the file "constant/polyMesh/boundary". If all patches are of type "patch" or if none of the patches are of type wall, then it's only natural that you don't have non-zero values near the walls that don't exist ;)

For example, if you run this command in the tutorial case "compressible/rhoCentralFoam/biconic25-55Run35", after the mesh has been created:
Code:

patchSummary -constant -noZero
It will tell you that the following patches are defined:
Code:

Valid fields:

patch    : cone
patch    : outlet
patch    : freestream
group    : symmetryPlane
group    : wedge

End

See, there are no "walls" :D

Best regards,
Bruno

SKLee March 4, 2014 22:46

Hi Bruno,

That's fine. It works. Thanks so much for your help.

SK


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