Create the New Cohesion Physics

The nest step is to add the Time Factor and create the library file (64 bit) to create the new cohesion Physics.

To create the new cohesion Physics:
  1. Add the Time Factor.
    1. In the Visual Studio Solution Explorer dialog box, double-click CVariableCohesion_v3_7_0.cpp.
    2. Press Ctrl + F to search for contactResults.normalForce.

      This indicates the end of the Physics section where the Vector F_cohesive is added to the Normal Force of the contact. Cohesion is calculated from the energy density values (nCohesiveFactor) multiplied by the overlap area (nArea).

    3. Locate the F_cohesive vector in the source file as follows:


    4. Add the multiplying factor of the current simulation time to the F_cohesive calculation as follows:
      Create a new double called cohesion_time before the F_cohesive calculation and assign this as the value of the current simulation time:


    5. Add a limit of 0 - 3 s for the cohesion increase to take place and update the code as follows:


      Note: Multiplying by time causes an error where, after a large time has elapsed (60 s), the cohesion value will have increased accordingly, and could be unexpectedly high as the cohesive force increase does not have any limitations.
    6. Save the file.
  2. Create the .dll library file (64 bit).
    1. Go to Build > Configuration manager.
    2. In the Active Solution Platform, select Release and x64.

      You can run this simulation with the Debug or Release .dlls. It is usually recommended to test the simulation in the Debug mode and run the simulation using the Release mode once the model is finalized, as the Release mode is significantly faster to compute.

    3. Select Build > Build Solution to compile the model.
      Note:
      • If compilation is successful, the Output window in Visual Studio will display “Build: 1 succeeded”, along with the location of the newly created *.dll file.


      • If the build fails, additional information is displayed to explain build failure. It is recommended to always start with the first error message in the list as it may be the reason for subsequent errors.
    4. Copy the newly created .dll file to the same location as the cohesion_input.dem file which is included with the tutorial files.
    5. Copy and paste the cohesion_prefsV2.txt file into the same location.