Hi all,
I'd like to know how
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 |
Takuya, did you ever find a more efficient way to do this?
|
I'm afraid not. :(
T |
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. |
What is db?
Hi
I have a question. May be it is not related. What is db() in db().lookupObject? Thanks a lot |
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.
|
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 |
All times are GMT -4. The time now is 04:06. |