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

how to interpolate grad(p)

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 31, 2012, 21:59
Default how to interpolate grad(p)
  #1
New Member
 
Lun Yu
Join Date: Aug 2012
Posts: 8
Rep Power: 14
victorconan is on a distinguished road
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!

Last edited by victorconan; August 31, 2012 at 22:29.
victorconan is offline   Reply With Quote

Old   September 2, 2012, 18:04
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by victorconan View Post
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)
gschaider is offline   Reply With Quote

Old   September 3, 2012, 02:56
Default
  #3
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 22
Bernhard is on a distinguished road
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.
Bernhard is offline   Reply With Quote

Old   September 3, 2012, 06:44
Default
  #4
New Member
 
Lun Yu
Join Date: Aug 2012
Posts: 8
Rep Power: 14
victorconan is on a distinguished road
Quote:
Originally Posted by gschaider View Post
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 is offline   Reply With Quote

Old   September 3, 2012, 06:46
Default
  #5
New Member
 
Lun Yu
Join Date: Aug 2012
Posts: 8
Rep Power: 14
victorconan is on a distinguished road
Quote:
Originally Posted by Bernhard View Post
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
victorconan is offline   Reply With Quote

Old   September 3, 2012, 09:14
Default
  #6
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by victorconan View Post
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)
gschaider is offline   Reply With Quote

Old   September 3, 2012, 09:24
Default
  #7
New Member
 
Lun Yu
Join Date: Aug 2012
Posts: 8
Rep Power: 14
victorconan is on a distinguished road
Quote:
Originally Posted by gschaider View Post
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!
victorconan is offline   Reply With Quote

Reply

Tags
interpolate


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
Interpolate in some points ivan_cozza OpenFOAM Post-Processing 2 April 22, 2009 09:58
Interpolate a boundary condition Xabi OpenFOAM Pre-Processing 0 April 9, 2009 05:23
overflow when interpolate initial result richard CFX 1 June 11, 2008 08:36
GradP in channeloodles nikos_fb16 OpenFOAM Running, Solving & CFD 1 September 4, 2007 11:52
Interpolate Stex CFX 2 June 30, 2003 09:04


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