aboutsummaryrefslogtreecommitdiff
path: root/src/CopyBoundary.c
diff options
context:
space:
mode:
authorallen <allen@6a38eb6e-646e-4a02-a296-d141613ad6c4>2000-07-12 10:55:41 +0000
committerallen <allen@6a38eb6e-646e-4a02-a296-d141613ad6c4>2000-07-12 10:55:41 +0000
commit35e47f97ca82d39e84faa5568233ffeacc4389fc (patch)
tree4570c47d2cd08252bb8c22991ebc3a3a57c0a271 /src/CopyBoundary.c
parent9d2f55120f794d823382d71b6c1690af07c8ff49 (diff)
Tidied up a lot, so that everything is in one file, and the wrappers
only have code in one call. NOTE: A lot of the routine names have unfortunately changed again, this time we hope we have fixed on a standard. The old names are still there until the next release, but you will get a warning message every time you call one. git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/Boundary/trunk@111 6a38eb6e-646e-4a02-a296-d141613ad6c4
Diffstat (limited to 'src/CopyBoundary.c')
-rw-r--r--src/CopyBoundary.c494
1 files changed, 467 insertions, 27 deletions
diff --git a/src/CopyBoundary.c b/src/CopyBoundary.c
index 8614bbd..6ae555e 100644
--- a/src/CopyBoundary.c
+++ b/src/CopyBoundary.c
@@ -1,4 +1,11 @@
-/*#define DEBUG_BOUND*/
+ /*@@
+ @file ScalarBoundary.c
+ @date Mon Mar 15 15:09:00 1999
+ @author Gerd Lanfermann, Gabrielle Allen
+ @desc
+ Wrappers for calling routines for applying scalar boundary conditions
+ @enddesc
+ @@*/
#include <stdio.h>
#include <assert.h>
@@ -8,17 +15,361 @@
#include <string.h>
#include "cctk.h"
-#include "cctk_Parameters.h"
#include "cctk_FortranString.h"
+#include "cctk_Parameters.h"
-#include "Boundary.h"
#include "Symmetry.h"
+#include "Boundary.h"
-#include "cctk_Parameters.h"
+/* Internal routine prototypes */
+
+static int BndApplyCopy3Di(cGH *GH,
+ int gdim,
+ int *doBC,
+ int *lssh,
+ int *stencil_size,
+ CCTK_REAL *var,
+ CCTK_REAL *varp);
+
+static int BndApplyCopy2Di(cGH *GH,
+ int gdim,
+ int *doBC,
+ int *lssh,
+ int *stencil_size,
+ CCTK_REAL *var,
+ CCTK_REAL *varp);
+
+static int BndApplyCopy1Di(cGH *GH,
+ int gdim,
+ int *doBC,
+ int *lssh,
+ int *stencil_size,
+ CCTK_REAL *var,
+ CCTK_REAL *varp);
+
+static int ApplyBndCopy(cGH *GH,
+ int *stencil,
+ int first_var,
+ int second_var,
+ int num_vars);
+
+/* Local variables */
+
+
+
+/********************************************************************
+ ******************** External Routines ************************
+ ********************************************************************/
+
+/*@@
+ @routine BndCopyVI
+ @date Thu Mar 2 11:02:10 2000
+ @author Gerd Lanfermann
+ @desc
+ Apply copy boundary routines by var index
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
+
+@@*/
+
+int BndCopyVI(cGH *GH,
+ int *stencil,
+ int vi_to,
+ int vi_from)
+{
+ return ApplyBndCopy(GH,stencil,vi_to,vi_from,1);
+}
-static char *rcsid = "$Header$";
+void CCTK_FCALL CCTK_FNAME(BndCopyVI)
+ (int *ierr,
+ cGH *GH,
+ int *stencil,
+ int *vi_to,
+ int *vi_from)
+{
+ *ierr = BndCopyVI(GH, stencil, *vi_to, *vi_from);
+}
+
+
+
+ /*@@
+ @routine BndCopyGI
+ @date Thu Mar 2 11:07:11 2000
+ @author Gerd Lanfermann
+ @desc
+ Apply copy boundaries by group index
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
+
+@@*/
+
+int BndCopyGI(cGH *GH,
+ int *stencil,
+ int gi_to,
+ int gi_from)
+{
+ int first_vi_to,first_vi_from;
+ int numvars;
+
+ first_vi_to = CCTK_FirstVarIndexI(gi_to);
+ first_vi_from= CCTK_FirstVarIndexI(gi_from);
+ numvars = CCTK_NumVarsInGroupI(gi_to);
+
+ return ApplyBndCopy(GH,stencil,first_vi_to,first_vi_from,numvars);
+}
+
+void CCTK_FCALL CCTK_FNAME(BndCopyGI)
+ (int *ierr,
+ cGH *GH,
+ int *stencil,
+ int *gi_to,
+ int *gi_from)
+{
+ *ierr = BndCopyGI(GH, stencil, *gi_to, *gi_from);
+}
+
+
+
+/*@@
+ @routine BndCopyGN
+ @date Thu Mar 2 11:02:10 2000
+ @author Gerd Lanfermann
+ @desc
+ Apply copy boundary routines by group name
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
+
+@@*/
+
+int BndCopyGN(cGH *GH,
+ int *stencil,
+ const char *gn_to,
+ const char *gn_from)
+{
+ int retval;
+ int gi_to, gi_from;
+
+ gi_to = CCTK_GroupIndex(gn_to);
+ gi_from = CCTK_GroupIndex(gn_from);
+
+ if ((gi_to>-1)&&(gi_from>-1))
+ retval = BndCopyGI(GH, stencil, gi_to, gi_from);
+ else
+ {
+ CCTK_VWarn(2,__LINE__,__FILE__,"Boundary",
+ "BndCopyGN: Cannot find group indices for %s, %s ",
+ gn_to,gn_from);
+ retval = -1;
+ }
+
+ return retval;
+
+}
+
+void CCTK_FCALL CCTK_FNAME(BndCopyGN)
+ (int *ierr,
+ cGH *GH,
+ int *stencil,
+ TWO_FORTSTRINGS_ARGS)
+{
+ TWO_FORTSTRINGS_CREATE(gn_to, gn_from)
+ *ierr = BndCopyGN(GH, stencil, gn_to, gn_from);
+ free(gn_to);
+ free(gn_from);
+}
+
+
+
+/*@@
+ @routine BndCopyVN
+ @date Thu Mar 2 11:02:10 2000
+ @author Gerd Lanfermann
+ @desc
+ Apply copy boundary routines by variable name
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
+
+@@*/
+
+int BndCopyVN(cGH *GH,
+ int *stencil,
+ const char *vn_to,
+ const char *vn_from)
+{
+ int vi_to, vi_from;
+ int retval;
+
+ vi_to = CCTK_VarIndex(vn_to);
+ vi_from = CCTK_VarIndex(vn_from);
+
+ if ((vi_to>-1)&&(vi_from>-1))
+ retval = BndCopyVI(GH, stencil, vi_to, vi_from);
+ else
+ {
+ CCTK_VWarn(2,__LINE__,__FILE__,"Boundary",
+ "BndCopyVN: Cannot find variable indices for %s, %s",
+ vn_to,vn_from);
+ retval = -1;
+ }
+
+ return retval;
+}
+
+void CCTK_FCALL CCTK_FNAME(BndCopyVN)
+ (int *ierr,
+ cGH *GH,
+ int *stencil,
+ TWO_FORTSTRINGS_ARGS)
+{
+ TWO_FORTSTRINGS_CREATE(vn_to, vn_from)
+ *ierr = BndCopyVN(GH, stencil, vn_to, vn_from);
+ free(vn_to);
+ free(vn_from);
+ return;
+}
+
+
+
+/********************************************************************
+ ********************* Local Routines *************************
+ ********************************************************************/
+
+/*@@
+ @routine ApplyBndCopy
+ @date Thu Mar 2 11:02:10 2000
+ @author Gerd Lanfermann
+ @desc
+ Apply copy boundary routines by group index
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
+
+@@*/
+
+static int ApplyBndCopy(cGH *GH,
+ int *stencil,
+ int first_var,
+ int second_var,
+ int num_vars)
+{
+ int symmetry_handle; /* handle for the optional symmetry structure */
+ int vi, vi2, gi, dim;
+ int idim;
+ int berr,ierr;
+ int *doBC, *dstag, *lssh;
+ SymmetryGHex *sGHex;
+
+ /* See if we have a symmetry array */
+ symmetry_handle = CCTK_GHExtensionHandle("Symmetry");
+ if (symmetry_handle < 0)
+ {
+ sGHex = NULL;
+ }
+ else
+ {
+ sGHex = (SymmetryGHex*)GH->extensions[symmetry_handle];
+ }
+
+ /* Get group dimension */
+ dim = CCTK_GroupDimFromVarI(first_var);
+
+ /* allocate arrays */
+ doBC = (int *)malloc((2*dim)*sizeof(int));
+ dstag = (int *)malloc(dim*sizeof(int));
+ lssh = (int *)malloc(dim*sizeof(int));
+
+ /* get the directional staggering of the group */
+ gi = CCTK_GroupIndexFromVarI(first_var);
+ ierr = CCTK_GroupStaggerDirArrayGI(dstag, dim, gi);
+
+ for (vi=first_var; vi<first_var+num_vars; vi++)
+ {
+ vi2 = (vi-first_var+second_var);
+
+ /* Apply condition if:
+ + boundary is not a symmetry boundary
+ (no symmetry or unset(=unsed))
+ + boundary is a physical boundary
+ + have enough grid points
+ */
+ if (sGHex)
+ {
+ for (idim=0;idim<dim;idim++)
+ {
+ doBC[idim*2] = (((sGHex->GFSym[vi][idim*2]==GFSYM_NOSYM)||
+ (sGHex->GFSym[vi][idim*2]==GFSYM_UNSET)) &&
+ GH->cctk_lsh[idim]>1 && GH->cctk_bbox[idim*2]);
+ doBC[idim*2+1] = (((sGHex->GFSym[vi][idim*2+1]==GFSYM_NOSYM)||
+ (sGHex->GFSym[vi][idim*2+1]==GFSYM_UNSET)) &&
+ GH->cctk_lsh[idim]>1 && GH->cctk_bbox[idim*2+1]);
+ lssh[idim] = GH->cctk_lssh[CCTK_LSSH_IDX(dstag[idim],idim)];
+ }
+ }
+ else
+ {
+ for (idim=0;idim<dim;idim++)
+ {
+ doBC[idim*2] = (GH->cctk_lsh[idim]>1 && GH->cctk_bbox[idim*2]);
+ doBC[idim*2+1] = (GH->cctk_lsh[idim]>1 && GH->cctk_bbox[idim*2+1]);
+ lssh[idim] = GH->cctk_lssh[CCTK_LSSH_IDX(dstag[idim],idim)];
+ }
+ }
+
+
+ switch (dim)
+ {
+ case 1: berr = BndApplyCopy1Di(GH,
+ dim,
+ doBC,
+ lssh,
+ stencil,
+ GH->data[vi][0],
+ GH->data[vi2][0]); break;
+ case 2: berr = BndApplyCopy2Di(GH,
+ dim,
+ doBC,
+ lssh,
+ stencil,
+ GH->data[vi][0],
+ GH->data[vi2][0]); break;
+ case 3: berr = BndApplyCopy3Di(GH,
+ dim,
+ doBC,
+ lssh,
+ stencil,
+ GH->data[vi][0],
+ GH->data[vi2][0]); break;
+ default : berr = -1; CCTK_WARN(1, "No BC for dim>3");
+ }
+ berr = (berr>-1) ? 0 : -1;
+ }
+
+ free(dstag);
+ free(doBC);
+ free(lssh);
+
+ return(ierr);
+}
-CCTK_FILEVERSION(CactusBase_Boundary_CopyBoundary_c)
/*@@
@@ -37,13 +388,13 @@ CCTK_FILEVERSION(CactusBase_Boundary_CopyBoundary_c)
@@*/
-int BndApplyCopy3Di(cGH *GH,
- int gdim,
- int *doBC,
- int *lssh,
- int *stencil_size,
- CCTK_REAL *var,
- CCTK_REAL *varp)
+static int BndApplyCopy3Di(cGH *GH,
+ int gdim,
+ int *doBC,
+ int *lssh,
+ int *stencil_size,
+ CCTK_REAL *var,
+ CCTK_REAL *varp)
{
int i,j,k,sw,lin;
@@ -147,6 +498,7 @@ int BndApplyCopy3Di(cGH *GH,
}
+
/*@@
@routine BndApplyCopy2Di
@date Thu Mar 2 11:04:52 2000
@@ -163,13 +515,13 @@ int BndApplyCopy3Di(cGH *GH,
@@*/
-int BndApplyCopy2Di(cGH *GH,
- int gdim,
- int *doBC,
- int *lssh,
- int *stencil_size,
- CCTK_REAL *var,
- CCTK_REAL *varp)
+static int BndApplyCopy2Di(cGH *GH,
+ int gdim,
+ int *doBC,
+ int *lssh,
+ int *stencil_size,
+ CCTK_REAL *var,
+ CCTK_REAL *varp)
{
int i,j,sw,lin;
@@ -229,6 +581,8 @@ int BndApplyCopy2Di(cGH *GH,
return(0);
}
+
+
/*@@
@routine BndApplyCopy1Di
@date Thu Mar 2 11:04:52 2000
@@ -245,13 +599,13 @@ int BndApplyCopy2Di(cGH *GH,
@@*/
-int BndApplyCopy1Di(cGH *GH,
- int gdim,
- int *doBC,
- int *lssh,
- int *stencil_size,
- CCTK_REAL *var,
- CCTK_REAL *varp)
+static int BndApplyCopy1Di(cGH *GH,
+ int gdim,
+ int *doBC,
+ int *lssh,
+ int *stencil_size,
+ CCTK_REAL *var,
+ CCTK_REAL *varp)
{
int sw,lin;
@@ -279,3 +633,89 @@ int BndApplyCopy1Di(cGH *GH,
return(0);
}
+
+
+
+/********************************************************************
+ ********************* DEPRECATED: Beta 8 **********************
+ ********************************************************************/
+
+int CopyBCGroup(cGH *GH,
+ int *stencil_size,
+ const char *impgrpname,
+ const char *imppgrpname)
+{
+ CCTK_WARN(1,"CopyBCGroup: ROUTINE DEPRECATED, see Beta8 release notices");
+ return(BndCopyGN(GH,stencil_size,impgrpname,imppgrpname));
+}
+
+void CCTK_FCALL CCTK_FNAME(CopyBCGroup)(int *retval,
+ cGH *GH,
+ int *stencil_size,
+ TWO_FORTSTRINGS_ARGS)
+{
+ TWO_FORTSTRINGS_CREATE(impgrpname,imppgrpname)
+ CCTK_WARN(1,"CopyBCGroup: ROUTINE DEPRECATED, see Beta8 release notices");
+ *retval = BndCopyGN(GH, stencil_size, impgrpname,imppgrpname);
+ free(impgrpname);
+ free(imppgrpname);
+}
+
+int CopyBCGroupI(cGH *GH,
+ int *stencil_size,
+ int gi,
+ int gip)
+{
+ CCTK_WARN(1,"CopyBCGroupI: ROUTINE DEPRECATED, see Beta8 release notices");
+ return(BndCopyGI(GH,stencil_size,gi,gip));
+}
+
+void CCTK_FCALL CCTK_FNAME(CopyBCGroupI)(int *retval,
+ cGH *GH,
+ int *stencil_size,
+ int *gi,
+ int *gip)
+{
+ CCTK_WARN(1,"CopyBCGroupI: ROUTINE DEPRECATED, see Beta8 release notices");
+ *retval = BndCopyGI(GH, stencil_size, *gi, *gip);
+}
+
+int CopyBCVar(cGH *GH,
+ int *stencil_size,
+ const char *impvarname,
+ const char *imppvarname)
+{
+ CCTK_WARN(1,"CopyBCVar: ROUTINE DEPRECATED, see Beta8 release notices");
+ return(BndCopyVN(GH, stencil_size, impvarname,imppvarname));
+}
+
+void CCTK_FCALL CCTK_FNAME(CopyBCVar)(int *retval,
+ cGH *GH,
+ int *stencil_size,
+ TWO_FORTSTRINGS_ARGS)
+{
+ TWO_FORTSTRINGS_CREATE(impvarname,imppvarname)
+ CCTK_WARN(1,"CopyBCVar: ROUTINE DEPRECATED, see Beta8 release notices");
+ *retval = BndCopyVN(GH, stencil_size, impvarname, imppvarname);
+ free(impvarname);
+ free(imppvarname);
+}
+
+int CopyBCVarI(cGH *GH,
+ int *stencil_size,
+ int vi,
+ int vip)
+{
+ CCTK_WARN(1,"CopyBCVarI: ROUTINE DEPRECATED, see Beta8 release notices");
+ return(BndCopyVI(GH, stencil_size, vi, vip));
+}
+
+void CCTK_FCALL CCTK_FNAME(CopyBCVarI)(int *retval,
+ cGH *GH,
+ int *stencil_size,
+ int *vi,
+ int *vip)
+{
+ CCTK_WARN(1,"CopyBCVarI: ROUTINE DEPRECATED, see Beta8 release notices");
+ *retval = BndCopyVI(GH,stencil_size, *vi,*vip);
+}