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

Advice on how to couple two different DEFINE_PROFILE

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By AlexanderZ
  • 1 Post By AlexanderZ

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 9, 2019, 18:28
Red face Advice on how to couple two different DEFINE_PROFILE
  #1
Member
 
Abhinand
Join Date: Jun 2016
Posts: 75
Rep Power: 9
Abhinand is on a distinguished road
Hello CFDUDF giants,

I have a pressing issue.
My problem statement:
I need to take some flow variables (like, U,V,T,rho) from outlet BC and do an algebraic calculation using it and set the final value as the value for the inlet BC
eg : u_inlet = 2*u_outlet

I tried by using a begin_f_loop(f,o_thread), where o_thread accesses the thread in the outlet plane and then hooking this function in the inlet plane.
Fluent never seems to give correct values.

Any help on this would be appreciated. Thanks

//code//
DEFINE_PROFILE(x_vel_out,t,pos)
{
face_t f;
Domain *d;
real FCR[2];
int notime;

Thread *r_thread;
notime = 0;
d = Get_Domain(1);
r_thread = Lookup_Thread(d,ID_rplane);

begin_f_loop(f,r_thread)
{
F_U(f,t) = F_U(f,r_thread);
if (notime<=5)
{
F_CENTROID(FCR,f,r_thread);
printf("Outlet x-coor=%f,y-coor-%f\n",FCR[0],FCR[1]);
printf("For outlet x-vel is %f\n",F_U(f,r_thread));
printf("For inlet thread x-vel is %f\n",F_U(f,t));
notime++;
}
}
end_f_loop(f,r_thread)
}
Abhinand is offline   Reply With Quote

Old   October 21, 2019, 07:36
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
use DEFINE_ADJUST macro to get values on inlet before each iteration(timestep) and send this value to DEFINE_PROFILE
don;t forget to put correct initial condition

best regards
Abhinand likes this.
__________________
best regards


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

Old   October 26, 2019, 01:16
Smile
  #3
Member
 
Abhinand
Join Date: Jun 2016
Posts: 75
Rep Power: 9
Abhinand is on a distinguished road
Hi,

Thanks for the reply.
I dont know if this is a viable solution, but this is how I had done it
I got the values from the outlet inside the define profile.
Did the calculation using the values from outlet and passed it to F_PROFILE since I am already working on a define profile.

For eg. I know the thread values of outlet and inlet so, I had got the values using F_U(f, (appropriate thread)) to get the values from outlet.

However, I have one followup question.
I do not know how to access a thread inside a domain. Lets say at a distance of 10 units from inlet and get values from that thread

Thank you. Please let me know what you think
Abhinand is offline   Reply With Quote

Old   October 28, 2019, 01:50
Default
  #4
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
you can access these data using following approach:
1. check if the cell/thread is 10 units far from origin point
2. get cell/thread value using UDMI
however, it will be value from center of cell.
Abhinand likes this.
__________________
best regards


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

Old   October 28, 2019, 12:59
Smile
  #5
Member
 
Abhinand
Join Date: Jun 2016
Posts: 75
Rep Power: 9
Abhinand is on a distinguished road
Thanks AlexanderZ,

I am having some trouble understanding your first point.
The thread ids of the face or the cell would be fixed by the number of boundary conditions right?

My domain is a rectangular 2d grid of dimensions 100mmx50mm

I tried to find the thread id
DEFINE_ADJUST(myadj,d)
{
face_t f;
Thread *th;
cell_t ct;
real FC[2];
int ctr;

ctr = 0;
thread_loop_c(th,d)
{
begin_c_loop(ct,th)
{
ctr++;
C_CENTROID(FC,ct,th);
if(FC[0] ==50e-3)
{
printf("Xcoor %f Ycoor %f\n",FC[0],FC[1]);
printf("Thread ID found %d\n",THREAD_ID(th));
}
}
end_c_loop(ct,th)
}

}

This just doesn't go inside the loop. And if I try to print the values of velocity and other variables at this specific location, it just doesn't work.
So is it necessary for me to create a case file such that there is an interior location available so that it can act as a thread location?


2. Secondly, I have a case files split_dom.cas where I have a location inside the domain which I can extract solver values.
That case file has an interior line/rake at a distance of x=50mm from origin

