Question about reset custom property in configtimestep()
Hi,
To reset the custom property in the contactmodel API. I pretend to use the resetCustomProperty() in ISimulationManagerApi_1_1.h.
Firstly, I defined a m_mngr in the header file with NApiCore::ISimulationManagerApi_1_1* m_mngr, and then initialized m_mngr in the starting(), but when I want to use it the configForTimeStep(), it can not work, I don't know if configForTimeStep() only contains particleManager and geometryManager.
I also noticed that resetCustomproperty() also exists in the particlemanngerApi, but for contact model, I guess ISimulationManager is the one appropriate.
Or I missed something?
Thanks
Answers
-
Hi Raheem,
Just to make sure, what is the type of the custom property you want to reset ?
If you use a simulation manager, the properties to reset are gonna be simulation custom properties.
I have the feeling you might be working with a contact custom property, is that correct ? In that case, I would recommend doing the reset within the calculateForce function instead of configForTimeStep (where I don't think it's possible).
You just need to subtract the current value of the property to the delta, for instance :
const double* myPropertyValue = contactCustomProperties->getValue(PROPERTY_INDEX);
double* myPropertyDelta = contactCustomProperties->getDelta(PROPERTY_INDEX);
*myPropertyDelta = -*myPropertyValue;
I always do that myself to reset a contact property.
I think the reason configForTimestep() exists is because you cannot use the same method to easily reset particle property, as one particle can be involved in multiple contacts, which would cause you to subtract the value more than once.
I hope this helps !
Come0 -
Duret Come said:
Hi Raheem,
Just to make sure, what is the type of the custom property you want to reset ?
If you use a simulation manager, the properties to reset are gonna be simulation custom properties.
I have the feeling you might be working with a contact custom property, is that correct ? In that case, I would recommend doing the reset within the calculateForce function instead of configForTimeStep (where I don't think it's possible).
You just need to subtract the current value of the property to the delta, for instance :
const double* myPropertyValue = contactCustomProperties->getValue(PROPERTY_INDEX);
double* myPropertyDelta = contactCustomProperties->getDelta(PROPERTY_INDEX);
*myPropertyDelta = -*myPropertyValue;
I always do that myself to reset a contact property.
I think the reason configForTimestep() exists is because you cannot use the same method to easily reset particle property, as one particle can be involved in multiple contacts, which would cause you to subtract the value more than once.
I hope this helps !
ComeHi Come,
Just as you said, I want to reset the contact custom property where used in the calculteForce(). Your method I think is correct. But what if I want to export the myProperty in the EDEM->Analyst? Because I think if I follow the code "*myPropertyDelta = -myPropertyValue" after the using of myProperty, the export value would be 0 all the time, so the only way is to print this value before I reset it.
Regards!
Raheem
0 -
Raheem Sterling_22160 said:
Hi Come,
Just as you said, I want to reset the contact custom property where used in the calculteForce(). Your method I think is correct. But what if I want to export the myProperty in the EDEM->Analyst? Because I think if I follow the code "*myPropertyDelta = -myPropertyValue" after the using of myProperty, the export value would be 0 all the time, so the only way is to print this value before I reset it.
Regards!
Raheem
Hi Raheem,
The code example I shared is only for resetting. If you add anything else to the delta, you should get the desired value to show up in the Analyst.
In short, you can do :
*myPropertyDelta = -*myPropertyValue + newValue;
(Sorry, I made a mistake in the previous post, forgot the "*" before myPropertyValue !)
Note that the Value is updated only at the end of the timestep.
newValue will then be the value appearing in the Analyst.
Best regards,
Come0