How to get position of floating particles

edited November 12 in DualSPHysics v5.0

I am reading through to understand the source code for DualSPHysics. Can someone help me understand where the positions of the floating particles are stored. Where I think the variables are stored do not give me the values I would expect to see. I added a few print statements just after the for loop at line 940 of JSphCpuSingle.cpp. below is the full modified loop.

     int fxav = 0;

     int fyav = 0;

     int fzav = 0;

     int psize = 0;

     for(unsigned fp=fpini;fp<fpfin;fp++){

       printf("Particle: %d x: %f y:%f z:%f\n",fp,Posc[fp].x, Posc[fp].y, Posc[fp].z);

       fxav += Posc[fp].x;

       fyav += Posc[fp].y;

       fzav += Posc[fp].z;

       psize++;

       const int p=FtRidp[fp];

       if(p!=UINT_MAX){


         tfloat4 *velrhop=Velrhopc+p;

         //-Compute and record position displacement. | Calcula y graba desplazamiento de posicion.

         const double dx=dt*double(velrhop->x);

         const double dy=dt*double(velrhop->y);

         const double dz=dt*double(velrhop->z);

         UpdatePos(Posc[p],dx,dy,dz,false,p,Posc,Dcellc,Codec);

         //-Compute and record new velocity. | Calcula y graba nueva velocidad.

         tfloat3 dist=(PeriActive? FtPeriodicDist(Posc[p],fcenter,fradius): ToTFloat3(Posc[p]-fcenter));

         velrhop->x=fvel.x+(fomega.y*dist.z-fomega.z*dist.y);

         velrhop->y=fvel.y+(fomega.z*dist.x-fomega.x*dist.z);

         velrhop->z=fvel.z+(fomega.x*dist.y-fomega.y*dist.x);

       }

     }

     fxav = fxav/psize;

    fyav = fyav/psize;

    fzav = fzav/psize;

    printf("Average Floating Particle Position: \n x: %f y: %f z: %f\n",fxav, fyav, fzav);


Here is the output:

Particle: 0 x: -0.500000 y:-0.500000 z:-0.250000

Particle: 1 x: -0.500000 y:-0.500000 z:-0.240000

Particle: 2 x: -0.500000 y:-0.500000 z:-0.230000

Particle: 3 x: -0.500000 y:-0.500000 z:-0.220000

Particle: 4 x: -0.500000 y:-0.490000 z:-0.250000

.......

Particle: 176 x: -0.270000 y:-0.470000 z:-0.250000

Particle: 177 x: -0.260000 y:-0.500000 z:-0.250000

Particle: 178 x: -0.260000 y:-0.500000 z:-0.240000

Average Floating Particle Position:

 x: -0.260000 y: -0.500000 z: -0.240000



Here is a snippit of my case setup that shows sphere and floating settings:

               <setmkbound mk="2"/>

               <setdrawmode mode="full"/>

               <drawsphere radius="0.025" objname="Sphere">

                   <point x="0.3" y="-0.3" z="0.0" />

               </drawsphere>

               <shapeout file="" />

               </mainlist>

           </commands>

       </geometry>

       <floatings>

           <floating mkbound="2" rhopbody="800.0">

           </floating>

       </floatings>



So... the average position of the floating ball should be around .3 in the x and -.3 in the y, but this is not that values I am getting at the start of the sim. How do I figure out the position of the floating particles? can anyone give me some guidance? Obviously my understanding is wrong.

Comments

  • Ok I Figured out how to get the centre of a floating object... It is given in FtObjs[cf].center...

  • The post-processing tool FloatingInfo already gives you all that information

Sign In or Register to comment.