From 24ab84c1b08adfad5c1fa8d6a65bb923a6474709 Mon Sep 17 00:00:00 2001 From: schnetter Date: Tue, 6 May 2003 11:45:52 +0000 Subject: Works. git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/Periodic/trunk@3 1bf05452-ddb3-4880-bfa1-00436340132b --- doc/documentation.tex | 62 ++++++++++++++++++++--------------- interface.ccl | 9 +++++ schedule.ccl | 5 +++ src/make.code.defn | 2 +- src/periodic.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++----- src/periodic.h | 5 +++ 6 files changed, 139 insertions(+), 35 deletions(-) diff --git a/doc/documentation.tex b/doc/documentation.tex index c848aa9..45cef5f 100644 --- a/doc/documentation.tex +++ b/doc/documentation.tex @@ -82,12 +82,11 @@ \author{Erik Schnetter \textless schnetter@uni-tuebingen.de\textgreater} % The title of the document (not necessarily the name of the Thorn) -\title{} +\title{Periodic} % the date your document was last changed, if your document is in CVS, % please use: -% \date{$ $Date$ $} -\date{May 05 2003} +\date{$ $Date$ $} \maketitle @@ -99,7 +98,7 @@ % Add an abstract for this thorn's documentation \begin{abstract} - + Provide periodic boundary conditions. \end{abstract} % The following sections are suggestive only. @@ -107,36 +106,47 @@ \section{Introduction} -\section{Physical System} - -\section{Numerical Implementation} + This thorn provides periodic boundary conditions that are + independent of PUGH, i.e.\ they work with both PUGH and Carpet. + They use the new boundary condition scheme, so that no changes to + existing code and only small changes to existing parameter files + are necessary. Currently, thorn \texttt{Periodic} works in single + patch mode only. \section{Using This Thorn} -\subsection{Obtaining This Thorn} - -\subsection{Basic Usage} + Make sure that the other symmetry thorns (e.g.\ + \texttt{CartGrid3D}) do not provide symmetry boundary conditions + for the same boundaries as \texttt{Periodic}. Then activate thorn + \texttt{Periodic} and thorn \texttt{Slab}. Set the parameters + \texttt{Periodic::periodic*} according to your wishes. -\subsection{Special Behaviour} +\subsection{Obtaining This Thorn} -\subsection{Interaction With Other Thorns} + This thorn (and thorn \texttt{Slab}) are available in the + \texttt{TAT} arrangement. \subsection{Examples} -\subsection{Support and Feedback} - -\section{History} - -\subsection{Thorn Source Code} - -\subsection{Thorn Documentation} - -\subsection{Acknowledgements} - - -\begin{thebibliography}{9} - -\end{thebibliography} + The following lines come from a WaveToy simulation with Carpet: +\begin{verbatim} + driver::global_nx = 19 + driver::global_ny = 26 + driver::global_nz = 34 + + driver::ghost_size = 2 + + grid::type = byrange + grid::xmin = -5.4 + grid::ymin = -7.2 + grid::zmin = -9.6 + grid::xmax = 5.4 + grid::ymax = 7.8 + grid::zmax = 10.2 + grid::domain = full + + periodic::periodic = yes +\end{verbatim} % Do not delete next line % END CACTUS THORNGUIDE diff --git a/interface.ccl b/interface.ccl index c551dc3..2b33d82 100644 --- a/interface.ccl +++ b/interface.ccl @@ -7,3 +7,12 @@ INHERITS: Slab INCLUDES HEADER: periodic.h IN Periodic.h USES INCLUDE HEADER: Slab.h + + + + +CCTK_INT FUNCTION Boundary_SelectedGVs(CCTK_POINTER IN GH, \ + CCTK_INT IN array_size, CCTK_INT ARRAY OUT var_indicies, \ + CCTK_INT ARRAY OUT faces, CCTK_INT ARRAY OUT boundary_widths, \ + CCTK_INT ARRAY OUT table_handles, CCTK_STRING IN bc_name) +USES FUNCTION Boundary_SelectedGVs diff --git a/schedule.ccl b/schedule.ccl index 1ad8254..9be1b93 100644 --- a/schedule.ccl +++ b/schedule.ccl @@ -1,2 +1,7 @@ # Schedule definitions for thorn Periodic # $Header$ + +SCHEDULE Periodic_ApplyBC IN BoundaryConditions +{ + LANG: C +} "Apply periodic boundary conditions" diff --git a/src/make.code.defn b/src/make.code.defn index a62de81..8c52d6b 100644 --- a/src/make.code.defn +++ b/src/make.code.defn @@ -2,7 +2,7 @@ # $Header$ # Source files in this directory -SRCS = +SRCS = periodic.c # Subdirectories containing source files SUBDIRS = diff --git a/src/periodic.c b/src/periodic.c index feb6aec..7339d9e 100644 --- a/src/periodic.c +++ b/src/periodic.c @@ -2,10 +2,11 @@ #include #include +#include #include "cctk.h" #include "cctk_Parameters.h" #include "Slab.h" -#include "Periodic.h" +#include "periodic.h" static const char * restrict const rcsid = "$Header$"; CCTK_FILEVERSION(TAT_Periodic_periodic_c); @@ -17,6 +18,8 @@ BndPeriodicVI (cGH const * restrict const cctkGH, int const * restrict const stencil, int const vi) { + DECLARE_CCTK_PARAMETERS; + cGroup group; cGroupDynamicData data; void * restrict varptr; @@ -53,6 +56,11 @@ BndPeriodicVI (cGH const * restrict const cctkGH, do_periodic[1] = periodic || periodic_y; do_periodic[2] = periodic || periodic_z; + printf ("BndPeriodicVI var=%s\n", CCTK_FullName(vi)); + for (d=0; d<3; ++d) { + printf (" d=%d per=%d ste=%d\n", d, do_periodic[d], stencil[d]); + } + /* Allocate slab transfer description */ xferinfo = malloc(group.dim * sizeof *xferinfo); assert (xferinfo); @@ -91,19 +99,20 @@ BndPeriodicVI (cGH const * restrict const cctkGH, if (f==0) { /* Fill in lower face */ - xferinfo[dir].src.off = data.lsh[d] - data.nghostzones[d]; - xferinfo[dir].src.len = data.nghostzones[d]; - xferinfo[dir].dst.len = data.nghostzones[d]; + xferinfo[dir].src.off = data.gsh[dir] - 2 * stencil[dir]; + xferinfo[dir].src.len = stencil[dir]; + xferinfo[dir].dst.len = stencil[dir]; } else { /* Fill in upper face */ - xferinfo[dir].src.len = data.nghostzones[d]; - xferinfo[dir].dst.off = data.lsh[d] - data.nghostzones[d]; - xferinfo[dir].dst.len = data.nghostzones[d]; + xferinfo[dir].src.off = stencil[dir]; + xferinfo[dir].src.len = stencil[dir]; + xferinfo[dir].dst.off = data.gsh[dir] - stencil[dir]; + xferinfo[dir].dst.len = stencil[dir]; } ierr = Slab_Transfer (cctkGH, group.dim, xferinfo, -1, group.vartype, varptr, group.vartype, varptr); - assert (ierr); + assert (!ierr); } /* for f */ @@ -161,3 +170,69 @@ BndPeriodicGN (cGH const * restrict const cctkGH, assert (gi>=0 && gi=0); + + 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 (i=0; i=0 && vi= 0); + + dim = CCTK_GroupDimFromVarI (vi); + assert (dim>=0); + + stencil = malloc (dim * sizeof *stencil); + assert (stencil); +#if 0 + for (d=0; d