aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorherrmann <herrmann@f4913095-0e4f-0410-abea-a123d184f1f3>2005-03-18 18:36:10 +0000
committerherrmann <herrmann@f4913095-0e4f-0410-abea-a123d184f1f3>2005-03-18 18:36:10 +0000
commit59e1172ee9a2bd413e2e0d1ac9afa513ac5797f8 (patch)
tree2d049b5f80d88c5076f4c532bca411244cd8782f
parentccdd5a80d7f6c6cd0300fa0eb765cfd50c6621f7 (diff)
allow subtraction of static background
git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/Norms/trunk@8 f4913095-0e4f-0410-abea-a123d184f1f3
-rw-r--r--interface.ccl5
-rw-r--r--schedule.ccl2
-rw-r--r--src/Compute_Norm.c2
-rw-r--r--src/Setup_Vars.c38
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;i<max_nr_vars;i++) {
varindices_1st[i]=-1;
varindices_2nd[i]=-1;
+ bgvals_1st[i]=0.;
+ bgvals_2nd[i]=0.;
}
nvars = CCTK_NumVars();
@@ -143,17 +137,21 @@ void Norms_Setup_Vars (CCTK_ARGUMENTS)
for (n=0; n<nvars; ++n) {
if (norms_opts_1st[n].active) {
varindices_1st[*nr1stvars]=norms_opts_1st[n].vi;
+ bgvals_1st[*nr1stvars]=norms_opts_1st[n].bg;
if (verbose>0) {
- 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<max_nr_vars;n++) {
- fprintf(stderr," i:%d 1st (vi:%d vn:%s) 2nd (vi:%d vn:%s)\n",
- n,varindices_1st[n],CCTK_VarName(varindices_1st[n]),
- varindices_2nd[n],CCTK_VarName(varindices_2nd[n]));
+ fprintf(stderr," i:%d (vi:%d vn:%s bg:%f) (vi:%d vn:%s bg:%f)\n",
+ n,varindices_1st[n],CCTK_VarName(varindices_1st[n]),bgvals_1st[n],
+ varindices_2nd[n],CCTK_VarName(varindices_2nd[n]),bgvals_2nd[n]);
}
}