... | @@ -79,3 +79,25 @@ int ixyz = iz + lNZ*iy + lNZ*lNY*ix; |
... | @@ -79,3 +79,25 @@ int ixyz = iz + lNZ*iy + lNZ*lNY*ix; |
|
h_densities.density_a[ixyz]; // value of density in center of the box
|
|
h_densities.density_a[ixyz]; // value of density in center of the box
|
|
```
|
|
```
|
|
|
|
|
|
|
|
#Iterating over lattice points
|
|
|
|
The following scheme is used to iterate over lattice points.
|
|
|
|
```c
|
|
|
|
int lNX=h_densities.nx, lNY=h_densities.ny, lNZ=h_densities.nz; // local sizes
|
|
|
|
// or ...
|
|
|
|
// int lNX=NX, lNY=NY, lNZ=NZ;
|
|
|
|
int ix, iy, iz, ixyz;
|
|
|
|
|
|
|
|
// ITERATE OVER ALL POINTS
|
|
|
|
ixyz=0;
|
|
|
|
for(ix=0; ix<lNX; ix++) for(iy=0; iy<lNY; iy++) for(iz=0; iz<lNZ; iz++)
|
|
|
|
{
|
|
|
|
double x = DX*(ix-lNX/2);
|
|
|
|
double y = DY*(iy-lNY/2); // for 1d code y will be always 0
|
|
|
|
double z = DZ*(iz-lNZ/2); // for 1d and 2d codes z will be always 0
|
|
|
|
|
|
|
|
// ... compute something for coordinate (x,y,z) ....
|
|
|
|
// rho_a[ixyz]=...;
|
|
|
|
|
|
|
|
ixyz++; // go to the next point, it should be the last line of the triple loop
|
|
|
|
}
|
|
|
|
``` |