Closed VijayN10 closed 1 year ago
Hi @VijayN10,
the most straightforward way is this:
lbm.run(0u); // initialize simulation
const string filepath = "path/to/file.dat"
write_file(filepath, "# velocities at one point\n"); // create new file with a header "# velocities at one point"
while(lbm.get_t()<100000ull) {
const ulong n_test = lbm.index(12u, 23u, 34u); // x/y/z coordinates of the point
lbm.u.read_from_device(); // copy entire velocity field from GPU VRAM to CPU RAM
const float3 u_test = float3(lbm.u.x[n_test], lbm.u.y[n_test], lbm.u.z[n_test]); // read 3D veclocity vector from CPU RAM
string s = to_string(u_test.x))+", "+to_string(u_test.y))+", "+to_string(u_test.z))+"\n"; // convert velocity components to string
write_line(filepath, s); // append new line to existing file
lbm.run(10u);
}
However the lbm.u.read_from_device();
command copies the entire velocity field over PCIe which is very slow for repeatedly probing the velocity. You can instead copy the velocity at only a single lattice point with this:
lbm.lbm[0]->u.read_from_device( n_test, 1ull); // velocity x component at point index n_test
lbm.lbm[0]->u.read_from_device( lbm.lbm[0]->get_N()+n_test, 1ull); // velocity y component at point index n_test
lbm.lbm[0]->u.read_from_device(2ull*lbm.lbm[0]->get_N()+n_test, 1ull); // velocity z component at point index n_test
This works for single-GPU simulations. For multi-GPU simulations, you first need to figure out in which domain your grid point is, and then change the domain index in lbm.lbm[domain_index]
.
Regards, Moritz
Thanks Moritz! It worked.
Hello!
I have a query regarding postprocessing - How can we write the values of velocities of fluid at particular point in each time step? Please let me know if anyone has any idea about this. Thank you.
Regards.