From 13008424c6f9dd16a624e072c358557e71f6a225 Mon Sep 17 00:00:00 2001 From: eschnett Date: Mon, 18 Jun 2012 01:45:48 +0000 Subject: Implement GetBoundarySizesAndTypes Provide aliased function GetBoundarySizesAndTypes that describes which faces have what size and what type. git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/CoordBase/trunk@53 0337457d-221f-4ee6-a5f0-14255d5370d8 --- src/Domain.c | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 115 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Domain.c b/src/Domain.c index 53ac817..75272a0 100644 --- a/src/Domain.c +++ b/src/Domain.c @@ -1,9 +1,6 @@ -/* $Header$ */ - - - -#include "cctk.h" -#include "cctk_Parameters.h" +#include +#include +#include @@ -380,3 +377,115 @@ CCTK_INT CoordBase_ConvertFromExteriorBoundary return 0; } + + + +CCTK_INT CoordBase_GetBoundarySizesAndTypes + (CCTK_POINTER_TO_CONST const cctkGH_, + CCTK_INT const size, + CCTK_INT * restrict const bndsize, + CCTK_INT * restrict const is_ghostbnd, + CCTK_INT * restrict const is_symbnd, + CCTK_INT * restrict const is_physbnd) +{ + cGH const * restrict const cctkGH = cctkGH_; + + /* Check arguments */ + int const dim = cctkGH->cctk_dim; + if (size != 2*dim) { + CCTK_WARN(CCTK_WARN_ABORT, "Inconsistent size argument"); + } + + /* Obtain multi-patch bbox information, specifying which boundaries + are set by a multi-patch system (bbox=1) and which by a physical + boundary condition (bbox=0) */ + CCTK_INT mp_bbox[2*dim]; + if (CCTK_IsFunctionAliased("MultiPatch_GetBbox")) { + int const ierr = MultiPatch_GetBbox(cctkGH, 2*dim, mp_bbox); + if (ierr != 0) { + CCTK_WARN(CCTK_WARN_ABORT, + "Could not obtain multi-patch bbox specification"); + } + } else { + for (int d=0; d<2*dim; ++d) { + mp_bbox[d] = 0; + } + } + + /* Obtain boundary information */ + CCTK_INT nboundaryzones[2*dim]; + CCTK_INT is_internal[2*dim]; + CCTK_INT is_staggered[2*dim]; + CCTK_INT shiftout[2*dim]; + if (CCTK_IsFunctionAliased("MultiPatch_GetBoundarySpecification")) { + /* We are using a multi-patch system */ + int const map = MultiPatch_GetMap(cctkGH); + if (map < 0) { + CCTK_WARN(CCTK_WARN_ABORT, "Could not determine current map (need to be called in local mode)"); + } + int const ierr = MultiPatch_GetBoundarySpecification + (map, 2*dim, nboundaryzones, is_internal, is_staggered, shiftout); + if (ierr != 0) { + CCTK_WARN(CCTK_WARN_ABORT, "Could not obtain boundary specification"); + } + } else if (CCTK_IsFunctionAliased("GetBoundarySpecification")) { + /* We are not using a multi-patch system */ + int const ierr = GetBoundarySpecification + (2*dim, nboundaryzones, is_internal, is_staggered, shiftout); + if (ierr != 0) { + CCTK_WARN(CCTK_WARN_ABORT, "Could not obtain boundary specification"); + } + } else { + CCTK_WARN(CCTK_WARN_ABORT, "Could not obtain boundary specification"); + } + + /* Obtain symmetry information */ + int const symtable = SymmetryTableHandleForGrid(cctkGH); + if (symtable < 0) { + CCTK_WARN(CCTK_WARN_ABORT, "Could not obtain symmetry table"); + } + CCTK_INT symbnd[2*dim]; + int const iret = + Util_TableGetIntArray(symtable, 2*dim, symbnd, "symmetry_handle"); + if (iret != 2*dim) { + CCTK_WARN(CCTK_WARN_ABORT, "Could not obtain symmetry information"); + } + + /* Determine boundary types */ + for (int d=0; d<2*dim; ++d) { + /* Ghost boundaries (inter-process or mesh refinement boundaries) + have cctk_bbox=0 */ + is_ghostbnd[d] = !cctkGH->cctk_bbox[d]; + /* Symmetry boundaries are not ghost boundaries, are described as + symmetry boundaries, and are not multi-patch outer + boundaries */ + is_symbnd [d] = !is_ghostbnd[d] && symbnd[d]>=0 && !mp_bbox[d]; + /* Physical (outer) boundaries are all other boundaries */ + is_physbnd[d] = !is_ghostbnd[d] && !is_symbnd[d]; + } + + /* Determine boundary sizes */ + for (int dir=0; dircctk_nghostzones[dir]; + } else { + /* Symmetry or physical boundary */ + bndsize[2*dir+face] = nboundaryzones[2*dir+face]; + + if (is_symbnd[2*dir+face]) { + /* Ensure that the number of symmetry zones is the same as + the number of ghost zones */ + if (bndsize[2*dir+face] != cctkGH->cctk_nghostzones[dir]) { + CCTK_WARN(CCTK_WARN_ALERT, + "The number of symmetry points is different from the number of ghost points; this is probably an error"); + } + } + } + } + } + + return 0; +} -- cgit v1.2.3