aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Compute_Norm.c67
1 files changed, 40 insertions, 27 deletions
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;k<cctk_lsh[0];k++) {
+ for (j=0;j<cctk_lsh[1];j++) {
+ for (i=0;i<cctk_lsh[2];i++) {
+ index=CCTK_GFINDEX3D(cctkGH,i,j,k);
+ diff_term[index]=0.;
+ }
+ }
+ }
target_proc = 0;
reduction_handle = CCTK_ReductionArrayHandle("norm2");
@@ -56,7 +66,7 @@ void Norms_Compute_Norms (CCTK_ARGUMENTS)
if (verbose>2)
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);
}
}