From 3cc8f7c0557609bb1ad0edfc4986c12cdaa41233 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Tue, 28 Apr 2009 13:28:28 -0500 Subject: Create helper thorns automatically from a prototype --- m/Makefile | 56 ++++++++--- m/create-helper-thorn.sh | 11 +++ m/prototype/ML_BSSN_Helper/configuration.ccl | 1 + m/prototype/ML_BSSN_Helper/interface.ccl | 10 ++ m/prototype/ML_BSSN_Helper/param.ccl | 12 +++ m/prototype/ML_BSSN_Helper/schedule.ccl | 109 +++++++++++++++++++++ m/prototype/ML_BSSN_Helper/src/CopyADMBase.c | 50 ++++++++++ m/prototype/ML_BSSN_Helper/src/RegisterSlicing.c | 10 ++ m/prototype/ML_BSSN_Helper/src/SelectBCsADMBase.c | 31 ++++++ .../ML_BSSN_Helper/src/UnsetCheckpointTags.c | 59 +++++++++++ m/prototype/ML_BSSN_Helper/src/make.code.defn | 2 + 11 files changed, 337 insertions(+), 14 deletions(-) create mode 100755 m/create-helper-thorn.sh create mode 100644 m/prototype/ML_BSSN_Helper/configuration.ccl create mode 100644 m/prototype/ML_BSSN_Helper/interface.ccl create mode 100644 m/prototype/ML_BSSN_Helper/param.ccl create mode 100644 m/prototype/ML_BSSN_Helper/schedule.ccl create mode 100644 m/prototype/ML_BSSN_Helper/src/CopyADMBase.c create mode 100644 m/prototype/ML_BSSN_Helper/src/RegisterSlicing.c create mode 100644 m/prototype/ML_BSSN_Helper/src/SelectBCsADMBase.c create mode 100644 m/prototype/ML_BSSN_Helper/src/UnsetCheckpointTags.c create mode 100644 m/prototype/ML_BSSN_Helper/src/make.code.defn (limited to 'm') diff --git a/m/Makefile b/m/Makefile index 08e4f70..e6484ab 100644 --- a/m/Makefile +++ b/m/Makefile @@ -8,49 +8,77 @@ all: McLachlan_ADM.out McLachlan_BSSN.out McLachlanW.out WaveToy.out hydro.out McLachlan_ADM.out: McLachlan_ADM.m rm -rf ML_ADM* ./runmath.sh $^ - for thorn in ML_ADM*; do ./copy-if-changed.sh $$thorn ../$$thorn; done + for thorn in ML_ADM*; do \ + ./copy-if-changed.sh $$thorn ../$$thorn; \ + done McLachlan_BSSN.out: McLachlan_BSSN.m rm -rf ML_BSSN* ./runmath.sh $^ - for thorn in ML_BSSN*; do ./copy-if-changed.sh $$thorn ../$$thorn; done + for thorn in ML_BSSN*; do \ + ./copy-if-changed.sh $$thorn ../$$thorn; \ + ./create-helper-thorn.sh $$thorn; \ + ./copy-if-changed.sh $${thorn}_Helper ../$${thorn}_Helper; \ + done McLachlanW.out: McLachlanW.m rm -rf ML_BSSNW ./runmath.sh $^ - for thorn in ML_BSSNW; do ./copy-if-changed.sh $$thorn ../$$thorn; done + for thorn in ML_BSSNW; do \ + ./copy-if-changed.sh $$thorn ../$$thorn; \ + ./create-helper-thorn.sh $$thorn; \ + ./copy-if-changed.sh $${thorn}_Helper ../$${thorn}_Helper; \ + done McLachlanUp.out: McLachlanUp.m rm -rf ML_BSSNUp ./runmath.sh $^ - for thorn in ML_BSSNUp; do ./copy-if-changed.sh $$thorn ../$$thorn; done + for thorn in ML_BSSNUp; do \ + ./copy-if-changed.sh $$thorn ../$$thorn; \ + ./create-helper-thorn.sh $$thorn; \ + ./copy-if-changed.sh $${thorn}_Helper ../$${thorn}_Helper; \ + done McLachlan6.out: McLachlan6.m rm -rf ML_BSSN6 ./runmath.sh $^ - for thorn in ML_BSSN6; do ./copy-if-changed.sh $$thorn ../$$thorn; done + for thorn in ML_BSSN6; do \ + ./copy-if-changed.sh $$thorn ../$$thorn; \ + ./create-helper-thorn.sh $$thorn; \ + ./copy-if-changed.sh $${thorn}_Helper ../$${thorn}_Helper; \ + done McLachlan_Psilon.out: McLachlan_Psilon.m rm -rf ML_Psilon* ./runmath.sh $^ - for thorn in ML_Psilon*; do ./copy-if-changed.sh $$thorn ../$$thorn; done + for thorn in ML_Psilon*; do \ + ./copy-if-changed.sh $$thorn ../$$thorn; \ + done WaveToy.out: WaveToy.m rm -rf ML_WaveToy ML_FOWaveToy ./runmath.sh $^ - for thorn in ML_WaveToy ML_FOWaveToy; do ./copy-if-changed.sh $$thorn ../$$thorn; done + for thorn in ML_WaveToy ML_FOWaveToy; do \ + ./copy-if-changed.sh $$thorn ../$$thorn; \ + done hydro.out: hydro.m rm -rf ML_hydro ./runmath.sh $^ - for thorn in ML_hydro; do ./copy-if-changed.sh $$thorn ../$$thorn; done + for thorn in ML_hydro; do \ + ./copy-if-changed.sh $$thorn ../$$thorn; \ + done clean: - rm -rf McLachlan_ADM.out McLachlan_ADM.err ML_ADM* - rm -rf McLachlan_BSSN.out McLachlan_BSSN.err ML_BSSN* - rm -rf McLachlanW.out McLachlanW.err - rm -rf McLachlanUp.out McLachlanUp.err - rm -rf McLachlan6.out McLachlan6.err - rm -rf WaveToy.out WaveToy.err ML_WaveToy ML_FOWaveToy + rm -rf ML_ADM* ML_BSSN* + rm -rf ML_WaveToy ML_FOWaveToy + rm -rf ML_hydro + rm -rf McLachlan_ADM.out McLachlan_ADM.err + rm -rf McLachlan_BSSN.out McLachlan_BSSN.err + rm -rf McLachlanW.out McLachlanW.err + rm -rf McLachlanUp.out McLachlanUp.err + rm -rf McLachlan6.out McLachlan6.err + rm -rf WaveToy.out WaveToy.err + rm -rf hydro.out hydro.err .PHONY: all clean diff --git a/m/create-helper-thorn.sh b/m/create-helper-thorn.sh new file mode 100755 index 0000000..79854d3 --- /dev/null +++ b/m/create-helper-thorn.sh @@ -0,0 +1,11 @@ +#! /bin/bash + +name=$1 + +# Create a thorn $name_Helper + +orig=ML_BSSN + +cp -R prototype/${orig}_Helper ${name}_Helper +find ${name}_Helper -name '*~' | xargs rm +find ${name}_Helper -type f | xargs perl -pi -e "s/${orig}/${name}/g" diff --git a/m/prototype/ML_BSSN_Helper/configuration.ccl b/m/prototype/ML_BSSN_Helper/configuration.ccl new file mode 100644 index 0000000..edaa5b7 --- /dev/null +++ b/m/prototype/ML_BSSN_Helper/configuration.ccl @@ -0,0 +1 @@ +REQUIRES THORNS: CartGrid3D CoordGauge diff --git a/m/prototype/ML_BSSN_Helper/interface.ccl b/m/prototype/ML_BSSN_Helper/interface.ccl new file mode 100644 index 0000000..8ad9ba2 --- /dev/null +++ b/m/prototype/ML_BSSN_Helper/interface.ccl @@ -0,0 +1,10 @@ +IMPLEMENTS: ML_BSSN_Helper + +INHERITS: ADMBase CoordGauge ML_BSSN + +USES INCLUDE: Symmetry.h + + + +CCTK_INT FUNCTION Boundary_SelectGroupForBC(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) +USES FUNCTION Boundary_SelectGroupForBC diff --git a/m/prototype/ML_BSSN_Helper/param.ccl b/m/prototype/ML_BSSN_Helper/param.ccl new file mode 100644 index 0000000..8669144 --- /dev/null +++ b/m/prototype/ML_BSSN_Helper/param.ccl @@ -0,0 +1,12 @@ +SHARES: ADMBase + +USES KEYWORD evolution_method + +SHARES: GenericFD + +USES CCTK_INT boundary_width + +SHARES: ML_BSSN + +USES CCTK_INT timelevels +USES KEYWORD calculate_ADMBase_variables_at diff --git a/m/prototype/ML_BSSN_Helper/schedule.ccl b/m/prototype/ML_BSSN_Helper/schedule.ccl new file mode 100644 index 0000000..08c8e1e --- /dev/null +++ b/m/prototype/ML_BSSN_Helper/schedule.ccl @@ -0,0 +1,109 @@ +if (CCTK_EQUALS (evolution_method, "ML_BSSN")) { + + if (timelevels == 1) { + STORAGE: ADMBase::metric[1] + STORAGE: ADMBase::curv[1] + STORAGE: ADMBase::lapse[1] + STORAGE: ADMBase::shift[1] + STORAGE: ADMBase::dtlapse[1] + STORAGE: ADMBase::dtshift[1] + } else if (timelevels == 2) { + STORAGE: ADMBase::metric[2] + STORAGE: ADMBase::curv[2] + STORAGE: ADMBase::lapse[2] + STORAGE: ADMBase::shift[2] + STORAGE: ADMBase::dtlapse[2] + STORAGE: ADMBase::dtshift[2] + } else if (timelevels == 3) { + STORAGE: ADMBase::metric[3] + STORAGE: ADMBase::curv[3] + STORAGE: ADMBase::lapse[3] + STORAGE: ADMBase::shift[3] + STORAGE: ADMBase::dtlapse[3] + STORAGE: ADMBase::dtshift[3] + } + + SCHEDULE ML_BSSN_RegisterSlicing AT startup + { + LANG: C + OPTIONS: meta + } "Register slicing" + + SCHEDULE ML_BSSN_UnsetCheckpointTags AT startup + { + LANG: C + OPTIONS: meta + } "Don't checkpoint ADMBase variables" + + + + SCHEDULE GROUP ML_BSSN_evolCalcGroup IN MoL_CalcRHS + { + } "Calculate BSSN RHS" + + SCHEDULE GROUP ML_BSSN_evolCalcGroup AT analysis + { + TRIGGERS: ML_BSSN::ML_log_confacrhs + TRIGGERS: ML_BSSN::ML_metricrhs + TRIGGERS: ML_BSSN::ML_Gammarhs + TRIGGERS: ML_BSSN::ML_trace_curvrhs + TRIGGERS: ML_BSSN::ML_curvrhs + TRIGGERS: ML_BSSN::ML_lapserhs + TRIGGERS: ML_BSSN::ML_dtlapserhs + TRIGGERS: ML_BSSN::ML_shiftrhs + TRIGGERS: ML_BSSN::ML_dtshiftrhs + } "Calculate BSSN RHS" + + + + SCHEDULE GROUP ML_BSSN_convertToADMBaseGroup IN ML_BSSN_convertToADMBaseGroupWrapper + { + } "Calculate ADM variables" + + if (CCTK_EQUALS (calculate_ADMBase_variables_at, "MoL_PostStep")) + { + if (timelevels > 1) + { + SCHEDULE ML_BSSN_CopyADMBase AT CCTK_PRESTEP + { + LANG: C + } "Copy ADMBase variables to current time level" + } + SCHEDULE GROUP ML_BSSN_convertToADMBaseGroupWrapper IN MoL_PostStep AFTER (ML_BSSN_ApplyBCs ML_BSSN_enforce) BEFORE (ADMBase_SetADMVars Whisky_PostStep) + { + } "Calculate ADM variables" + } + else if (CCTK_EQUALS (calculate_ADMBase_variables_at, "CCTK_EVOL")) + { + SCHEDULE GROUP ML_BSSN_convertToADMBaseGroupWrapper AT evol AFTER MoL_Evolution BEFORE (ADMBase_SetADMVars Whisky_PostStep) + { + } "Calculate ADM variables" + } + else if (CCTK_EQUALS (calculate_ADMBase_variables_at, "CCTK_ANALYSIS")) + { + SCHEDULE GROUP ML_BSSN_convertToADMBaseGroupWrapper AT analysis BEFORE (ADMBase_SetADMVars Whisky_PostStep) + { + TRIGGERS: ML_BSSN::ML_Ham + TRIGGERS: ML_BSSN::ML_mom + } "Calculate ADM variables" + } + + SCHEDULE ML_BSSN_SelectBCsADMBase IN ML_BSSN_convertToADMBaseGroupWrapper AFTER ML_BSSN_convertToADMBaseGroup + { + LANG: C + OPTIONS: level + } "Apply boundary conditions to ADMBase variables" + + SCHEDULE GROUP ApplyBCs AS ML_BSSN_ApplyBCsADMBase IN ML_BSSN_convertToADMBaseGroupWrapper AFTER ML_BSSN_SelectBCsADMBase + { + } "Apply boundary conditions to ADMBase variables" + + + + SCHEDULE GROUP ML_BSSN_constraintsCalcGroup AT analysis + { + TRIGGERS: ML_BSSN::ML_Ham + TRIGGERS: ML_BSSN::ML_mom + } "Calculate BSSN constraints" + +} diff --git a/m/prototype/ML_BSSN_Helper/src/CopyADMBase.c b/m/prototype/ML_BSSN_Helper/src/CopyADMBase.c new file mode 100644 index 0000000..529e1c8 --- /dev/null +++ b/m/prototype/ML_BSSN_Helper/src/CopyADMBase.c @@ -0,0 +1,50 @@ +#include +#include + +#include +#include + +static void +copy (cGH const * restrict cctkGH, + CCTK_REAL * restrict dst, CCTK_REAL const * restrict src); + +void +ML_BSSN_CopyADMBase (CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + + copy (cctkGH, gxx, gxx_p); + copy (cctkGH, gxy, gxx_p); + copy (cctkGH, gxz, gxx_p); + copy (cctkGH, gyy, gxx_p); + copy (cctkGH, gyz, gxx_p); + copy (cctkGH, gzz, gxx_p); + + copy (cctkGH, kxx, gxx_p); + copy (cctkGH, kxy, gxx_p); + copy (cctkGH, kxz, gxx_p); + copy (cctkGH, kyy, gxx_p); + copy (cctkGH, kyz, gxx_p); + copy (cctkGH, kzz, gxx_p); + + copy (cctkGH, alp, alp_p); + + copy (cctkGH, betax, betax_p); + copy (cctkGH, betay, betay_p); + copy (cctkGH, betaz, betaz_p); + + copy (cctkGH, dtalp, dtalp_p); + + copy (cctkGH, dtbetax, dtbetax_p); + copy (cctkGH, dtbetay, dtbetay_p); + copy (cctkGH, dtbetaz, dtbetaz_p); +} + +static void +copy (cGH const * restrict const cctkGH, + CCTK_REAL * restrict const dst, CCTK_REAL const * restrict const src) +{ + size_t const npoints = + (size_t) cctkGH->cctk_lsh[0] * cctkGH->cctk_lsh[1] * cctkGH->cctk_lsh[2]; + memcpy (dst, src, npoints * sizeof *dst); +} diff --git a/m/prototype/ML_BSSN_Helper/src/RegisterSlicing.c b/m/prototype/ML_BSSN_Helper/src/RegisterSlicing.c new file mode 100644 index 0000000..313bf32 --- /dev/null +++ b/m/prototype/ML_BSSN_Helper/src/RegisterSlicing.c @@ -0,0 +1,10 @@ +#include + +#include "CactusEinstein/CoordGauge/src/Slicing.h" + +int +ML_BSSN_RegisterSlicing (void) +{ + Einstein_RegisterSlicing ("ML_BSSN"); + return 0; +} diff --git a/m/prototype/ML_BSSN_Helper/src/SelectBCsADMBase.c b/m/prototype/ML_BSSN_Helper/src/SelectBCsADMBase.c new file mode 100644 index 0000000..315d713 --- /dev/null +++ b/m/prototype/ML_BSSN_Helper/src/SelectBCsADMBase.c @@ -0,0 +1,31 @@ +#include + +#include +#include +#include + +static void +select_bcs (cGH const * restrict cctkGH, char const * restrict gn); + +void +ML_BSSN_SelectBCsADMBase (CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + + select_bcs (cctkGH, "ADMBase::metric"); + select_bcs (cctkGH, "ADMBase::curv"); + select_bcs (cctkGH, "ADMBase::lapse"); + select_bcs (cctkGH, "ADMBase::shift"); + select_bcs (cctkGH, "ADMBase::dtlapse"); + select_bcs (cctkGH, "ADMBase::dtshift"); +} + +static void +select_bcs (cGH const * restrict const cctkGH, char const * restrict const gn) +{ + DECLARE_CCTK_PARAMETERS; + + int const ierr = Boundary_SelectGroupForBC + (cctkGH, CCTK_ALL_FACES, boundary_width, -1, gn, "none"); + assert (! ierr); +} diff --git a/m/prototype/ML_BSSN_Helper/src/UnsetCheckpointTags.c b/m/prototype/ML_BSSN_Helper/src/UnsetCheckpointTags.c new file mode 100644 index 0000000..3eaf347 --- /dev/null +++ b/m/prototype/ML_BSSN_Helper/src/UnsetCheckpointTags.c @@ -0,0 +1,59 @@ +#include +#include + +#include + +static void +unset_checkpoint_tag (int prolongate, char const * restrict gn); + +int +ML_BSSN_UnsetCheckpointTags (void) +{ + unset_checkpoint_tag (1, "ADMBase::metric"); + unset_checkpoint_tag (1, "ADMBase::curv"); + unset_checkpoint_tag (1, "ADMBase::lapse"); + unset_checkpoint_tag (1, "ADMBase::shift"); + unset_checkpoint_tag (1, "ADMBase::dtlapse"); + unset_checkpoint_tag (1, "ADMBase::dtshift"); + + unset_checkpoint_tag (0, "ML_BSSN::ML_cons_detg"); + unset_checkpoint_tag (0, "ML_BSSN::ML_cons_Gamma"); + unset_checkpoint_tag (0, "ML_BSSN::ML_cons_traceA"); + unset_checkpoint_tag (0, "ML_BSSN::ML_Ham"); + unset_checkpoint_tag (0, "ML_BSSN::ML_mom"); + unset_checkpoint_tag (0, "ML_BSSN::ML_curvrhs"); + unset_checkpoint_tag (0, "ML_BSSN::ML_dtlapserhs"); + unset_checkpoint_tag (0, "ML_BSSN::ML_dtshiftrhs"); + unset_checkpoint_tag (0, "ML_BSSN::ML_Gammarhs"); + unset_checkpoint_tag (0, "ML_BSSN::ML_lapserhs"); + unset_checkpoint_tag (0, "ML_BSSN::ML_log_confacrhs"); + unset_checkpoint_tag (0, "ML_BSSN::ML_metricrhs"); + unset_checkpoint_tag (0, "ML_BSSN::ML_shiftrhs"); + unset_checkpoint_tag (0, "ML_BSSN::ML_trace_curvrhs"); + + return 0; +} + +static void +unset_checkpoint_tag (int const prolongate, char const * restrict const gn) +{ + assert (gn); + + int const gi = CCTK_GroupIndex (gn); + assert (gi >= 0); + + int const table = CCTK_GroupTagsTableI (gi); + assert (table >= 0); + + int ierr; + ierr = Util_TableSetString (table, "no", "Checkpoint"); + assert (! ierr); + + ierr = Util_TableSetString (table, "no", "Persistent"); + assert (! ierr); + + if (! prolongate) { + ierr = Util_TableSetString (table, "none", "Prolongation"); + assert (! ierr); + } +} diff --git a/m/prototype/ML_BSSN_Helper/src/make.code.defn b/m/prototype/ML_BSSN_Helper/src/make.code.defn new file mode 100644 index 0000000..86aceb8 --- /dev/null +++ b/m/prototype/ML_BSSN_Helper/src/make.code.defn @@ -0,0 +1,2 @@ +# -*-Makefile-*- +SRCS = CopyADMBase.c RegisterSlicing.c SelectBCsADMBase.c UnsetCheckpointTags.c -- cgit v1.2.3