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

udf for finding coordinate of last cell of water on vertical line in domain domain

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 7, 2022, 08:42
Default udf for finding coordinate of last cell of water on vertical line in domain domain
  #1
New Member
 
sheida
Join Date: Mar 2021
Posts: 11
Rep Power: 4
shedo is on a distinguished road
Hello experts,
I have 2 phase flow(water and air) and I generated waves. after a while I want to find water elevation on the vertical line defined in the domain (located at 2m from the inlet boundary), I have the ID of the line, but I don't know how to find the water elevation and save it on file to reuse it in the next steps? can anyone help me with it?
shedo is offline   Reply With Quote

Old   March 8, 2022, 01:09
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 33
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
how did you make that line?
make a sketch

my vision:
to find the coordinate of water you may make a loop over cells and check C_VOF (in case you are using VOF to simulate water)

if C_VOF = 1 (or close to 1) you may consider it as water, so now you may check it's coordinates and get the max along the axis you need
__________________
best regards


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

Old   March 8, 2022, 14:42
Default
  #3
New Member
 
sheida
Join Date: Mar 2021
Posts: 11
Rep Power: 4
shedo is on a distinguished road
thanks, AlexanderZ
I wrote to UDF, but only the first one gives me the output and the second one always shows 0 value for C_VOF .
-------------------------
the first UDF is:
==============
#include "udf.h"
#include "sg_mphase.h"
/* domain passed to Adjust function is mixture domain for multiphase*/
FILE *fp;
DEFINE_ADJUST(report_VOF, domain)
{
/* "Parallelized" Sections */
#if !RP_HOST /* Compile this section for computing processes only (serial and node) since these variables are not available on the host */

Thread *t;
cell_t c;
real xc[ND_ND],x0=2.4327,dx=0.2;
real max1=0.0;

fp = fopen("output.txt","w");
thread_loop_c(t,domain)
{
begin_c_loop(c,t){
C_CENTROID(xc, c, t);
if(xc[0]<x0+dx && xc[0]>x0-dx && max1<xc[1] && C_R(c,t)>900.0){
max1=xc[1];
}

}
end_c_loop(c,t)
}
fprintf(fp,"%f\n",max1);
fclose(fp);

}
#endif /* !RP_HOST */
}



-------------------------------------------------------------------
and the second udf is:
=========================================

DEFINE_ADJUST(max_value, domain)
{
#if !RP_HOST
real FC[2],Max=0.0;
cell_t c; //Cell thread
face_t f;
Thread *t_air; // Phase level thread
///domain = Get_Domain(2);
///int ID = 11;
//Domain *subdomain;
//subdomain = Get_Domain(2); /* returns phase with ID=2 domain pointer
// and assigns to variable
// Zone ID for wall-1 zone from Boundary Conditions task page
Thread *thread = Lookup_Thread(domain, 2);
t_air = THREAD_SUB_THREAD(thread, 1);
begin_f_loop(f, thread)
{
//c = F_C0(f,thread);
c = F_C0(f,thread);
F_CENTROID(FC,f,thread);
if(Max<FC[1] && C_R(c,t_air)>100.0 ){
Max=FC[1];
}
///if (C_VOF(c,t_air) <0.2) {
// C_VOF(c,t_air)=0;
// printf("x-coord = %f y-coord = %f phi=%f\n", FC[0], FC[1],C_VOF(c,t_air));
//printf("x-coord = %f y-coord = %f phi=%f\n", FC[0], FC[1],C_VOF(c,domain));
// }

}
end_f_loop(f,thread)

printf("max=%f \n",Max);
#endif
}
shedo is offline   Reply With Quote

Old   March 14, 2022, 06:03
Default
  #4
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 33
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
you may see Max=0 as output in two cases:
1. your condition is never true
Code:
f(Max<FC[1] && C_R(c,t_air)>100.0 ){
2. max y-coordinate of our boundary (with ID 2) is 0, in other words all other coordinates of boundary are negative

test if C_R(c,t_air) macro returns you correct value
__________________
best regards


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

Reply

Tags
c_vof, multiphase, udf

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
problem during mpi in server: expected Scalar, found on line 0 the word 'nan' muth OpenFOAM Running, Solving & CFD 3 August 27, 2018 05:18
[blockMesh] BlockMeshmergePatchPairs hjasak OpenFOAM Meshing & Mesh Conversion 11 August 15, 2008 08:36
[blockMesh] BlockMeshmergePatchPairs polyTopoChanger benru OpenFOAM Meshing & Mesh Conversion 3 June 29, 2008 22:24
Problems of Duns Codes! Martin J Main CFD Forum 8 August 15, 2003 00:19
error while compiling the USER Sub routine CFD user CFX 3 November 25, 2002 16:16


All times are GMT -4. The time now is 03:45.