Unclear about CBonded.cpp

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

Hi, I have meet some questions when I looked through the API example: CBonded.cpp, for example:

 

iBOND_STATUS = contactCustomPropertyManager->getPropertyIndex(BOND_STATUS.c_str());

const double* m_BondStatus = contactCustomProperties->getValue(iBOND_STATUS);
double* m_BondStatusDelta = contactCustomProperties->getDelta(iBOND_STATUS);

How the value transfered in these words? 

If I want to add new contact model, can I just define the value to 'm_Bondstatus' directly in head file?

Thanks

Raheem

Best Answer

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

    Hi Raheem,

     

    getPropertyIndex is just converting the name of the custom property to an index/integer value and storing in iBOND_STATUS.  The index is faster to query than the original name as a string.

     

    getValue queries the existing value of the property and writes it to m_BondStatus.  Typically this would be m_BondStatus[0] for a custom property with 1 element.  If it had more than 1 (for example a force vector would have 3 elements, x,y,z) then this would be m_BondStatus[n] where n is the element you want.

     

    getDelta assigns the delta value to m_BondStatusDelta[n], the only way to change the custom property value is to set the Delta, you can't change the Value directly.  So if you want to update the value by 1 you can do m_BondStatusDelta[0] += 1.0; and at the end of the timestep EDEM will add all the delta's to the value.

     

    In the code you should also see getDetailsForProperty where the type of property is set and getNumberOfRequiredProperties where the number of each type of property is set, if you were creating a new property you also should follow the format of these.

     


    Regards

    Stephen

