- **OpenFOAM Programming & Development**
(*https://www.cfd-online.com/Forums/openfoam-programming-development/*)

- - **How to calculate the gradient along the boundaries from a known volScalarFiled?**
(*https://www.cfd-online.com/Forums/openfoam-programming-development/90681-how-calculate-gradient-along-boundaries-known-volscalarfiled.html*)

How to calculate the gradient along the boundaries from a known volScalarFiled?Hi,
I first obtained a volScalarField in a calculation domain, and then I want to calculate the gradient along the domain boundaries. Does anyone know how to obtain the gradient along domain boundaries from a known volScalarField? Thank you very much! |

hi shddx1:
I have the same problem with you ! I define a volScalrField first and the value is fixed for all the cells, but I want to caculate the gradient. Do you solve the problem, can you tell me? Thank you! |

You can obtain the surface normal gradient at each boundary using snGrad function.
p.boundaryField()[patchI].snGrad(); This will give you the surface normal gradient without any non-orthogonality or skewness corrections. If you need these corrections, use fvc::snGrad(). surfaceScalarField snGradP = fvc::snGrad(p); Then access the value at the boundary with snGradP.boundaryField()[patchI]. If you are looking for a full gradient vector at the boundary, this is a little tricker. Here you will have to interpolate the field gradient (fvc::grad(p)) to the faces and then replace the surface normal component of this with the value coming from fvc::snGrad(p). Hope this helps Ivor |

Quote:
could you please explain about it more? Where should we get this command: p.boundaryField()[patchI].snGrad(); ?? Thanks |

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