aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--param.ccl6
-rw-r--r--src/Cartoon2DBC.c94
-rw-r--r--src/CheckParameters.c4
-rw-r--r--src/include/cartoon2D.h5
-rw-r--r--src/include/cartoon2D_tensortypes.h12
5 files changed, 84 insertions, 37 deletions
diff --git a/param.ccl b/param.ccl
index f935161..a42b5e8 100644
--- a/param.ccl
+++ b/param.ccl
@@ -3,10 +3,6 @@
private:
-BOOLEAN active "Use cartoon to implement axisymmetry"
-{
-} "no"
-
BOOLEAN verbose "Verbose information"
{
} "no"
@@ -18,5 +14,5 @@ BOOLEAN stencil "Use custom 2D stencil if available"
INT order "Cartoon's interpolation order"
{
- 0:* ::
+ 1:5 ::
} 4
diff --git a/src/Cartoon2DBC.c b/src/Cartoon2DBC.c
index 30730fe..f57d1ce 100644
--- a/src/Cartoon2DBC.c
+++ b/src/Cartoon2DBC.c
@@ -24,25 +24,20 @@ static char *rcsid = "$Id$";
#include "cctk_parameters.h"
#include "cctk_FortranString.h"
-#include "cartoon2D.h"
-
-/* Number of components */
-CCTK_INT tensor_type_n[N_TENSOR_TYPES] = {1, 3, 6};
-
+#include "cartoon2D_tensortypes.h"
+CCTK_INT Cartoon2DBCVar(cGH *GH, CCTK_INT tensortype, const char *var);
+CCTK_INT Cartoon2DBCVarI(cGH *GH, CCTK_INT tensortype, CCTK_INT vi);
CCTK_REAL Cartoon2DInterp(cGH *GH, CCTK_REAL *f, CCTK_INT i, CCTK_INT di,
CCTK_INT ijk, CCTK_REAL x);
CCTK_REAL interpolate_local(CCTK_INT order, CCTK_REAL x0, CCTK_REAL dx,
CCTK_REAL y[], CCTK_REAL x);
-CCTK_INT Cartoon2DBCVarI(cGH *GH, CCTK_INT vi, CCTK_INT tensor_type);
-CCTK_INT Cartoon2DBCVar(cGH *GH, const char *impvarname, CCTK_INT tensortype);
-
-
void FMODIFIER FORTRAN_NAME(Cartoon2DBCVarI)(CCTK_INT *retval, cGH *GH,
- CCTK_INT *vi, CCTK_INT *tensortype);
+ CCTK_INT *tensortype, CCTK_INT *vi);
void FMODIFIER FORTRAN_NAME(Cartoon2DBCVar)(CCTK_INT *retval, cGH *GH,
CCTK_INT *tensortype, ONE_FORTSTRING_ARG);
+
/* set boundaries of a grid tensor assuming axisymmetry
- handles lower boundary in x
- does not touch other boundaries
@@ -58,7 +53,7 @@ void FMODIFIER FORTRAN_NAME(Cartoon2DBCVar)(CCTK_INT *retval, cGH *GH,
cos(phi) etc with messy signs
*/
-CCTK_INT Cartoon2DBCVarI(cGH *GH, CCTK_INT vi, CCTK_INT tensor_type)
+CCTK_INT Cartoon2DBCVarI(cGH *GH, CCTK_INT tensortype, CCTK_INT vi)
{
DECLARE_CCTK_PARAMETERS
@@ -66,6 +61,7 @@ CCTK_INT Cartoon2DBCVarI(cGH *GH, CCTK_INT vi, CCTK_INT tensor_type)
CCTK_INT i, j, k, di, dj, dk, ijk;
CCTK_INT jj, n, s;
CCTK_INT lnx, lny, lnz, ny;
+ CCTK_INT n_tensortype;
CCTK_REAL *xp;
CCTK_REAL x, y, rho;
CCTK_REAL lx0, dx0, dy0;
@@ -74,6 +70,20 @@ CCTK_INT Cartoon2DBCVarI(cGH *GH, CCTK_INT vi, CCTK_INT tensor_type)
CCTK_REAL f[6], fx, fy, fz, fxx, fxy, fxz, fyy, fyz, fzz;
CCTK_REAL *t, *tx, *ty, *tz, *txx, *txy, *txz, *tyy, *tyz, *tzz;
+ 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.");
+ }
+
s = GH->cctk_nghostzones[0];
lnx = GH->cctk_lsh[0];
lny = GH->cctk_lsh[1];
@@ -130,16 +140,16 @@ CCTK_INT Cartoon2DBCVarI(cGH *GH, CCTK_INT vi, CCTK_INT tensor_type)
syy = rxx;
/* interpolate grid functions */
- for (n = 0; n < tensor_type_n[tensor_type]; n++)
+ for (n = 0; n < n_tensortype; n++)
f[n] = Cartoon2DInterp(GH, GH->data[vi+n][0], i, di, ijk, rho);
/* rotate grid tensor by matrix multiplication */
- if (tensor_type == TENSOR_TYPE_SCALAR) {
+ if (tensortype == TENSORTYPE_SCALAR) {
t = GH->data[vi][0];
t[ijk+dj] = f[0];
t[ijk-dj] = f[0];
}
- else if (tensor_type == TENSOR_TYPE_U) {
+ else if (tensortype == TENSORTYPE_U) {
tx = GH->data[vi][0];
ty = GH->data[vi+1][0];
tz = GH->data[vi+2][0];
@@ -155,7 +165,7 @@ CCTK_INT Cartoon2DBCVarI(cGH *GH, CCTK_INT vi, CCTK_INT tensor_type)
ty[ijk-dj] = syx * fx + syy * fy;
tz[ijk-dj] = fz;
}
- else if (tensor_type == TENSOR_TYPE_DDSYM) {
+ else if (tensortype == TENSORTYPE_DDSYM) {
txx = GH->data[vi][0];
txy = GH->data[vi+1][0];
txz = GH->data[vi+2][0];
@@ -192,34 +202,72 @@ CCTK_INT Cartoon2DBCVarI(cGH *GH, CCTK_INT vi, CCTK_INT tensor_type)
}
/* syncs needed after interpolation (actually only for x direction) */
- for (n = 0; n < tensor_type_n[tensor_type]; n++)
- CCTK_SyncGroup(GH, CCTK_GroupNameFromVarI(vi+n));
+ CCTK_SyncGroup(GH, CCTK_GroupNameFromVarI(vi));
return(0);
}
-void FMODIFIER FORTRAN_NAME(Cartoon2DBCVarI)(CCTK_INT *retval, cGH *GH, CCTK_INT *vi, CCTK_INT *tensortype) {
- *retval = Cartoon2DBCVarI(GH, *vi, *tensortype);
+void FMODIFIER FORTRAN_NAME(Cartoon2DBCVarI)(CCTK_INT *retval, cGH *GH, CCTK_INT *tensortype, CCTK_INT *vi) {
+ *retval = Cartoon2DBCVarI(GH, *tensortype, *vi);
}
-CCTK_INT Cartoon2DBCVar(cGH *GH, const char *impvarname, CCTK_INT tensortype)
+CCTK_INT Cartoon2DBCVar(cGH *GH, CCTK_INT tensortype, const char *impvarname)
{
DECLARE_CCTK_PARAMETERS
CCTK_INT vi;
- if (verbose) printf("cartoon_2d_tensorbound called for %s\n", impvarname);
+ if (verbose) printf("cartoon2D called for %s\n", impvarname);
vi = CCTK_VarIndex(impvarname);
- return(Cartoon2DBCVarI(GH, vi, tensortype));
+ return(Cartoon2DBCVarI(GH, tensortype, vi));
}
void FMODIFIER FORTRAN_NAME(Cartoon2DBCVar)(CCTK_INT *retval, cGH *GH, CCTK_INT *tensortype, ONE_FORTSTRING_ARG) {
ONE_FORTSTRING_CREATE(impvarname)
- *retval = Cartoon2DBCVar(GH, impvarname, *tensortype);
+ *retval = Cartoon2DBCVar(GH, *tensortype, impvarname);
free(impvarname);
}
+CCTK_INT Cartoon2DBCGroup(cGH *GH, CCTK_INT tensortype, const char *group)
+{
+ DECLARE_CCTK_PARAMETERS
+
+ CCTK_INT n_tensortype;
+
+ if (verbose) printf("cartoon2D called for %s\n", 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.");
+ }
+
+ if(CCTK_NumVarsInGroup(group) != n_tensortype){
+ char *msg;
+ msg = malloc(1024*sizeof(char));
+ sprintf(msg, "%s should have only %d component(s).\n",
+ group, n_tensortype);
+ CCTK_WARN(0,msg);
+ free(msg);
+ }
+
+ return(Cartoon2DBCVarI(GH, tensortype, CCTK_FirstVarIndex(group)));
+}
+void FMODIFIER FORTRAN_NAME(Cartoon2DBCGroup)(CCTK_INT *retval, cGH *GH, CCTK_INT *tensortype, ONE_FORTSTRING_ARG) {
+ ONE_FORTSTRING_CREATE(group)
+ *retval = Cartoon2DBCGroup(GH, *tensortype, group);
+ free(group);
+}
+
/* interpolation on x-axis */
CCTK_REAL Cartoon2DInterp(cGH *GH, CCTK_REAL *f, CCTK_INT i, CCTK_INT di,
CCTK_INT ijk, CCTK_REAL x)
diff --git a/src/CheckParameters.c b/src/CheckParameters.c
index c7fcc79..78eacee 100644
--- a/src/CheckParameters.c
+++ b/src/CheckParameters.c
@@ -43,10 +43,6 @@ void Cartoon2D_CheckParameters(CCTK_CARGUMENTS)
CCTK_PARAMWARN("Ghostzone width in x direction too small.");
}
- if(order < 1 || order > 5)
- {
- CCTK_PARAMWARN("Interpolation order should be between 1 and 5.");
- }
return;
}
diff --git a/src/include/cartoon2D.h b/src/include/cartoon2D.h
deleted file mode 100644
index 034d577..0000000
--- a/src/include/cartoon2D.h
+++ /dev/null
@@ -1,5 +0,0 @@
-/* tensor types */
-#define TENSOR_TYPE_SCALAR 0
-#define TENSOR_TYPE_U 1
-#define TENSOR_TYPE_DDSYM 2
-#define N_TENSOR_TYPES 3
diff --git a/src/include/cartoon2D_tensortypes.h b/src/include/cartoon2D_tensortypes.h
new file mode 100644
index 0000000..4d0092b
--- /dev/null
+++ b/src/include/cartoon2D_tensortypes.h
@@ -0,0 +1,12 @@
+/* Number of tensor types defined */
+#define N_TENSORTYPES 3
+
+/* Tensor types */
+#define TENSORTYPE_SCALAR 0
+#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