# Calculating gradient only at patchInternalField

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

 January 30, 2007, 20:19 Hi all, I'd like to know how #1 Super Moderator   Takuya OSHIMA Join Date: Mar 2009 Location: Niigata City, Japan Posts: 518 Blog Entries: 1 Rep Power: 11 Hi all, I'd like to know how to calculate gradient (not surface-normal gradient) at patchInternalField within a boundary condition code in a computationally efficient way. Doing it simple programming-wise I could write #include "fvcGrad.H" const volScalarField& phi = db().lookupObject("phi"); const Field gPhip = patchInternalField(Field(fvc::grad(phi))); but obviously this is computationally too inefficient (calculating gradient of the entire field just for patchInternalField). I appreciate any suggestions. Thanks, Takuya

 February 2, 2011, 05:17 #2 Senior Member     Anton Kidess Join Date: May 2009 Location: Delft, Netherlands Posts: 919 Rep Power: 17 Takuya, did you ever find a more efficient way to do this?

 February 2, 2011, 20:36 #3 Super Moderator   Takuya OSHIMA Join Date: Mar 2009 Location: Niigata City, Japan Posts: 518 Blog Entries: 1 Rep Power: 11 I'm afraid not. T

 March 17, 2011, 09:51 #4 Senior Member   Eugene de Villiers Join Date: Mar 2009 Posts: 725 Rep Power: 12 I just had a look at the grad calculation code and what you suggest should be relatively easy to implement (for an explicit gauss gradient at least, I didn't check the requirements for least squares and other gradient calculation methods). The gradient is calculated from: grad(phi)_cell = sum_cellfaces(Sf*phi_f) / cellVolume; Simple as that. So all you would need for the gradient at the patchInternalField is to loop through the cells, calculate the interpolated face value on each face in the set and compute the simple sum. There is no parallel complexity or anything required that I can see. You will just have to find an efficient way to limit the number of face interpolations so there is no duplicate calculation.

 March 20, 2011, 09:43 What is db? #5 Senior Member     ata kamyabi Join Date: Aug 2009 Location: Kerman Posts: 322 Rep Power: 8 Hi I have a question. May be it is not related. What is db() in db().lookupObject? Thanks a lot

 March 20, 2011, 19:59 #6 Senior Member   Sandeep Menon Join Date: Mar 2009 Location: Amherst, MA Posts: 386 Rep Power: 15 I actually think this is straightforward. Create a cellSet and use that to make an fvMeshSubset. This should also carry all necessary information to estimate the cell-centered gradient that you're asking for. __________________ Sandeep Menon University of Massachusetts Amherst https://github.com/smenon

 March 20, 2011, 22:06 #7 Super Moderator   Takuya OSHIMA Join Date: Mar 2009 Location: Niigata City, Japan Posts: 518 Blog Entries: 1 Rep Power: 11 Hi all, thanks for the input. @Eugene: Yes you are right, that was exactly what came up to my mind, but I was so lazy that I thought there would have been a simpler (or more OpenFOAM-ish) way. @ata: db() returns a reference to the object registry. @Sandeep: That sounds like what I was looking for at that time if the subsetMesh and the field do not have to be constructed each time step. In fact I no longer have to do this, but shall try your proposal if I have to do this next time Takuya

 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 Ajay Rao FLUENT 8 February 15, 2010 10:15 Andrew FLUENT 5 September 4, 2007 11:10 student Main CFD Forum 3 December 26, 2006 08:53 Sebastiaan Bottenheim FLUENT 1 May 11, 2004 09:25 ustcer FLUENT 1 April 4, 2004 13:08

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