udf for finding coordinate of last cell of water on vertical line in domain domain
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? |
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 |
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 } |
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 ){ test if C_R(c,t_air) macro returns you correct value |
All times are GMT -4. The time now is 20:12. |