CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Trouble Saving Wall Shear using DEFINE_EXECUTE_AT_END (https://www.cfd-online.com/Forums/fluent-udf/179743-trouble-saving-wall-shear-using-define_execute_at_end.html)

jbo214 November 6, 2016 11:59

Trouble Saving Wall Shear using DEFINE_EXECUTE_AT_END
 
I'm trying to access the wall shear stress values for a certain wall. I'm trying to replicate the method used by here (p.91) and here (p.2) .

My UDF right now is:

Code:

#include "udf.h"
#include "storage.h"

DEFINE_EXECUTE_AT_END(store_wall_shear)
{       
        FILE *fp = NULL;
        char filename[] = "shear.txt";
        double NV_VEC(Wall_Shear_Force);
       
        Domain *d;
        Thread *t;

        face_t f;
        cell_t c;

        d = Get_Domain(1); /* Domain ID integer is 1 for single phase flows*/
        t = Lookup_Thread(d,9); /* wall zone ID*/

        fp = fopen(filename,"a");
        Wall_Shear_Force[0] = F_STORAGE_R_N3V(f,t,SV_WALL_SHEAR)[0];

        fprintf(fp,"Test2 \n");
        fclose(fp);
}

The UDF compiles and hooks fine, however when I run the calculation I receive a segmentation fault.

Quote:

Error: received a fatal signal (Segmentation fault).
Error Object: #f
Since I received a segmentation fault, I must be trying to access a variable that wasn't available or stored. I tried forcing Fluent to keep all of the date by setting
Quote:

Keep temporary solver memory from being freed? [yes]
through the TUI.

Do I need to calculate the shear stress directly to be able to access it or is there another step I need to take to make it available?

jbo214 November 6, 2016 17:35

From that link, am I correct in interpreting the following?

Wall_Shear_stress_X is Tau_xy
Wall_Shear_stress_Y is Tau_yz
Wall_Shear_stress_Z is Tau_zx

mali28 November 6, 2016 17:53

As far as I am aware:

Tx = [Nx*Mu*(2*Du/Dx)]+[Ny*Mu*(Du/Dy+Dv/Dx)]+[Nz*Mu*(Du/Dz+Dw/Dx)]

Ty = [Nx*Mu*(Dv/Dx+Du/Dy)]+[Ny*Mu*(2*Dv/Dy)]+[Nz*Mu*(Dv/Dz+Dw/Dy)]

Tz = [Nx*Mu*(Dw/Dx+Du/Dz)]+[Ny*Mu*(Dw/Dy+Dv/Dz)]+[Nz*Mu*(2*Dw/Dz)]

T = sqrt(Tx^2+Ty^2+Tz^2)

:rolleyes:

jbo214 November 7, 2016 11:28

I found this forum thread about using F_STORAGE.

I exported the shear stresses from the UDF and plotted them and compared to the shear stress plots provided by Fluent and they're the same.


All times are GMT -4. The time now is 19:24.