def set_Nxx_dxx_invdx_params__and__xx_h(outdir='.', grid_centering='cell'):
    if (grid_centering not in ('cell', 'vertex')):
        print((('rfm.set_Nxx_dxx_invdx_params__and__xx_h(): grid_centering = "' + grid_centering) + '" not supported!'))
        sys.exit(1)
    with open(os.path.join(outdir, 'set_Nxx_dxx_invdx_params__and__xx.h'), 'w') as file:
        file.write('\nvoid set_Nxx_dxx_invdx_params__and__xx(const int EigenCoord, const int Nxx[3],\n                                       paramstruct *restrict params, REAL *restrict xx[3]) {\n    // Override parameter defaults with values based on command line arguments and NGHOSTS.\n    params->Nxx0 = Nxx[0];\n    params->Nxx1 = Nxx[1];\n    params->Nxx2 = Nxx[2];\n    params->Nxx_plus_2NGHOSTS0 = Nxx[0] + 2*NGHOSTS;\n    params->Nxx_plus_2NGHOSTS1 = Nxx[1] + 2*NGHOSTS;\n    params->Nxx_plus_2NGHOSTS2 = Nxx[2] + 2*NGHOSTS;\n    // Step 0d: Set up space and time coordinates\n    // Step 0d.i: Declare \\Delta x^i=dxx{0,1,2} and invdxx{0,1,2}, as well as xxmin[3] and xxmax[3]:\n#include "set_Cparameters.h"\n    REAL xxmin[3],xxmax[3];\n    if(EigenCoord == 0) {\n')
        for i in range(3):
            file.write((((('        xxmin[' + str(i)) + '] = ') + str(xxmin[i])) + ';\n'))
            file.write((((('        xxmax[' + str(i)) + '] = ') + str(xxmax[i])) + ';\n'))
        file.write('\n    } else { // if (EigenCoord == 1)\n')
        CoordSystem_orig = par.parval_from_str('reference_metric::CoordSystem')
        par.set_parval_from_str('reference_metric::CoordSystem', get_EigenCoord())
        reference_metric()
        for i in range(3):
            file.write((((('        xxmin[' + str(i)) + '] = ') + str(xxmin[i])) + ';\n'))
            file.write((((('        xxmax[' + str(i)) + '] = ') + str(xxmax[i])) + ';\n'))
        par.set_parval_from_str('reference_metric::CoordSystem', CoordSystem_orig)
        reference_metric()
        file.write('\n    }\n\n    params->dxx0 = (xxmax[0] - xxmin[0]) / ((REAL)Nxx[0]);\n    params->dxx1 = (xxmax[1] - xxmin[1]) / ((REAL)Nxx[1]);\n    params->dxx2 = (xxmax[2] - xxmin[2]) / ((REAL)Nxx[2]);\n    params->invdx0 = 1.0/params->dxx0;\n    params->invdx1 = 1.0/params->dxx1;\n    params->invdx2 = 1.0/params->dxx2;\n')
        cell_offset = '(1.0/2.0)'
        cell_comment = 'Cell-centered grid.'
        if (grid_centering == 'vertex'):
            cell_offset = '0.0'
            cell_comment = 'Vertex-centered grid.'
        file.write((((((((((((('\n    // Now that params.dxx{0,1,2} and params.invdxx{0,1,2} have been set,\n    // Step 0d.iii: Set up uniform coordinate grids\n    xx[0] = (REAL *)malloc(sizeof(REAL)*Nxx_plus_2NGHOSTS0);\n    for(int j=0;j<Nxx_plus_2NGHOSTS0;j++)\n        xx[0][j] = xxmin[0] + ((REAL)(j-NGHOSTS) + ' + cell_offset) + ')*params->dxx0; // ') + cell_comment) + '\n    xx[1] = (REAL *)malloc(sizeof(REAL)*Nxx_plus_2NGHOSTS1);\n    for(int j=0;j<Nxx_plus_2NGHOSTS1;j++)\n        xx[1][j] = xxmin[1] + ((REAL)(j-NGHOSTS) + ') + cell_offset) + ')*params->dxx1; // ') + cell_comment) + '\n    xx[2] = (REAL *)malloc(sizeof(REAL)*Nxx_plus_2NGHOSTS2);\n    for(int j=0;j<Nxx_plus_2NGHOSTS2;j++)\n        xx[2][j] = xxmin[2] + ((REAL)(j-NGHOSTS) + ') + cell_offset) + ')*params->dxx2; // ') + cell_comment) + '\n    //fprintf(stderr,"hey inside setxx: %e %e %e | %e %e\\n",xxmin[0],xxmin[1],xxmin[2],xx[0][0],params->dxx0);\n}\n'))
