fix a few bugs and pass build; to be verified
This commit is contained in:
@@ -311,7 +311,7 @@ extern "C" void ScaLBL_D3Q7_PoissonResidualError(int *neighborList, int *Map, do
|
||||
nn = ijk-strideZ+strideY; // neighbor index (get convention)
|
||||
m18 = Psi[nn]; // get neighbor for phi - 18
|
||||
|
||||
psi_Laplacian = 2.0*3.0/18.0*(m1+m2+m3+m4+m5+m6-6*phi+0.5*(m7+m8+m9+m10+m11+m12+m13+m14+m15+m16+m17+m18-12*psi));//Laplacian of electric potential
|
||||
psi_Laplacian = 2.0*3.0/18.0*(m1+m2+m3+m4+m5+m6-6*psi+0.5*(m7+m8+m9+m10+m11+m12+m13+m14+m15+m16+m17+m18-12*psi));//Laplacian of electric potential
|
||||
residual_error = psi_Laplacian+rho_e/epsilon_LB;
|
||||
ResidualError[n] = residual_error;
|
||||
}
|
||||
|
||||
@@ -542,7 +542,7 @@ void ScaLBL_Poisson::Run(double *ChargeDensity, int timestep_from_Study){
|
||||
|
||||
timestep=0;
|
||||
double error = 1.0;
|
||||
double psi_avg_previous = 0.0;
|
||||
//double psi_avg_previous = 0.0;
|
||||
while (timestep < timestepMax && error > tolerance) {
|
||||
//************************************************************************/
|
||||
// *************ODD TIMESTEP*************//
|
||||
@@ -562,16 +562,24 @@ void ScaLBL_Poisson::Run(double *ChargeDensity, int timestep_from_Study){
|
||||
// Check convergence of steady-state solution
|
||||
if (timestep%analysis_interval==0){
|
||||
|
||||
ScaLBL_D3Q7_PoissonResidualError(NeighborList,dvcMap,ResidualError,Psi,ChargeDensity,epsilon_LB,Nx,Nx*Ny,ScaLBL_Comm->FirstInterior(), ScaLBL_Comm->LastInterior())
|
||||
ScaLBL_D3Q7_PoissonResidualError(NeighborList,dvcMap,ResidualError,Psi,ChargeDensity,epsilon_LB,Nx,Nx*Ny,0, ScaLBL_Comm->LastExterior())
|
||||
ScaLBL_D3Q7_PoissonResidualError(NeighborList,dvcMap,ResidualError,Psi,ChargeDensity,epsilon_LB,Nx,Nx*Ny,ScaLBL_Comm->FirstInterior(), ScaLBL_Comm->LastInterior());
|
||||
ScaLBL_D3Q7_PoissonResidualError(NeighborList,dvcMap,ResidualError,Psi,ChargeDensity,epsilon_LB,Nx,Nx*Ny,0, ScaLBL_Comm->LastExterior());
|
||||
|
||||
vector<double> ResidualError_host(Np);
|
||||
double error_loc_max;
|
||||
//calculate the maximum residual error
|
||||
ScaLBL_CopyToHost(ResidualError_host,ResidualError,sizeof(double)*Np);
|
||||
vector<double>::iterator it_max = max_element(ResidualError_host[0],ResidualError_host[ScaLBL_Comm->LastExterior()]);
|
||||
ScaLBL_CopyToHost(&ResidualError_host,ResidualError,sizeof(double)*Np);
|
||||
vector<double>::iterator it_temp1,it_temp2;
|
||||
it_temp1=ResidualError_host.begin();
|
||||
advance(it_temp1,ScaLBL_Comm->LastExterior());
|
||||
vector<double>::iterator it_max = max_element(ResidualError_host.begin(),it_temp1);
|
||||
unsigned int idx_max1 = distance(ResidualError_host.begin(),it_max);
|
||||
it_max = max_element(ResidualError_host[ScaLBL_Comm->FirstInterior()], ResidualError_host[ScaLBL_Comm->LastInterior()]);
|
||||
|
||||
it_temp1=ResidualError_host.begin();
|
||||
it_temp2=ResidualError_host.begin();
|
||||
advance(it_temp1,ScaLBL_Comm->FirstInterior());
|
||||
advance(it_temp2,ScaLBL_Comm->LastInterior());
|
||||
it_max = max_element(it_temp1,it_temp2);
|
||||
unsigned int idx_max2 = distance(ResidualError_host.begin(),it_max);
|
||||
if (ResidualError_host[idx_max1]>ResidualError_host[idx_max2]){
|
||||
error_loc_max=ResidualError_host[idx_max1];
|
||||
|
||||
Reference in New Issue
Block a user