Quote:
|
The general idea is that you write a 1st order taylor series approximation of a variable phi in the neighborhood n of the point c where you need the gradient (it is used for gradients in general) and assume that:
phi_n = phi_c + dphi/dx_i * (x_n-x_c)_i Write this for all the available neighbors of a given point c and you get a system of equations that, in most cases, needs to be solved by a least squares method because you have more neighbors than gradient components. However, the exact least squares solution of the equations is available and you don't typically solve it by a numerical procedure. There is abundant literature on this. I suggest the book by Blazek as textbook reference because it is the one that covers it best (he and Haselbacher actually developed one of the available closed solutions to the problem). EDIT: a different version of the exact solution (basically, you have the one based on solving the normal equations and the one based on QR factorization) can also be found in several of the early works of Prof. Z. J. Wang but, unfortunately, each one of them has a slight little error, and you need to look at all of them together to catch it. Let me also highlight that the work of Blazek and Haselbacher is more general and has, indeed, been extended to higher than first order approximations (used for k-exact rexonstructions) as well as to filters for unstructured grids. Doru Caraeni also put forward some developments/derivations for the easy application for 3rd order codes Finally, Nishikawa and coworkers have also made several studies recently |
Or you simply use this slide:
edit: By the way it is called Least Squares! https://i.ibb.co/B2qBQVZ/leastsquares.png |
Quote:
|
Quote:
|
Quote:
|
Quote:
Quote:
and therefore . This is more easy to discretisize. Regards |
Quote:
for a function of the form , representative of the energy at large large scales (i.e., no dissipative range). When you look at this in log k the peak is much more spread (besides the fact that the delta log(k) are much smaller than the delta k). However, without knowing the original use case for least squares here, Ferziger & Peric has straighforward formulas for both 1st and 2nd derivatives in 1D for non uniform grids, without need to resort to anything fancy. |
Quote:
|
Quote:
|
Quote:
|
Well, the function I used is just an example of how the energy spectra behave at low wave numbers (I used k^4, but k^2 would have been another possibility), where they tipically have a peak.
Now, what approach is more suited obviously depends from what the final goal is, but I would point out the following: 1) The formula with log k is just a second derivative, while the formula with k has two derivatives (first and second) multiplied by k and k^2 respectively. More work and typically more error. 2) The steps in k are much larger than those in log k, so this is necessarily linked to higher error 3) Now that I think more about it, this might simply be a restatement of 2 but, if you plot the function above as function of k and of log k, the latter is much more smoother around the peak, which means that any given formula would give less error. When I wrote the message this morning, I actually tried both formulas and they indeed differ at low wavenumbers for the function I mentioned. I deleted the script I used, but I suggest you to make a similar test to better understand them both. |
Quote:
|
All times are GMT -4. The time now is 16:58. |