H6GIS2UO4G25J7MFBEEC5TV4LVM66TRPJFHXXVXAMJTZIDVAWA7QC
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Step 0 define my own looping constructs\n",
"def loop_int(kernel):\n",
" return \"\"\"Loop::loop_int<0,0,0>(cctkGH, [&](const Loop::PointDesc &p){\n",
" const int i0 = p.i;\n",
" const int i1 = p.j;\n",
" const int i2 = p.k;\n",
"\"\"\"+kernel+\"\"\"\n",
"});\\n\"\"\"\n",
"def loop_all(kernel):\n",
" return \"\"\"Loop::loop_all<0,0,0>(cctkGH, [&](const Loop::PointDesc &p){\n",
" const int i0 = p.i;\n",
" const int i1 = p.j;\n",
" const int i2 = p.k;\n",
"\"\"\"+kernel+\"\"\"\n",
"});\\n\"\"\""
]
},
{
" file.write(lp.loop([\"i2\",\"i1\",\"i0\"],[\"cctk_nghostzones[2]\",\"cctk_nghostzones[1]\",\"cctk_nghostzones[0]\"],\n",
" [\"cctk_lsh[2]-cctk_nghostzones[2]\",\"cctk_lsh[1]-cctk_nghostzones[1]\",\"cctk_lsh[0]-cctk_nghostzones[0]\"],\n",
" [\"1\",\"1\",\"SIMD_width\"],\n",
" [\"#pragma omp parallel for\",\n",
" \"#include \\\"rfm_files/rfm_struct__SIMD_outer_read2.h\\\"\",\n",
" \"#include \\\"rfm_files/rfm_struct__SIMD_outer_read1.h\\\"\"],\"\",\n",
" \"#include \\\"rfm_files/rfm_struct__SIMD_inner_read0.h\\\"\\n\"+BSSN_RHSs_string))\n",
" file.write(loop_int(BSSN_RHSs_string))\n",
" file.write(lp.loop([\"i2\",\"i1\",\"i0\"],[\"cctk_nghostzones[2]\",\"cctk_nghostzones[1]\",\"cctk_nghostzones[0]\"],\n",
" [\"cctk_lsh[2]-cctk_nghostzones[2]\",\"cctk_lsh[1]-cctk_nghostzones[1]\",\"cctk_lsh[0]-cctk_nghostzones[0]\"],\n",
" [\"1\",\"1\",\"SIMD_width\"],\n",
" [\"#pragma omp parallel for\",\n",
" \"#include \\\"rfm_files/rfm_struct__SIMD_outer_read2.h\\\"\",\n",
" \"#include \\\"rfm_files/rfm_struct__SIMD_outer_read1.h\\\"\"],\"\",\n",
" \"#include \\\"rfm_files/rfm_struct__SIMD_inner_read0.h\\\"\\n\"+Ricci_string))\n",
" file.write(loop_int(Ricci_string))\n",
" file.write(lp.loop([\"i2\",\"i1\",\"i0\"],[\"cctk_nghostzones[2]\",\"cctk_nghostzones[1]\",\"cctk_nghostzones[0]\"],\n",
" [\"cctk_lsh[2]-cctk_nghostzones[2]\",\"cctk_lsh[1]-cctk_nghostzones[1]\",\"cctk_lsh[0]-cctk_nghostzones[0]\"],\n",
" [\"1\",\"1\",\"1\"],[\"#pragma omp parallel for\",\"\",\"\"], \"\", Ham_mom_string))\n",
" file.write(loop_int(Ham_mom_string))\n",
" file.write(lp.loop([\"i2\",\"i1\",\"i0\"],[\"0\", \"0\", \"0\"],\n",
" [\"cctk_lsh[2]\",\"cctk_lsh[1]\",\"cctk_lsh[0]\"],\n",
" [\"1\",\"1\",\"1\"],\n",
" [\"#pragma omp parallel for\",\n",
" \"#include \\\"rfm_files/rfm_struct__read2.h\\\"\",\n",
" \"#include \\\"rfm_files/rfm_struct__read1.h\\\"\"],\"\",\n",
" \"#include \\\"rfm_files/rfm_struct__read0.h\\\"\\n\"+enforce_gammadet_string))\n",
" file.write(loop_all(enforce_gammadet_string))\n",
" file.write(lp.loop([\"i2\",\"i1\",\"i0\"],[\"0\", \"0\", \"0\"],\n",
" [\"cctk_lsh[2]\",\"cctk_lsh[1]\",\"cctk_lsh[0]\"],\n",
" [\"1\",\"1\",\"1\"],\n",
" [\"#pragma omp parallel for\",\"\",\"\",],\"\",set_rhss_to_zero))\n",
" file.write(loop_all(set_rhss_to_zero))\n",
"\n",
" adm_to_bssn_gfs = []\n",
" adm_to_bssn_gfs.append(\"alphaSphorCart\"+\"GF\")\n",
" adm_to_bssn_gfs.append(\"trK\"+\"GF\")\n",
" adm_to_bssn_gfs.append(\"alpha\"+\"GF\")\n",
" adm_to_bssn_gfs.append(\"cf\"+\"GF\")\n",
" for i in range(DIM):\n",
" adm_to_bssn_gfs.append(\"betaSphorCartU\"+str(i)+\"GF\")\n",
" adm_to_bssn_gfs.append(\"BSphorCartU\"+str(i)+\"GF\")\n",
" adm_to_bssn_gfs.append(\"vetU\"+str(i)+\"GF\")\n",
" adm_to_bssn_gfs.append(\"betU\"+str(i)+\"GF\")\n",
" adm_to_bssn_gfs.append(\"lambdaU\"+str(i)+\"GF\")\n",
" for j in range(i,DIM):\n",
" adm_to_bssn_gfs.append(\"gammaSphorCartDD\"+str(i)+str(j)+\"GF\")\n",
" adm_to_bssn_gfs.append(\"KSphorCartDD\"+str(i)+str(j)+\"GF\")\n",
" adm_to_bssn_gfs.append(\"hDD\"+str(i)+str(j)+\"GF\")\n",
" adm_to_bssn_gfs.append(\"aDD\"+str(i)+str(j)+\"GF\")\n",
" for gf in adm_to_bssn_gfs:\n",
" file.write(\"Loop::GF3D<CCTK_REAL,0,0,0> \"+gf+\"_(cctkGH,\"+gf+\");\\n\")\n",
" file.write(\"\\n\")\n",
"\n",
" file.write(lp.loop([\"i2\",\"i1\",\"i0\"],[\"0\",\"0\",\"0\"],[\"cctk_lsh[2]\",\"cctk_lsh[1]\",\"cctk_lsh[0]\"],\n",
" [\"1\",\"1\",\"1\"],[\"#pragma omp parallel for\",\"\",\"\"],\"\",all_but_lambdaU_outC))\n",
" file.write(loop_all(all_but_lambdaU_outC))\n",
" file.write(lp.loop([\"i2\",\"i1\",\"i0\"],[\"cctk_nghostzones[2]\",\"cctk_nghostzones[1]\",\"cctk_nghostzones[0]\"],\n",
" [\"cctk_lsh[2]-cctk_nghostzones[2]\",\"cctk_lsh[1]-cctk_nghostzones[1]\",\"cctk_lsh[0]-cctk_nghostzones[0]\"],\n",
" [\"1\",\"1\",\"1\"],[\"#pragma omp parallel for\",\"\",\"\"],\"\",lambdaU_expressions_FDout))\n",
" file.write(loop_all(lambdaU_expressions_FDout))\n",
" ExtrapolateGammas(cctkGH,lambdaU0GF);\n",
" ExtrapolateGammas(cctkGH,lambdaU1GF);\n",
" ExtrapolateGammas(cctkGH,lambdaU2GF);\n",
" //ExtrapolateGammas(cctkGH,lambdaU0GF);\n",
" //ExtrapolateGammas(cctkGH,lambdaU1GF);\n",
" //ExtrapolateGammas(cctkGH,lambdaU2GF);\n",
" bssn_to_adm_gfs = []\n",
" bssn_to_adm_gfs.append(\"trK\"+\"GF\")\n",
" bssn_to_adm_gfs.append(\"alpha\"+\"GF\")\n",
" bssn_to_adm_gfs.append(\"alp\")\n",
" bssn_to_adm_gfs.append(\"cf\"+\"GF\")\n",
" for i in range(DIM):\n",
" bssn_to_adm_gfs.append(\"beta\"+chr(ord('x')+i))\n",
" bssn_to_adm_gfs.append(\"dtbeta\"+chr(ord('x')+i))\n",
" bssn_to_adm_gfs.append(\"vetU\"+str(i)+\"GF\")\n",
" bssn_to_adm_gfs.append(\"betU\"+str(i)+\"GF\")\n",
" for j in range(i,DIM):\n",
" bssn_to_adm_gfs.append(\"g\"+chr(ord('x')+i)+chr(ord('x')+j))\n",
" bssn_to_adm_gfs.append(\"k\"+chr(ord('x')+i)+chr(ord('x')+j))\n",
" bssn_to_adm_gfs.append(\"hDD\"+str(i)+str(j)+\"GF\")\n",
" bssn_to_adm_gfs.append(\"aDD\"+str(i)+str(j)+\"GF\")\n",
" for gf in bssn_to_adm_gfs:\n",
" file.write(\"Loop::GF3D<CCTK_REAL,0,0,0> \"+gf+\"_(cctkGH,\"+gf+\");\\n\")\n",
" file.write(\"\\n\") \n",
"\n",
" file.write(lp.loop([\"i2\",\"i1\",\"i0\"],[\"0\",\"0\",\"0\"],[\"cctk_lsh[2]\",\"cctk_lsh[1]\",\"cctk_lsh[0]\"],\n",
" [\"1\",\"1\",\"1\"],[\"#pragma omp parallel for\",\"\",\"\"],\"\",bssn_to_adm_Ccode))\n",
" file.write(loop_all(bssn_to_adm_Ccode))\n",
" const CCTK_REAL NOSIMDinvdx0 = 1.0/CCTK_DELTA_SPACE(0);\n",
" const REAL_SIMD_ARRAY invdx0 = ConstSIMD(NOSIMDinvdx0);\n",
" const CCTK_REAL NOSIMDinvdx1 = 1.0/CCTK_DELTA_SPACE(1);\n",
" const REAL_SIMD_ARRAY invdx1 = ConstSIMD(NOSIMDinvdx1);\n",
" const CCTK_REAL NOSIMDinvdx2 = 1.0/CCTK_DELTA_SPACE(2);\n",
" const REAL_SIMD_ARRAY invdx2 = ConstSIMD(NOSIMDinvdx2);\n",
"#include \"BSSN_Ricci.h\"\n",
" const CCTK_REAL invdx0 = 1.0/CCTK_DELTA_SPACE(0);\n",
" const CCTK_REAL invdx1 = 1.0/CCTK_DELTA_SPACE(1);\n",
" const CCTK_REAL invdx2 = 1.0/CCTK_DELTA_SPACE(2);\n",
"\"\"\")\n",
" pt1_bssn_ricci_gfs = []\n",
" for i in range(DIM):\n",
" pt1_bssn_ricci_gfs.append(\"lambdaU\"+str(i)+\"GF\")\n",
" for j in range(i,DIM):\n",
" pt1_bssn_ricci_gfs.append(\"hDD\"+str(i)+str(j)+\"GF\")\n",
" pt1_bssn_ricci_gfs.append(\"RbarDD\"+str(i)+str(j)+\"GF\")\n",
" for gf in pt1_bssn_ricci_gfs:\n",
" file.write(\"Loop::GF3D<CCTK_REAL,0,0,0> \"+gf+\"_(cctkGH,\"+gf+\");\\n\")\n",
" file.write(\"\\n\") \n",
"\n",
" file.write(\"\"\"#include \"BSSN_Ricci.h\"\n",
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def SIMD_declare_C_params():\n",
" SIMD_declare_C_params_str = \"\"\n",
" for i in range(len(par.glb_Cparams_list)):\n",
" # keep_param is a boolean indicating whether we should accept or reject\n",
" # the parameter. singleparstring will contain the string indicating\n",
" # the variable type.\n",
" keep_param, singleparstring = keep_param__return_type(par.glb_Cparams_list[i])\n",
"\n",
" if (keep_param) and (\"CCTK_REAL\" in singleparstring):\n",
" parname = par.glb_Cparams_list[i].parname\n",
" SIMD_declare_C_params_str += \" const \"+singleparstring + \"*NOSIMD\"+parname+\\\n",
" \" = CCTK_ParameterGet(\\\"\"+parname+\"\\\",\\\"BaikalETK\\\",NULL);\\n\"\n",
" SIMD_declare_C_params_str += \" const REAL_SIMD_ARRAY \"+parname+\" = ConstSIMD(*NOSIMD\"+parname+\");\\n\"\n",
" return SIMD_declare_C_params_str"
" const CCTK_REAL NOSIMDinvdx0 = 1.0/CCTK_DELTA_SPACE(0);\n",
" const REAL_SIMD_ARRAY invdx0 = ConstSIMD(NOSIMDinvdx0);\n",
" const CCTK_REAL NOSIMDinvdx1 = 1.0/CCTK_DELTA_SPACE(1);\n",
" const REAL_SIMD_ARRAY invdx1 = ConstSIMD(NOSIMDinvdx1);\n",
" const CCTK_REAL NOSIMDinvdx2 = 1.0/CCTK_DELTA_SPACE(2);\n",
" const REAL_SIMD_ARRAY invdx2 = ConstSIMD(NOSIMDinvdx2);\n",
"\"\"\"+SIMD_declare_C_params()+\"\"\"\n",
" const CCTK_REAL invdx0 = 1.0/CCTK_DELTA_SPACE(0);\n",
" const CCTK_REAL invdx1 = 1.0/CCTK_DELTA_SPACE(1);\n",
" const CCTK_REAL invdx2 = 1.0/CCTK_DELTA_SPACE(2);\n",
"\"\"\")\n",
" pt2_bssn_rhs_gfs = []\n",
" pt2_bssn_rhs_gfs.append(\"trK\"+\"GF\")\n",
" pt2_bssn_rhs_gfs.append(\"trK\"+\"_rhsGF\")\n",
" pt2_bssn_rhs_gfs.append(\"alpha\"+\"GF\")\n",
" pt2_bssn_rhs_gfs.append(\"alpha\"+\"_rhsGF\")\n",
" pt2_bssn_rhs_gfs.append(\"cf\"+\"GF\")\n",
" pt2_bssn_rhs_gfs.append(\"cf\"+\"_rhsGF\")\n",
" for i in range(DIM):\n",
" pt2_bssn_rhs_gfs.append(\"lambdaU\"+str(i)+\"GF\")\n",
" pt2_bssn_rhs_gfs.append(\"lambdaU\"+str(i)+\"_rhsGF\")\n",
" pt2_bssn_rhs_gfs.append(\"vetU\"+str(i)+\"GF\")\n",
" pt2_bssn_rhs_gfs.append(\"vetU\"+str(i)+\"_rhsGF\")\n",
" pt2_bssn_rhs_gfs.append(\"betU\"+str(i)+\"GF\")\n",
" pt2_bssn_rhs_gfs.append(\"betU\"+str(i)+\"_rhsGF\")\n",
" for j in range(i,DIM):\n",
" pt2_bssn_rhs_gfs.append(\"hDD\"+str(i)+str(j)+\"GF\")\n",
" pt2_bssn_rhs_gfs.append(\"aDD\"+str(i)+str(j)+\"GF\")\n",
" pt2_bssn_rhs_gfs.append(\"hDD\"+str(i)+str(j)+\"_rhsGF\")\n",
" pt2_bssn_rhs_gfs.append(\"aDD\"+str(i)+str(j)+\"_rhsGF\")\n",
" pt2_bssn_rhs_gfs.append(\"RbarDD\"+str(i)+str(j)+\"GF\")\n",
" for gf in pt2_bssn_rhs_gfs:\n",
" file.write(\"Loop::GF3D<CCTK_REAL,0,0,0> \"+gf+\"_(cctkGH,\"+gf+\");\\n\")\n",
" file.write(\"\\n\") \n",
"\n",
" file.write(\"\"\"\n",
"\"\"\")\n",
" enforce_detgammabar_constraint_gfs = []\n",
" for i in range(DIM):\n",
" for j in range(i,DIM):\n",
" enforce_detgammabar_constraint_gfs.append(\"hDD\"+str(i)+str(j)+\"GF\")\n",
" for gf in enforce_detgammabar_constraint_gfs:\n",
" file.write(\"Loop::GF3D<CCTK_REAL,0,0,0> \"+gf+\"_(cctkGH,\"+gf+\");\\n\")\n",
" file.write(\"\\n\") \n",
"\"\"\")\n",
" BSSN_constraints_gfs = []\n",
" BSSN_constraints_gfs.append(\"trK\"+\"GF\")\n",
" BSSN_constraints_gfs.append(\"cf\"+\"GF\")\n",
" BSSN_constraints_gfs.append(\"H\"+\"GF\")\n",
" for i in range(DIM):\n",
" BSSN_constraints_gfs.append(\"lambdaU\"+str(i)+\"GF\")\n",
" BSSN_constraints_gfs.append(\"MU\"+str(i)+\"GF\")\n",
" for j in range(i,DIM):\n",
" BSSN_constraints_gfs.append(\"hDD\"+str(i)+str(j)+\"GF\")\n",
" BSSN_constraints_gfs.append(\"aDD\"+str(i)+str(j)+\"GF\")\n",
" for gf in BSSN_constraints_gfs:\n",
" file.write(\"Loop::GF3D<CCTK_REAL,0,0,0> \"+gf+\"_(cctkGH,\"+gf+\");\\n\")\n",
" file.write(\"\\n\") \n",
" T4UUstr_loop = lp.loop([\"i2\",\"i1\",\"i0\"],[\"0\",\"0\",\"0\"],[\"cctk_lsh[2]\",\"cctk_lsh[1]\",\"cctk_lsh[0]\"],\n",
" [\"1\",\"1\",\"SIMD_width\"],[\"#pragma omp parallel for\",\"\",\"\"],\"\",T4UUstr)\n",
" T4UUstr_loop = loop_all(T4UUstr)\n",