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

Access Flow variables at an arbitrary location using UDF

Register Blogs Community New Posts Updated Threads Search

 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old   November 11, 2019, 07:34
Default Access Flow variables at an arbitrary location using UDF
  #1
Member
 
Abhinand
Join Date: Jun 2016
Posts: 75
Rep Power: 9
Abhinand is on a distinguished road
Hello All,

I need to get the flow quantities inside a rectangular 2d (100mmx50mm) domain at a distance of 50mm from inlet.
I have two case files
One without splitting the domain at the location I need and the other with an interior boundary at the location I need so that I get to access a thread ID from Fluent.
However I get this mysterious error from Fluent where I can't get to access the values inside the domain.
I would really appreciate your help. Thanks


Please find attached code:

CODE:

This code is attached to a domain without any explicit interior lines. I search for a location I need inside the domain. The next code has an explicit thread defined,coz I created the case by splitting the domain at the position I need.

I also made sure I added user defined memory locations before I interpreted this udf

DEFINE_ADJUST(adjcell,d)

{

face_t f;

Thread *th, *r_thread;

real FC[2];

int ctr,ctr1,n_faces;

cell_t c;

d = Get_Domain(1);

th = Lookup_Thread(d,3);

c = F_C0(f,th);

ctr=0;

ctr1=0;

r_thread = Lookup_Thread(d,ID_rplane);

n_faces = THREAD_N_ELEMENTS_INT(r_thread);

begin_c_loop(c,th)

{

C_CENTROID(FC,c,th);

if(FC[0]>51.512e-3&&FC[0]<51.516e-3)

{ if(ctr<5)

{

printf("Xcoor %f Ycoor %f\n",FC[0],FC[1]);

*** printf("Uvel is %f\n",C_U(c,th));

*** C_UDMI(c,th,0) = C_U(c,th);

}

ctr++;

}

}

end_c_loop(c,th)

printf("No of faces in outlet %d\n",n_faces);

printf("No of faces in recycle plane is %d\n",ctr);

}

CODE2:

This code is hooked to a case where, I have a BC condition of a line inside the domain (50mm from inlet) set to Interior

DEFINE_ADJUST(adjface,d)

{

face_t f;

Thread *th, *r_thread;

real FC[2];

int ctr,ctr1,n_faces;

cell_t c;

d = Get_Domain(1);

th = Lookup_Thread(d,12);

c = F_C0(f,th);

ctr=0;

ctr1=0;

r_thread = Lookup_Thread(d,15);

n_faces = THREAD_N_ELEMENTS_INT(r_thread);

begin_f_loop(f,th)

{

F_CENTROID(FC,f,th);

if(ctr<5)

{

printf("Xcoor %f Ycoor %f\n",FC[0],FC[1]);

*** printf("Uvel is %f\n",F_U(f,th));

*** printf("Uvel cell is %f\n",C_U(c,th));

}

ctr++;

}

end_f_loop(f,th)

printf("No of faces in outlet %d\n",n_faces);

printf("No of faces in recycle plane is %d\n",ctr);

}

OUTPUT:

1. When I do not include the *** statements

Xcoor 0.051515 Ycoor 0.000002

Xcoor 0.051515 Ycoor 0.000008

Xcoor 0.051515 Ycoor 0.000013

Xcoor 0.051515 Ycoor 0.000018

Xcoor 0.051515 Ycoor 0.000024

No of faces in outlet 140

No of faces in recycle plane is 140

2. When I include the *** statements

================================================== ============================

Node 0: Process 18176: Received signal SIGSEGV.

================================================== ============================

MPI Application rank 0 exited before MPI_Finalize() with status 2

The fluent process could not be started.

Please tell me what is going wrong with this error. I just cant find a way to access the flow variables at a location i need inside the domain.

I can however access the values at the inlet and outlet though.
Abhinand is offline   Reply With Quote

 


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
Extracting flow variables inside domain in UDF Abhinand Fluent UDF and Scheme Programming 8 November 20, 2019 14:42
How could I access drag term in multiphase flow using UDF Jay Yin Fluent UDF and Scheme Programming 0 October 23, 2016 22:10
Multiphase flow - incorrect velocity on inlet Mike_Tom CFX 6 September 29, 2016 01:27
UDF profile based on function of flow time ERROR! Ash Kot Fluent UDF and Scheme Programming 1 September 2, 2016 09:35
UDF to calculate phase-averaged turbulence variables in a periodic flow ShuangqingXu Fluent UDF and Scheme Programming 0 October 26, 2011 23:48


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