yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #02889
[Branch ~yade-dev/yade/trunk] Rev 1930: 1. Forgotten new file.
------------------------------------------------------------
revno: 1930
committer: Václav Šmilauer <eudoxos@xxxxxxxx>
branch nick: trunk
timestamp: Wed 2009-12-30 18:39:02 +0100
message:
1. Forgotten new file.
added:
core/Cell.cpp
--
lp:yade
https://code.launchpad.net/~yade-dev/yade/trunk
Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-dev/yade/trunk/+edit-subscription.
=== added file 'core/Cell.cpp'
--- core/Cell.cpp 1970-01-01 00:00:00 +0000
+++ core/Cell.cpp 2009-12-30 17:39:02 +0000
@@ -0,0 +1,43 @@
+
+#include<yade/core/Cell.hpp>
+
+void Cell::integrateAndUpdate(Real dt){
+ //incremental displacement gradient
+ _trsfInc=dt*velGrad;
+ // total transformation; M = (Id+G).M = F.M
+ trsf+=_trsfInc*trsf;
+ // Hsize will contain colums with transformed base vectors
+ Matrix3r Hsize(refSize[0],refSize[1],refSize[2]); Hsize=trsf*Hsize;
+ // lengths of transformed cell vectors, skew cosines
+ Matrix3r Hnorm; // normalized transformed base vectors
+ for(int i=0; i<3; i++){
+ Vector3r base(Hsize.GetColumn(i));
+ _size[i]=base.Normalize(); //returns length
+ Hnorm.SetColumn(i,base);
+ };
+ //cerr<<"Hsize="<<endl<<Hsize[0][0]<<" "<<Hsize[0][1]<<" "<<Hsize[0][2]<<endl<<Hsize[1][0]<<" "<<Hsize[1][1]<<" "<<Hsize[1][2]<<endl<<Hsize[2][0]<<" "<<Hsize[2][1]<<" "<<Hsize[2][2]<<endl;
+ // skew cosines
+ for(int i=0; i<3; i++){
+ int i1=(i+1)%3, i2=(i+2)%3;
+ // sin between axes is cos of skew
+ _cos[i]=(Hnorm.GetColumn(i1).Cross(Hnorm.GetColumn(i2))).SquaredLength();
+ }
+ // pure shear trsf: ones on diagonal
+ _shearTrsf=Hnorm;
+ //cerr<<"shearTrsf="<<endl<<_shearTrsf[0][0]<<" "<<_shearTrsf[0][1]<<" "<<_shearTrsf[0][2]<<endl<<_shearTrsf[1][0]<<" "<<_shearTrsf[1][1]<<" "<<_shearTrsf[1][2]<<endl<<_shearTrsf[2][0]<<" "<<_shearTrsf[2][1]<<" "<<_shearTrsf[2][2]<<endl;
+ // pure unshear transformation
+ _unshearTrsf=_shearTrsf.Inverse();
+ // some parts can branch depending on presence/absence of shear
+ _hasShear=(trsf[0][1]!=0 || trsf[0][2]!=0 || trsf[1][0]!=0 || trsf[1][2]!=0 || trsf[2][0]!=0 || trsf[2][1]!=0);
+ // OpenGL shear matrix (used frequently)
+ fillGlShearTrsfMatrix(_glShearTrsfMatrix);
+}
+
+void Cell::fillGlShearTrsfMatrix(double m[16]){
+ m[0]=_shearTrsf[0][0]; m[4]=_shearTrsf[0][1]; m[8]=_shearTrsf[0][2]; m[12]=0;
+ m[1]=_shearTrsf[1][0]; m[5]=_shearTrsf[1][1]; m[9]=_shearTrsf[1][2]; m[13]=0;
+ m[2]=_shearTrsf[2][0]; m[6]=_shearTrsf[2][1]; m[10]=_shearTrsf[2][2];m[14]=0;
+ m[3]=0; m[7]=0; m[11]=0; m[15]=1;
+}
+
+