def set_Nxx_dxx_invdx_params__and__xx_h(outdir='.', grid_centering='cell'):
    if (grid_centering not in ('cell', 'vertex')):
        print((('rfm.set_Nxx_dxx_invdx_params__and__xx_h(): grid_centering = "' + grid_centering) + '" not supported!'))
        sys.exit(1)
    with open(os.path.join(outdir, 'set_Nxx_dxx_invdx_params__and__xx.h'), 'w') as file:
        file.write('\nvoid set_Nxx_dxx_invdx_params__and__xx(const int EigenCoord, const int Nxx[3],\n                                       paramstruct *restrict params, REAL *restrict xx[3]) {\n    // Override parameter defaults with values based on command line arguments and NGHOSTS.\n    params->Nxx0 = Nxx[0];\n    params->Nxx1 = Nxx[1];\n    params->Nxx2 = Nxx[2];\n    params->Nxx_plus_2NGHOSTS0 = Nxx[0] + 2*NGHOSTS;\n    params->Nxx_plus_2NGHOSTS1 = Nxx[1] + 2*NGHOSTS;\n    params->Nxx_plus_2NGHOSTS2 = Nxx[2] + 2*NGHOSTS;\n    // Step 0d: Set up space and time coordinates\n    // Step 0d.i: Declare \\Delta x^i=dxx{0,1,2} and invdxx{0,1,2}, as well as xxmin[3] and xxmax[3]:\n#include "set_Cparameters.h"\n    REAL xxmin[3],xxmax[3];\n    if(EigenCoord == 0) {\n')
        for i in range(3):
            file.write((((('        xxmin[' + str(i)) + '] = ') + str(xxmin[i])) + ';\n'))
            file.write((((('        xxmax[' + str(i)) + '] = ') + str(xxmax[i])) + ';\n'))
        file.write('\n    } else { // if (EigenCoord == 1)\n')
        CoordSystem_orig = par.parval_from_str('reference_metric::CoordSystem')
        par.set_parval_from_str('reference_metric::CoordSystem', get_EigenCoord())
        reference_metric()
        for i in range(3):
            file.write((((('        xxmin[' + str(i)) + '] = ') + str(xxmin[i])) + ';\n'))
            file.write((((('        xxmax[' + str(i)) + '] = ') + str(xxmax[i])) + ';\n'))
        par.set_parval_from_str('reference_metric::CoordSystem', CoordSystem_orig)
        reference_metric()
        file.write('\n    }\n\n    params->dxx0 = (xxmax[0] - xxmin[0]) / ((REAL)Nxx[0]);\n    params->dxx1 = (xxmax[1] - xxmin[1]) / ((REAL)Nxx[1]);\n    params->dxx2 = (xxmax[2] - xxmin[2]) / ((REAL)Nxx[2]);\n    params->invdx0 = 1.0/params->dxx0;\n    params->invdx1 = 1.0/params->dxx1;\n    params->invdx2 = 1.0/params->dxx2;\n')
        cell_offset = '(1.0/2.0)'
        cell_comment = 'Cell-centered grid.'
        if (grid_centering == 'vertex'):
            cell_offset = '0.0'
            cell_comment = 'Vertex-centered grid.'
        file.write((((((((((((('\n    // Now that params.dxx{0,1,2} and params.invdxx{0,1,2} have been set,\n    // Step 0d.iii: Set up uniform coordinate grids\n    xx[0] = (REAL *)malloc(sizeof(REAL)*Nxx_plus_2NGHOSTS0);\n    for(int j=0;j<Nxx_plus_2NGHOSTS0;j++)\n        xx[0][j] = xxmin[0] + ((REAL)(j-NGHOSTS) + ' + cell_offset) + ')*params->dxx0; // ') + cell_comment) + '\n    xx[1] = (REAL *)malloc(sizeof(REAL)*Nxx_plus_2NGHOSTS1);\n    for(int j=0;j<Nxx_plus_2NGHOSTS1;j++)\n        xx[1][j] = xxmin[1] + ((REAL)(j-NGHOSTS) + ') + cell_offset) + ')*params->dxx1; // ') + cell_comment) + '\n    xx[2] = (REAL *)malloc(sizeof(REAL)*Nxx_plus_2NGHOSTS2);\n    for(int j=0;j<Nxx_plus_2NGHOSTS2;j++)\n        xx[2][j] = xxmin[2] + ((REAL)(j-NGHOSTS) + ') + cell_offset) + ')*params->dxx2; // ') + cell_comment) + '\n    //fprintf(stderr,"hey inside setxx: %e %e %e | %e %e\\n",xxmin[0],xxmin[1],xxmin[2],xx[0][0],params->dxx0);\n}\n'))