API function
Hi,
I am looking at the code for particle replacement and have difficulty with a function :
void CRemoval::processParticleOfInterest(int threadID, int particleOfInterestId)
I would like to know when and how this function is executed? And since markParticleOfInterest(particle.ID) must be called before this function to mark specific particles. Does it mean I could mark particles in step 2,4,5 in the following picture and the processParticleOfInterest function is called between step 5 and 6 for every particle marked in the current timestep, no matter particles are marked in Particle factory, Contact model or body force?
Best Answer
-
Hi Guozhen,
The 'mark particle of interest' function is part of the Particle Manager which you can call from points 4 and 5, you don't really need to call it in the factory as this runs on CPU anyway.
Once a particles ID is passed to the Particle of Interest function then it is processed as an additional External Force (within the Calculate Forces function) but it will be called after the calculate force is run on GPU which allows it to be processed that time-step.
Regards
Stephen
1
Answers
-
Hi Guozhen,
The 'mark particle of interest' function is part of the Particle Manager which you can call from points 4 and 5, you don't really need to call it in the factory as this runs on CPU anyway.
Once a particles ID is passed to the Particle of Interest function then it is processed as an additional External Force (within the Calculate Forces function) but it will be called after the calculate force is run on GPU which allows it to be processed that time-step.
Regards
Stephen
1 -
Stephen Cole_21117 said:
Hi Guozhen,
The 'mark particle of interest' function is part of the Particle Manager which you can call from points 4 and 5, you don't really need to call it in the factory as this runs on CPU anyway.
Once a particles ID is passed to the Particle of Interest function then it is processed as an additional External Force (within the Calculate Forces function) but it will be called after the calculate force is run on GPU which allows it to be processed that time-step.
Regards
Stephen
Dear Stephen,
Many thanks to your answer, I have some further questions. I noticed that externalForce() function is defined similarly in both CPU and GPU APIs. Left is CPU and Right is GPU. What is the sequence of calling those two CPU/GPU functions? Are both functions called for every particle in the simulation and final body force is operated via the reference variable result/results?
Regards,
Jason
0 -
Guozhen Li said:
Dear Stephen,
Many thanks to your answer, I have some further questions. I noticed that externalForce() function is defined similarly in both CPU and GPU APIs. Left is CPU and Right is GPU. What is the sequence of calling those two CPU/GPU functions? Are both functions called for every particle in the simulation and final body force is operated via the reference variable result/results?
Regards,
Jason
Hi Jason,
If you are running on CUDA GPU then it won't enter the CPU calculation for this external force, you only really need to add the CPU version if you also want to run on CPU and match the GPU result/code directly. It is useful for debugging to have both the CPU and GPU option as it is often easier to get the code working on CPU first (if the model supports CPU), however you only really need one of them for the processor type, and then this is passed to the process particle of interest option.
RegardsStephen
1