示例#1
0
文件: poisson.cpp 项目: gluap/bphylib
void poisson_xyz(Grid3D& Ex, Grid3D& Ey, Grid3D& rho, Greenfb& gf)
{
 int NX=rho.get_NX(),NY=rho.get_NX(), NZ=rho.get_NZ();
 double dx=rho.get_dx(), dy=rho.get_dy();
 for(int i=0; i<NZ; i++)
 {
  poisson_xy(rho[i],gf);  
  for(int j=1;j<NX-1;j++)
   for(int l=1;l<NY-1;l++)
    {
     Ex[i](j,l)=-(rho[i](j+1,l)-rho[i](j-1,l))/(2.0*dx);
     Ey[i](j,l)=-(rho[i](j,l+1)-rho[i](j,l-1))/(2.0*dy);
    }
 }
}
示例#2
0
文件: poisson.cpp 项目: boine/bphylib
void poisson_xyz(Grid3D& Ex, Grid3D& Ey, Grid3D& Ez, Grid3D& rho, Greenfb& gf)
{
 int NX=rho.get_NX(),NY=rho.get_NX(), NZ=rho.get_NZ();
 double dx=rho.get_dx(), dy=rho.get_dy(), dz=rho.get_dz();
 
 poisson_xy(rho.get_ghostl2(),gf);
 poisson_xy(rho.get_ghostr2(),gf);
 poisson_xy(rho[0],gf); 
 
 for(int i=0; i<NZ; i++)
 {  
  if (i < NZ-1) poisson_xy(rho[i+1],gf);   
  for(int j=1;j<NX-1;j++)
   for(int l=1;l<NY-1;l++)
    {
     Ex[i](j,l)=-(rho[i](j+1,l)-rho[i](j-1,l))/(2.0*dx);
     Ey[i](j,l)=-(rho[i](j,l+1)-rho[i](j,l-1))/(2.0*dy);
     
     if (i==0) Ez[i](j,l)=-(rho[i+1](j,l)-rho.get_ghostl(j,l))/(2.0*dz);
     else if (i==NZ-1) Ez[i](j,l)=-(rho.get_ghostr(j,l)-rho[i-1](j,l))/(2.0*dz);
     else Ez[i](j,l)=-(rho[i+1](j,l)-rho[i-1](j,l))/(2.0*dz);
    }
 }
}