aboutsummaryrefslogtreecommitdiff
path: root/src/apply.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/apply.c')
-rw-r--r--src/apply.c50
1 files changed, 31 insertions, 19 deletions
diff --git a/src/apply.c b/src/apply.c
index 0ef2674..0c09b8e 100644
--- a/src/apply.c
+++ b/src/apply.c
@@ -149,7 +149,7 @@ BndReflectVI (cGH const * restrict const cctkGH,
int gi;
cGroup group;
cGroupDynamicData data;
- int firstvar, numvars;
+ int firstvar, numvars, vectorlength;
char * restrict fullname;
void * restrict varptr;
@@ -229,6 +229,9 @@ BndReflectVI (cGH const * restrict const cctkGH,
assert (firstvar>=0 && firstvar<CCTK_NumVars());
numvars = CCTK_NumVarsInGroupI (gi);
assert (numvars>=0);
+ vectorlength = group.vectorlength;
+ assert (vectorlength>=0);
+ assert (vectorlength==1 || group.vectorgroup);
ierr = CCTK_GroupDynamicData (cctkGH, gi, &data);
assert (!ierr);
@@ -294,64 +297,73 @@ BndReflectVI (cGH const * restrict const cctkGH,
|| CCTK_EQUALS (tensortypealias, "d"))
{
/* vector */
- assert (numvars == 3);
+ const int numcomps = 3;
+ /* special case to handle things like vel[3] */
+ assert (numvars % numcomps == 0 &&
+ (numvars == numcomps * vectorlength || numvars == vectorlength));
ttype = VECTOR;
- tcomponent = vi - firstvar;
+ tcomponent = (vi - firstvar) % numcomps;
} else if (CCTK_EQUALS (tensortypealias, "4u")
|| CCTK_EQUALS (tensortypealias, "4d"))
{
/* 4-vector */
- assert (numvars == 4);
- if (vi == firstvar) {
+ const int numcomps = 4;
+ assert (numvars % numcomps == 0 && numvars == numcomps * vectorlength);
+ if ((vi - firstvar) % numcomps == 0) {
ttype = SCALAR;
tcomponent = 0;
} else {
ttype = VECTOR;
- tcomponent = vi - firstvar - 1;
+ tcomponent = (vi - firstvar) % numcomps - 1;
}
} else if (CCTK_EQUALS (tensortypealias, "uu_sym")
|| CCTK_EQUALS (tensortypealias, "dd_sym"))
{
/* symmetric tensor */
- assert (numvars == 6);
+ const int numcomps = 6;
+ assert (numvars % numcomps == 0 && numvars == numcomps * vectorlength);
ttype = SYMTENSOR;
- tcomponent = vi - firstvar;
+ tcomponent = (vi - firstvar) % numcomps;
} else if (CCTK_EQUALS (tensortypealias, "uu")
|| CCTK_EQUALS (tensortypealias, "ud")
|| CCTK_EQUALS (tensortypealias, "du")
|| CCTK_EQUALS (tensortypealias, "dd"))
{
/* non-symmetric tensor */
- assert (numvars == 9);
+ const int numcomps = 9;
+ assert (numvars % numcomps == 0 && numvars == numcomps * vectorlength);
ttype = TENSOR;
- tcomponent = vi - firstvar;
+ tcomponent = (vi - firstvar) % numcomps;
} else if (CCTK_EQUALS (tensortypealias, "4uu_sym")
|| CCTK_EQUALS (tensortypealias, "4dd_sym"))
{
/* symmetric 4-tensor */
- assert (numvars == 10);
- if (vi == firstvar) {
+ const int numcomps = 10;
+ assert (numvars % numcomps == 0 && numvars == numcomps * vectorlength);
+ if ((vi - firstvar) % numcomps == 0) {
ttype = SCALAR;
tcomponent = 0;
- } else if (vi <= firstvar+3) {
+ } else if ((vi - firstvar) % numcomps <= 3) {
ttype = VECTOR;
- tcomponent = vi - firstvar - 1;
+ tcomponent = (vi - firstvar) % numcomps - 1;
} else {
ttype = SYMTENSOR;
- tcomponent = vi - firstvar - 4;
+ tcomponent = (vi - firstvar) % numcomps - 4;
}
} else if (CCTK_EQUALS (tensortypealias, "ddd_sym")) {
/* 3rd rank tensor, symmetric in last 2 indices */
- assert (numvars == 18);
+ const int numcomps = 18;
+ assert (numvars % numcomps == 0 && numvars == numcomps * vectorlength);
ttype = SYMTENSOR3;
- tcomponent = vi - firstvar;
+ tcomponent = (vi - firstvar) % numcomps;
} else if (CCTK_EQUALS (tensortypealias, "weylscalars_real")) {
/* Weyl scalars, stored as 10 real values. NOTE: This assumes
that Psi_0 comes first, which is NOT the default with
PsiKadelia. */
- assert (numvars == 10);
+ const int numcomps = 10;
+ assert (numvars % numcomps == 0 && numvars == numcomps * vectorlength);
ttype = WEYLSCALARS_REAL;
- tcomponent = vi - firstvar;
+ tcomponent = (vi - firstvar) % numcomps;
} else if (CCTK_EQUALS (tensortypealias, "ManualCartesian")) {
/* Reflection symmetries specified by hand */
ttype = MANUALCARTESIAN;