CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   How can i get properties using UDF (https://www.cfd-online.com/Forums/fluent/251090-how-can-i-get-properties-using-udf.html)

hobing July 26, 2023 00:26

How can i get properties using UDF
 
Hello I am using the Fluent V19 to analysis the propeller.

The propeller is analyzed in unsteady, and at each time step, a udf is created and used to obtain the coordinates of the various faces of the propeller surface, normal vector (x,y,z), force (x,y,z), static pressure, and area there is.

But there are some problems. Does anyone know how to achieve the above using udf? can someone help me?

Code:

..\..\src\udf.c(9): error C2040: 'x': 'real'
..\..\src\udf.c(22): error C2065: 'THREAD_WALL':
..\..\src\udf.c(27): error C2065: 'farea':
..\..\src\udf.c(27): error C2109:
..\..\src\udf.c(28): error C2223: '->storage'
..\..\src\udf.c(32): warning C4477: 'fprintf' :

Below is my udf code.
domain = Get_Domain(3); where 3 is the boundary condition ID of the propeller.

Code:

#include "udf.h"

DEFINE_EXECUTE_AT_END(store_wall_info)
{
    Domain *domain;
    Thread *t;
    face_t f;
    real x[ND_ND];
    real x, y, z, area, pressure;
    real nx, ny, nz, fx, fy, fz;
    FILE *file;
    int time_step;

    time_step = N_TIME;

    file = fopen("wall_info.txt", "a");

    domain = Get_Domain(3);

    thread_loop_c(t, domain)
    {
        if (THREAD_TYPE(t) == THREAD_WALL)
        {
            begin_f_loop(f, t)
            {
                F_CENTROID(x, f, t);
                F_AREA(farea, f, t);
                F_P(pressure, f, t);
                F_NORMAL(nx, ny, nz, f, t);


                fprintf(file, "%e, %e, %e, %e, %e, %e, %e, %e, %e\n", x, y, z, area, pressure, nx, ny, nz, fx, fy, fz);
            }
            end_f_loop(f, t)
        }
    }

    fclose(file);
}


AlexanderZ July 27, 2023 01:43

Quote:

3 is the boundary condition ID of the propeller.
you are talking about thread not domain.
domain is 1 for single phase flow
Code:

t=Lookup_Thread(domain, 3);
so you dont need this loop
Code:

thread_loop_c(t, domain)
    {
        if (THREAD_TYPE(t) == THREAD_WALL)
        {

compile code

hobing July 27, 2023 02:33

Thank you!

thank you The code is modified and in use.
But I have one question for you.

I can output the cell coordinates of the WALL corresponding to ID 19. I want to know the cell's NORMAL VECTOR and FORCE X, Y, Z.

FORCE = P * A is defined as
It can be defined as FORCE X = P * A[0]. If defined here, the output will be 0.

How should I define it?

Code:

#include "udf.h"

FILE *fout;

DEFINE_ADJUST(print_f_centroids, domain)
{
    real FC[3];
    /* real es[3]; */
    /* real force_x, force_y, force_z; */
    face_t f;
    /* real NV_VEC(A); */
    int ID = 19;
    Thread *thread = Lookup_Thread(domain, ID);
    fout=fopen("faces.out", "w");

    begin_f_loop(f, thread)
    {
        F_CENTROID(FC, f, thread);
       
        fprintf(fout, "xc = %f yc = %f zc = %f, fx = %f, fx = %f, fx = %f", FC[0], FC[1], FC[2]);
    }
    end_f_loop(f,thread)

    fclose(fout);
}



All times are GMT -4. The time now is 02:59.