Errors with user defined bond model

Raheem Sterling_22160
Raheem Sterling_22160 Altair Community Member
edited November 2022 in Community Q&A

Hi,

I have added a new contact model based on the src from "BondedParticle_v3_1_0". I have meet a errors when I import dll into EDEM as figure attached.

I have created new custom properties as below:

iBOND_NORMAL_TORQUE_A = contactCustomPropertyManager->getPropertyIndex(BOND_NORMAL_TORQUE_A.c_str());;
iBOND_TANGENTIAL_TORQUE_A = contactCustomPropertyManager->getPropertyIndex(BOND_TANGENTIAL_TORQUE_A.c_str());;
iBOND_NORMAL_TORQUE_B = contactCustomPropertyManager->getPropertyIndex(BOND_NORMAL_TORQUE_B.c_str());;
iBOND_TANGENTIAL_TORQUE_B = contactCustomPropertyManager->getPropertyIndex(BOND_TANGENTIAL_TORQUE_B.c_str());;

and I also modified the "getNumberOfRequiredProperties" as below:

unsigned int CBonded::getNumberOfRequiredProperties(const EPluginPropertyCategory category) { if (eContact == category) { return 9; // 9 propertied in total } else { return 0; } }

and in "getDetailsForProperty" as below:

 

if (3 == propertyIndex && eContact == category) { strncpy(name, BOND_NORMAL_TORQUE_A.c_str(), NApi::CUSTOM_PROP_MAX_NAME_LENGTH); dataType = eDouble; numberOfElements = 3; unitType = eForce;  // Initialization of the property values in this case 0.0 for all components - X,Y,Z std::ostringstream oss; oss << 0.0 << NApi::delim() << 0.0 << NApi::delim() << 0.0; strncpy(initValBuff, oss.str().c_str(), NApi::BUFF_SIZE); return true; }

Shouldn't I change the name of "BOND_NORMAL_TORQUE" or "BOND_TANGENTIAL_TORQUE"?

I don't know where the value of "NormBondTorque_a" etc. from?

 

Thanks for anyone can help.

Regards!

Raheem

Tagged:

Best Answer

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

    Hi Raheem,


    There are some restrictions to the name you can give to a custom property.  I'm not sure on the full list of restrictuions but _ isn't allowed.  You should see something in the .cpp file or .h file like:

     

    const string CBonded::BOND_NORMAL_TORQUE = "NormBondTorque_a";

    This specifies the name you see in the EDEM Analyst. Changing to the following should work:

    const string CBonded::BOND_NORMAL_TORQUE = "NormBondTorqueA";

     

    There is a second error that BondProps clashes with existing property in your file.  This means that a custom property called 'BondProps' has been created and loaded into your simulation file already.  However this BondProps has a slightly different definition and you can't have two properties with the same name but different definitions.

    So for this one you can either check if there is any change to the way the property is defined or clear out the existing properties from your simulation file (or create a new simulation from a blank file) and this should load OK.  To clear out custom properties go to Analyst > File > Export Simulation Deck and de-select the 'Export Custom Properties' option.  This creates a new file without any custom properties so you should be able to load yours in.


    Regards

    Stephen

Answers

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

    Hi Raheem,


    There are some restrictions to the name you can give to a custom property.  I'm not sure on the full list of restrictuions but _ isn't allowed.  You should see something in the .cpp file or .h file like:

     

    const string CBonded::BOND_NORMAL_TORQUE = "NormBondTorque_a";

    This specifies the name you see in the EDEM Analyst. Changing to the following should work:

    const string CBonded::BOND_NORMAL_TORQUE = "NormBondTorqueA";

     

    There is a second error that BondProps clashes with existing property in your file.  This means that a custom property called 'BondProps' has been created and loaded into your simulation file already.  However this BondProps has a slightly different definition and you can't have two properties with the same name but different definitions.

    So for this one you can either check if there is any change to the way the property is defined or clear out the existing properties from your simulation file (or create a new simulation from a blank file) and this should load OK.  To clear out custom properties go to Analyst > File > Export Simulation Deck and de-select the 'Export Custom Properties' option.  This creates a new file without any custom properties so you should be able to load yours in.


    Regards

    Stephen

  • Raheem Sterling_22160
    Raheem Sterling_22160 Altair Community Member
    edited November 2022

    Hi Raheem,


    There are some restrictions to the name you can give to a custom property.  I'm not sure on the full list of restrictuions but _ isn't allowed.  You should see something in the .cpp file or .h file like:

     

    const string CBonded::BOND_NORMAL_TORQUE = "NormBondTorque_a";

    This specifies the name you see in the EDEM Analyst. Changing to the following should work:

    const string CBonded::BOND_NORMAL_TORQUE = "NormBondTorqueA";

     

    There is a second error that BondProps clashes with existing property in your file.  This means that a custom property called 'BondProps' has been created and loaded into your simulation file already.  However this BondProps has a slightly different definition and you can't have two properties with the same name but different definitions.

    So for this one you can either check if there is any change to the way the property is defined or clear out the existing properties from your simulation file (or create a new simulation from a blank file) and this should load OK.  To clear out custom properties go to Analyst > File > Export Simulation Deck and de-select the 'Export Custom Properties' option.  This creates a new file without any custom properties so you should be able to load yours in.


    Regards

    Stephen

    Hi Stephen,

    It works when I change the name.

    Another question I meet when I use the custom property value is that:

    I have added the number of value in BOND_PREFS to 10.

    if (5 == propertyIndex &&         eContact == category)     {         strncpy(name, BOND_PREFS.c_str(), NApi::CUSTOM_PROP_MAX_NAME_LENGTH);         dataType         = eDouble;         numberOfElements = 10;         unitType         = eNone;          // Initialization of the property values in this case 0.0 for all components - ten in total         std::ostringstream oss;         oss << 0.0 << NApi::delim() << 0.0 << NApi::delim() << 0.0 << NApi::delim() << 0.0 << NApi::delim() << 0.0             << NApi::delim() << 0.0 << NApi::delim() << 0.0 << NApi::delim() << 0.0 << NApi::delim() << 0.0 << NApi::delim() << 0.0;         strncpy(initValBuff, oss.str().c_str(), NApi::BUFF_SIZE);         return true;     }

    Then when I defined the value in m_BondPrefsDelta, and then in m_BondPrefs some value changed. As figures show, temp_n is the value in m_BondPrefs and test_n is the value in m_BondPrefsDelta. The value of m_BondPrefsDelta[7](test8) and m_BondPrefsDelta[8](test9) were change in temp8 and temp9. It seems that something changed in the pointer.

    I am not sure if I have made mistakes or missed somthing in the "propertyIndex", because when debug the code, I found in "getDetailsForProperty", some values of property cannot respond to the iBondPrefs, for example: my total number of custom properties is 9, but the value of "iBOND_TANGENTIAL_TORQUE_B" is 12, how to know the value "iBondPrefs" when I change the code in "getDetailsForProperty"?

    Regards!

    Raheem