
[Sponsors] 
make a new data from external .txt data and save it in a UDM 

LinkBack  Thread Tools  Search this Thread  Display Modes 
February 24, 2020, 12:28 

#21 
Member
Join Date: Jan 2020
Posts: 31
Rep Power: 6 

February 24, 2020, 14:48 
Objective

#22 
Senior Member

You wanted to fetch values of xcoordinate and then calculate the corresponding values. You have already been able to calculate those. Values are not wrong; those are just not in the order your expect, but the values are correct. If you want something more, you have to explain the requirements.
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. 

February 24, 2020, 18:01 

#23 
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 
you may use 2 UDMIs:
1. save yy 2. save 1cos((PI/2)*(yy/L)); from my point of view, you can't write to file inside first loop because you can do it only from host you may try this, compile it Code:
#include "udf.h" #define PI 3.141592654 #define ID 3 real xold=0.0;real yold=0.0; real uold=0.0;real vold=0.0; real dx=0.0e0;real dy=0.0e0; real L=0.03; DEFINE_EXECUTE_AT_END(ForceCalculate) { real Fy=0.0e0; real x[ND_ND]; real yy; real C=1.38e9; real teta=3.69e6; real my=3.87e5; real kyy=3.6; real ky=kyy+((teta*teta)/C); real zety=0.0; // real wny=sqrt(ky/my); real cy=2.0e0*my*wny*zety; real wdy=wny*sqrt(1.0e0zety*zety); // real ts=CURRENT_TIMESTEP; real time=CURRENT_TIME; // real Ay,By,y; FILE *fout; real NV_VEC(WS); real area[ND_ND]; real Fpy = 0.0; real Fvy=0.0; Domain *d= Get_Domain(1); Thread *t=Lookup_Thread(d,ID); face_t f; begin_f_loop(f,t) { F_CENTROID(x,f,t); yy = x[0]; F_UDMI(f, t, 0) = 1cos((PI/2)*(yy/L)); F_UDMI(f, t, 1) = yy; F_AREA(area,f,t); Fpy+=L*area[1]*F_P(f,t)*F_UDMI(f, t, 0); } end_f_loop(f,t) Fy = Fpy; #if RP_NODE /* SERIAL or NODE */ Fy=PRF_GRSUM1(Fy); #endif /* RP_NODE */ // Message0(" k=%g wd= %g Fy=%g\n",k,wd,Fy); // Message0(" time=%g xold= %g deltaT=%g\n",time,xold,ts); node_to_host_real_1(Fy); /* Does nothing in SERIAL */ #if !RP_NODE /* SERIAL or HOST */ Ay=yoldFy/ky; By=(vold+zety*wny*Ay)/wdy; y=exp(zety*wny*ts)*(Ay*cos(wdy*ts)+By*sin(wdy*ts))+Fy/ky; vold=zety*wny*(yFy/ky)+wdy*exp(zety*wny*ts)*(By*cos(wdy*ts)Ay*sin(wdy*ts)); dy=yyold; yold=y; // // fout = fopen ("data2D.out","a"); begin_f_loop(f,t) { fprintf(fout," %f %f %f\n",time,F_UDMI(f, t, 0),F_UDMI(f, t, 1)); } end_f_loop(f,t) fclose(fout); fout = fopen ("data2DD.out","a"); fprintf(fout," %f %f %f %f\n",time,yold,Fy,vold); fclose(fout); #endif /* !RP_NODE */ }
__________________
best regards ****************************** press LIKE if this message was helpful 

February 25, 2020, 02:46 
File writing

#24 
Senior Member

You are right about host not having this data, Alexander. However, file writing can be done inside the face loop. The problem is not with respect to the host rather will respect to the availability of the file to all nodes, including the host. So, all that is needed is to ensure that at any given time only one node access the file. Simpler option, of course, would be do it in Serial. However, if the case is big, you have two options. Either pass all the data to node 0 and let it do the writing or run in a sequential manner from node 0 to the node N (N being the number of parallel cores being used) and let every node write its data. You can use macro PRF_CSEND_INT to keep track of this. Look at the example DEFINE_OUTPUT_PARAMETER in UDF manual for its use
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. 

February 25, 2020, 05:55 

