Particle Factory User Defined Libraries (UDL)

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.

Creating a New Particle Factory

  1. Create a directory to contain the new Particle Factory project.
  2. Copy the following header files into the directory:
    1. IPluginParticleFactory.h

    2. PluginParticleFactoryCore.h

    3. IPluginParticleFactoryV2_1_0.h

    4. PluginConstants.h

    5. Helpers.h

  3. Create a new class (CNewParticleFactory) derived from the 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 should consist of declarations of the methods in the chosen 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. For example, save as NewParticleFactory.cpp.
  7. Compile all your src files and link them together in to .dll (Windows) or .so (Linux) library files.
  8. Ensure that the library and optional preferences file are in the factories folder (as specified with Tools > Options > File Locations) or in the same folder as the simulation_name.dem file (only for versions EDEM 2017.1 onwards).
  9. Start EDEM and then switch to the Factories tab.
  10. Click Import and then select the new factory from the Import Factory popup.
  11. Click OK.

Particle Factory API v2.1.0

The contact model interface IPluginParticleFactoryV2_1_0 provides these methods:

Method Description Type
getPreferenceFileName Retrieves the name of the config file used by the UDL. Setup
usesCustomProperties Indicates whether the UDL wishes to register or receive custom property data. Setup
setFilePath Called inside starting() Method to provide the plugin with the full simulation path (including the simulation filename). Simulation
setup Initializes the UDL by reading any config files, opening temporary files, generating data structures or any other setup work. Setup
starting Called to indicate processing is about to begin and the model should allocate any temporary storage and retrieve any required file/API/socket handles. Simulation
stopping Called to indicate processing is finished and that 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 clash 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

See the API documentation for more details.

(c) 2023 Altair Engineering Inc. All Rights Reserved.

Intellectual Property Rights Notice | Technical Support