DEFINE_ADJUST(adjtest,d)
{
face_t f;
Thread *th;
real FC[2];
int ctr;
cell_t c;

th = Lookup_Thread(d,ID_mplane);
c = F_C0(f,th);
ctr=0;
begin_c_loop(c,th)
{
if (ctr<3){
C_CENTROID(FC,c,th);
printf("Xcoor %f Ycoor %f\n",FC[0],FC[1]);
** C_UDMI(c,th,0) = C_U(c,th);
ctr++;}
}
end_c_loop(c,th)
}
where ID_mplane refers to the ID of the location I need.
** This statement does not work. I need to store the values of cell variables in that location and use it somewhere else ,how do I do that?

Thank you for your timely help.
Abhinand is offline   Reply With Quote

Old   October 29, 2019, 00:02
Default
  #6
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
1.

lets imagine you have 100x50mm domain with 1x1 grid, so to get vales in 1 column you should get the cell between specific range.
for expamle you want to get values from 70mm away from inlet:
Code:
DEFINE_ADJUST(myadj,d)
{
face_t f;
Thread *th;
cell_t ct;
real FC[2];
int ctr;

ctr = 0;
thread_loop_c(th,d)
{
begin_c_loop(ct,th)
{
ctr++;
C_CENTROID(FC,ct,th);
if(FC[0] >0.0694 & FC[0] <0.0706)
{
printf("Xcoor %f Ycoor %f\n",FC[0],FC[1]);
printf("Thread ID found %d\n",THREAD_ID(th));
}
}
end_c_loop(ct,th)
}

}
in this case you will have access to values from cell's centers


2.
interior is a face, but you've made a loop over cells. I think it will fix the issue
__________________
best regards


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

Old   November 7, 2019, 01:33
Default
  #7
Member
 
Abhinand
Join Date: Jun 2016
Posts: 75
Rep Power: 9
Abhinand is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
1.

lets imagine you have 100x50mm domain with 1x1 grid, so to get vales in 1 column you should get the cell between specific range.
for expamle you want to get values from 70mm away from inlet:
Code:
DEFINE_ADJUST(myadj,d)
{
face_t f;
Thread *th;
cell_t ct;
real FC[2];
int ctr;

ctr = 0;
thread_loop_c(th,d)
{
begin_c_loop(ct,th)
{
ctr++;
C_CENTROID(FC,ct,th);
if(FC[0] >0.0694 & FC[0] <0.0706)
{
printf("Xcoor %f Ycoor %f\n",FC[0],FC[1]);
printf("Thread ID found %d\n",THREAD_ID(th));
}
}
end_c_loop(ct,th)
}

}
in this case you will have access to values from cell's centers


2.
interior is a face, but you've made a loop over cells. I think it will fix the issue
AlexanderZ,

Thank you for your suggestions.
I tried everything you had suggested, sadly, my issue is not resolved

1. For the first problem I was able to locate a particular line inside the thread, without explicitly creating a BC with an interior type by accessing between two values of FC(1).

I was only able to print the values of coordinates at that particular location.
**When I tried to print either F_U(at that thread) or C_U(at that thread) (cell was found using F_C0), the fluent stopped and throwed an error. This has been a continuous issue and I can't seem to get my way out of it.

2. Secondly I tried to create an BC with interior type. And as you had suggested I tried printing the coordinates and velocity values inside an f loop
Again the same problem happened I was able to print only the coordinates and not the value of flow variables.

3. I also tried copying the values to C_UDMI and stillthe same error came where fluent stopped working

Can you please have any more suggestions or ideas??
I would really appreciate any help from the community.

Thank you
Abhinand is offline   Reply With Quote

Old   November 7, 2019, 02:57
Default
  #8
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
show you code,
show your error's log
__________________
best regards


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

Old   November 10, 2019, 02:23
Question Problem with getting flow variables inside domain
  #9
Member
 
Abhinand
Join Date: Jun 2016
Posts: 75
Rep Power: 9
Abhinand is on a distinguished road
AlexanderZ,

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.
Abhinand is offline   Reply With Quote

Reply

Tags
boundary condition, change boundary condition, define_profile, udf, udf and programming


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
Need x Advice ChukerSweet OpenFOAM Running, Solving & CFD 0 June 13, 2014 13:15
Couple error Yehia Siemens 3 January 25, 2007 03:58
[Commercial meshers] Trimmed cell and embedded refinement mesh conversion issues michele OpenFOAM Meshing & Mesh Conversion 2 July 15, 2005 04:15
couple and spin index novice Siemens 6 July 8, 2004 03:31
couple problems leo Siemens 3 January 28, 2003 03:09


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