From 4418c9485d2948f96d381123bd56a2acc942df7e Mon Sep 17 00:00:00 2001 From: schnetter Date: Sat, 26 Mar 2005 14:44:34 +0000 Subject: Initialise boundary of temporary grid function to zero before reducing it. Convert all expressions to int or double before printfing them. Use the L2 instead of the L1 norm when reducing the individual variables for norm_u, norm_v, and norm_grad. git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/Norms/trunk@13 f4913095-0e4f-0410-abea-a123d184f1f3 --- src/Compute_Norm.c | 67 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/Compute_Norm.c b/src/Compute_Norm.c index e159b80..22bf952 100644 --- a/src/Compute_Norm.c +++ b/src/Compute_Norm.c @@ -44,9 +44,19 @@ void Norms_Compute_Norms (CCTK_ARGUMENTS) jstart = cctk_nghostzones[1]; kstart = cctk_nghostzones[2]; - iend = cctk_lsh[0]-cctk_nghostzones[0]; - jend = cctk_lsh[1]-cctk_nghostzones[1]; - kend = cctk_lsh[2]-cctk_nghostzones[2]; + iend = cctk_lsh[0] - cctk_nghostzones[0]; + jend = cctk_lsh[1] - cctk_nghostzones[1]; + kend = cctk_lsh[2] - cctk_nghostzones[2]; + + /* initialise boundaries */ + for (k=0;k2) fprintf(stderr," nr1stvars %d nr2ndvars %d\n", - *nr1stvars,*nr2ndvars); + (int)*nr1stvars,(int)*nr2ndvars); /* L2-norm of 1st order variables */ *norm_u=0.; @@ -67,16 +77,16 @@ void Norms_Compute_Norms (CCTK_ARGUMENTS) CCTK_WARN(1,"reduction failed"); if (verbose>4) { fprintf(stderr," vind=%d vi=%d var=%s result=%1.8g\n", - vind,varindices_1st[vind], - CCTK_VarName(varindices_1st[vind]),result); + vind,(int)varindices_1st[vind], + CCTK_VarName(varindices_1st[vind]),(double)result); } result=result-bgvals_1st[vind]; - *norm_u=*norm_u+result; + *norm_u=*norm_u+result*result; *norm=*norm+result*result; } if (verbose>2) - fprintf(stderr," after 1st order vars norm=%16.8g\n",*norm); + fprintf(stderr," after 1st order vars norm=%16.8g\n",(double)*norm); /* L2-norm of 2nd order variables */ *norm_v=0.; @@ -87,16 +97,16 @@ void Norms_Compute_Norms (CCTK_ARGUMENTS) CCTK_WARN(1,"reduction failed"); if (verbose>4) { fprintf(stderr," vind=%d vi=%d var=%s result=%1.8g\n", - vind,varindices_2nd[vind], - CCTK_VarName(varindices_2nd[vind]),result); + vind,(int)varindices_2nd[vind], + CCTK_VarName(varindices_2nd[vind]),(double)result); } result=result-bgvals_2nd[vind]; - *norm_v=*norm_v+result; + *norm_v=*norm_v+result*result; *norm=*norm+result*result; } if (verbose>2) - fprintf(stderr," after 2nd order vars norm=%16.8g\n",*norm); + fprintf(stderr," after 2nd order vars norm=%16.8g\n",(double)*norm); /* L2-norm of D_{+i} terms */ *norm_grad=0.; @@ -119,15 +129,15 @@ void Norms_Compute_Norms (CCTK_ARGUMENTS) CCTK_WARN(1,"reduction failed"); if (verbose>4) { fprintf(stderr," vind=%d vi=%d var=%s result=%1.8g\n", - vind,varindices_2nd[vind], - CCTK_VarName(varindices_2nd[vind]),result); + vind,(int)varindices_2nd[vind], + CCTK_VarName(varindices_2nd[vind]),(double)result); } - *norm_grad=*norm_grad+result; + *norm_grad=*norm_grad+result*result; *norm=*norm+result*result; } if (verbose>2) - fprintf(stderr," after dx 2nd order terms norm=%16.8g\n",*norm); + fprintf(stderr," after dx 2nd order terms norm=%16.8g\n",(double)*norm); /* d_y */ for (vind=0; vind< *nr2ndvars; vind++) { @@ -148,15 +158,15 @@ void Norms_Compute_Norms (CCTK_ARGUMENTS) CCTK_WARN(1,"reduction failed"); if (verbose>4) { fprintf(stderr," vind=%d vi=%d var=%s result=%1.8g\n", - vind,varindices_2nd[vind], - CCTK_VarName(varindices_2nd[vind]),result); + vind,(int)varindices_2nd[vind], + CCTK_VarName(varindices_2nd[vind]),(double)result); } - *norm_grad=*norm_grad+result; + *norm_grad=*norm_grad+result*result; *norm=*norm+result*result; } if (verbose>2) - fprintf(stderr," after dy 2nd order terms norm=%16.8g\n",*norm); + fprintf(stderr," after dy 2nd order terms norm=%16.8g\n",(double)*norm); /* d_z */ for (vind=0; vind< *nr2ndvars; vind++) { @@ -177,27 +187,30 @@ void Norms_Compute_Norms (CCTK_ARGUMENTS) CCTK_WARN(1,"reduction failed"); if (verbose>4) { fprintf(stderr," vind=%d vi=%d var=%s result=%1.8g\n", - vind,varindices_2nd[vind], - CCTK_VarName(varindices_2nd[vind]),result); + vind,(int)varindices_2nd[vind], + CCTK_VarName(varindices_2nd[vind]),(double)result); } - *norm_grad=*norm_grad+result; + *norm_grad=*norm_grad+result*result; *norm=*norm+result*result; } if (verbose>2) - fprintf(stderr," after dz 2nd order terms norm=%16.8g\n",*norm); + fprintf(stderr," after dz 2nd order terms norm=%16.8g\n",(double)*norm); if (verbose>2) fprintf(stderr," after 2nd order vars (incl. D_{+i}): norm=%16.8g\n", - *norm); + (double)*norm); if (verbose>2) - fprintf(stderr,"final norm^2=%16.8g on this CPU\n",*norm); + fprintf(stderr,"final norm^2=%16.8g on this CPU\n",(double)*norm); + *norm_u=sqrt(*norm_u); + *norm_v=sqrt(*norm_v); + *norm_grad=sqrt(*norm_grad); *norm=sqrt(*norm); if (verbose>1) { CCTK_VInfo(CCTK_THORNSTRING, "norm= %16.8g (norm_u=%f, norm_v=%f, norm_grad=%f)", - *norm,*norm_u,*norm_v,*norm_grad); + (double)*norm,(double)*norm_u,(double)*norm_v,(double)*norm_grad); } } -- cgit v1.2.3