Question about custom property in the simulation with parallel cpus

Raheem Sterling_22160
Raheem Sterling_22160 Altair Community Member
edited September 2023 in Community Q&A

Hi

I have added a custom properties for each contact to store some value, for example myvalue[n].

If I retrive this value like "double tmp = myvalue[0]", where "tmp" was defined in the calculateforce(), then all the calculation I used tmp, in the parallel mode, does "tmp" for each contact  assgined correctly?

Thanks

Tagged:

Welcome!

It looks like you're new here. Sign in or register to get started.

Answers

  • Stephen Cole
    Stephen Cole
    Altair Employee
    edited September 2023

    Hi Raheem,


    Yes...and no.  It will depend on how you are using tmp.   It will assign myvalue[0] to tmp when called, and do this for every contact every time-step, and also be doing this simultaneously per thread.

    If you are setting tmp from 'contact 1' and then want to use this as a constant for contacts 1-n you would have to add some special condition, like only assigning if element1 and element2 ID's are specific values.  Also would want to apply it at t+1.  This is because  "double tmp = myvalue[0]" would set a new value per thread and also the contacts 1-n would come in a random order.

    However if you want to use  "double tmp = myvalue[0]" and have a unique value per contact then it would be OK.

    Regards

    Stephen

     

     

  • Raheem Sterling_22160
    Raheem Sterling_22160 Altair Community Member
    edited September 2023

    Hi Raheem,


    Yes...and no.  It will depend on how you are using tmp.   It will assign myvalue[0] to tmp when called, and do this for every contact every time-step, and also be doing this simultaneously per thread.

    If you are setting tmp from 'contact 1' and then want to use this as a constant for contacts 1-n you would have to add some special condition, like only assigning if element1 and element2 ID's are specific values.  Also would want to apply it at t+1.  This is because  "double tmp = myvalue[0]" would set a new value per thread and also the contacts 1-n would come in a random order.

    However if you want to use  "double tmp = myvalue[0]" and have a unique value per contact then it would be OK.

    Regards

    Stephen

     

     

    Thanks Stephen,

    For example of my code, rij_0 for each bond created at requested time, the force calculation of each bond depends on rij_0, and I used rij_0 and a_par in the calculation, from the results of simulations, it seems right at now. But I am not sure if I am using custom properties correctly.

    CSimple3DVector rij_0; RIJ = element2.position-element1.position; if(timeStepData.time >= m_requestedBondTime  && m_BondStatus[0] == 0.0 && nBondSeperation < 0.0)         {             m_InitialVectorIDelta[0] = RIJ.getX();              m_InitialVectorIDelta[1] = RIJ.getY();              m_InitialVectorIDelta[2] = RIJ.getZ();   }  if(m_BondStatus[0] == 1.0) {            rij_0 = CSimple3DVector(m_InitialVectorI[0], m_InitialVectorI[1], m_InitialVectorI[2]); //initial vector             double a_par = rij_0.length(); }
  • Stephen Cole
    Stephen Cole
    Altair Employee
    edited September 2023

    Thanks Stephen,

    For example of my code, rij_0 for each bond created at requested time, the force calculation of each bond depends on rij_0, and I used rij_0 and a_par in the calculation, from the results of simulations, it seems right at now. But I am not sure if I am using custom properties correctly.

    CSimple3DVector rij_0; RIJ = element2.position-element1.position; if(timeStepData.time >= m_requestedBondTime  && m_BondStatus[0] == 0.0 && nBondSeperation < 0.0)         {             m_InitialVectorIDelta[0] = RIJ.getX();              m_InitialVectorIDelta[1] = RIJ.getY();              m_InitialVectorIDelta[2] = RIJ.getZ();   }  if(m_BondStatus[0] == 1.0) {            rij_0 = CSimple3DVector(m_InitialVectorI[0], m_InitialVectorI[1], m_InitialVectorI[2]); //initial vector             double a_par = rij_0.length(); }

    Hi Raheem,

     

    That looks correct to me so long as you are using rij_0 per bond.

     

    Just to note I don't think that this is doing anything with the code as shown:

    double a_par = rij_0.length();

    As you are declaring this inside the bracers {} as soon as this is closed with } anything declared within these brackets is deleted.  As you have declared rij_0 outside the brackets shown this will continue to exist.

    Regards

    Stephen

  • Raheem Sterling_22160
    Raheem Sterling_22160 Altair Community Member
    edited September 2023

    Hi Raheem,

     

    That looks correct to me so long as you are using rij_0 per bond.

     

    Just to note I don't think that this is doing anything with the code as shown:

    double a_par = rij_0.length();

    As you are declaring this inside the bracers {} as soon as this is closed with } anything declared within these brackets is deleted.  As you have declared rij_0 outside the brackets shown this will continue to exist.

    Regards

    Stephen

    Hi Stephen,

    Because the force and torque calculation are in the bracers{}, and double "a_par" was easy for me to read the code.

    rij_0 was declared outside the brackets, and I know it will continue to exist, but it seems no difference here to define it inside or outside the brackets, until now, no bug happens to me.

    And I post this question because when I rerun the simulation, the broken behaviour of bonds was difference. The strength for each bond was the same. So I am doubt may some bond properties given to each bond changed over the time.

    Regards!

    Raheem

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.