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 Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 11, 2019, 07:34
Default Access Flow variables at an arbitrary location using UDF
  #1
Member
 
Abhinand
Join Date: Jun 2016
Posts: 74
Rep Power: 7
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

Old   November 12, 2019, 07:05
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,860
Rep Power: 23
pakk will become famous soon enough
And what happens if you only include the first *** lines, where you print?
pakk is online now   Reply With Quote

Old   November 12, 2019, 18:17
Default
  #3
Member
 
Joshua
Join Date: Aug 2014
Posts: 49
Rep Power: 8
jbo214 is on a distinguished road
Quote:
I need to get the flow quantities inside a rectangular 2d (100mmx50mm) domain at a distance of 50mm from inlet.

Insert a plane and select the 'Bounded Surface' option. You provide Fluent with the (x,y,z) coordinates of three points that define a rectangle. Figure out the coordinates that define your rectangle and you are good to go.


You can then select that surface to do all the normal reporting stuff with. No need for a UDF or to split the domain.

Additionally, you can split the domain and label the face you want with a named selection (ex 'interior-my-face') and use that instead.
jbo214 is offline   Reply With Quote

Old   November 12, 2019, 23:02
Default
  #4
Member
 
Abhinand
Join Date: Jun 2016
Posts: 74
Rep Power: 7
Abhinand is on a distinguished road
Quote:
Originally Posted by pakk View Post
And what happens if you only include the first *** lines, where you print?
Hi.

If I include any of the *** lines in my code
I get the error which I mentioned above. Only if I remove those lines(essentially I'm not able to print the values inside the domain). However I'm able to print the values of Coordinates in that domain. Nothing other than that.

If I change the thread to either of outlet or inlet plane I'm able to print all the variables. It just wouldn't work only for any other region/thread inside the domain.

Please let me know if you have some ideas to circumvent this
Abhinand is offline   Reply With Quote

Old   November 12, 2019, 23:03
Default
  #5
Member
 
Abhinand
Join Date: Jun 2016
Posts: 74
Rep Power: 7
Abhinand is on a distinguished road
Quote:
Originally Posted by jbo214 View Post
Insert a plane and select the 'Bounded Surface' option. You provide Fluent with the (x,y,z) coordinates of three points that define a rectangle. Figure out the coordinates that define your rectangle and you are good to go.


You can then select that surface to do all the normal reporting stuff with. No need for a UDF or to split the domain.

Additionally, you can split the domain and label the face you want with a named selection (ex 'interior-my-face') and use that instead.
Hi.
This is the usual way to just get the values at any location by creating a line/rake.
However I need to do this over and over for Every iteration and do some calculations based on those values and solve the NS eqns accordingly.
Abhinand is offline   Reply With Quote

Old   November 13, 2019, 03:10
Default
  #6
Senior Member
 
Join Date: Nov 2013
Posts: 1,860
Rep Power: 23
pakk will become famous soon enough
Do you do this in a simulation that has already a solution, or a simulation that is not initialized yet? I can understand that you would get this error when you initialize, but you did not mention anything about initializing.
pakk is online now   Reply With Quote

Old   November 13, 2019, 11:35
Default
  #7
Member
 
Abhinand
Join Date: Jun 2016
Posts: 74
Rep Power: 7
Abhinand is on a distinguished road
I am not using this during initialization. I read a data file and then hook the udf and then start my calculations again
Abhinand is offline   Reply With Quote

Old   November 13, 2019, 15:37
Default
  #8
Senior Member
 
Join Date: Nov 2013
Posts: 1,860
Rep Power: 23
pakk will become famous soon enough
I just noticed that you talk about 'interpreting'. Don't do that. Compile it.

(Even if it does not solve your current problem, it will help you in the future.)

Otherwise, I have no idea.
pakk is online now   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 00:41.