CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   how to interpolate grad(p) (http://www.cfd-online.com/Forums/openfoam/106556-how-interpolate-grad-p.html)

victorconan August 31, 2012 20:59

how to interpolate grad(p)
 
Hi, everyone,
I am new to openfoam. I wanna interpolate the grad(p) but I don't know how to do this. I tried to use fvc::interpolate(fvc::grad(p)), but it does not work. Could anyone do me a favor to teach me how to do this?
Thanks!

PS:I also tried to build a volScalarField and interpolate it, but it did not work. I tried this:
volScalarField surfP
(
IOobject
(
"surfP",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("zero",dimensionSet(0,1,-2,0,0,0,0),0.0)
);
surfP.internalField()=fvc::grad(p);
I suppose there is something wrong with the surfP.internalField()=fvc::grad(p), could anyone tell me how to correct it? Thanks!

gschaider September 2, 2012 17:04

Quote:

Originally Posted by victorconan (Post 379790)
Hi, everyone,
I am new to openfoam. I wanna interpolate the grad(p) but I don't know how to do this. I tried to use fvc::interpolate(fvc::grad(p)), but it does not work. Could anyone do me a favor to teach me how to do this?
Thanks!

You want to have the value of the gradient on the cell faces, right? Have you considered doing this directly with snGrad(p)? (Mind that this is only the gradient in the direction of the surface normal. But that is the only one you're going to get anyway)

Bernhard September 3, 2012 01:56

Also, it would help a lot if you gave some compilation errors. "It does not work" does not help us a lot. Are you sure you want your variable surfP to be of type volScalarField? As I understand, you want a vector on the faces, so then it'd be surfaceVectorField... Anyhow, the snGrad(p) is probably already what you need.

victorconan September 3, 2012 05:44

Quote:

Originally Posted by gschaider (Post 379916)
You want to have the value of the gradient on the cell faces, right? Have you considered doing this directly with snGrad(p)? (Mind that this is only the gradient in the direction of the surface normal. But that is the only one you're going to get anyway)

Thanks for your reply!
What I need is the interpolated pressure gradient. I have no idea whether the snGrad(p) is the interpolated value.
Lun

victorconan September 3, 2012 05:46

Quote:

Originally Posted by Bernhard (Post 379943)
Also, it would help a lot if you gave some compilation errors. "It does not work" does not help us a lot. Are you sure you want your variable surfP to be of type volScalarField? As I understand, you want a vector on the faces, so then it'd be surfaceVectorField... Anyhow, the snGrad(p) is probably already what you need.

Thanks!
I found what was wrong. now I use:
volScalarField gradp=mag(fvc::grad(p));
now no error occurs during the compiling.
Thanks again!
Lun

gschaider September 3, 2012 08:14

Quote:

Originally Posted by victorconan (Post 379978)
Thanks for your reply!
What I need is the interpolated pressure gradient. I have no idea whether the snGrad(p) is the interpolated value.
Lun

It's better. It is the grad on the face between to cell in the direction of the normal of that face. Basically this value was used to calculate the grad in the cell. Have a look in the programmers guide. Unless you want to have the numerical inaccuracies of the roundtrip (1. to cell 2. interpolate back to face)

victorconan September 3, 2012 08:24

Quote:

Originally Posted by gschaider (Post 380012)
It's better. It is the grad on the face between to cell in the direction of the normal of that face. Basically this value was used to calculate the grad in the cell. Have a look in the programmers guide. Unless you want to have the numerical inaccuracies of the roundtrip (1. to cell 2. interpolate back to face)

I wanna implement the rhie-chow interpolation, in which I need the interpolated pressure gradient. That means I have to calculate the grad(p) in the cell and then interpolate it to the surface. As you say, snGrad is used for grad in the cell, so it is another term in rhie-chow interpolation[rhie-chow interpolation is: U=U_interpolate-(1/rAU)(gradp-gradp_interpolate)].
Thanks for your reply!


All times are GMT -4. The time now is 16:48.