Create a Cohesion Model on Linux

This section describes how to create a new cohesion contact model on Linux. To complete this tutorial on Linux instead of Windows, the library file which is loaded into EDEM must be compiled as a.so (shared-object) file instead of a .dll file.

To create a new cohesion model on Linux:
  1. Extract the following tutorial source files to a shared directory:
    1. cohesion_prefsV2.txt – Preference text file containing cohesion inputs
    2. CCohesionParameters.cpp – CPU file for managing preference file inputs
    3. CCohesionParametersList.cpp – CPU file for managing preference file inputs
    4. CVariableCohesion_v3_7_0.cpp – CPU Physics model
    5. VariableCohesion_v3_7_0.cpp – CPU version file
    6. CCohesionParameters.h – Header file for managing preference file inputs
    7. CCohesionParametersList.h – Header file for managing preference file inputs
    8. VariableCohesion_v3_7_0.h – CPU header file for the Physics model
      Note: EDEM header files (.h) are required to compile the Contact Model as a Library (.so). For more information about why header files are important, see the Programming Guide.
    9. Open the file CVariableCohesion_v3_7_0.cpp in your preferred file editor.
  2. Create the .so library file.
    1. Open a terminal in the directory containing the source files.
    2. Enter the following command:
      gcc -std=c++11 -O2 -shared -fPIC 
      -I/opt/Altair/2024.1/EDEM/src/Api/ContactModels/ 
      -I/opt/Altair/2024.1/ EDEM/src/Api/Core/ 
      -I/opt/Altair/2024.1/ EDEM/src/Misc/
      CCohesionParameters.cpp CCohesionParametersList.cpp
      CVariableCohesion_v3_7_0.cpp
      VariableCohesion_v3_7_0.cpp
      -o VariableCohesion.so
    If successful, a file named VariableCohesion.so will be displayed in the directory.
    Note: If the build fails, additional information is displayed to explain build failure. For more information about how to compile the library file, see Compile API Models to Libraries.
  3. Once the .so file is successfully compiled, see EDEM Creator - Use the Linear Cohesion API Model and proceed with the simulation.
    Note: The changes made within the source files are identical for both operating systems. For more information about how to add the Time Factor, see Create the New Cohesion Physics using a text editor such as Emacs, Vim or gedit, before compilation.