Hi,
There is not a direct way. The x,y,z values are implicit, based on the formatting of the file. Since the simulation box is always a cuboid, the formatting is very consistent. For instance, the first cell, corresponding to 0,0,0 will be in the bottom (y-direction), left (x-direction), top (z-direction) cell , and in the file it will be the first line. What I would recommend is doing is generating a few simple example files to get used to the format. The OVF format is pretty straightforward, it just list the cells in order. Once you see some actual examples, it will be clear.
One silly example OVF files would be to save something like B_ext, but set B_ext in each cell to be the position value. (You can't do this with m since it's restricted to be [-1,1] for each component). For instance, something like:
Nx := 64
Ny := 32
Nz := 4
c := 5e-9
setgridsize(Nx, Ny, Nz)
setcellsize(c, c, c)
m = uniform(0, 0, 1)
mask := newVectorMask(Nx, Ny, Nz)
for i:=0; i<Nx; i++{
for j:=0; j<Ny; j++{
for k:=0; k<Nz; k++{
r := index2coord(i, j, k)
x := r.X()
y := r.Y()
z := r.Z()
mask.setVector(i, j, k, vector(i,j,k))
}
}
}
B_ext.add(mask, 1)
OutputFormat = OVF2_TEXT
save(B_ext)
This is just a test file, so that B_x=x, B_y=y=y, B_z=z, so you can follow the formatting. When you open the file, you will see that it indexes from (0,0,0) to (1,0,0) etc... up to eventually 63,0,0, which is followed by 0,1,0.. etc, until the final line is (63,31,3). If you want physical positions in nm instead of cell indices, you can instead save x,y,z in the script by setting
mask.setVector(i, j, k, vector(x,y,z))
instead. x,y,z position values are measured from the center of the simulation (and then to the center of each cell). So cell 0,0,0, which was bottom (y-direction), left (x-direction), top (z-direction) cell, will be x=- 64*5e-9/2-2.5e-9=-1.575e-7 nm (64 cells, divided by 2 to center, and 5 nm per cell, shifted by 2.5nm to get the center of the cell), y= 32*5e-9/2 -2.5e-9
, z=-4*5e-9 -2.5e-9
, etc.
Best,
Josh L.