void updatePMLEFieldUtilEx(int xStart, int xEnd, int yStart, int yEnd, int zStart, int zEnd, int xBound, int yBound, int zBound, pmlConstStruct cx[], pmlConstStruct cy[], pmlConstStruct cz[], int n){ int i, j, k; // These are the indexes int x,y,z;// There are indexes for the pmlConstStruct indexs long p; int m; double dxStore; double eps; for (i=xStart;i<xEnd+1;i++){ x = abs(xBound - i)%PML_LAYERS; for (j=yStart;j<yEnd+1;j++){ y = abs(yBound - j)%PML_LAYERS; for (k=zStart;k<zEnd+1;k++){ z = abs(zBound - k)%PML_LAYERS; p = PMLINDEX(i,j,k); dxStore = DX(p); m = MATERIALINDEX(i,j,k); eps = EPSR(m)*EPSNOT; DX(p) = cy[y].c1*DX(p) + cy[y].c2*(HZ(i,j,k) - HZ(i,j-1,k) - HY(i,j,k) + HY(i,j,k-1) - JSX(m)); EX(i,j,k) = cz[z].c3*EX(i,j,k) + cz[z].c4*(cx[x].c5*DX(p)-cx[x].c6*dxStore)/eps; }}} // end for }// end updatePMLEFieldUtilEx
void updatePMLHFieldUtilAll(int xStart, int xEnd, int yStart, int yEnd, int zStart, int zEnd, int xBound, int yBound, int zBound, pmlConstStruct cx[], pmlConstStruct cy[], pmlConstStruct cz[], int n){ int i, j, k; // These are the indexes int x,y,z;// There are indexes for the pmlConstStruct indexs long p; int m; double bxStore, byStore, bzStore; double mu; // Either this, or make cOnes a bigger array with number of elements which are the max of xLen, yLen, zLen for (i=xStart;i<xEnd+1;i++){ x = abs(xBound - i)%PML_LAYERS; for (j=yStart;j<yEnd+1;j++){ y = abs(yBound - j)%PML_LAYERS; for (k=zStart;k<zEnd+1;k++){ z = abs(zBound - k)%PML_LAYERS; p = PMLINDEX(i,j,k); bxStore = BX(p); byStore = BY(p); bzStore = BZ(p); mu = MUR(m)*MUNOT; BX(p) = cy[y].c1*BX(p) + cy[y].c2*(EY(i,j,k+1) - EY(i,j,k) + EZ(i,j,k) - EZ(i,j+1,k) - MSX(m)); HX(i,j,k) = cz[z].c3*HX(i,j,k) + cz[z].c4*(cx[x].c5*BX(p)-cx[x].c6*bxStore)/mu; BY(p) = cz[z].c1*BY(p) + cz[z].c2*(EZ(i+1,j,k) - EZ(i,j,k) + EX(i,j,k) - EX(i,j,k+1) - MSY(m)); HY(i,j,k) = cx[x].c3*HY(i,j,k) + cx[x].c4*(cy[y].c5*BY(p)-cy[y].c6*byStore)/mu; BZ(p) = cx[x].c1*BZ(p) + cx[x].c2*(EX(i,j+1,k) - EX(i,j,k) + EY(i,j,k) - EY(i+1,j,k) - MSZ(m)); HZ(i,j,k) = cy[y].c3*HZ(i,j,k) + cy[y].c4*(cz[z].c5*BZ(p)-cz[z].c6*bzStore)/mu; }}} // end for }// end updatePMLHFieldUtilAll
static inline void calcE(){ for(int i=1; i<N_PX-1; i++) for(int j=1; j<N_PY-1; j++) Ezx[ind(i,j)] = CEZX(i,j)*EZX(i,j) + CEZXLX(i,j)*(HY(i,j) - HY(i-1,j)); for(int i=1; i<N_PX-1; i++) for(int j=1; j<N_PY-1; j++) Ezy[ind(i,j)] = CEZY(i,j)*EZY(i,j) - CEZYLY(i,j)*(HX(i,j) - HX(i,j-1)); }
//calculate J and D static inline void calcJD() { for(int i=1; i<N_PX-1; i++){ for(int j=1; j<N_PY-1; j++){ double complex nowJz = JZ(i,j); Jz[ind(i,j)] = CJZ(i,j)*JZ(i,j) + CJZHXHY(i,j)*(+HY(i,j) - HY(i-1,j) - HX(i,j) + HX(i,j-1) ); Dz[ind(i,j)] = CDZ(i,j)*DZ(i,j) + CDZJZ1(i,j)*JZ(i,j) - CDZJZ0(i,j)*nowJz; } } }
static inline void calcH(){ for(int i=1; i<N_PX-1; i++) for(int j=1; j<N_PY-1; j++) Hx[ind(i,j)] = CHX(i,j)*HX(i,j) - CHXLY(i,j)*( EZX(i,j+1)-EZX(i,j) + EZY(i,j+1)-EZY(i,j)); for(int i=1; i<N_PX-1; i++) for(int j=1; j<N_PY-1; j++) Hy[ind(i,j)] = CHY(i,j)*HY(i,j) + CHYLX(i,j)*( EZX(i+1,j)-EZX(i,j) + EZY(i+1,j)-EZY(i,j) ); }
void updatePMLEFieldUtilAll(int xStart, int xEnd, int yStart, int yEnd, int zStart, int zEnd, int xBound, int yBound, int zBound, pmlConstStruct cx[], pmlConstStruct cy[], pmlConstStruct cz[], int n){ int i, j, k; // These are the indexes int x,y,z;// There are indexes for the pmlConstStruct indexs long p; int m; double dxStore, dyStore, dzStore; double eps; // Either this, or make cOnes a bigger array with number of elements which are the max of xLen, yLen, zLen for (i=xStart;i<xEnd+1;i++){ x = abs(xBound - i)%PML_LAYERS; for (j=yStart;j<yEnd+1;j++){ y = abs(yBound - j)%PML_LAYERS; for (k=zStart;k<zEnd+1;k++){ z = abs(zBound - k)%PML_LAYERS; //printf("(i,j,k) (%d, %d, %d), (x,y,z) (%d,%d,%d)\n", i,j,k,x,y,z); p = PMLINDEX(i,j,k); dxStore = DX(p); dyStore = DY(p); dzStore = DZ(p); m = MATERIALINDEX(i,j,k); eps = EPSR(m)*EPSNOT; DX(p) = cy[y].c1*DX(p) + cy[y].c2*(HZ(i,j,k) - HZ(i,j-1,k) - HY(i,j,k) + HY(i,j,k-1) - JSX(m)); EX(i,j,k) = cz[z].c3*EX(i,j,k) + cz[z].c4*(cx[x].c5*DX(p)-cx[x].c6*dxStore)/eps; DY(p) = cz[z].c1*DY(p) + cz[z].c2*(HX(i,j,k) - HX(i,j,k-1) + HZ(i-1,j,k) - HZ(i,j,k) - JSY(m)); EY(i,j,k) = cx[x].c3*EY(i,j,k) + cx[x].c4*(cy[y].c5*DY(p)-cy[y].c6*dyStore)/eps; DZ(p) = cx[x].c1*DZ(p) + cx[x].c2*(HY(i,j,k) - HY(i-1,j,k) - HX(i,j,k) + HX(i,j-1,k) - JSZ(m)); EZ(i,j,k) = cy[y].c3*EZ(i,j,k) + cy[y].c4*(cz[z].c5*DZ(p)-cz[z].c6*dzStore)/eps; }}} // end for }// end updatePMLEFieldUtilAll