/** The functions within this file aim to calculate a second-order longitudional structure function from a vector field. We can define a distance vector $\mathbf{l}$ separating two points in space ($\mathbf{x_1,x_1+l}$). Generally speaking, the vectors $\mathbf{u}$ at these points are differt. The difference in the magnitude of their projections on the $\mathbf{l}$ vector may have some interesting properties. We define: $$\delta v_{\|}(\mathbf{x_1,l})= \left( \mathbf{v(x_1+l)-v(x_1)}\right) \cdot \frac{\mathbf{l}}{l},$$ where l is $\|\mathbf{l}\|$. By definition, from a statistical perspective, within a homogeneous and isotropic region, one would expect $\|\delta v_{\|}(\mathbf{x_1,l})\|$ only to be dependend on $l$, i.e. the length of the separation vector. Therefore we can define a second order statistic related to a vector field ($\mathbf{u}$) according to: $$S_2(l)=\langle \delta v_{\|}(\mathbf{x_1,l})^2 \rangle$$ where the variable $\langle x \rangle$ represents a region-averaged value of a dummy variable $x$. The code belows aims to evaluate some discretized version of $S_2(l)$ from a vector field on a three-dimensional-tree grid. */ int obtain_a_cache(int j,double d[][6],int lev[],vector u){ #if _MPI MPI_Barrier(MPI_COMM_WORLD); #endif srand(time(NULL));// In order to obtain a smooth-ish pair distances distribution we add a stogastic component; int index[j]; int n=0; foreach() n++; double meaninc=(double)(n)/(double)(j); //The mean increment to obtain approx j cells. index[0]=0; int g=1; while (g0.&&l0.){ aa = dvarr[it][1]/dvarr[it][2]; dvarr[it][1] = aa; } dvarr[it][0]=it*Del; it++; } printdvarr(fp,dvarr,Len); #if _MPI } #endif return 1; }