CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   get velocity gradient with a boundary function (http://www.cfd-online.com/Forums/openfoam-programming-development/84121-get-velocity-gradient-boundary-function.html)

Chris Lucas January 20, 2011 10:08

get velocity gradient with a boundary function
 
Hi
I want to write a new inlet boundary condition for epsilon. For this new boundary condition, I need calculate for instance the velocity gradient ( and magSqr(symm(fvc::grad(U))) )

I know I can get the velocity field at the patch using:
const fvPatchField<vector>& U = patch().lookupPatchField<volVectorField, vector>("U");

The problem is (as I understand it) that by using the code above, U is a “vector patch field”. But if I want to get the velocity gradient (using fvc::grad(U)), U must be a volVectorField.


Is there a way to get the velocity of the entire grid within the boundary condition, so that I can calculate the velocity gradient and then use this result to get the velocity gradient at the patch?


Thanks for the help.
Christian

lindstroem August 10, 2011 05:57

Hi Chris,

did you succeed?

I also want to get the velocity gradient at a patch..

Thanks in advance.

Chris Lucas August 10, 2011 08:36

Hi,

I didn't looked into this subject much more and therefore didn't solve the problem. Please let me know if you do :)

Best Regards
Christian

mathslw August 24, 2012 13:17

Quote:

Originally Posted by lindstroem (Post 319598)
Hi Chris,

did you succeed?

I also want to get the velocity gradient at a patch..

Thanks in advance.

Hi,

I also want to get the velocity gradient at a patch.

did you succeed?

Thanks!

Wei

Chris Lucas August 27, 2012 03:11

Hi,

no, I have not continued this work.


The following is a guess only (not sure if this works or even if this is correct):

I guess you need the normal BC gradient and not the fvc::grad.

Look at src/thermophysicalmodelbasic/derivatedFvPatchFields/gradientEnthalpy.C

as shown there, you get the surfaceNormalGradient of a fvPatchScalarfield (hope the same is true for fvPatchVectorField) with the function snGrad.


Another method is to calculate the gradient by hand. You have the value at the BC and the cell value next to the BC + the distance. However, this way you do not get the surfaceNormalGradient.


Kind Regards,
Christian


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