/* $Header$ */ #include #include #include #include #include "cctk.h" #include "cctk_Arguments.h" #include "cctk_Parameters.h" #include "util_ErrorCodes.h" #include "util_Table.h" #include "Slab.h" /* This is pretty hard coded into all the tensor types and cannot be changed easily. */ #define DIM 3 /* spatial dimension */ static int convert_index (int const step, int const index, int const * restrict const alldirs, int * restrict const parity) { int srcindex; assert (index>=0 && index=0 && alldirs[0]=0 && alldirs[1]=0 && vis[var]0); gis = malloc (nvars * sizeof *gis); assert (nvars==0 || gis); varptrs = malloc (nvars * sizeof *varptrs); assert (nvars==0 || varptrs); vartypes = malloc (nvars * sizeof *vartypes); assert (nvars==0 || vartypes); for (var=0; var=0 && gis[var]= 0); } for (d=0; dcctk_bbox[d]; for (d=0; d< DIM; ++d) local[2*DIM+d] = -cctkGH->cctk_lbnd[d]; for (d=0; d< DIM; ++d) local[3*DIM+d] = cctkGH->cctk_ubnd[d]; ierr = CCTK_ReduceLocArrayToArray1D (cctkGH, -1, max_handle, local, global, 4*DIM, CCTK_VARIABLE_INT); for (d=0; d<2*DIM; ++d) global_bbox[d] = global[ d]; for (d=0; d< DIM; ++d) global_lbnd[d] = -global[2*DIM+d]; for (d=0; d< DIM; ++d) global_ubnd[d] = global[3*DIM+d]; for (d=0; d0); firstvar = CCTK_FirstVarIndexI(gis[var]); assert (firstvar>=0); index = vis[var] - firstvar; assert (index>=0 && index=0); ierr = Util_TableGetString (table, sizeof tensortypealias, tensortypealias, "tensortypealias"); if (ierr == UTIL_ERROR_TABLE_NO_SUCH_KEY) { /* assume a scalar */ if (numvars != 1) { static int * restrict didwarn = 0; if (! didwarn) { didwarn = calloc (CCTK_NumGroups(), sizeof *didwarn); } if (! didwarn[gis[var]]) { char * groupname = CCTK_GroupName(gis[var]); assert (groupname); CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, "Group \"%s\" has no tensor type and contains more than one element -- treating these as \"scalar\"", groupname); free (groupname); didwarn[gis[var]] = 1; } } strcpy (tensortypealias, "scalar"); } else if (ierr<0) { char * groupname = CCTK_GroupName(gis[var]); assert (groupname); CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING, "Error in tensor type alias declaration for group \"%s\"", groupname); free (groupname); } if (CCTK_EQUALS (tensortypealias, "scalar")) { /* scalar */ } else if (CCTK_EQUALS (tensortypealias, "4scalar")) { /* 4-scalar */ } else if (CCTK_EQUALS (tensortypealias, "u") || CCTK_EQUALS (tensortypealias, "d")) { /* vector */ assert (numvars == DIM); } else if (CCTK_EQUALS (tensortypealias, "4u") || CCTK_EQUALS (tensortypealias, "4d")) { /* 4-vector */ assert (numvars == DIM+1); } else if (CCTK_EQUALS (tensortypealias, "uu_sym") || CCTK_EQUALS (tensortypealias, "dd_sym")) { /* symmetric tensor */ assert (numvars == DIM*(DIM+1)/2); } else if (CCTK_EQUALS (tensortypealias, "4uu_sym") || CCTK_EQUALS (tensortypealias, "4dd_sym")) { /* symmetric 4-tensor */ assert (numvars == (DIM+1)*(DIM+2)/2); } else if (CCTK_EQUALS (tensortypealias, "weylscalars_real")) { /* Weyl scalars, stored as 10 real numbers */ assert (numvars == 10); } else { char * groupname = CCTK_GroupName(gis[var]); assert (groupname); CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING, "Illegal tensor type alias for group \"%s\"", groupname); free (groupname); } } parities[var] = +1; if (CCTK_EQUALS (tensortypealias, "scalar")) { /* scalar */ srcvi = vis[var]; /* do nothing */ } else if (CCTK_EQUALS (tensortypealias, "4scalar")) { /* 4-scalar */ srcvi = vis[var]; /* do nothing */ } else if (CCTK_EQUALS (tensortypealias, "u") || CCTK_EQUALS (tensortypealias, "d")) { /* vector */ int srcindex; assert (index>=0 && index=0 && index=0 && index=0 && index<(DIM+1)*(DIM+2)/2); if (index==0) { /* temporal-temporal component */ srcvi = firstvar; } else if (index=0 && index<10); srcvi = vis[var]; } else { assert (0); } srcptrs[var] = CCTK_VarDataPtrI (cctkGH, 0, srcvi); assert (srcptrs[var]); } /* for var */ have_global_bbox = 1; for (q=0; q= 0); if (data.gsh[otherdir[q]] < data.nghostzones[dir[q]] + data.nghostzones[otherdir[q]] + offset[otherdir[q]]) { assert (nvars > 0); var = 0; CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING, "The group \"%s\" has in the %c-direction only %d grid points. " "This is not large enough for a 90 degree rotating symmetry boundary that is %d grid points wide in the %c-direction. " "The group needs to have at least %d grid points in the %c-direction.", CCTK_GroupNameFromVarI(vis[var]), "xyz"[dir[q]], data.gsh[dir[q]], data.nghostzones[dir[q]], "xyz"[otherdir[q]], data.nghostzones[dir[q]] + data.nghostzones[otherdir[q]] + offset[otherdir[q]], "xyz"[dir[q]]); } } /* Allocate slab transfer description */ xferinfo = malloc(group.dim * sizeof *xferinfo); assert (xferinfo); /* Fill in slab transfer description */ for (d=0; d= cctk_lsh[d]) imax[d] = cctk_lsh[d]; } assert (group.dim == DIM); switch (group.vartype) { case CCTK_VARIABLE_INT: for (k=imin[2]; k=0); if (nvars==0) return; indices = malloc (nvars * sizeof *indices); assert (indices); faces = malloc (nvars * sizeof *faces); assert (faces); widths = malloc (nvars * sizeof *widths); assert (widths); tables = malloc (nvars * sizeof *tables); assert (tables); ierr = Boundary_SelectedGVs (cctkGH, nvars, indices, faces, widths, tables, 0); assert (ierr == nvars); for (var=0; var=0 && indices[var]=0); } ierr = BndRot90VI (cctkGH, nvars, indices); assert (!ierr); free (indices); free (faces); free (widths); free (tables); }