diff options
author | schnetter <schnetter@1bf05452-ddb3-4880-bfa1-00436340132b> | 2003-05-06 11:45:52 +0000 |
---|---|---|
committer | schnetter <schnetter@1bf05452-ddb3-4880-bfa1-00436340132b> | 2003-05-06 11:45:52 +0000 |
commit | 24ab84c1b08adfad5c1fa8d6a65bb923a6474709 (patch) | |
tree | 7dcfe980747c004592fa0e94f9a98171bcf9209b | |
parent | 7d957cbc6da68f0b6bc24065ee7ada778f688a70 (diff) |
Works.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/Periodic/trunk@3 1bf05452-ddb3-4880-bfa1-00436340132b
-rw-r--r-- | doc/documentation.tex | 62 | ||||
-rw-r--r-- | interface.ccl | 9 | ||||
-rw-r--r-- | schedule.ccl | 5 | ||||
-rw-r--r-- | src/make.code.defn | 2 | ||||
-rw-r--r-- | src/periodic.c | 91 | ||||
-rw-r--r-- | 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 <assert.h> #include <stdlib.h> +#include <stdio.h> #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<CCTK_NumGroups()); return BndPeriodicGI (cctkGH, stencil, gi); } + + + +void +Periodic_ApplyBC (cGH const * restrict const cctkGH) +{ + int nvars; + CCTK_INT * restrict indices; + CCTK_INT * restrict faces; + CCTK_INT * restrict widths; + CCTK_INT * restrict tables; + int vi; + int dim; + int * restrict stencil; + int i; + int d; + int ierr; + + assert (cctkGH); + + nvars = Boundary_SelectedGVs (cctkGH, 0, 0, 0, 0, 0, 0); + assert (nvars>=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<nvars; ++i) { + vi = indices[i]; + assert (vi>=0 && vi<CCTK_NumVars()); + + assert (widths[i] >= 0); + + dim = CCTK_GroupDimFromVarI (vi); + assert (dim>=0); + + stencil = malloc (dim * sizeof *stencil); + assert (stencil); +#if 0 + for (d=0; d<dim; ++d) { + stencil[d] = widths[i]; + } +#endif + ierr = CCTK_GroupnghostzonesVI (cctkGH, dim, stencil, vi); + assert (!ierr); + + ierr = BndPeriodicVI (cctkGH, stencil, vi); + assert (!ierr); + + free (stencil); + } + + free (indices); + free (faces); + free (widths); + free (tables); +} diff --git a/src/periodic.h b/src/periodic.h index 2f381f3..c423c73 100644 --- a/src/periodic.h +++ b/src/periodic.h @@ -25,5 +25,10 @@ BndPeriodicGN (cGH const * restrict const cctkGH, int const * restrict const stencil, char const * restrict const gn); + + +void +Periodic_ApplyBC (cGH const * restrict const cctkGH); + #endif /* defined PERIODIC_H */ |