/* FDCT3D (Fast 3d Curvelet Transform) Copyright (C) 2004 Caltech Written by Lexing Ying */ #include "fdct3d.hpp" #include "fdct3dinline.hpp" //--------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------- int fdct3d_partition_cpxnumtnsblkd_z(int N1,int N2,int N3,int b, BolNumTns& exists, IntNumTns& owners) { int e = N1/b; int f = N2/b; int g = N3/b; int mpirank; MPI_Comm_rank(MPI_COMM_WORLD, &mpirank); int mpisize; MPI_Comm_size(MPI_COMM_WORLD, &mpisize); iA(g%mpisize==0); int bpp = g/mpisize; //block per processor for(int k=0; k >& exists, vector< vector >& owners) { int mpirank; MPI_Comm_rank(MPI_COMM_WORLD, &mpirank); int mpisize; MPI_Comm_size(MPI_COMM_WORLD, &mpisize); exists.resize(nbscales-1); owners.resize(nbscales-1); { int s = 0; vector& es = exists[s]; vector& os = owners[s]; es.resize(1); os.resize(1); int pi = 0; os[0] = pi; es[0] = (pi==mpirank); } int nf = 6; for(int s=1; s& es = exists[s]; vector& os = owners[s]; es.resize(nd*nd * nf); os.resize(nd*nd * nf); int face; int wcnt = 0; int wpp = (nd*nd*nf)/mpisize; if(wpp*mpisize=0; h--) { for(int g=nd-1; g>=0; g--) { int pi = wcnt/wpp; os[wcnt] = pi; es[wcnt] = (pi==mpirank); wcnt++; } } //face 4 -y -z -x face = 4; for(int f=nd-1; f>=0; f--) { for(int h=nd-1; h>=0; h--) { int pi = wcnt/wpp; os[wcnt] = pi; es[wcnt] = (pi==mpirank); wcnt++; } } //face 5 -z -x -y face = 5; for(int g=nd-1; g>=0; g--) { for(int f=nd-1; f>=0; f--) { int pi = wcnt/wpp; os[wcnt] = pi; es[wcnt] = (pi==mpirank); wcnt++; } } iA(wcnt==nf*nd*nd); } //scale return 0; } //--------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------- int fdct3d_dependency_center(int N1,int N2,int N3, int b, double L1, double L2, double L3, vector& crvowners, BolNumTns& tnsexists) { int mpirank; MPI_Comm_rank(MPI_COMM_WORLD, &mpirank); int mpisize; MPI_Comm_size(MPI_COMM_WORLD, &mpisize); int S1, S2, S3; int F1, F2, F3; double R1, R2, R3; fdct3d_rangecompute(L1, L2, L3, S1, S2, S3, F1, F2, F3, R1, R2, R3); if(crvowners[0]==mpirank) { for(int xcur=-F1; xcur<=F1; xcur++) for(int ycur=-F2; ycur<=F2; ycur++) for(int zcur=-F3; zcur<=F3; zcur++) { int bi,bj,bk; int oi,oj,ok; fdct3d_position_aux(N1,N2,N3,b,xcur,ycur,zcur,bi,bj,bk,oi,oj,ok); tnsexists(bi,bj,bk) = true; } } return 0; } int fdct3d_dependency_angles(int N1,int N2,int N3, int b, double L1, double L2, double L3, int nd, vector& crvowners, BolNumTns& tnsexists) { int mpirank; MPI_Comm_rank(MPI_COMM_WORLD, &mpirank); int mpisize; MPI_Comm_size(MPI_COMM_WORLD, &mpisize); int nf = 6; int wcnt = 0; int S1, S2, S3; int F1, F2, F3; double R1, R2, R3; fdct3d_rangecompute(L1, L2, L3, S1, S2, S3, F1, F2, F3, R1, R2, R3); double W1 = L1/nd; double W2 = L2/nd; double W3 = L3/nd; //face 0: x,y,z for(int h=0; h=0; h--) { for(int g=nd-1; g>=0; g--) { if(crvowners[wcnt]==mpirank) { double xs = -R1; double xe = -R1/4+(W1/2)/4; double ys = -R2 + (2*g-1)*W2/2; double ye = -R2 + (2*g+3)*W2/2; double zs = -R3 + (2*h-1)*W3/2; double ze = -R3 + (2*h+3)*W3/2; int xn = int(ceil(xe-xs)); int yn = int(ceil(ye-ys)); int zn = int(ceil(ze-zs)); double thts, thtm, thte; //y to x if(g==0) { thts = atan2(-1.0, 1.0-1.0/nd); thtm = atan2(-1.0+1.0/nd, 1.0); thte = atan2(-1.0+3.0/nd, 1.0); } else if(g==nd-1) { thts = atan2(-1.0+(2.0*g-1.0)/nd, 1.0); thtm = atan2(-1.0+(2.0*g+1.0)/nd, 1.0); thte = atan2(1.0, 1.0-1.0/nd); } else { thts = atan2(-1.0+(2.0*g-1.0)/nd, 1.0); thtm = atan2(-1.0+(2.0*g+1.0)/nd, 1.0); thte = atan2(-1.0+(2.0*g+3.0)/nd, 1.0); } double phis, phim, phie; //z to x if(h==0) { phis = atan2(-1.0, 1.0-1.0/nd); phim = atan2(-1.0+1.0/nd, 1.0); phie = atan2(-1.0+3.0/nd, 1.0); } else if(h==nd-1) { phis = atan2(-1.0+(2.0*h-1.0)/nd, 1.0); phim = atan2(-1.0+(2.0*h+1.0)/nd, 1.0); phie = atan2(1.0, 1.0-1.0/nd); } else { phis = atan2(-1.0+(2.0*h-1.0)/nd, 1.0); phim = atan2(-1.0+(2.0*h+1.0)/nd, 1.0); phie = atan2(-1.0+(2.0*h+3.0)/nd, 1.0); } //int xh = xn/2; int yh = yn/2; int zh = zn/2; double R21 = R2/R1; double R31 = R3/R1; for(int xcur=(int)ceil(xs); xcur=0; f--) { for(int h=nd-1; h>=0; h--) { if(crvowners[wcnt]==mpirank) { double ys = -R2; double ye = -R2/4+(W2/2)/4; double zs = -R3 + (2*h-1)*W3/2; double ze = -R3 + (2*h+3)*W3/2; double xs = -R1 + (2*f-1)*W1/2; double xe = -R1 + (2*f+3)*W1/2; int xn = int(ceil(xe-xs)); int yn = int(ceil(ye-ys)); int zn = int(ceil(ze-zs)); double thts, thtm, thte; //z to y if(h==0) { thts = atan2(-1.0, 1.0-1.0/nd); thtm = atan2(-1.0+1.0/nd, 1.0); thte = atan2(-1.0+3.0/nd, 1.0); } else if(h==nd-1) { thts = atan2(-1.0+(2.0*h-1.0)/nd, 1.0); thtm = atan2(-1.0+(2.0*h+1.0)/nd, 1.0); thte = atan2(1.0, 1.0-1.0/nd); } else { thts = atan2(-1.0+(2.0*h-1.0)/nd, 1.0); thtm = atan2(-1.0+(2.0*h+1.0)/nd, 1.0); thte = atan2(-1.0+(2.0*h+3.0)/nd, 1.0); } double phis, phim, phie; //z to x if(f==0) { phis = atan2(-1.0, 1.0-1.0/nd); phim = atan2(-1.0+1.0/nd, 1.0); phie = atan2(-1.0+3.0/nd, 1.0); } else if(f==nd-1) { phis = atan2(-1.0+(2.0*f-1.0)/nd, 1.0); phim = atan2(-1.0+(2.0*f+1.0)/nd, 1.0); phie = atan2(1.0, 1.0-1.0/nd); } else { phis = atan2(-1.0+(2.0*f-1.0)/nd, 1.0); phim = atan2(-1.0+(2.0*f+1.0)/nd, 1.0); phie = atan2(-1.0+(2.0*f+3.0)/nd, 1.0); } //int xh = xn/2; int yh = yn/2; int zh = zn/2; double R32 = double(F3)/double(F2); double R12 = double(F1)/double(F2); for(int ycur=(int)ceil(ys); ycur=0; g--) { for(int f=nd-1; f>=0; f--) { if(crvowners[wcnt]==mpirank) { double zs = -R3; double ze = -R3/4+(W3/2)/4; double xs = -R1 + (2*f-1)*W1/2; double xe = -R1 + (2*f+3)*W1/2; double ys = -R2 + (2*g-1)*W2/2; double ye = -R2 + (2*g+3)*W2/2; int xn = int(ceil(xe-xs)); int yn = int(ceil(ye-ys)); int zn = int(ceil(ze-zs)); double thts, thtm, thte; //y to x if(f==0) { thts = atan2(-1.0, 1.0-1.0/nd); thtm = atan2(-1.0+1.0/nd, 1.0); thte = atan2(-1.0+3.0/nd, 1.0); } else if(f==nd-1) { thts = atan2(-1.0+(2.0*f-1.0)/nd, 1.0); thtm = atan2(-1.0+(2.0*f+1.0)/nd, 1.0); thte = atan2(1.0, 1.0-1.0/nd); } else { thts = atan2(-1.0+(2.0*f-1.0)/nd, 1.0); thtm = atan2(-1.0+(2.0*f+1.0)/nd, 1.0); thte = atan2(-1.0+(2.0*f+3.0)/nd, 1.0); } double phis, phim, phie; //z to x if(g==0) { phis = atan2(-1.0, 1.0-1.0/nd); phim = atan2(-1.0+1.0/nd, 1.0); phie = atan2(-1.0+3.0/nd, 1.0); } else if(g==nd-1) { phis = atan2(-1.0+(2.0*g-1.0)/nd, 1.0); phim = atan2(-1.0+(2.0*g+1.0)/nd, 1.0); phie = atan2(1.0, 1.0-1.0/nd); } else { phis = atan2(-1.0+(2.0*g-1.0)/nd, 1.0); phim = atan2(-1.0+(2.0*g+1.0)/nd, 1.0); phie = atan2(-1.0+(2.0*g+3.0)/nd, 1.0); } //int xh = xn/2; int yh = yn/2; int zh = zn/2; double R13 = double(F1)/double(F3); double R23 = double(F2)/double(F3); for(int zcur=(int)ceil(zs); zcur >& crvowners, BolNumTns& tnsexists) { //int e = N1/b; int f = N2/b; int g = N3/b; int mpirank; MPI_Comm_rank(MPI_COMM_WORLD, &mpirank); int mpisize; MPI_Comm_size(MPI_COMM_WORLD, &mpisize); setvalue(tnsexists, false); int L = nbscales; { int s = 0; double L1 = 2.0*N1/3.0 / pow2(L-2-s); double L2 = 2.0*N2/3.0 / pow2(L-2-s); double L3 = 2.0*N3/3.0 / pow2(L-2-s); fdct3d_dependency_center(N1,N2,N3,b, L1,L2,L3, crvowners[s], tnsexists); } for(int s=1; s