Révision 178

NBody/NBody.py (revision 178)
362 362
    MYFLOAT N = (MYFLOAT)get_global_size(0);
363 363
    uint zmwc=seed_z+(uint)gid;
364 364
    uint wmwc=seed_w-(uint)gid;
365
    MYFLOAT4 CrossVector,SpeedVector;
365
    MYFLOAT4 CrossVector,SpeedVector,FromCoM;
366
    MYFLOAT Heat,ThetaA,PhiA,ThetaB,PhiB,Length,tA,tB,Polar;
366 367

  
368
    for (int i=0;i<gid;i++)
369
    {
370
        Heat=MWCfp;
371
    }
372

  
373
    // cast to float for sin,cos are NEEDED by Mesa FP64 implementation!
374
    // Implemention on AMD Oland are probably broken in float
375

  
376
    FromCoM=(MYFLOAT4)(clDataX[gid]-clCoM[0]);
377
    Length=length(FromCoM);
378
    //Theta=acos(FromCoM.z/Length);
379
    //Phi=atan(FromCoM.y/FromCoM.x);
380
    // First tangential vector to sphere of length radius
381
    ThetaA=acos(FromCoM.x/Length)+5.e-1f*PI;
382
    PhiA=atan(FromCoM.y/FromCoM.z);
383
    // Second tangential vector to sphere of length radius
384
    ThetaB=acos(FromCoM.x/Length);
385
    PhiB=atan(FromCoM.y/FromCoM.z)+5.e-1f*PI;
386
    // (x,y) random coordonates to plane tangential to sphere
387
    Polar=MWCfp*2.e0f*PI;
388
    tA=cos(Polar);
389
    tB=sin(Polar);
390
    //tA=MWCfp*2.e0f-1.e0f;
391
    //tB=MWCfp*2.e0f-1.e0f;
392

  
393
    // Exception for 2 particules to ovoid shifting
367 394
    if (get_global_size(0)==2) {
368 395
       CrossVector=(MYFLOAT4)(1.e0f,1.e0f,1.e0f,0.e0f);
369 396
    } else {
370
       CrossVector=(MYFLOAT4)(MWCfp-5e-1f,MWCfp-5e-1f,MWCfp-5e-1f,0.e0f);
397
       CrossVector.s0=tA*cos(ThetaA)+tB*cos(ThetaB);
398
       CrossVector.s1=tA*sin(ThetaA)*sin(PhiA)+tB*sin(ThetaB)*sin(PhiB);
399
       CrossVector.s2=tA*sin(ThetaA)*cos(PhiA)+tB*sin(ThetaB)*cos(PhiB);
400
       CrossVector.s3=0.e0f;
371 401
    }
372 402

  
373 403
    if (velocity<SMALL_NUM) {
374
       SpeedVector=(MYFLOAT4)normalize(cross(clDataX[gid]-clCoM[0],CrossVector))*sqrt((-AtomicPotential(clDataX,gid)/(MYFLOAT)2.e0f));
404
       SpeedVector=(MYFLOAT4)normalize(cross(FromCoM,CrossVector))*sqrt((-AtomicPotential(clDataX,gid)/(MYFLOAT)2.e0f));
375 405
    }
376 406
    else
377
    {    
378
       // cast to float for sin,cos are NEEDED by Mesa FP64 implementation!
379
       // Implemention on AMD Oland are probably broken in float
407
    {
380 408

  
381 409
       SpeedVector=(MYFLOAT4)((MWCfp-5e-1f)*velocity,(MWCfp-5e-1f)*velocity,
382 410
                              (MWCfp-5e-1f)*velocity,0.e0f);
......
559 587
def special(k,x,y):
560 588
    global ViewRX, ViewRY
561 589

  
590
    Step=1.
562 591
    if k == GLUT_KEY_UP:
563
        ViewRX += 1.0
592
        ViewRX += Step
564 593
    elif k == GLUT_KEY_DOWN:
565
        ViewRX -= 1.0
594
        ViewRX -= Step
566 595
    elif k == GLUT_KEY_LEFT:
567
        ViewRY += 1.0
596
        ViewRY += Step
568 597
    elif k == GLUT_KEY_RIGHT:
569
        ViewRY -= 1.0
598
        ViewRY -= Step
570 599
    else:
571 600
        return
572 601
    glRotatef(ViewRX, 1.0, 0.0, 0.0)

Formats disponibles : Unified diff