CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT

How can i get properties using UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 26, 2023, 00:26
Default How can i get properties using UDF
  #1
New Member
 
HOJUN YU
Join Date: Jul 2020
Posts: 24
Rep Power: 5
hobing is on a distinguished road
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);
}
hobing is offline   Reply With Quote

Old   July 27, 2023, 01:43
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
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
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   July 27, 2023, 02:33
Default
  #3
New Member
 
HOJUN YU
Join Date: Jul 2020
Posts: 24
Rep Power: 5
hobing is on a distinguished road
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);
}
hobing is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Obtaining fluid properties using UDF UchihaMadara Fluent UDF and Scheme Programming 5 May 24, 2021 21:47
UDF phase properties separately U1990 FLUENT 3 April 13, 2021 03:37
Checking UDF material properties salumi FLUENT 0 December 2, 2016 05:57
How to show the properties in the specific zone ID using UDF (Define_adjust) sagga18 Fluent UDF and Scheme Programming 2 December 12, 2009 16:01
How to find Properties of Fluid at specific location, using UDF? pmghadge FLUENT 0 December 8, 2009 13:53


All times are GMT -4. The time now is 06:33.