← Back to team overview

yade-dev team mailing list archive

Why Ip2 functors must be symmetric?

 

Hi guys

is there I reason why we only have symmetric Ip2 functors? I recently committed a contact law with non-symmetric Ip2 functor (Ip2_FrictMat_FrictViscoMat_FrictViscoPhys) but at the moment it is not working as expected. It turns out that the reason is in InteractionLoop.cpp line 122 and following (and maybe somewhere else too):

		// IPhysDispatcher
		if(!I->functorCache.phys){
			I->functorCache.phys=physDispatcher->getFunctor2D(b1->material,b2->material,swap);
			assert(!swap); // InteractionPhysicsEngineUnits are symmetric
		}

It assumes swap is always false. Is there a reason why we are not doing it the same way as for the Ig2 functors (see lines 90-104)? Well, if there is no reason I would like to change it to something like this:

		bool swap=false;
		// IPhysDispatcher
		if(!I->functorCache.phys){
			I->functorCache.phys=physDispatcher->getFunctor2D(b1->material,b2->material,swap);
		}
		if(swap){I->swapOrder();}
		// body pointers must be updated, in case we swapped
		const shared_ptr<Body>& bb1=swap?b2:b1;
		const shared_ptr<Body>& bb2=swap?b1:b2;

What do you think? Would this change work or am I missing something?

Further, I can see that in the Ig2 functors we have a goReverse. Is this ever called? A quick grep did not show any calls but only definitions. Not sure, but is this something we can get rid of?

Cheers,
Klaus


Follow ups