|
[Sponsors] |
Calculating gradient only at patchInternalField |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
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: 20 |
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 |
|
February 2, 2011, 05:17 |
|
#2 |
Senior Member
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30 |
Takuya, did you ever find a more efficient way to do this?
|
|
March 17, 2011, 09:51 |
|
#4 |
Senior Member
Eugene de Villiers
Join Date: Mar 2009
Posts: 725
Rep Power: 21 |
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: 323
Rep Power: 18 |
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: 403
Rep Power: 25 |
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.
|
|
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: 20 |
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 |
|
|
|
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 |