double GLGPU3DDataset::Flux(int face) const { // TODO: pre-compute the flux switch (face) { case 0: return -dx() * dy() * Bz(); case 1: return -dy() * dz() * Bx(); case 2: return -dz() * dx() * By(); case 3: return dx() * dy() * Bz(); case 4: return dy() * dz() * Bx(); case 5: return dz() * dx() * By(); default: assert(false); } return 0.0; }
float GLGPUDataset::QP(const float X0[], const float X1[]) const { const float *L = Lengths(), *O = Origins(); float d[3] = {X1[0] - X0[0], X1[1] - X0[1], X1[2] - X0[2]}; int p[3] = {0}; // 0: not crossed; 1: positive; -1: negative for (int i=0; i<3; i++) { d[i] = X1[i] - X0[i]; if (d[i]>L[i]/2) {d[i] -= L[i]; p[i] = 1;} else if (d[i]<-L[i]/2) {d[i] += L[i]; p[i] = -1;} } const float X[3] = {X0[0] - O[0], X0[1] - O[1], X0[2] - O[2]}; if (By()>0 && p[0]!=0) { // By>0 return p[0] * L[0] * (Bz()*X[1] - By()*X[2]); } else if (p[1]!=0) { return p[1] * L[1] * (Bx()*X[2] - Bz()*X[0]); } else return 0.0; }
double GLGPU3DDataset::GaugeTransformation(const double X0[], const double X1[]) const { double gx, gy, gz; double dx = X1[0] - X0[0], dy = X1[1] - X0[1], dz = X1[2] - X0[2]; double x = X0[0] + 0.5*dx, y = X0[1] + 0.5*dy, z = X0[2] + 0.5*dz; if (By()>0) { // Y-Z gauge gx = dx * Kex(); gy =-dy * x * Bz(); // -dy*x^hat*Bz gz = dz * x * By(); // dz*x^hat*By } else { // X-Z gauge gx = dx * y * Bz() + dx * Kex(); // dx*y^hat*Bz + dx*K gy = 0; gz =-dz * y * Bx(); // -dz*y^hat*Bx } return gx + gy + gz; }
// float Ax(const float X[3], int slot=0) const {if (By()>0) return 0; else return -X[1]*Bz();} float Ay(const float X[3], int slot=0) const {if (By()>0) return X[0]*Bz(); else return 0;}
float Ax(const float X[3], int slot=0) const {if (By()>0) return -Kex(slot); else return -X[1]*Bz()-Kex(slot);}