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.

To create a new Particle Factory:
  1. Create a directory in which you want to save the new Particle Factory project.
  2. Copy the following header files into the directory that you have created:
    • IPluginParticleFactory.h
    • PluginParticleFactoryCore.h
    • IPluginParticleFactoryV3_3_0.h
    • PluginConstants.h
    • Helpers.h
  3. Create a new class (CNewParticleFactory) derived from the Particle Factory interface you want to use (for example, IPluginParticleFactoryV2_1_0).
  4. 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.
  5. Implement all the methods defined in your header file and save as a .cpp file (for example, CNewParticleFactory.cpp).
  6. Create a new .cpp file with implementations of the methods in PluginParticleFactoryCore.h.
  7. Save this file as NewParticleFactory.cpp.
  8. Create a new .cpp file with implementations of the methods in PluginParticleFactoryCore.h.
  9. Save this file as NewParticleFactory.cpp.
  10. Compile all your src files and link them together into .dll (Windows) or .so (Linux) library files.
  11. Ensure that the library and optional preferences file are saved in the Particle Factory model folder (as specified in Tools > Options > File Locations), or in the same folder as the simulation_name.dem file (only applicable for EDEM versions 2017 and above).
  12. Start EDEM and then select the Factories tabbed page.
  13. Click Import and then select the new factory from the Import Factory dialog box.
  14. 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.