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

Calculating gradient only at patchInternalField

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 30, 2007, 20:19
Default 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: 20
7islands is on a distinguished road
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<volscalarfield>("phi");
const Field<vector> gPhip
= patchInternalField(Field<vector>(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
7islands is offline   Reply With Quote

Old   February 2, 2011, 05:17
Default
  #2
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30
akidess will become famous soon enough
Takuya, did you ever find a more efficient way to do this?
akidess is offline   Reply With Quote

Old   February 2, 2011, 20:36
Default
  #3
Super Moderator
 
Takuya OSHIMA
Join Date: Mar 2009
Location: Niigata City, Japan
Posts: 518
Blog Entries: 1
Rep Power: 20
7islands is on a distinguished road
I'm afraid not.

T
7islands is offline   Reply With Quote

Old   March 17, 2011, 09:51
Default
  #4
Senior Member
 
Eugene de Villiers
Join Date: Mar 2009
Posts: 725
Rep Power: 21
eugene is on a distinguished road
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.
eugene is offline   Reply With Quote

Old   March 20, 2011, 09:43
Default What is db?
  #5
ata
Senior Member
 
ata's Avatar
 
ata kamyabi
Join Date: Aug 2009
Location: Kerman
Posts: 323
Rep Power: 18
ata is on a distinguished road
Hi
I have a question. May be it is not related. What is db() in db().lookupObject?
Thanks a lot
ata is offline   Reply With Quote

Old   March 20, 2011, 19:59
Default
  #6
Senior Member
 
Sandeep Menon
Join Date: Mar 2009
Location: Amherst, MA
Posts: 403
Rep Power: 25
deepsterblue will become famous soon enough
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
deepsterblue is offline   Reply With Quote

Old   March 20, 2011, 22:06
Default
  #7
Super Moderator
 
Takuya OSHIMA
Join Date: Mar 2009
Location: Niigata City, Japan
Posts: 518
Blog Entries: 1
Rep Power: 20
7islands is on a distinguished road
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
7islands is offline   Reply With Quote

Reply


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
Calculating Drag Ajay Rao FLUENT 8 February 15, 2010 10:15
Calculating torque Andrew FLUENT 5 September 4, 2007 12:10
calculating temp student Main CFD Forum 3 December 26, 2006 08:53
Calculating the average y+ value Sebastiaan Bottenheim FLUENT 1 May 11, 2004 10:25
errors in calculating ustcer FLUENT 1 April 4, 2004 14:08


All times are GMT -4. The time now is 21:20.