Particle Factory User Defined Libraries (UDL)
Using the EDEM API, you can write and compile a custom Particle Factory for creating and initializing particles.
Creating a New Particle Factory
- Create a directory to contain the new Particle Factory project.
- Copy the following header files into the directory:
-
IPluginParticleFactory.h
-
PluginParticleFactoryCore.h
-
IPluginParticleFactoryV2_1_0.h
-
PluginConstants.h
-
Helpers.h
-
- Create a new class (CNewParticleFactory) derived from the factory interface you want to use (for example, IPluginParticleFactoryV2_1_0).
- 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.
- 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 in PluginParticleFactoryCore.h. For example, save as NewParticleFactory.cpp.
- Compile all your src files and link them together in to .dll (Windows) or .so (Linux) library files.
- 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).
- Start EDEM and then switch to the Factories tab.
- Click Import and then select the new factory from the Import Factory popup.
- 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.