[Developers] extend ICN to (swapped/unswapped) theta-ICN, default does not change

Frank Loeffler frank.loeffler at aei.mpg.de
Tue Aug 8 04:28:16 CDT 2006


Hi,

I still have here this patch, which extends ICN by request to theta-ICN, 
which can also be swapped, as published recently.

The default does not change and the code is simple.

This is Cactus Problem Report: 2043

thanks, Frank

Index: param.ccl
===================================================================
RCS file: /cactusdevcvs/CactusBase/MoL/param.ccl,v
retrieving revision 1.17
diff -u -r1.17 param.ccl
--- param.ccl	30 Mar 2005 16:08:33 -0000	1.17
+++ param.ccl	8 Aug 2006 09:13:10 -0000
@@ -98,6 +98,15 @@
   "Classic RK3"	:: "Efficient RK3 - classical version"
 } "RK"
 
+CCTK_REAL ICN_avg_theta "theta of averaged ICN method, usually 0.5"
+{
+  0:1 :: "0 <= theta <= 1"
+} 0.5
+
+BOOLEAN ICN_avg_swapped "Use swapped averages in ICN method?"
+{
+} "no"
+
 CCTK_INT MoL_Intermediate_Steps "Number of intermediate steps taken by the ODE method"
 {
   1:*		:: "Anything greater than 1"
Index: src/ICN.c
===================================================================
RCS file: /cactusdevcvs/CactusBase/MoL/src/ICN.c,v
retrieving revision 1.12
diff -u -r1.12 ICN.c
--- src/ICN.c	11 Dec 2005 05:44:40 -0000	1.12
+++ src/ICN.c	8 Aug 2006 09:13:10 -0000
@@ -74,7 +74,7 @@
   CCTK_INT groupindex, ierr;
   CCTK_INT arraytotalsize, arraydim;
 
-  CC K_INT index, var;
+  CCTK_INT index, var;
   CCTK_INT totalsize;
   CCTK_REAL *OldVar;
   CCTK_REAL *UpdateVar;
@@ -92,8 +92,8 @@
 #endif
 
 #ifdef MOLDEBUG
-  printf("Inside ICN.\nProcessor %d.\nStep %d.\nRefinement %d.\n"
-         "Timestep %g.\nSpacestep %g.\nTime %g\n",
+  printf("Inside ICN. Processor %d. Step %d. Refinement %d.\n"
+         " Timestep %g. Spacestep %g. Time %g\n",
          CCTK_MyProc(cctkGH),
          MoL_Intermediate_Steps - *MoL_Intermediate_Step + 1,
          *cctk_levfac,
@@ -109,7 +109,7 @@
   }
 
 #ifdef MOLDEBUG
-  printf("MoL: the ICN routine says dt = %f.\n", CCTK_DELTA_TIME);
+  printf(" MoL: the ICN routine says dt = %f.\n", CCTK_DELTA_TIME);
 #endif
   for (var = 0; var < MoLNumEvolvedVariables; var++)
   {
@@ -215,8 +215,9 @@
   CCTK_REAL *UpdateVar;
   CCTK_REAL *RHSVar;
   
-  /* FIXME */
+  CCTK_REAL theta;
 
+  /* FIXME */
 #ifdef MOLDOESCOMPLEX
 
   CCTK_COMPLEX *OldComplexVar;
@@ -226,15 +227,22 @@
 
 #endif
 
+  theta = ICN_avg_theta;
+  if (ICN_avg_swapped && (*MoL_Intermediate_Step%2))
+  {
+    theta = 1.0 - theta;
+  }
+
 #ifdef MOLDEBUG
-  printf("Inside ICN.\nProcessor %d.\nStep %d.\nRefinement %d.\n"
-         "Timestep %g.\nSpacestep %g.\nTime %g\n",
+  printf("Inside ICN. Processor %d. Step %d. Refinement %d.\n"
+         " Timestep %g. Spacestep %g. Time %g Theta %g\n",
          CCTK_MyProc(cctkGH),
          MoL_Intermediate_Steps - *MoL_Intermediate_Step + 1,
          *cctk_levfac,
          CCTK_DELTA_TIME,
          CCTK_DELTA_SPACE(0),
-         cctk_time);
+         cctk_time,
+         theta);
 #endif  
 
   totalsize = 1;
@@ -244,7 +252,7 @@
   }
 
 #ifdef MOLDEBUG
-  printf("MoL: the ICN routine says dt = %f.\n", CCTK_DELTA_TIME);
+  printf(" MoL: the ICN routine says dt = %f.\n", CCTK_DELTA_TIME);
 #endif
   for (var = 0; var < MoLNumEvolvedVariables; var++)
   {
@@ -257,7 +265,8 @@
     
     for (index = 0; index < totalsize; index++)
     {
-      UpdateVar[index] = 0.5 * (UpdateVar[index] + OldVar[index]);
+      UpdateVar[index] = (1.0-theta) * UpdateVar[index] +
+                              theta  * OldVar[index];
     }
   }
   
@@ -288,7 +297,8 @@
 
     for (index = 0; index < arraytotalsize; index++)
     {
-      UpdateVar[index] = 0.5 * (UpdateVar[index] + OldVar[index]);
+      UpdateVar[index] = (1.0-theta) * UpdateVar[index] +
+                              theta  * OldVar[index];
     }
   }
 


--- StripMime Report -- processed MIME parts ---
multipart/mixed
  text/plain (text body -- kept)
  text/plain (text body -- kept)
---


More information about the Developers mailing list