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/)
-   -   The most efficient way to compute n:th derivative? (https://www.cfd-online.com/Forums/openfoam-programming-development/153221-most-efficient-way-compute-n-th-derivative.html)

heksel8i May 20, 2015 15:41

The most efficient way to compute n:th derivative?
 
For the beginning I am interested in to compute efficiently a second derivative of a variable with respect to spatial coordinates x y and z. In other words the diagonal terms of grad(grad(f)).

I would like to benefit as much as possible from the existing functions as grad, div and existing boundary condition calls, but still obtain an efficient way to manage this. For example when approaching this by two gradient calls, we compute extra cross terms, which are not used.

Would the following be faster : f_xx = div([grad(f).component.X 0 0]) ? where the brackets describe a vector.

Or maybe by simply creating a new matrix operation to do this. Would I enter up having problems when applying boundary conditions?


Another thing is that the implementation should be able to take the mesh non-orthogonality / skewness corrections into account. E.g. something like f_xx = grad(snGrad(f)) . component(X)

Thirdly it would be beneficial to have this easily extended to higher order derivatives either by applying the operation several times in a row or by creating simply a new operator.


I am open to any ideas and suggestions!


All times are GMT -4. The time now is 17:14.