
[Sponsors] 
July 20, 2016, 16:13 
How to calculate grad(p) for a specific point?

#1 
Member
Jack
Join Date: Dec 2011
Posts: 89
Rep Power: 7 
Hi guys,
I know that if I do a fvc::grad(p), it will return a volScalarField with the values of pressure gradient. However, what should I do if I want fvc::grad(p) to only calculate pressure gradient at a specific grid point (instead of the whole field)? The reason I ask this is that I need to calculate the pressure gradient just for a few points (instead the whole field), and I need to do it a couple of thousand times per iteration. So it will be a waste of computational time if I calculate the pressure gradient for the whole field. Any ideas? Thanks very much in advance! Regards, 

July 21, 2016, 04:20 

#2 
Member
Jerry
Join Date: Oct 2013
Location: Salt Lake City, UT, USA
Posts: 52
Rep Power: 5 
Hi ripperjack,
The following is my idea: First of all, you need to decide what method you are going to use for the evaluation of the gradient as well as what surface interpolation scheme you want to apply to obtain values on the internal surfaces from cell center values. Take the gaussian gradient and linear interpolation scheme for example. (I am not quite familiar with the leastsquare gradient. If anyone knows the implementation of this method, please add.) The first step, you need to take those cells where gradient evaluations are needed out. The information needed from those cells is as follows: cell indexes of those cells; owner, neighbor information around those cells; weights information between those cells and their neighbors. After getting all the information above, the second step is to perform a linear interpolation: gf = w*gC+(1w)*gF to obtain the values on the internal surfaces, where w represents the weight. The third step is to calculate gradient based on the gaussian method. Also, depending on whether you want to apply nonorthogonal correction, between step two and step three, you can add the corrections to the interpolation values. This is just the general idea. I hope this can help you. 

July 21, 2016, 10:08 

#3  
Member
Jack
Join Date: Dec 2011
Posts: 89
Rep Power: 7 
Quote:
Thank you very much for your detailed reply! However, I would like to know if I can use some highlevel functions such as fvc::grad(p,pointID) which only calculate the gradient at a specific point. I understand your idea and I think it will work for pressure gradient. But I also need to calculate div, laplacian, etc. Is there a way that I don't need to write the code from scratch? Otherwise, I might need to write such class by myself. lol Thanks! 

July 21, 2016, 12:43 

#4 
Member
Jerry
Join Date: Oct 2013
Location: Salt Lake City, UT, USA
Posts: 52
Rep Power: 5 
Hi ripperjack,
I checked fvcGrad.H, it seems that there is no such function that evaluates gradient at specific points. I think you might end up defining all these functions yourself. This seems to be not an easy task. Good luck to you. 

July 21, 2016, 13:34 

#5 
Senior Member
Mahdi Hosseinali
Join Date: Apr 2009
Location: NB, Canada
Posts: 270
Rep Power: 11 
1. You can point a new field to a few cells around the one you want and use the standard functions on the new field.
2. Define a separate region for that small part (probably will have more than a few cells) and do your iterations only for that part. This one will not be a very portable code though 

July 21, 2016, 13:45 

#6 
Member
Jerry
Join Date: Oct 2013
Location: Salt Lake City, UT, USA
Posts: 52
Rep Power: 5 
Yeah, it might work. The problem of doing it this way is that there would be lots of problems in dealing with the indexes, boundary conditions...


July 24, 2016, 09:59 

#7  
Member
Jack
Join Date: Dec 2011
Posts: 89
Rep Power: 7 
Quote:
Thanks very much for your reply. I am very interested in the first method. Can you give me more details in terms of how to point a new field to a few cells around a specific field? I did some search and it seems that creating a "fvMeshSubset" may work for my case (this post). fvMeshSubset will take care of the boundary conditions as well, which is exactly what I want. But I am not sure how to implement it in details. Thanks very much in advance. 

July 25, 2016, 12:00 

#8  
Senior Member
Mahdi Hosseinali
Join Date: Apr 2009
Location: NB, Canada
Posts: 270
Rep Power: 11 
I took a look at it in Doxygen but couldn't figure it out!
What I would go for is to create a Field so I can pass it to grad() then. Something like Quote:


Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
How to define to right point for locationInMesh  Mirage12  OpenFOAM Native Meshers: snappyHexMesh and Others  7  March 13, 2016 15:07 
How to get cell labels for all the points within specific distance from a given point  gxy200992243  OpenFOAM Programming & Development  7  October 11, 2014 15:17 
how to calculate flow properties along the first grid point near to the wall  kiran  OpenFOAM PostProcessing  2  September 12, 2010 12:59 
Gmsh and samplesurface  touf  Open Source Meshers: Gmsh, Netgen, CGNS, ...  2  December 10, 2007 03:27 
Overall picture versus specific point  Nick  Main CFD Forum  0  October 7, 2004 11:25 