From 59e1172ee9a2bd413e2e0d1ac9afa513ac5797f8 Mon Sep 17 00:00:00 2001 From: herrmann Date: Fri, 18 Mar 2005 18:36:10 +0000 Subject: allow subtraction of static background git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/Norms/trunk@8 f4913095-0e4f-0410-abea-a123d184f1f3 --- interface.ccl | 5 +++++ schedule.ccl | 2 +- src/Compute_Norm.c | 2 ++ src/Setup_Vars.c | 38 ++++++++++++++++++-------------------- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/interface.ccl b/interface.ccl index 4395b91..0c4cf42 100644 --- a/interface.ccl +++ b/interface.ccl @@ -28,6 +28,11 @@ INT nrdecvar_gr TYPE=SCALAR nr1stvars, nr2ndvars } "number of vars to compute for 1st & 2nd order vars" +REAL bgvals_group TYPE=SCALAR +{ + bgvals_1st,bgvals_2nd +} "background value for variable - these get subtracted" + REAL norm_group TYPE=SCALAR { norm diff --git a/schedule.ccl b/schedule.ccl index 4067605..cdc6421 100644 --- a/schedule.ccl +++ b/schedule.ccl @@ -1,7 +1,7 @@ # Schedule definitions for thorn Norms # $Header$ -STORAGE: do_nothing_group,handles_group,varinfo,nrdecvar_gr,norm_group,diff_term_group +STORAGE: do_nothing_group,handles_group,varinfo,nrdecvar_gr,norm_group,diff_term_group, bgvals_group diff --git a/src/Compute_Norm.c b/src/Compute_Norm.c index b6cdcff..8fc641a 100644 --- a/src/Compute_Norm.c +++ b/src/Compute_Norm.c @@ -86,6 +86,7 @@ void Norms_Compute_Norms (CCTK_ARGUMENTS) vind,varindices_1st[vind], CCTK_VarName(varindices_1st[vind]),result); } + result=result-bgvals_1st[vind]; *norm=*norm+result*result; } @@ -103,6 +104,7 @@ void Norms_Compute_Norms (CCTK_ARGUMENTS) vind,varindices_2nd[vind], CCTK_VarName(varindices_2nd[vind]),result); } + result=result-bgvals_2nd[vind]; *norm=*norm+result*result; } diff --git a/src/Setup_Vars.c b/src/Setup_Vars.c index 8f14a88..056c72a 100644 --- a/src/Setup_Vars.c +++ b/src/Setup_Vars.c @@ -19,7 +19,7 @@ CCTK_FILEVERSION(Norms_Setup_Vars_c); struct norms_opts { int active; int vi; /* variable index */ - int norm_type; + CCTK_REAL bg; /* background value which gets subtracted */ }; @@ -31,7 +31,7 @@ static void getopt (int const idx, int table; int cnt; int ierr; - int norm_type; + CCTK_REAL bg; assert (idx >= 0 && idx < CCTK_NumVars()); @@ -59,26 +59,18 @@ static void getopt (int const idx, norms_opts->vi = idx; if (optstring) { - /* XXX norm_type is not used currently !*/ - cnt = Util_TableGetInt (table, &norm_type , "norm_type"); + cnt = Util_TableGetReal (table, &bg , "bg"); if (cnt < 0) { - norms_opts->norm_type = -100; /* XXX magic value */ + norms_opts->bg = 0.; /* don't subtract any background */ } else { - norms_opts->norm_type = norm_type; + norms_opts->bg = bg; } ierr = Util_TableDestroy (table); assert (!ierr); } - /* Don't compute norms if not output was requested */ - if (norms_opts->active) { - if (norms_opts->norm_type==-100) { - norms_opts->active = 0; - } - } - } @@ -119,6 +111,8 @@ void Norms_Setup_Vars (CCTK_ARGUMENTS) for(i=0;i0) { - CCTK_VInfo(CCTK_THORNSTRING," %s (1st order var)", - CCTK_FullName(varindices_1st[i])); + CCTK_VInfo(CCTK_THORNSTRING," %s (1st order var) - %f", + CCTK_FullName(varindices_1st[*nr1stvars]), + bgvals_1st[*nr1stvars]); } *nr1stvars=*nr1stvars+1; } if (norms_opts_2nd[n].active) { varindices_2nd[*nr2ndvars]=norms_opts_2nd[n].vi; + bgvals_2nd[*nr2ndvars]=norms_opts_2nd[n].bg; if (verbose>0) { - CCTK_VInfo(CCTK_THORNSTRING," %s (2nd order var)", - CCTK_FullName(varindices_2nd[i])); + CCTK_VInfo(CCTK_THORNSTRING," %s (2nd order var) - %f", + CCTK_FullName(varindices_2nd[*nr2ndvars]), + bgvals_2nd[*nr2ndvars]); } *nr2ndvars=*nr2ndvars+1; } @@ -166,9 +164,9 @@ void Norms_Setup_Vars (CCTK_ARGUMENTS) if (verbose>4) { fprintf(stderr," The actual variable arrays look like\n"); for (n=0;n