Fluids

Fluids

Compute the derivative of an arbitrary varaible in a FLUENT UDF

    • admin
      Ansys Employee

      How to compute the derivative of an arbitrary varaible in a FLUENT UDF?

    • admin
      Ansys Employee

      User can set a dummy user defined scalar (do not need to solve that UDS), assign the varible he wants to compute the gradient to that UDS. Then use the following udf: #include "udf.h" DEFINEEXECUTEATEND(myadjust) { Domain *d=GetDomain(1); Thread *t; cellt c; threadloopc(t,d) { begincloop(c,t) CUDSI(c,t,0)=CU(c,t); endcloop(c,t) } AllocStorageVars(d, SVUDSIRG(0), SVUDSIG(0), SVNULL); ScalarReconstruction(d, SVUDSI(0), -1, SVUDSIRG(0), NULL); ScalarDerivatives (d, SVUDSI(0), -1, SVUDSIG(0), SVUDSIRG(0), NULL); threadloopc(t,d) { begincloop(c,t) { CUDMI(c,t,0)=CUDSIG(c,t,0)[0]; CUDMI(c,t,1)=CUDSIG(c,t,0)[1]; CUDMI(c,t,2)=CUDSIG(c,t,0)[2]; } endcloop(c,t) } FreeStorageVars(d,SVUDSIRG(0), SVUDSIG(0), SV_NULL); }

Viewing 1 reply thread
  • You must be logged in to reply to this topic.