# How to calculate grad(p) for a specific point?

 Register Blogs Members List Search Today's Posts Mark Forums Read

 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 least-square 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+(1-w)*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. Jerrydqfan and LogiDF like this.

July 21, 2016, 10:08
#3
Member

Jack
Join Date: Dec 2011
Posts: 89
Rep Power: 7
Quote:
 Originally Posted by Jerryfan 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 least-square 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+(1-w)*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.
Hi Jerryfan,

Thank you very much for your detailed reply! However, I would like to know if I can use some high-level 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:
 Originally Posted by anishtain4 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
Hi Mahdi,

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.

July 25, 2016, 12:00
#8
Senior Member

Mahdi Hosseinali
Join Date: Apr 2009
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:
 labelList myCellList = list of labels of your cells Field myTinyField(p.internalField(),myCellList)
It's just off the top of my head though, it probably needs more work

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Mirage12 OpenFOAM Native Meshers: snappyHexMesh and Others 7 March 13, 2016 15:07 gxy200992243 OpenFOAM Programming & Development 7 October 11, 2014 15:17 kiran OpenFOAM Post-Processing 2 September 12, 2010 12:59 touf Open Source Meshers: Gmsh, Netgen, CGNS, ... 2 December 10, 2007 03:27 Nick Main CFD Forum 0 October 7, 2004 11:25

All times are GMT -4. The time now is 05:19.