mark particle of interest in contact model API
I am attempting to use the markParticleOfInterest function in API to process particles who undergo physical contact using the contact model API. However, after a particle is marked as a particle of interest and is removed from the simulation, the processParticleOfInterest function does not seem to kick in?
Do I need to implement the particle body force plugin for this to work?
Answers
-
Hi,
It's hard to say what's going on without seeing code, but if you're removing the particle first...there's no particle to process. Sounds like you should move the markForRemoval call inside the processParticleOfInterest.
Richard
0 -
Richard Wood_20774 said:
Hi,
It's hard to say what's going on without seeing code, but if you're removing the particle first...there's no particle to process. Sounds like you should move the markForRemoval call inside the processParticleOfInterest.
Richard
Hi Richard,
Thank you for response.
The code where I mark the particle of interest is as follows:
ECalculateResult CRemoval::calculateForce(int threadID, const NCalcForceTypesV3_0_0::STimeStepData& timeStepData, const NCalcForceTypesV3_0_0::SDiscreteElement& element1, NApiCore::ICustomPropertyDataApi_1_0* elem1CustomProperties, const NCalcForceTypesV3_0_0::SDiscreteElement& element2, NApiCore::ICustomPropertyDataApi_1_0* elem2CustomProperties, NApiCore::ICustomPropertyDataApi_1_0* contactCustomProperties, NApiCore::ICustomPropertyDataApi_1_0* simulationCustomProperties, const NCalcForceTypesV3_0_0::SInteraction& interaction, const NCalcForceTypesV3_0_0::SContact& contact, NApiHelpersV3_0_0::CSimple3DVector& tangentialPhysicalOverlap, NCalcForceTypesV3_0_0::SContactResult& contactResults) { //check if particle is in contact and velocity above 4 if (element1.velocityAtContactPoint.length() >= 4.0) { //check if particle contact geometry if (!element2.isSphere) { //check if this is the correct type of particle we want to replace if (strcmp(element1.type, ParticleReplace.c_str()) == 0) { m_particleMngr->markParticleOfInterest(element1.ID); } } } return eSuccess; }
Followed by the code from the EDEM API tutorial 1 which is used to process the particle of interest.
void CRemoval::processParticleOfInterest(int threadID, int particleOfInterestId) { NExternalForceTypesV3_4_0::SParticle particle; bool ret = m_particleMngr->getParticleData(particleOfInterestId, particle); if (particle.ID <= 0) { return; } //create list newPart to store particle info CParticleDef newPart; //write info to newPart strncpy(newPart.Type, ParticleCluster.c_str(), NApi::API_BASIC_STRING_LENGTH); newPart.Scale = m_particleMngr->getScale(particle.ID); newPart.Position = CSimple3DVector(particle.position.x, particle.position.y, particle.position.z); newPart.Velocity = CSimple3DVector(particle.velocity.x, particle.velocity.y, particle.velocity.z); newPart.AngVelocity = CSimple3DVector(particle.angVel.x, particle.angVel.y, particle.angVel.z); newPart.Orientation = CSimple3x3Matrix(particle.orientation.getXX(), particle.orientation.getXY(), particle.orientation.getXZ(), particle.orientation.getYX(), particle.orientation.getYY(), particle.orientation.getYZ(), particle.orientation.getZX(), particle.orientation.getZY(), particle.orientation.getZZ()); //add particle to factory list ParticleList[threadID].push_back(newPart); //Particle Of Interest is removed automatically m_particleMngr->markForRemoval(particle.ID); }
I have also edited the header file for the .cpp code to include the following code after the code from the IPluginContactModelV3_2_0.
virtual bool usesParticleOfInterest(); virtual void processParticleOfInterest(int threadID, int particleOfInterestId);
I have added the code to this post if its more helpful to look at them directly.Regards,Megan0 -
Hi Megan,
I checked the API documentation and it seems that the IPluginContactModel class doesn't have a usesParticleOfInterest function nor a processParticleOfInterest function. Those functions are only available on the IPluginParticleBodyForce class. My guess is that you'd have to set a custom property so the body force can read it and only then you'd be able to post process your particle.
Best regards,
Renan
1