Hello @JoJo, you’re absolutely right, the documentation is in dire need of improvements.
While there is a “main loop” in GPUSPH (GPUSPH::runSimulaiton()
in src/GPUSPH.cc
, the while () try { dispatchCommand() } catch {}
), this is not where the logic of the main loop is stored.
The reason for this is that, depending on the simulation setup and integration scheme, the steps that need to be executed can be very different, and having all these integrated conditionals in the main loop made things extremely fragile.
The sequence of commands is now defined once by the chosen Integrator
, which for normal simulations is the PredictorCorrectorIntegrator
. For integrators, there is some common code in src/Integrator.h
and src/Integrator.cc
, and the integrator-specific code under appropriate files in src/integrators
(e.g. for the standard predictor/corrector, the files are PredictorCorrectorIntegrator.cc
and the corresponding header file).
Integrators collect sequences of commands, grouping them into “phases”. The logic to transition between one phase and the next is in the next_phase()
method of the integrator, while the sequence of commands that compose each phase are defined in each initializePhase
specialization.
Here’s a scheme of the current predictor/corrector integration scheme (you can open the image and view it in detail):
The actual commands defined by the integrator are then read one after the other in the loop in GPUSPH::runSimulation()
and dispatched to the appropriate component: some commands are run on host, and their implementation is the runCommand
specializations in GPUSPH
itself, while others are run on device, and their implementation is the runCommand
specializations in GPUWorker
(there will be one running for every GPU used in the simulation).
Most of the worker commands end up calling CUDA kernels, which are defined in the .cu
files under src/cuda
, with different specializations based on the static simulation configuration (“framework options” such as the choice of smoothing kernel or boundary model).
I hope this is enough to get you started. Feel free to ask more if needed.