ProjectPhysX / FluidX3D

The fastest and most memory efficient lattice Boltzmann CFD software, running on all GPUs via OpenCL. Free for non-commercial use.
https://youtube.com/@ProjectPhysX
Other
3.81k stars 301 forks source link

Simulation Time and unit conversion #27

Closed trparry closed 1 year ago

trparry commented 1 year ago

Hello, in the windows graphics on the lower right corner you show simulation time. Simulation time looks like it has units of steps.

image

Could you possibly report simulation time in seconds instead so that it is easier to compare how close to real time we are?

Is there a way to report simulation time and elapsed (real) execution time? I'm trying to easily differentiate these to see how close they are. Thanks!

ProjectPhysX commented 1 year ago

LBM uses a different unit system from SI units, to have the numerical values close to 1.0f where accuracy is best. You therefore have to convert from SI units to LBM units in main_setup(). You can set the unit conversion factors with units.set_m_kg_s(lbm_length, lbm_velocity, lbm_density=1.0f, si_length, si_velocity, si_density);; note that the average density in LBM units always is 1.0f. This command computes the three base units m, kg, s as conversion factors between LBM units and SI units. Afterwards you convert all other quantities such as the viscosity lbm_nu = units.nu(si_nu); and insert that in the LBM constructor.

By default, if not explicitly set with units.set_m_kg_s(...);, the conversion factors are all 1. So 1 LBM time step is converted to 1 second by default, that's why the numbers match in the setup you have.

The Elapsed Time / Remaining Time is displayed based on the lbm.run(...); command. It it's lbm.run(); without an argument, an infinite number of time steps is computed, until manually terminated by the user, and "Elapsed Time" is shown. It the number of time steps is set, for example lbm.run(10000u);, or better lbm.run(units.t(5.2f)); to run as many LBM time steps as equivalent to 5.2 seconds, the "Remaining Time" will be counted down.

If in main_setup()a while loop repeatedly computes small time intervals and generates images in between, then lbm.run(30u); is used with a small number as explicit argument, so the "Remaining Time" will be counted down for every iteration of the while loop, often only a few seconds, so it is possible to see "Remaining Time" always displaying "0s".

trparry commented 1 year ago

Makes perfect sense thank you!