A question about particle replacement in EDEM
Hi,
I had a question when I was learning EDEMAPI Tutorial 1 - Particle Replacement and trying to implement particle replacement in EDEM. There is a file 'Particle_Cluster_Data' in this tutorial, which basically about a particle will be replaced by how many meta-particles. However, I have no idea how the coordinates of each meta-particle were obtained. Could you please explain to me how these coordinates were obtained?
Many thanks,
Chao
Best Answer
-
Hi Chao,
The cluster data .txt file was exported from EDEM. In a pre-simulation a sphere geometry was imported and used as a factory to place the smaller particles inside this sphere. Once fully packed the coordinates of the particles were exported to the text file.
During simulation initially we have large particles that we want to replace. In the code CRemoval.cpp this checks the particle names against the name of the particle to replace (as specified in Particle_Replacement_prefs.txt). Once the particle is identified it's coordinates are written to an array (ParticleList) and then the particle is deleted.
Next time-step the factory takes the coordinates of the particles in ParticleList and replaces the deleted particle with the smaller particles as specified in the cluster data .txt file.
RegardsStephen
0
Answers
-
Hi Chao,
The cluster data .txt file was exported from EDEM. In a pre-simulation a sphere geometry was imported and used as a factory to place the smaller particles inside this sphere. Once fully packed the coordinates of the particles were exported to the text file.
During simulation initially we have large particles that we want to replace. In the code CRemoval.cpp this checks the particle names against the name of the particle to replace (as specified in Particle_Replacement_prefs.txt). Once the particle is identified it's coordinates are written to an array (ParticleList) and then the particle is deleted.
Next time-step the factory takes the coordinates of the particles in ParticleList and replaces the deleted particle with the smaller particles as specified in the cluster data .txt file.
RegardsStephen
0 -
Hi,
If you look in the src folder you'll see the source code for the plugin.
The file CReplacementFactory.cpp contains the source code for the factory component of the plugin and you can see on line 15 that PREFS_FILE stores the name of the file in question ("Particle_Cluster_Data.txt").
To inform EDEM of the name of the preference file to look for, the value of PREFS_FILE is passed to prefFileName (using strncpy) within getPreferenceFileName( ), on line 37. The value stored in prefFileName can be accessed within setup( ) using prefFile. In this way you can access the contents of Particle_Cluster_Data.txt from inside setup( ) - this is how a lot of preference file reading happens with EDEM API plugins, though if you have a lot of data to read in it's better to do it in starting( ).
In line 49 an ifstream is set up to to store the data coming from prefFile (which now hold the full path of the file Particle_Cluster_Data.txt) and the reading of it is done in lines 60 and 72, storing values from the ifstream as they are looped over.
Hope that helps,
Richard
0 -
Richard Wood_20774 said:
Hi,
If you look in the src folder you'll see the source code for the plugin.
The file CReplacementFactory.cpp contains the source code for the factory component of the plugin and you can see on line 15 that PREFS_FILE stores the name of the file in question ("Particle_Cluster_Data.txt").
To inform EDEM of the name of the preference file to look for, the value of PREFS_FILE is passed to prefFileName (using strncpy) within getPreferenceFileName( ), on line 37. The value stored in prefFileName can be accessed within setup( ) using prefFile. In this way you can access the contents of Particle_Cluster_Data.txt from inside setup( ) - this is how a lot of preference file reading happens with EDEM API plugins, though if you have a lot of data to read in it's better to do it in starting( ).
In line 49 an ifstream is set up to to store the data coming from prefFile (which now hold the full path of the file Particle_Cluster_Data.txt) and the reading of it is done in lines 60 and 72, storing values from the ifstream as they are looped over.
Hope that helps,
Richard
Thank you very much!
0 -
Stephen Cole_21117 said:
Hi Chao,
The cluster data .txt file was exported from EDEM. In a pre-simulation a sphere geometry was imported and used as a factory to place the smaller particles inside this sphere. Once fully packed the coordinates of the particles were exported to the text file.
During simulation initially we have large particles that we want to replace. In the code CRemoval.cpp this checks the particle names against the name of the particle to replace (as specified in Particle_Replacement_prefs.txt). Once the particle is identified it's coordinates are written to an array (ParticleList) and then the particle is deleted.
Next time-step the factory takes the coordinates of the particles in ParticleList and replaces the deleted particle with the smaller particles as specified in the cluster data .txt file.
RegardsStephen
Thank you very much, it makes sense to me!
However, can I ask one more question? I know how to export the coordinates for a single particle. But I'm just curious if I need to select and export all the smaller particles one by one if I want to get their coordinates, or is there another way, as I've just recently started working on particle replacement?
Thank you in advance for your help!
Regards,
Chao
0