aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschnetter <schnetter@eec4d7dc-71c2-46d6-addf-10296150bf52>2005-06-01 19:43:30 +0000
committerschnetter <schnetter@eec4d7dc-71c2-46d6-addf-10296150bf52>2005-06-01 19:43:30 +0000
commit55377f0d42a931cba25c97977a70c90f0095dedf (patch)
treec7a35de78b68d3283857f8f71cf78e425390d62f
parentbf0ebb2acc212e439727a551be97a772af94d1b5 (diff)
Handle groups of tensor type Scalar that have more than one component.
This is actually legal and means that these components are all scalars themselves; it is used e.g. in Whisky. git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/Cartoon2D/trunk@91 eec4d7dc-71c2-46d6-addf-10296150bf52
-rw-r--r--src/Cartoon2DBC.c96
-rw-r--r--src/Cartoon2D_tensors.h5
2 files changed, 55 insertions, 46 deletions
diff --git a/src/Cartoon2DBC.c b/src/Cartoon2DBC.c
index 0145b22..6f72d87 100644
--- a/src/Cartoon2DBC.c
+++ b/src/Cartoon2DBC.c
@@ -83,33 +83,67 @@ int BndCartoon2DVI(const cGH *cctkGH, int tensortype, int prolongtype, int vi)
/* static int xindx=-1; */
+ char * groupname;
+
int i, j, k, di, dj, ijk;
int jj, n, s;
int lnx, lnz, ny;
- int n_tensortype;
+ int gi, var0;
+ int n_vars;
int timelevel;
/* CCTK_REAL *xp; */
CCTK_REAL x, y, rho;
CCTK_REAL lx0, dx0, dy0;
CCTK_REAL rxx, rxy, ryx, ryy;
CCTK_REAL sxx, sxy, syx, syy;
- CCTK_REAL f[6], fx, fy, fz, fxx, fxy, fxz, fyy, fyz, fzz;
+ CCTK_REAL f[100], fx, fy, fz, fxx, fxy, fxz, fyy, fyz, fzz;
CCTK_REAL *t, *tx, *ty, *tz, *txx, *txy, *txz, *tyy, *tyz, *tzz;
+ gi = CCTK_GroupIndexFromVarI (vi);
+ assert (gi >= 0);
+ n_vars = CCTK_NumVarsInGroupI (gi);
+ assert (n_vars > 0);
+ var0 = CCTK_FirstVarIndexI (gi);
+ assert (var0 >= 0);
+
+ if (n_vars > 100)
+ {
+ groupname = CCTK_GroupName (gi);
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Group \"%s\" has more than 100 variables -- cannot apply Cartoon boundary condition",
+ groupname);
+ free (groupname);
+ return -1;
+ }
+
switch (tensortype) {
case TENSORTYPE_SCALAR:
- n_tensortype = N_TENSORTYPE_SCALAR;
break;
case TENSORTYPE_U:
- n_tensortype = N_TENSORTYPE_U;
+ if (n_vars != 3)
+ {
+ groupname = CCTK_GroupName (gi);
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Group \"%s\" is declared with the tensor type U, but does not contain 3 variables -- cannot apply Cartoon boundary condition",
+ groupname);
+ free (groupname);
+ return -1;
+ }
break;
case TENSORTYPE_DDSYM:
- n_tensortype = N_TENSORTYPE_DDSYM;
+ if (n_vars != 6)
+ {
+ groupname = CCTK_GroupName (gi);
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Group \"%s\" is declared with the tensor type DDSYM, but does not contain 6 variables -- cannot apply Cartoon boundary condition",
+ groupname);
+ free (groupname);
+ return -1;
+ }
break;
default:
CCTK_WARN(0,"Tensor type not recognized by Cartoon2D.");
- n_tensortype = 0;
}
s = cctkGH->cctk_nghostzones[0];
@@ -148,7 +182,7 @@ int BndCartoon2DVI(const cGH *cctkGH, int tensortype, int prolongtype, int vi)
the const qualifier from a pointer target type */
GH_fake_const.const_ptr = cctkGH;
/* make sure that the input data is synced */
- CCTK_SyncGroup(GH_fake_const.non_const_ptr, CCTK_GroupNameFromVarI(vi));
+ CCTK_SyncGroupI(GH_fake_const.non_const_ptr, gi);
/* z-direction: include lower and upper boundary */
for (k = 0; k < lnz; k++)
@@ -189,13 +223,13 @@ int BndCartoon2DVI(const cGH *cctkGH, int tensortype, int prolongtype, int vi)
switch (prolongtype)
{
case PROLONG_LAGRANGE:
- for (n = 0; n < n_tensortype; n++)
- f[n] = Cartoon2DInterp(cctkGH, cctkGH->data[vi+n][timelevel],
+ for (n = 0; n < n_vars; n++)
+ f[n] = Cartoon2DInterp(cctkGH, cctkGH->data[var0+n][timelevel],
i, di, ijk, rho);
break;
case PROLONG_ENO:
- for (n = 0; n < n_tensortype; n++)
- f[n] = Cartoon2DInterp_ENO(cctkGH, cctkGH->data[vi+n][timelevel], i,
+ for (n = 0; n < n_vars; n++)
+ f[n] = Cartoon2DInterp_ENO(cctkGH, cctkGH->data[var0+n][timelevel], i,
di, ijk, rho);
break;
default:
@@ -204,9 +238,14 @@ int BndCartoon2DVI(const cGH *cctkGH, int tensortype, int prolongtype, int vi)
/* rotate grid tensor by matrix multiplication */
if (tensortype == TENSORTYPE_SCALAR) {
- t = cctkGH->data[vi][timelevel];
- t[ijk+dj] = f[0];
- t[ijk-dj] = f[0];
+ /* Scalar groups can have arbitrary many components; these
+ "components" are then all scalars. */
+ for (n = 0; n < n_vars; n++)
+ {
+ t = cctkGH->data[var0 + n][timelevel];
+ t[ijk+dj] = f[n];
+ t[ijk-dj] = f[n];
+ }
}
else if (tensortype == TENSORTYPE_U) {
tx = cctkGH->data[vi][timelevel];
@@ -264,7 +303,7 @@ int BndCartoon2DVI(const cGH *cctkGH, int tensortype, int prolongtype, int vi)
the const qualifier from a pointer target type */
GH_fake_const.const_ptr = cctkGH;
/* syncs needed after interpolation (actually only for x direction) */
- CCTK_SyncGroup(GH_fake_const.non_const_ptr, CCTK_GroupNameFromVarI(vi));
+ CCTK_SyncGroupI(GH_fake_const.non_const_ptr, gi);
return(0);
}
@@ -298,34 +337,9 @@ void CCTK_FCALL CCTK_FNAME(BndCartoon2DVN)
int BndCartoon2DGN(const cGH *GH, int tensortype, const char *group)
{
DECLARE_CCTK_PARAMETERS
- int n_tensortype, n_group;
+ int n_group;
if (verbose && GH->cctk_iteration==1) CCTK_VInfo(CCTK_THORNSTRING,"Cartoon2D called for %s (message appears only once)", group);
-
- switch (tensortype) {
- case TENSORTYPE_SCALAR:
- n_tensortype = N_TENSORTYPE_SCALAR;
- break;
- case TENSORTYPE_U:
- n_tensortype = N_TENSORTYPE_U;
- break;
- case TENSORTYPE_DDSYM:
- n_tensortype = N_TENSORTYPE_DDSYM;
- break;
- default:
- CCTK_WARN(0,"Tensor type not recognized by Cartoon2D.");
- n_tensortype = 0;
- }
-
- n_group = CCTK_NumVarsInGroup(group);
- if (n_group <0) CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "%s is an invalid group.",group);
- if(n_group != n_tensortype)
- {
- /*printf("group has %d components\n",CCTK_NumVarsInGroup(group));*/
- CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,
- "%s should have only %d component(s).", group, n_tensortype);
- }
return(BndCartoon2DVI(GH, tensortype, PROLONG_LAGRANGE,
CCTK_FirstVarIndex(group)));
diff --git a/src/Cartoon2D_tensors.h b/src/Cartoon2D_tensors.h
index 29c72ec..bbb4fa8 100644
--- a/src/Cartoon2D_tensors.h
+++ b/src/Cartoon2D_tensors.h
@@ -6,11 +6,6 @@
#define TENSORTYPE_U 1
#define TENSORTYPE_DDSYM 2
-/* Number of components */
-#define N_TENSORTYPE_SCALAR 1
-#define N_TENSORTYPE_U 3
-#define N_TENSORTYPE_DDSYM 6
-
/* Prolongation methods */
#define PROLONG_LAGRANGE 1
#define PROLONG_ENO 2