Custom contact model: Access violation writing location in C++ API, during implementation in EDEM

MQ
MQ Altair Community Member
edited October 2022 in Community Q&A

Hi Everyone,

I am unable to implement a custom contact model. EDEM simulation crashes as soon as it starts, pointing to a problem with the C++ code in debug mode (please see the attached image):

Access violation writing location...

No problem occurs during compilation in Visual Studio. This was working just fine with previous version of EDEM. I have updated IPluginContactModelV3_1_0 to IPluginContactModelV3_3_0 in the code, as it is prompted at the start of simulation that V3.1.0 may not able retreive forces (something similar!).

Can anyone please suggest the potential solution?

Thank you.

Best regards,

MQ

Tagged:

Best Answer

  • Stephen Cole
    Stephen Cole
    Altair Employee
    edited October 2022 Answer ✓

    Hi MQ,


    I'm unsure how normalPhysicalOvelrap_int is defined however based on the error the code is trying to write to an array and the area which it is trying to write to doesn't exist. If you can debug and check what the ID's are and also that when normalPhysicalOvelrap_int it will accept the ID 2 and ID 1.

     

    Usually when updating the code the errors tend to come from definitions in the header file.  Functions like starting or setup have additional inputs in the later version and you should ensure that the definition in the EDEM header files (e.g. IPluginContactModelV3_x_x.h in C:\Program Files\DEM Solutions\EDEM 202xx\src\Api\ContactModels) matches what you have in your code.


    Regards

    Stephen

Answers

  • Stephen Cole
    Stephen Cole
    Altair Employee
    edited October 2022 Answer ✓

    Hi MQ,


    I'm unsure how normalPhysicalOvelrap_int is defined however based on the error the code is trying to write to an array and the area which it is trying to write to doesn't exist. If you can debug and check what the ID's are and also that when normalPhysicalOvelrap_int it will accept the ID 2 and ID 1.

     

    Usually when updating the code the errors tend to come from definitions in the header file.  Functions like starting or setup have additional inputs in the later version and you should ensure that the definition in the EDEM header files (e.g. IPluginContactModelV3_x_x.h in C:\Program Files\DEM Solutions\EDEM 202xx\src\Api\ContactModels) matches what you have in your code.


    Regards

    Stephen