aboutsummaryrefslogtreecommitdiff
path: root/src/Registration.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/Registration.c')
-rw-r--r--src/Registration.c446
1 files changed, 445 insertions, 1 deletions
diff --git a/src/Registration.c b/src/Registration.c
index 06cf953..5f58d36 100644
--- a/src/Registration.c
+++ b/src/Registration.c
@@ -40,6 +40,8 @@ void MoL_SetScheduleStatus(CCTK_ARGUMENTS);
CCTK_INT MoL_RegisterEvolved(CCTK_INT EvolvedIndex, CCTK_INT RHSIndex);
+CCTK_INT MoL_RegisterEvolvedSlow(CCTK_INT EvolvedIndex, CCTK_INT RHSIndexSlow);
+
CCTK_INT MoL_RegisterConstrained(CCTK_INT ConstrainedIndex);
CCTK_INT MoL_RegisterSaveAndRestore(CCTK_INT SandRIndex);
@@ -52,9 +54,10 @@ CCTK_INT MoL_RegisterConstrainedGroup(CCTK_INT ConstrainedGroupIndex);
CCTK_INT MoL_RegisterSaveAndRestoreGroup(CCTK_INT SandRGroupIndex);
-
CCTK_INT MoL_RegisterEvolvedReal(CCTK_INT EvolvedIndex, CCTK_INT RHSIndex);
+CCTK_INT MoL_RegisterEvolvedRealSlow(CCTK_INT EvolvedIndex, CCTK_INT RHSIndexSlow);
+
CCTK_INT MoL_RegisterConstrainedReal(CCTK_INT ConstrainedIndex);
CCTK_INT MoL_RegisterSaveAndRestoreReal(CCTK_INT SandRIndex);
@@ -62,6 +65,10 @@ CCTK_INT MoL_RegisterSaveAndRestoreReal(CCTK_INT SandRIndex);
CCTK_INT MoL_RegisterEvolvedRealGroup(CCTK_INT EvolvedGroupIndex,
CCTK_INT RHSGroupIndex);
+CCTK_INT MoL_RegisterEvolvedRealGroupSlow(CCTK_INT EvolvedGroupIndex,
+ CCTK_INT RHSGroupIndexSlow);
+
+
CCTK_INT MoL_RegisterConstrainedRealGroup(CCTK_INT ConstrainedGroupIndex);
CCTK_INT MoL_RegisterSaveAndRestoreRealGroup(CCTK_INT SandRGroupIndex);
@@ -269,6 +276,109 @@ CCTK_INT MoL_RegisterEvolved(CCTK_INT EvolvedIndex, CCTK_INT RHSIndex)
}
+
+ /*@@
+ @routine MoL_RegisterEvolvedSlow
+ @date Thu May 30 11:36:59 2002
+ @author Ian Hawke
+ @desc
+ Given the index of the GF to be evolved and the RHS GF, it stores
+ the indexes for later use together with various error checking.
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
+
+@@*/
+
+CCTK_INT MoL_RegisterEvolvedSlow(CCTK_INT EvolvedIndex, CCTK_INT RHSIndexSlow)
+{
+
+ CCTK_INT retval, GroupType;
+
+ retval = 0;
+
+ if (!ScheduleStatus)
+ {
+ CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "MoL registration routine called too early!\n"
+ "Trying to register variable '%s',"
+ "Please ensure that all calls to MoL registration routines "
+ "occur within the \"MoL_Register\" timebin.",
+ CCTK_VarName(EvolvedIndex));
+ retval++;
+ }
+
+ GroupType = CCTK_GroupTypeFromVarI(EvolvedIndex);
+ if (GroupType < 0)
+ {
+ CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Evolved index %i is not a real variable index.",
+ EvolvedIndex);
+ retval++;
+ }
+
+ if (!retval)
+ {
+ switch (CCTK_VarTypeI(EvolvedIndex))
+ {
+ case CCTK_VARIABLE_REAL:
+ {
+ switch (GroupType)
+ {
+ case CCTK_GF:
+ {
+ retval +=
+ MoL_RegisterEvolvedRealSlow(EvolvedIndex,
+ RHSIndexSlow);
+ break;
+ }
+ case CCTK_ARRAY:
+ case CCTK_SCALAR:
+ {
+ CCTK_VWarn(0,__LINE__,__FILE__,CCTK_THORNSTRING,
+ "The variable '%s' is not supported for multirate methods",
+ CCTK_VarName(EvolvedIndex));
+ retval++;
+ break;
+ }
+ default:
+ {
+ CCTK_VWarn(0,__LINE__,__FILE__,CCTK_THORNSTRING,
+ "The variable '%s' is not supported for multirate methods",
+ CCTK_VarName(EvolvedIndex));
+ retval++;
+ break;
+ }
+ }
+ break;
+ }
+ case CCTK_VARIABLE_COMPLEX:
+ {
+ CCTK_VWarn(0,__LINE__,__FILE__,CCTK_THORNSTRING,
+ "The COMPLEX variable '%s' is not supported for multirate methods",
+ CCTK_VarName(EvolvedIndex));
+ break;
+ }
+ default:
+ {
+ CCTK_VWarn(0,__LINE__,__FILE__,CCTK_THORNSTRING,
+ "The variable '%s' is neither REAL nor COMPLEX.",
+ CCTK_VarName(EvolvedIndex));
+ retval++;
+ break;
+ }
+ }
+ }
+
+ return retval;
+
+}
+
+
+
/*@@
@routine MoL_RegisterConstrained
@date Thu May 30 12:35:58 2002
@@ -606,6 +716,91 @@ CCTK_INT MoL_RegisterEvolvedGroup(CCTK_INT EvolvedGroupIndex,
}
+CCTK_INT MoL_RegisterEvolvedGroupSlow(CCTK_INT EvolvedGroupIndex,
+ CCTK_INT RHSGroupIndex2)
+{
+
+ CCTK_INT retval, GroupFirstVar;
+
+ retval = 0;
+
+ if (!ScheduleStatus)
+ {
+ CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "MoL registration routine called too early!\n"
+ "Trying to register group '%s',"
+ "Please ensure that all calls to MoL registration routines "
+ "occur within the \"MoL_Register\" timebin.",
+ CCTK_GroupName(EvolvedGroupIndex));
+ retval++;
+ }
+
+ GroupFirstVar = CCTK_FirstVarIndexI(EvolvedGroupIndex);
+ if (GroupFirstVar < 0)
+ {
+ CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Evolved group index %i is not a real group index.",
+ EvolvedGroupIndex);
+ retval++;
+ }
+
+ switch (CCTK_VarTypeI(CCTK_FirstVarIndexI(EvolvedGroupIndex)))
+ {
+ case CCTK_VARIABLE_REAL:
+ {
+ switch (CCTK_GroupTypeI(EvolvedGroupIndex))
+ {
+ case CCTK_GF:
+ {
+ retval +=
+ MoL_RegisterEvolvedRealGroupSlow(EvolvedGroupIndex,
+ RHSGroupIndex2);
+ break;
+ }
+ case CCTK_ARRAY:
+ case CCTK_SCALAR:
+ {
+ CCTK_VWarn(0,__LINE__,__FILE__,CCTK_THORNSTRING,
+ "The group '%s' is not supported by multirate RK",
+ CCTK_GroupName(EvolvedGroupIndex));
+ retval++;
+ break;
+ }
+ default:
+ {
+ CCTK_VWarn(0,__LINE__,__FILE__,CCTK_THORNSTRING,
+ "The group '%s' is not supported by multirate RK",
+ CCTK_GroupName(EvolvedGroupIndex));
+ retval++;
+ break;
+ }
+ }
+ break;
+ }
+ case CCTK_VARIABLE_COMPLEX:
+ {
+ CCTK_VWarn(0,__LINE__,__FILE__,CCTK_THORNSTRING,
+ "The COMPLEX group '%s' is not supported by multirate RK",
+ CCTK_GroupName(EvolvedGroupIndex));
+ retval++;
+ break;
+ }
+ default:
+ {
+ CCTK_VWarn(0,__LINE__,__FILE__,CCTK_THORNSTRING,
+ "The group '%s' is neither REAL nor COMPLEX.",
+ CCTK_GroupName(EvolvedGroupIndex));
+ retval++;
+ break;
+ }
+ }
+
+ return retval;
+
+}
+
+
+
CCTK_INT MoL_RegisterConstrainedGroup(CCTK_INT ConstrainedGroupIndex)
{
@@ -992,6 +1187,198 @@ CCTK_INT MoL_RegisterEvolvedReal(CCTK_INT EvolvedIndex, CCTK_INT RHSIndex)
}
+
+ /*@@
+ @routine MoL_RegisterEvolvedSlow
+ @date Thu May 30 11:36:59 2002
+ @author Ian Hawke
+ @desc
+ Given the index of the GF to be evolved and the RHS GF, it stores
+ the indexes for later use together with various error checking.
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
+
+@@*/
+
+CCTK_INT MoL_RegisterEvolvedRealSlow(CCTK_INT EvolvedIndex, CCTK_INT RHSIndexSlow)
+{
+
+ DECLARE_CCTK_PARAMETERS;
+
+ CCTK_INT /* ierr, */ index, varused, numtimelevs1, numtimelevs2;
+
+#ifdef MOLDEBUG
+ printf("Arrived in MoLRegisterEvolvedSlow \n");
+ printf("The indexes are %d and %d.\n",EvolvedIndex, RHSIndexSlow);
+ printf("These correspond to variables %s and %s.\n",
+ CCTK_VarName(EvolvedIndex),CCTK_VarName(RHSIndexSlow));
+ printf("The pointer to EvolvedVariableIndex: %p\n",
+ EvolvedVariableIndex);
+#endif
+
+ if (!(CCTK_GroupTypeFromVarI(EvolvedIndex)==CCTK_GF))
+ {
+ CCTK_VWarn(0,__LINE__,__FILE__,CCTK_THORNSTRING,
+ "The variable %s is not a GF and so should "
+ "not be registered with MoLRegisterEvolved.",
+ CCTK_VarName(EvolvedIndex));
+ }
+
+ if (!(CCTK_GroupTypeFromVarI(RHSIndexSlow)==CCTK_GF))
+ {
+ CCTK_VWarn(0,__LINE__,__FILE__,CCTK_THORNSTRING,
+ "The rhs variable %s is not a GF and so should "
+ "not be registered with MoLRegisterEvolved.",
+ CCTK_VarName(RHSIndexSlow));
+ }
+
+ if (!(CCTK_VarTypeI(EvolvedIndex)==CCTK_VARIABLE_REAL))
+ {
+ CCTK_VWarn(0,__LINE__,__FILE__,CCTK_THORNSTRING,
+ "The variable %s is not of type CCTK_REAL and so "
+ "should not be registered with MoLRegisterEvolved.",
+ CCTK_VarName(EvolvedIndex));
+ }
+
+ if (!(CCTK_VarTypeI(RHSIndexSlow)==CCTK_VARIABLE_REAL))
+ {
+ CCTK_VWarn(0,__LINE__,__FILE__,CCTK_THORNSTRING,
+ "The rhs variable %s is not of type CCTK_REAL and "
+ "so should not be registered with MoLRegisterEvolved.",
+ CCTK_VarName(RHSIndexSlow));
+ }
+
+ numtimelevs1 = CCTK_MaxTimeLevelsVI(EvolvedIndex);
+ numtimelevs2 = CCTK_MaxTimeLevelsVI(RHSIndexSlow);
+
+ if ( (numtimelevs1 < 0) || (numtimelevs2 < 0) )
+ {
+ CCTK_VWarn(1,__LINE__,__FILE__,CCTK_THORNSTRING,
+ "Warning for variable index %i", EvolvedIndex);
+ CCTK_WARN(0, "The index passed does not correspond to a GF.");
+ }
+
+ if (numtimelevs1 < 2)
+ {
+ CCTK_VWarn(1,__LINE__,__FILE__,CCTK_THORNSTRING,
+ "Warning for variable index %i name %s",
+ EvolvedIndex, CCTK_VarName(EvolvedIndex));
+ CCTK_WARN(0, "The GF passed only has one timelevel. "
+ "It must have at least two.");
+ }
+
+ varused = 0;
+
+ for (index = 0; (index < MoLNumEvolvedVariablesSlow)&&(!varused); index++)
+ {
+ varused = (EvolvedIndex == EvolvedVariableIndexSlow[index]);
+#ifdef MOLDEBUG
+ printf("Registering %d. Checking index %d which is %d\n",EvolvedIndex,
+ index,EvolvedVariableIndexSlow[index]);
+#endif
+ }
+
+ if (varused)
+ {
+
+ CCTK_VWarn(2,__LINE__,__FILE__,CCTK_THORNSTRING,
+ "The GF %s has already been registered "
+ "as an evolved variable with RHS GF %s. "
+ "The attempt to register with RHS GF %s will be ignored",
+ CCTK_VarName(EvolvedIndex),
+ CCTK_VarName(RHSVariableIndexSlow[index-1]),
+ CCTK_VarName(RHSIndexSlow));
+
+ }
+ else
+ {
+
+ if (MoLNumEvolvedVariablesSlow+1 > MoL_Num_Evolved_Vars_Slow)
+ {
+ CCTK_WARN(0,"You have tried to register more evolved "
+ "variables than the accumulator parameter "
+ "MoL_Num_Evolved_Variables allows. Check that "
+ "you are accumulating onto this parameter correctly");
+ }
+
+ EvolvedVariableIndexSlow[MoLNumEvolvedVariablesSlow] = EvolvedIndex;
+ RHSVariableIndexSlow[MoLNumEvolvedVariablesSlow] = RHSIndexSlow;
+
+ MoLNumEvolvedVariablesSlow++;
+
+#ifdef MOLDEBUG
+ printf("The max number is now %d. Just added %d (%s).\n",
+ MoLNumEvolvedVariablesSlow, EvolvedIndex,
+ CCTK_VarName(EvolvedIndex));
+#endif
+
+ }
+
+ varused = -1;
+
+ for (index = 0; (index < MoLNumConstrainedVariables)&&(!(varused+1));
+ index++)
+ {
+ if (EvolvedIndex == ConstrainedVariableIndex[index])
+ {
+ varused = index;
+ }
+
+ }
+
+ if ((varused+1))
+ {
+ for (index = varused; index < MoLNumConstrainedVariables-1; index++)
+ {
+ ConstrainedVariableIndex[index] = ConstrainedVariableIndex[index+1];
+ }
+ MoLNumConstrainedVariables--;
+ }
+
+ varused = -1;
+
+ for (index = 0; (index < MoLNumSandRVariables)&&(!(varused+1)); index++)
+ {
+ if (EvolvedIndex == SandRVariableIndex[index])
+ {
+ varused = index;
+ }
+
+#ifdef MOLDEBUG
+ printf("Checking SandR var %d. Index %d (evolvedindex %d).\n",
+ index, SandRVariableIndex[index], EvolvedIndex);
+#endif
+
+ }
+
+ if ((varused+1))
+ {
+ for (index = varused; index < MoLNumSandRVariables-1; index++)
+ {
+ SandRVariableIndex[index] = SandRVariableIndex[index+1];
+
+#ifdef MOLDEBUG
+ printf("The registered evolved variable was SandR."
+ " Now index %d is %d (%s).\n",
+ index, SandRVariableIndex[index],
+ CCTK_VarName(SandRVariableIndex[index]));
+#endif
+
+ }
+ MoLNumSandRVariables--;
+ }
+
+ return 0;
+
+}
+
+
+
+
/*@@
@routine MoL_RegisterConstrained
@date Thu May 30 12:35:58 2002
@@ -1256,6 +1643,51 @@ CCTK_INT MoL_RegisterEvolvedRealGroup(CCTK_INT EvolvedGroupIndex,
}
+CCTK_INT MoL_RegisterEvolvedRealGroupSlow(CCTK_INT EvolvedGroupIndex,
+ CCTK_INT RHSGroupIndexSlow)
+{
+
+ CCTK_INT EvolvedGroupFirstVar, RHSGroupFirstVar, GroupNumVars, retval;
+ CCTK_INT EvolvedVar, RHSVar;
+
+ EvolvedGroupFirstVar = CCTK_FirstVarIndexI(EvolvedGroupIndex);
+ if (EvolvedGroupFirstVar < 0)
+ {
+ CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Evolved group index %i is not a real group index.",
+ EvolvedGroupIndex);
+ }
+
+ RHSGroupFirstVar = CCTK_FirstVarIndexI(RHSGroupIndexSlow);
+ if (RHSGroupFirstVar < 0)
+ {
+ CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "RHS group index %d is not a real group index.",
+ RHSGroupIndexSlow);
+ }
+
+ GroupNumVars = CCTK_NumVarsInGroupI(EvolvedGroupIndex);
+ if (CCTK_NumVarsInGroupI(RHSGroupIndexSlow) != GroupNumVars)
+ {
+ CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "There are a different number of variables in "
+ "evolved group %d and RHS group %d.",
+ EvolvedGroupIndex, RHSGroupIndexSlow);
+ }
+
+ retval = 0;
+
+ for (EvolvedVar = EvolvedGroupFirstVar, RHSVar = RHSGroupFirstVar;
+ EvolvedVar < EvolvedGroupFirstVar + GroupNumVars;
+ EvolvedVar++, RHSVar++)
+ {
+ retval += MoL_RegisterEvolvedRealSlow(EvolvedVar, RHSVar);
+ }
+
+ return retval;
+}
+
+
CCTK_INT MoL_RegisterConstrainedRealGroup(CCTK_INT ConstrainedGroupIndex)
{
@@ -2741,6 +3173,7 @@ CCTK_INT MoL_RegisterSaveAndRestoreComplexArrayGroup(CCTK_INT SandRGroupIndex)
@desc
Given the index of a registered evolved GF,
returns the corresponding RHS GF.
+ Checks both regular and slow evolved variables.
@enddesc
@calls
@calledby
@@ -2769,6 +3202,17 @@ CCTK_INT MoL_QueryEvolvedRHS(CCTK_INT EvolvedIndex)
}
}
+ // If we haven't found any registered variable that matches,
+ // we also try to check whether this has been registered with the slow multirate sector!
+
+ for (index = 0; index < MoLNumEvolvedVariablesSlow; index++)
+ {
+ if (EvolvedVariableIndexSlow[index] == EvolvedIndex)
+ {
+ return RHSVariableIndexSlow[index];
+ }
+ }
+
return -1;
}