Question about assign a value to custom property
Hi,
I wrote some custom properties as below:
m_NormalStressDelta[0] = 1.0;
double tmp1 = m_NormalStress[0];
but when I debug the code, I saw the values of tmp changes from 0 to 1 to 2 etc. Increasing with time.
But what I want is to give a m_NormalStress a certain value, means 1.0 all the time. But seems that for m_NormalStress it was "+=‘’ with time, not "=" even I wrote like this.
Thanks
Answers
-
Hi,
Custom property deltas are just that, deltas that are added to a value. There is no resetting of the value by default. In your case you're adding 1 to the value every time. If you want to reset the value to 0 before adding your delta, you can either do that in configForTimestep( ) or depending on how you're updating the delta, you can also do:
delta = 1.0 - value;However, this only works if it's being called once. If there are multiple calls to update the custom property, then you should use the configForTimestep( )->resetCustomProperty approach.
Richard
0 -
Hi Raheem,
The delta gets added to the normal stress every time step so the normal stress is increasing by one each time step. The value of tmp1 is equal to the value of the normal stress so it is also increasing by 1 each time step.
If you'd like to keep the normal stress constant you can set the delta to 1 - normal stress value:
m_NormalStressDelta[0] = 1.0 - m_NormalStress[0]
Best regards,
Stefan
0 -
Richard Wood_20774 said:
Hi,
Custom property deltas are just that, deltas that are added to a value. There is no resetting of the value by default. In your case you're adding 1 to the value every time. If you want to reset the value to 0 before adding your delta, you can either do that in configForTimestep( ) or depending on how you're updating the delta, you can also do:
delta = 1.0 - value;However, this only works if it's being called once. If there are multiple calls to update the custom property, then you should use the configForTimestep( )->resetCustomProperty approach.
Richard
Hi Richard,
Thanks for answering, because I want to store the value of each contact between pair at every step which not calculated incrementally, I think the only way is used configForTimestep( )->resetCustomProperty.
Can this just reset the selected CustomProperty, or are there anly examples about this function?
Regards!
Raheem
0 -
Stefan Pantaleev_21979 said:
Hi Raheem,
The delta gets added to the normal stress every time step so the normal stress is increasing by one each time step. The value of tmp1 is equal to the value of the normal stress so it is also increasing by 1 each time step.
If you'd like to keep the normal stress constant you can set the delta to 1 - normal stress value:
m_NormalStressDelta[0] = 1.0 - m_NormalStress[0]
Best regards,
Stefan
Thanks Stefan,
It helps a lot. But my normal stress dependent on the contact force at each timestep, I think retCustomProperty may be more appropriate, I am searching for examples about this function.
Regards!
Raheem
0