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.hPluginParticleFactoryCore.hIPluginParticleFactoryV3_3_0.hPluginConstants.hHelpers.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
.cppfile (for example,CNewParticleFactory.cpp). -
Create a new
.cppfile with implementations of the methods inPluginParticleFactoryCore.h. -
Save this file as
NewParticleFactory.cpp. -
Create a new
.cppfile with implementations of the methods inPluginParticleFactoryCore.h. -
Save this file as
NewParticleFactory.cpp. -
Compile all your
srcfiles 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 ), or in the same folder as the
simulation_name.demfile (only applicable for EDEM versions 2017 and above). - 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 getPreferenceFileNameRetrieves the name of the config file used by the UDL. Setup usesCustomPropertiesIndicates whether the UDL wants to register or receive custom property data. Setup setFilePathCalled inside the starting()method to provide the plugin with the full simulation path (including the simulation file name).Setup setupInitializes the plugin by reading any config files, opening temporary files, generating data structures, or other setup tasks. Setup startingCalled 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/sockethandles.Simulation stoppingCalled 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/sockethandles.Simulation createParticleCalled 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 getNumberOfRequiredPropertiesReturns the number of custom properties this UDL wants to register with the system. Setup getDetailsForPropertyRetrieves details for a given property. These properties will then be registered with the system if they do not conflict with any existing properties. Setup configForTimeStepCalled during processing, at the start of each Time Step. Simulation getSmallestScaleUsed 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.