Answers

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

    Hi Raheem,

     

    getPropertyIndex is just converting the name of the custom property to an index/integer value and storing in iBOND_STATUS.  The index is faster to query than the original name as a string.

     

    getValue queries the existing value of the property and writes it to m_BondStatus.  Typically this would be m_BondStatus[0] for a custom property with 1 element.  If it had more than 1 (for example a force vector would have 3 elements, x,y,z) then this would be m_BondStatus[n] where n is the element you want.

     

    getDelta assigns the delta value to m_BondStatusDelta[n], the only way to change the custom property value is to set the Delta, you can't change the Value directly.  So if you want to update the value by 1 you can do m_BondStatusDelta[0] += 1.0; and at the end of the timestep EDEM will add all the delta's to the value.

     

    In the code you should also see getDetailsForProperty where the type of property is set and getNumberOfRequiredProperties where the number of each type of property is set, if you were creating a new property you also should follow the format of these.

     


    Regards

    Stephen

  • Raheem Sterling_22160
    Raheem Sterling_22160 Altair Community Member
    edited November 2022

    Hi Raheem,

     

    getPropertyIndex is just converting the name of the custom property to an index/integer value and storing in iBOND_STATUS.  The index is faster to query than the original name as a string.

     

    getValue queries the existing value of the property and writes it to m_BondStatus.  Typically this would be m_BondStatus[0] for a custom property with 1 element.  If it had more than 1 (for example a force vector would have 3 elements, x,y,z) then this would be m_BondStatus[n] where n is the element you want.

     

    getDelta assigns the delta value to m_BondStatusDelta[n], the only way to change the custom property value is to set the Delta, you can't change the Value directly.  So if you want to update the value by 1 you can do m_BondStatusDelta[0] += 1.0; and at the end of the timestep EDEM will add all the delta's to the value.

     

    In the code you should also see getDetailsForProperty where the type of property is set and getNumberOfRequiredProperties where the number of each type of property is set, if you were creating a new property you also should follow the format of these.

     


    Regards

    Stephen

    Hi, Stephen,

    Thanks for your patience, I have looked through the getDetailsForProperty and figured it out.

    And one more question about m_BondPrefs and m_BondPrefDelta, from your explantation, can I that:

    I can't give a value to m_BondPref[0] directly, instead by assigning a value to m_BondPrefsDelta[0] as in the code. And it will add the delta's to the m_BondPref[0] automaticly.

    If what I understand is right, I'm still thinking that if m_BondPref[n] is only used for the calculation of bond, why not define a value that not belongs to the custom property value?

     

    Kind regards!

    Raheem

  • Stephen Cole
    Stephen Cole
    Altair Employee
    edited November 2022

    Hi, Stephen,

    Thanks for your patience, I have looked through the getDetailsForProperty and figured it out.

    And one more question about m_BondPrefs and m_BondPrefDelta, from your explantation, can I that:

    I can't give a value to m_BondPref[0] directly, instead by assigning a value to m_BondPrefsDelta[0] as in the code. And it will add the delta's to the m_BondPref[0] automaticly.

    If what I understand is right, I'm still thinking that if m_BondPref[n] is only used for the calculation of bond, why not define a value that not belongs to the custom property value?

     

    Kind regards!

    Raheem

    Hi Raheem,

     

    The custom property Value is fixed per time-step, I'm not sure if it is possible to change (it is a const) but even if it was changed in the code at the next time-step it would have reverted back to the original Value as changes to the property Value wouldn't be saved.   The only way to make a permanent change to the Value is to update the Delta.

     

    I'm unsure why it is set this way, possibly due to making the Custom Properties thread safe so it runs with multi-CPU/GPU.   It's similar in the way we can't modify the particle velocity, only add to the force which is then summed at the end of the time-step to change the velocity value.

     

    Regards

    Stephen

  • Raheem Sterling_22160
    Raheem Sterling_22160 Altair Community Member
    edited November 2022

    Hi Raheem,

     

    The custom property Value is fixed per time-step, I'm not sure if it is possible to change (it is a const) but even if it was changed in the code at the next time-step it would have reverted back to the original Value as changes to the property Value wouldn't be saved.   The only way to make a permanent change to the Value is to update the Delta.

     

    I'm unsure why it is set this way, possibly due to making the Custom Properties thread safe so it runs with multi-CPU/GPU.   It's similar in the way we can't modify the particle velocity, only add to the force which is then summed at the end of the time-step to change the velocity value.

     

    Regards

    Stephen

    Hi Stephen,

    Thanks, I saw some calculation in code is puzzled, like:

    relVel = element1.velocityAtContactPoint - element2.velocityAtContactPoint;

     I think it is as same as:

    relVel = element1.velocity - element2.velocity;

    And in EDEM, we have defined the contact radius, but in the "bond_particle_pref" file, the contact radius is defined again, it's strange.

    At last, if I use the complied dll to bonding particles, in the "analysist tree", I can only visualize the bond  in the "contact" selection (bond status) intead of in the "bond" selection. Are there any interface to visualize bond in "bond" selection?

     

    Kind regards!

    Raheem

  • Stephen Cole
    Stephen Cole
    Altair Employee
    edited November 2022

    Hi Stephen,

    Thanks, I saw some calculation in code is puzzled, like:

    relVel = element1.velocityAtContactPoint - element2.velocityAtContactPoint;

     I think it is as same as:

    relVel = element1.velocity - element2.velocity;

    And in EDEM, we have defined the contact radius, but in the "bond_particle_pref" file, the contact radius is defined again, it's strange.

    At last, if I use the complied dll to bonding particles, in the "analysist tree", I can only visualize the bond  in the "contact" selection (bond status) intead of in the "bond" selection. Are there any interface to visualize bond in "bond" selection?

     

    Kind regards!

    Raheem

    Hi Raheem,

     

    It's important to note that element1.velocityAtContactPoint will be different to element1.velocity as the 'velocity' is the centre of mass of the particle where the contact point may also be rotating so will give a different velocity.

     

    You can find the definitions in the help C:\Program Files\Altair\2022.1\EDEM\src\Api\Help > index.html

     

    If you are using an API model there are a few versions iwth different functions.  One of the API models allows you to set a large radius in the EDEM creator but in the .txt file you set a second smaller one. So bonds are created between neighbouring particles but can still have a large contact radius without bonding to everything in the contact radii area.  This is because as soon as the particles move out the contact radius area the bond information is lost.

     

    Also with the post-processing 'Bonds' in the Analyst are for the original Bonded model.  The API and the in-built Bonded V2 model use contacts as Contacts are supported on GPU where Bonds are not.  So you should be able to see the V2 or API bond information in particle-Particle Contact area.

    Regards

    Stephen