Hello,
I am implementing a new contact force model in order to mimic the fresh
state of concrete.
I did it for a very simple example where two spheres are in contact.
I defined a new function (MyContactForce) for overriding the default SMC
contact force calculation method using the callback option. In this
function, I needed to reach particle radius, which I managed by using
NarrowphaseCallback.
Also I need a state variable (a vector) for each contact in this function.
I suppose that it must be stored inside the contact-info properties or
somehow it should be related to a relevant contact. However, I couldn't
find a proper way to do these issues using the callback option. Is there
any trick to do this without modifying base classes?
I've also attached a copy of the code.
Thank you in advance.
Bahar
--
You received this message because you are subscribed to the Google Groups
"ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/projectchrono/CAB34S-2jqD%2BN4mpPRr-MkvB0aKvroWwoxvgF56tOvhRn6Fvp0A%40mail.gmail.com.
class MyNarrowphaseCallback: public ChCollisionSystem::NarrowphaseCallback {
public:
virtual bool OnNarrowphase(ChCollisionInfo& contactinfo) override {
auto objA=contactinfo.modelA ;
auto objB=contactinfo.modelB ;
auto shapeA=contactinfo.shapeA ;
auto shapeB=contactinfo.shapeB ;
auto
mat1=std::static_pointer_cast<ChMaterialSurfaceSMC>(contactinfo.shapeA->GetMaterial());
auto
mat2=std::static_pointer_cast<ChMaterialSurfaceSMC>(contactinfo.shapeB->GetMaterial());
auto R1=objA->GetShapeDimensions(0)[0];
auto R2=objB->GetShapeDimensions(0)[0];
ChVector<> vN=contactinfo.vN ;
ChVector<> vpA=contactinfo.vpA;
ChVector<> vpB=contactinfo.vpB;
float depth=contactinfo.distance ;
contactinfo.eff_radius=std::min<float>(R1,R2);
return true;
}
};
class MyContactForce : public ChSystemSMC::ChContactForceSMC {
public:
// Demonstration only.
double pi=3.141592654;
virtual ChVector<> CalculateForce(
const ChSystemSMC& sys, ///< containing sys
const ChVector<>& normal_dir, ///< normal contact direction
(expressed in global frame)
const ChVector<>& p1, ///< most penetrated point on obj1
(expressed in global frame)
const ChVector<>& p2, ///< most penetrated point on obj2
(expressed in global frame)
const ChVector<>& vel1, ///< velocity of contact point on
obj1 (expressed in global frame)
const ChVector<>& vel2, ///< velocity of contact point on
obj2 (expressed in global frame)
const ChMaterialCompositeSMC& mat, ///< composite material for contact
pair
double delta, ///< overlap in normal direction
double eff_radius, ///< effective radius of curvature
at contact
double mass1, ///< mass of obj1
double mass2 ///< mass of obj2
//ChVector<> statevar : state variables should be defined
in contactinfo class????
) const {
//
// This function will calculate contact forces and
corresponding moments if 2 object is in contact
//
ChVector<> force=(0,0,0);
//*****
// DO SOME CODING...
/////////
// state variables are needed inside this function...
return force;
}
}
};