Skip to content

Commit

Permalink
register Boundary conditions with Driver if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenrbrandt authored and rhaas80 committed May 27, 2020
1 parent 8b36a2a commit 8431587
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 8 deletions.
45 changes: 45 additions & 0 deletions Auxiliary/Cactus/SourceFiles/Kranc.hh
Expand Up @@ -46,6 +46,48 @@ typedef void(*Kranc_Calculation)(cGH const * restrict cctkGH,

// Boundary information

CCTK_ATTRIBUTE_UNUSED
static CCTK_INT KrancBdy_SelectVarForBC(
const CCTK_POINTER_TO_CONST cctkGH_,
const CCTK_INT faces,
const CCTK_INT width,
const CCTK_INT table_handle,
const CCTK_STRING var_name,
const CCTK_STRING bc_name) {

static bool is_aliased = CCTK_IsFunctionAliased("Driver_SelectGroupForBC");

int ierr = 0;

ierr = Boundary_SelectVarForBC(cctkGH_,faces,width,table_handle,var_name,bc_name);

if(ierr == 0 && is_aliased)
ierr = Driver_SelectVarForBC(cctkGH_,faces,width,table_handle,var_name,bc_name);

return ierr;
}

CCTK_ATTRIBUTE_UNUSED
static CCTK_INT KrancBdy_SelectGroupForBC(
const CCTK_POINTER_TO_CONST cctkGH_,
const CCTK_INT faces,
const CCTK_INT width,
const CCTK_INT table_handle,
const CCTK_STRING group_name,
const CCTK_STRING bc_name) {

static bool is_aliased = CCTK_IsFunctionAliased("Driver_SelectGroupForBC");

int ierr;

ierr = Boundary_SelectGroupForBC(cctkGH_,faces,width,table_handle,group_name,bc_name);

if(ierr == 0 && is_aliased)
ierr = Driver_SelectGroupForBC(cctkGH_,faces,width,table_handle,group_name,bc_name);

return ierr;
}

int GetBoundaryWidth(cGH const * restrict const cctkGH);

void GetBoundaryInfo(cGH const * restrict cctkGH,
Expand Down Expand Up @@ -173,4 +215,7 @@ KRANC_WHERE static inline int isgn(CCTK_REAL x)

} // namespace @THORN_NAME@

using @THORN_NAME@::KrancBdy_SelectVarForBC;
using @THORN_NAME@::KrancBdy_SelectGroupForBC;

#endif // #ifndef KRANC_HH
8 changes: 8 additions & 0 deletions Tools/CodeGen/CactusBoundary.m
Expand Up @@ -58,7 +58,15 @@
Type -> "CCTK_INT",
ArgString -> "CCTK_POINTER_TO_CONST IN GH, CCTK_INT IN faces, CCTK_INT IN boundary_width, CCTK_INT IN table_handle, CCTK_STRING IN group_name, CCTK_STRING IN bc_name"},

{Name -> "Driver_SelectGroupForBC",
Type -> "CCTK_INT",
ArgString -> "CCTK_POINTER_TO_CONST IN GH, CCTK_INT IN faces, CCTK_INT IN boundary_width, CCTK_INT IN table_handle, CCTK_STRING IN group_name, CCTK_STRING IN bc_name"},

{Name -> "Boundary_SelectVarForBC",
Type -> "CCTK_INT",
ArgString -> "CCTK_POINTER_TO_CONST IN GH, CCTK_INT IN faces, CCTK_INT IN boundary_width, CCTK_INT IN table_handle, CCTK_STRING IN var_name, CCTK_STRING IN bc_name"},

{Name -> "Driver_SelectVarForBC",
Type -> "CCTK_INT",
ArgString -> "CCTK_POINTER_TO_CONST IN GH, CCTK_INT IN faces, CCTK_INT IN boundary_width, CCTK_INT IN table_handle, CCTK_STRING IN var_name, CCTK_STRING IN bc_name"}
};
Expand Down
2 changes: 1 addition & 1 deletion Tools/CodeGen/CalculationBoundaries.m
Expand Up @@ -62,7 +62,7 @@
selectGroup[g_String] :=
Module[{},
{(* "table = GenericFD_BoundaryWidthTable(cctkGH);\n", *)
"ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GetBoundaryWidth(cctkGH), -1 /* no table */, ",
"ierr = KrancBdy_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, GetBoundaryWidth(cctkGH), -1 /* no table */, ",
Quote[g], ",", Quote["flat"], ");\n",
"if (ierr < 0)\n",
" CCTK_WARN(CCTK_WARN_ALERT, " <> Quote["Failed to register flat BC for "<>g<>"."] <> ");\n" }];
Expand Down
14 changes: 7 additions & 7 deletions Tools/CodeGen/MoL.m
Expand Up @@ -206,7 +206,7 @@
" CCTK_EQUALS(" <> boundpar <> ", \"zero\" ) )\n",
"{\n",

" ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, -1,\n",
" ierr = KrancBdy_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, -1,\n",
" \"" <> fullgroupname <> "\", " <> boundpar <> ");\n",

" if (ierr < 0)\n",
Expand All @@ -228,7 +228,7 @@
" CCTK_EQUALS(" <> boundpar <> ", \"zero\" ) )\n",
"{\n",

" ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, -1,\n",
" ierr = KrancBdy_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, -1,\n",
" \"" <> fullgfname <> "\", " <> boundpar <> ");\n",

" if (ierr < 0)\n",
Expand Down Expand Up @@ -261,7 +261,7 @@
" CCTK_ERROR(\"could not set SPEED value in table!\");\n",

"\n",
" ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, "<>myhandle<>", \n",
" ierr = KrancBdy_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, "<>myhandle<>", \n",
" \"" <> fullgroupname <> "\", \"Radiation\");\n\n",

" if (ierr < 0)\n",
Expand Down Expand Up @@ -295,7 +295,7 @@
" CCTK_ERROR(\"could not set SPEED value in table!\");\n",

"\n",
" ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, "<>myhandle<>", \n",
" ierr = KrancBdy_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, "<>myhandle<>", \n",
" \"" <> fullgfname <> "\", \"Radiation\");\n\n",

" if (ierr < 0)\n",
Expand Down Expand Up @@ -324,7 +324,7 @@
" CCTK_ERROR(\"could not set SCALAR value in table!\");\n",

"\n",
" ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, "<>myhandle<>", \n",
" ierr = KrancBdy_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, "<>myhandle<>", \n",
" \"" <> fullgroupname <> "\", \"scalar\");\n\n",

" if (ierr < 0)\n",
Expand Down Expand Up @@ -354,7 +354,7 @@
" CCTK_ERROR(\"could not set SCALAR value in table!\");\n",

"\n",
" ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, "<>myhandle<>", \n",
" ierr = KrancBdy_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, "<>myhandle<>", \n",
" \"" <> fullgfname <> "\", \"scalar\");\n\n",

" if (ierr < 0)\n",
Expand All @@ -371,7 +371,7 @@

Map[IncludeFile,
{"cctk.h", "cctk_Arguments.h", "cctk_Parameters.h",
"cctk_Faces.h", "util_Table.h", "Symmetry.h"}],
"cctk_Faces.h", "util_Table.h", "Symmetry.h", "Kranc.hh"}],

{"\n\n",
"/* the boundary treatment is split into 3 steps: */\n",
Expand Down

0 comments on commit 8431587

Please sign in to comment.