← Back to team overview

yade-dev team mailing list archive

Re: [Branch ~yade-dev/yade/trunk] Rev 2237: - Simplify equations inside plastic condition of Dem3Dof (1 sqrt instead of 3, less norm()), add ...

 


You should call it something clearer, like scaleDisplacementT() (why
Max?).

Because there was "max" in the original name and I went for the smallest change. I agree with the name you suggest.
I fixed the division by zero, thanks for pointing it out.


Since you added it as virtual function to the Dem3DofGeom base class,
you MUST also implement in Dem3DofGeom_FacetSphere and
Dem3DofGeom_WallSphere (not just Dem3DofGeom_SphereSphere).

Oh, you are right. It is a problem. I'll think about it.

Make it return void, not zero. It is more confusing to return
meaningless zero all the time, rather than nothing.

I will make it return the plastic displacement 2*diff (vector) as it is computed inside the function. It can be used to compute energy terms (btw, a general question : why computing distances for energy? can't we simply use cross products between force and disp. vectors?).

I don't really see why you don't add it as non-virtual method to
Dem3DofGeom which will call internally slipToDisplacementTMax (which is
virtual). This way you have to implement it at 3 times.  I don't think
computing norm() takes that much time (it could return squaredNorm
anyways, and compute the sqrt only where it is really used).
Looking only the interesting lines, and concatenating nested slipTo/scaleDisp functions, we have

Before :

if(trialFs.squaredNorm()>maxFsSq){ geom->slipToDisplacementTMax(sqrt(maxFsSq)/phys->ks); trialFs*=sqrt(maxFsSq/(trialFs.squaredNorm()));}
Vector3r p1=contPtInTgPlane1(), p2=contPtInTgPlane2();
   Real currDistSq=(p2-p1).squaredNorm();
   Vector3r diff=.5*(sqrt(currDistSq)/displacementTMax-1)*(p2-p1);
   return 2*diff.norm();

= 4 squaredNorm() + 4 sqrt() + 3 divisions (considering norm() = squaredNorm() + sqrt())


After :

   Real trialFsSq = trialFs.squaredNorm();
    if(trialFsSq>maxFsSq){
       Real multiplier=sqrt(maxFsSq/trialFsSq);
       geom->scaleDisplacementT(multiplier); trialFs*=multiplier;}
       Vector3r diff=.5*(multiplier-1)*(p2-p1);
       return 2*diff;

= 1 squaredNorm() + 1 sqrt() + 1 division

Does it make sense? :)


Cheers.

Bruno







Follow ups

References