Particle Factory User Defined Libraries
A Particle Factory UDL consists of a shared library file and, optionally, a file containing preferences. Using the EDEM API, you can write and compile a custom Particle Factory for creating and initializing particles.
- Create a directory in which you want to save the new Particle Factory project.
-
Copy the following header files into the directory that you have created:
IPluginParticleFactory.h
PluginParticleFactoryCore.h
IPluginParticleFactoryV3_3_0.h
PluginConstants.h
Helpers.h
-
Create a new class (
CNewParticleFactory
) derived from the Particle Factory interface you want to use (for example,IPluginParticleFactoryV2_1_0
). -
Save the class declaration to a header file (for
example,
CNewParticleFactory.h
).This file must consist of declarations of the methods in the selected interface, any extra methods required, and any variables. -
Implement all the methods defined in your header file and save as a
.cpp
file (for example,CNewParticleFactory.cpp
). -
Create a new
.cpp
file with implementations of the methods inPluginParticleFactoryCore.h
. -
Save this file as
NewParticleFactory.cpp
. -
Create a new
.cpp
file with implementations of the methods inPluginParticleFactoryCore.h
. -
Save this file as
NewParticleFactory.cpp
. -
Compile all your
src
files and link them together into.dll
(Windows) or.so
(Linux) library files. -
Ensure that the library and optional preferences file are saved in the Particle
Factory model folder (as specified in
simulation_name.dem
file (only applicable for EDEM versions 2017 and above). ), or in the same folder as the - Start EDEM and then select the Factories tabbed page.
- Click Import and then select the new factory from the Import Factory dialog box.
-
Click OK.
The following methods are available in the Particle factory Model interface
IPluginParticleFactoryV2_1_0
:Method Description Type getPreferenceFileName
Retrieves the name of the config file used by the UDL. Setup usesCustomProperties
Indicates whether the UDL wants to register or receive custom property data. Setup setFilePath
Called inside the starting()
method to provide the plugin with the full simulation path (including the simulation file name).Setup setup
Initializes the plugin by reading any config files, opening temporary files, generating data structures, or other setup tasks. Setup starting
Called once at the start of a simulation to indicate that processing is about to begin and the model should allocate any temporary storage and retrieve any required file/API/socket
handles.Simulation stopping
Called once at the end of a simulation to indicate that processing is complete and the model should free any temporary storage and close/release file/api/socket
handles.Simulation createParticle
Called when a new particle is to be created and passed back to EDEM for addition to the simulation. This Method is called at least once per Time Step. Simulation getNumberOfRequiredProperties
Returns the number of custom properties this UDL wants to register with the system. Setup getDetailsForProperty
Retrieves details for a given property. These properties will then be registered with the system if they do not conflict with any existing properties. Setup configForTimeStep
Called during processing, at the start of each Time Step. Simulation getSmallestScale
Used to retrieve a value for the smallest scale of a particle that the factory will create. Simulation Note: The methods of type 'Setup' are called once at the start of the simulation, whereas, those of type 'Simulation' are called during the simulation. For more information about how the methods are called, see the Help included in the EDEM installation folder.