text: //
  // nekRS User Defined File
  //
  #include <math.h>
  #include "udf.hpp"
  #include "velRecycling.hpp"
  
  #define ZLENGTH  20.0  /* diameters  */
  
  /* UDF Functions */                                                      
  
  void UDF_LoadKernels(ins_t *ins)
  {
    velRecycling::buildKernel(ins);
  }
  
  void UDF_Setup(ins_t *ins)
  {
    // get IC from nek
    if (!ins->readRestartFile) nek_copyTo(ins, ins->startTime);
  
    nek_userchk();
  
    // setup scratch space
    ins->o_Wrk.free(); free(ins->Wrk);
    ins->Wrk   = (dfloat*) calloc(ins->NVfields*ins->Ntotal, sizeof(dfloat));
    ins->o_Wrk = ins->mesh->device.malloc(ins->NVfields*ins->Ntotal*sizeof(dfloat), ins->Wrk);
  
    // recycling
    const int nSlabs   = 60; 
    const int nelSlab  = 108;
    dfloat zRecycLayer = 5.0;
    const hlong offset = nelSlab * round(nSlabs * zRecycLayer/ZLENGTH); 
    velRecycling::setup(ins, ins->o_Wrk, offset);
  }
  
  void UDF_ExecuteStep(ins_t *ins, dfloat time, int tstep)
  {
    velRecycling::copy();
  }
  