CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Post-Processing (
-   -   snGrad at a boundary patch (

EHo February 28, 2011 11:35

snGrad at a boundary patch
Hi all,

I'm trying to write the normal gradient of my temperature field T at a particular boundary patch = freeSurface to a file. I tried it like:

label patchIDsurf = mesh.boundaryMesh().findPatchID("freeSurface");
scalarField freeSurfaceTgrad(T.boundaryField()[patchIDsurf].snGrad());

and wrote the data to a file. The result is far from the value I can estimate in parafoam, not even the sign is true. I don't understand why! How doing it in the right way?

Best, Ernst

boger March 1, 2011 09:33

Is the sign always opposite to the one you expect, or it is mixed?

EHo March 1, 2011 10:02

It's mixed and the ratio between the written data "gradTwritten" and the data from Paraview "gradTexpected" is gradTwritten/gradTexpected \approx -6e3.

In the meantime I thought is has maybe to do with the corresponding face area, but the face area is A = 5e-9.

Any more ideas?

Best, Ernst

boger March 1, 2011 22:42

Not obvious to me that you're doing anything wrong. What type of boundary condition is it, and what does your fvSchemes dictionary say about snGradSchemes? Anything unusal about your grid along that boundary?

Have you looked at wallHeatFlux.C or wallGradU.C? Looks like you already have similar logic, but the utilities calculate all of the boundaries and write them out together - maybe it would help you to look at some of the other boundaries too.

EHo March 10, 2011 08:12

I think that it does not make any sense to calculate the surface normal gradient out of the data from a patch, because I guess that there is no data from neighbors and without neighbor cells there is no way to derive a gradient!?

Now I will try to do it like:

surfaceVectorField FvolGrad = fvc::interpolate(fvc::grad(Fvol));
vectorField FsurfGrad = FvolGrad.boundaryField()[patchID];
vectorField normal = patch().Sf()/patch().magSf();
scalarField snGradF = FsurfGrad & normal;

This works so far within a self-written BC to exclude the groovy BC and will try to implement this into my post-processing tool.

If it will not work, I'll be back!

So long

All times are GMT -4. The time now is 06:27.