aboutsummaryrefslogtreecommitdiff
path: root/src/announce.cc
diff options
context:
space:
mode:
authorschnetter <schnetter@83718e91-0e4f-0410-abf4-91180603181f>2005-05-29 15:49:59 +0000
committerschnetter <schnetter@83718e91-0e4f-0410-abf4-91180603181f>2005-05-29 15:49:59 +0000
commit6aae08c0746c3dda204cdf4ba7e89c85f887f36f (patch)
tree19e2449c924aba69ebfa5447d4058fbcc9f82ce0 /src/announce.cc
parent08de25904f7d64a31d31ac8e70ca6df2d33ad004 (diff)
Make it possible to announce or store grid scalars
git-svn-id: http://svn.cactuscode.org/arrangements/CactusUtils/Formaline/trunk@23 83718e91-0e4f-0410-abf4-91180603181f
Diffstat (limited to 'src/announce.cc')
-rw-r--r--src/announce.cc104
1 files changed, 104 insertions, 0 deletions
diff --git a/src/announce.cc b/src/announce.cc
index 46936b8..24639fc 100644
--- a/src/announce.cc
+++ b/src/announce.cc
@@ -566,6 +566,110 @@ Formaline_AnnounceUpdate (CCTK_ARGUMENTS)
stores.store ("cctk_iteration", cctk_iteration);
stores.store ("cctk_time", cctk_time);
}
+
+
+
+ // Groups and variables
+
+ {
+ struct args {
+ cGH * cctkGH;
+ multistorage * stores;
+ char const * reductions;
+
+ static void
+ output_variable (int const varindex,
+ char const * const options,
+ void * const theargs0)
+ {
+ args * const theargs = (args *) theargs0;
+ cGH * const cctkGH = theargs->cctkGH;
+ multistorage & stores = * theargs->stores;
+ char const * const reductions = theargs->reductions;
+
+ int const groupindex = CCTK_GroupIndexFromVarI (varindex);
+ assert (groupindex >= 0);
+ cGroup group;
+ int const ierr = CCTK_GroupData (groupindex, & group);
+ assert (! ierr);
+
+ ostringstream keybuf, valbuf;
+ char * const fullname = CCTK_FullName (varindex);
+ assert (fullname);
+ keybuf << "variables/" << fullname;
+ free (fullname);
+ string const keystr = keybuf.str();
+ char const * const key = keystr.c_str();
+
+ void const * const varptr
+ = CCTK_VarDataPtrI (cctkGH, 0, varindex);
+ if (! varptr) {
+ // No storage -- do nothing
+ // TODO: output warning
+ return;
+ }
+
+ switch (group.grouptype)
+ {
+ case CCTK_SCALAR:
+ switch (group.vartype)
+ {
+ case CCTK_VARIABLE_INT:
+ {
+ CCTK_INT const val = * (CCTK_INT const *) varptr;
+ stores.store (key, val);
+ }
+ break;
+ case CCTK_VARIABLE_REAL:
+ {
+ CCTK_REAL const val = * (CCTK_REAL const *) varptr;
+ stores.store (key, val);
+ }
+ break;
+ case CCTK_VARIABLE_COMPLEX:
+ {
+ CCTK_COMPLEX const val = * (CCTK_COMPLEX const *) varptr;
+ {
+ ostringstream keyrebuf;
+ keyrebuf << key << ".Re";
+ string const keyrestr = keyrebuf.str();
+ char const * const keyre = keyrestr.c_str();
+ stores.store (keyre, val.Re);
+ }
+ {
+ ostringstream keyimbuf;
+ keyimbuf << key << ".Im";
+ string const keyimstr = keyimbuf.str();
+ char const * const keyim = keyimstr.c_str();
+ stores.store (keyim, val.Im);
+ }
+ }
+ break;
+ default:
+ ;
+ // not supported yet
+ // TODO: output warning
+ }
+ break;
+ case CCTK_ARRAY:
+ case CCTK_GF:
+ // not supported yet
+ // TODO: output warning
+ break;
+ default:
+ CCTK_WARN (0, "internal error");
+ }
+ }
+ } theargs;
+
+ theargs.cctkGH = cctkGH;
+ theargs.stores = & stores;
+ theargs.reductions = out_reductions;
+
+ int const ierr
+ = CCTK_TraverseString (out_vars, theargs.output_variable, & theargs,
+ CCTK_GROUP_OR_VAR);
+ }
}