#25  
Member
Join Date: Jan 2020
Posts: 31
Rep Power: 6 
Quote:
thank you all my friends I will show you my main problem and what I want to do. my mesh linked too. My main problem is with 1 cell with no moving and this causes mistake in the blade shape and I think that the problem is with the X[0] data in the pictures, you can see the cell with no motion and the page of the article with the formulas to simulate this case! I think my Grid Motion has some mistakes too!(maybe this part: NV_V_VS(NODE_COORD(v), =, NODE_COORD(v), +, axis, *, F_UDMI(f, tf, 2)); ) thanks for your help here is my UDF with Grid Motion! #include "udf.h" #define PI 3.141592654 #define ID 3 real xold=0.0;real yold=0.0; real uold=0.0;real vold=0.0; real dx=0.0e0;real dy=0.0e0; real L=0.03; DEFINE_EXECUTE_AT_END(ForceCalculate) { real Fy=0.0e0; real x[ND_ND]; real yy; real C=1.38e9; real teta=3.69e6; real my=3.87e5; real kyy=3.6; real ky=kyy+((teta*teta)/C); real zety=0.0; // real wny=sqrt(ky/my); real cy=2.0e0*my*wny*zety; real wdy=wny*sqrt(1.0e0zety*zety); // real ts=CURRENT_TIMESTEP; real time=CURRENT_TIME; // real Ay,By,y; FILE *fout; real NV_VEC(WS); real area[ND_ND]; real Fpy = 0.0; real Fvy=0.0; Domain *d= Get_Domain(1); Thread *t=Lookup_Thread(d,ID); face_t f; begin_f_loop(f,t) { F_CENTROID(x,f,t); yy = x[0]; F_UDMI(f, t, 0) = 1cos((PI/2)*(yy/L)); F_UDMI(f, t, 1) = yy; F_AREA(area,f,t); Fpy+=L*area[1]*F_P(f,t)*F_UDMI(f, t, 0); } end_f_loop(f,t) Fy = Fpy; #if RP_NODE /* SERIAL or NODE */ Fy=PRF_GRSUM1(Fy); #endif /* RP_NODE */ // Message0(" k=%g wd= %g Fy=%g\n",k,wd,Fy); // Message0(" time=%g xold= %g deltaT=%g\n",time,xold,ts); node_to_host_real_1(Fy); /* Does nothing in SERIAL */ #if !RP_NODE /* SERIAL or HOST */ Ay=yoldFy/ky; By=(vold+zety*wny*Ay)/wdy; y=exp(zety*wny*ts)*(Ay*cos(wdy*ts)+By*sin(wdy*ts))+Fy/ky; vold=zety*wny*(yFy/ky)+wdy*exp(zety*wny*ts)*(By*cos(wdy*ts)Ay*sin(wdy*ts)); dy=yyold; yold=y; // // fout = fopen ("data2D.out","a"); begin_f_loop(f,t) { fprintf(fout," %f %f %f\n",time,F_UDMI(f, t, 0),F_UDMI(f, t, 1)); } end_f_loop(f,t) fclose(fout); fout = fopen ("data2DD.out","a"); fprintf(fout," %f %f %f %f\n",time,yold,Fy,vold); fclose(fout); #endif /* !RP_NODE */ } DEFINE_GRID_MOTION(beam,domain,dt,time,dtime) { Thread *tf = DT_THREAD(dt); face_t f; Node *v; int n; real x[ND_ND]; real yy; real yyy[ND_ND]; real NV_VEC(axis); real yoldd; real bb; /* set deforming flag on adjacent cell zone */ SET_DEFORMING_THREAD_FLAG(THREAD_T0(tf)); begin_f_loop(f,tf) { F_UDMI(f, tf, 2) = F_UDMI(f, tf, 0)*yold; } end_f_loop(f,tf); Message ("time = %f, \n", time); NV_D(axis, =, 0.0, 1, 0.0); begin_f_loop(f,tf) { f_node_loop(f,tf,n) { v = F_NODE(f,tf,n); if ( NODE_POS_NEED_UPDATE (v)) { NODE_POS_UPDATED(v); NV_V_VS(NODE_COORD(v), =, NODE_COORD(v), +, axis, *, F_UDMI(f, tf, 2)); } } } end_f_loop(f,tf); } http://8upload.ir/uploads/f9239726.rar 

February 25, 2020, 07:53 
A few checks

#26 
Senior Member

1. There is no need to multiply by L in the calculation of Fpy since the area already includes it.
2. Value of yold is being calculated at the host but I do not see any host_to_node_... transfer. 3. Check the value for UDM 0 for the last face. Since you are writing value for x, check its value for the maximum x. The value should be slightly smaller than 1.
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. 

February 26, 2020, 02:26 

#27  
Member
Join Date: Jan 2020
Posts: 31
Rep Power: 6 
Quote:
I use fluent with serial type, still, need a host to node? sorry about these questions I am not good in UDF and how can I fix my UDF? still, it doesn't work! can you fix it from the article page I sent you?! I work on it for months! 

February 26, 2020, 03:15 
Host To Node

#28 
Senior Member

In serial, you do not need host to node or node to host, since this classification does not exist.
To debug the code, I'd suggest you simplify it. Do not use any equation for moving the nodes. Try moving those by a constant value, so, replace F_UDMI in node update with a small constant value. If the end node still does not show any movement, then it will be easier to find the reason. If it shows a movement, then you know that the displacement provided by the UDM is not correct. This way, it will become easier to find out the solution.
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. 

Tags 
#fluent #udf #data 
Thread Tools  Search this Thread 
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
[General] "Save Data" from "Plot Over Line" for a single type of data  HakikiCanakkaleli  ParaView  1  March 5, 2022 22:39 
[General] Save Data for all time steps  mvdl1996  ParaView  3  March 30, 2021 02:12 
X Y PLOT  Save the data  sidam  STARCCM+  3  July 9, 2013 08:35 
How to save 2D data in contour plot  mssound  FLUENT  0  February 15, 2010 14:01 
Save data  massimo  Siemens  0  November 18, 2002 05:35 