CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Programming & Development (
-   -   terms with the second derivative (

ziemowitzima February 14, 2013 12:26

terms with the second derivative
Dear Foamers,
I need to discretize/calculate terms which contain second derivative (not Laplacian), as follows:
\frac{\partial }{\partial y} \left( \frac{\partial f}{\partial x} \right)
\frac{\partial }{\partial x} \left( \frac{\partial f}{\partial x} \right) - \frac{\partial }{\partial y} \left( \frac{\partial f}{\partial y} \right)

and non-linear term with first derivative:
\left( \frac{\partial f}{\partial x}  \right)^2 - \left( \frac{\partial f}{\partial  y} \right)^2

For now the only way which works for me is to calculate twice the gradient of the function:
HTML Code:

gradf = fvc::grad(f); \\ it gives (f_x, f_y)
gradgradf0 = fvc::grad(gradf.component(0)); \\it gives (f_xx, f_yx)
gradgradf1 = fvc::grad(gradf.component(1)); \\it gives (f_xy, f_yy)

then term 1. is:
HTML Code:

gradgradf1.component(1); \\ f_xy
term 2. is:
HTML Code:

gradgradf0.component(0) - gradgradf1.component(1); \\ (f_xx - f_yy)
term 3. is:
HTML Code:

gradf.component(0)*gradf.component(0) - gradf.component(1)*gradf.component(1); \\ (f_x)^2- (f_y)^2
but unfortunately second derivative calculated as above gives me non-smooth results...

Is there any other/better way to compute terms like the one above ?


All times are GMT -4. The time now is 08:05.