Contact Model User Defined Libraries
A Contact Model UDL consists of a shared library file and, optionally, a file containing preferences. Using the EDEM API, you can write and compile a custom Contact Model as a User Defined Library (UDL) written in C/C++.
- Create a directory in which you want to save the new Contact Model project.
-
Copy the following header files into the directory that you have created:
IPluginContactModel.hPluginContactModelCore.hIPluginContactModelV3_3_0.hPluginConstants.h
-
If required, copy the following optional header files:
CGenericFileReader.hHelpers.h
-
Create a new class (
CNewContactModel) derived from the Contact Model interface you want to use (for example,IPluginContactModelV3_3_0). -
Save the class declaration to a header file (for
example,
CNewContactModel.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.
-
Save the file as a
.cppfile (for example,CNewContactModel.cpp). -
Create a new
.cppfile with implementations of the methods inPluginContactModelCore.h. For example, save this file asNewContactModel.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 Contact
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 required Contact Model category from the Interaction dropdown list in the Physics section.
-
Click the + dropdown list and then select the new
Contact Model.
The following methods are available in the Contact Model interface
IPluginContactModelV3_4_0:Method Description Type getPreferenceFileNameRetrieves the name of the config file used by the UDL. Setup isThreadSafeIf the UDL’s calculateForce()method is thread-safe then this method must return 'true'. Thread- safe programming requires a number of conventions and restrictions to be followed. If in doubt, set this to return 'false'. Not applicable for CUDA API.Setup usesCustomPropertiesIndicates whether the UDL wants to register or receive custom property data. Setup getModelTypeIndicates the model type of the plugin. This is a mandatory method for every model. Setup getExecutionChainPositionIndicates the position in the Contact-Model chain for the plugin to be executed. This is a mandatory method for every model. Setup usesContactFactorIndicates whether the UDL wants to use contact factor. Contact factor is the number of contacts between two particles or between one particle and different mesh elements belonging to the same plane. Setup setFilePathCalled inside the starting()method to provide the plugin with the full simulation path (including the simulation file name).Setup getGpuFileNameInitializes the GPU plugin by accepting the file name without an extension. If empty, the model will not be supported on the GPU solver. 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 externalForceCalled at every single Time Step for every single particle and allows you to add particle body forces (for example, electromagnetic force or drag force) to particles. This is not used by CUDA solvers and should be left empty.
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 the existing properties. Setup configForTimeStepCalled during processing, at the start of each Time Step. Simulation This must be empty for CUDA solvers and implemented in the CUDA file instead. getParticleParameterDataRetrieves particle parameter data in buffer format. Setup getSimulationParameterDataRetrieves simulation parameter data in buffer format. Setup processParticleOfInterestProcesses particles marked for additional processing in the externalForcecall.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..