CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   terms with the second derivative (https://www.cfd-online.com/Forums/openfoam-programming-development/113194-terms-second-derivative.html)

ziemowitzima February 14, 2013 11:26

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

3.
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 ?

Thanks
ZZM


All times are GMT -4. The time now is 03:10.