Particle Body Force 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 custom particle body forces as a User Defined Library (UDL) written in C/C++.
- Create a directory in which you want to save the new Particle Body Force project.
-
Copy the following header files into the directory that you have created:
IPluginParticleBodyForce.hPluginParticleBodyForceCore.hIPluginParticleBodyForceV3_3_0.hPluginConstants.hHelpers.h
-
Create a new class (
CNewParticleBodyForce) derived from the Particle Body Force interface you want to use (for example,IPluginParticleBodyForceV3_3_0). -
Save the class declaration to a header file (for
example,
CNewParticleBodyForce.h). -
Implement all the methods defined in your header file and save as a
.cppfile (for example,CNewParticleBodyForce.cpp). -
Create a new
.cppfile with implementations of the methods inPluginParticleBodyForceCore.h. -
Save this file as
NewParticleBodyForce.cpp. -
Create a new
.cppfile with implementations of the methods inPluginParticleBodyForceCore.h. -
Save this file as
NewParticleBodyForce.cpp. -
Use command line or create a makefile (or equivalent) to build and compile
.dll(Windows) or.so(Linux) library files. -
Ensure that the library and optional preferences file are saved in the Particle
Body Force 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 Particle Body Force Model category from the Interaction dropdown list in the Physics section.
-
Click the + dropdown list and then select the new
Particle Body Force Model .
The following methods are available in the Particle Body Force Model interface
IPluginContactModelV3_3_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 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 calculateForceCalled when two elements are in contact with each other. These may be surfaces (in-contact when their contact radii cross), or a surface and a Geometry element (when the contact radius of the surface touches the surface geometry). Also used to set contact forces and deltas for custom properties. Not mandatory for CUDA solvers. Simulation configForTimeStepCalled during processing, at the start of each Time Step. Not used for CUDA solvers, but must be implemented in the CUDA file. 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 getGeometryParameterDataRetrieves Geometry parameter data in buffer format. Setup getParticleParameterDataRetrieves particle parameter data in buffer format. Setup getPartPartContactParameterDataRetrieves Particle-Particle contact parameter data in buffer format. Setup getPartGeomContactParameterDataRetrieves Particle-Geometry contact parameter data in buffer format. Setup getSimulationParameterDataRetrieves simulation parameter data in buffer format. Setup calculateTriangleDeformationCalculates deformation for triangle elements and returns parameters for the updated mesh element. Simulation deformationEnabledEnables and disables mesh deformation. Simulation ignoreZeroForceTrianglesSkips Geometry deformation call if the force acting on the Geometry element is zero. Simulation getDeformationTransformSpaceDefines the Global or Local reference frame for triangle deformation. 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.