| 4 | 1/1 | 返回列表 |
| 查看: 1819 | 回復(fù): 3 | ||
[求助]
剛體附近網(wǎng)格隨剛體一起運動 已有1人參與
|
|
利用udf計算動網(wǎng)格問題,我想要做的是使得結(jié)構(gòu)體附近的網(wǎng)格隨剛體一起運動。 udf介紹:該udf使用newmark算法進行并行運算,使用了define cg motion,并將剛體運動后的坐標輸出到txt文件中。 問題:編寫的udf沒有問題,能夠使得結(jié)構(gòu)體運動,但是當(dāng)把附近網(wǎng)格(此部分網(wǎng)格已經(jīng)單獨劃分并命名為fb),將該網(wǎng)格設(shè)置為rigid body 使用同一個udf,發(fā)現(xiàn)出現(xiàn)運行錯誤。也就是不設(shè)置fb為rigid body時候可以運行,設(shè)置成rigid body時候不能運行。 文獻中提到,是要編寫兩個udf來實現(xiàn)。 求助第二個udf該怎么寫? |

銅蟲 (小有名氣)
銅蟲 (小有名氣)
|
#include <stdio.h> #include <math.h> #include "udf.h" #define WALLID 44 #define NUM_CALLS 7 DEFINE_CG_MOTION(cylinder, dt, vel, omega, time, dtime) { FILE *fp=NULL; char filename[]="out.txt"; Domain *domain=Get_Domain(1); Thread *t=Lookup_Thread(domain, WALLID); face_t f; static real lift=0.0,drag=0,lift_coeff=0.0,drag_coeff=0.0; static real a0=0.0,a1=0.0,a2=0.0,a3=0.0,a4=0.0,a5=0.0,a6=0.0,a7=0.0,KK=0.0,DeltT=0.0; static real Y=0.0,YY=0.0,Y1=0.0,YY1=0.0,YYY=0.0,PPt=0.0,Y0=0.0,YY0=0.0,YYY0=0.0; static int last_call=0; static int calls=0; int i; real rho=998.2, U=0.015, Dia=0.01; real m=0.2, k=0.710612, c=0; real Beta=0.25, Gama=0.5; real A[ND_ND],press_forces[ND_ND],viscous_forces[ND_ND]; real x_force=0.0, y_force=0.0; if ((++calls)==NUM_CALLS) last_call=1; if (last_call) { NV_S(A,=,0.0); begin_f_loop(f,t) { F_AREA(A,f,t); press_forces[0]+=F_P(f,t)*A[0]; press_forces[1]+=F_P(f,t)*A[1]; viscous_forces[0]+=F_STORAGE_R_N3V(f,t,SV_WALL_SHEAR)[0]; viscous_forces[1]+=F_STORAGE_R_N3V(f,t,SV_WALL_SHEAR)[1]; } end_f_loop(f,t) drag=press_forces[0]-viscous_forces[0]; lift=press_forces[1]-viscous_forces[1]; drag_coeff=drag/(0.5*rho*U*U*Dia); lift_coeff=lift/(0.5*rho*U*U*Dia); DeltT=dtime; a0 =1/(Beta*DeltT*DeltT); a1=Gama/(Beta*DeltT); a2=1/(Beta*DeltT); a3=1/(2*Beta)-1; a4=Gama/Beta-1; a5=(Gama/(2*Beta)-1)*DeltT; a6=(1-Gama)*DeltT; a7=DeltT*Gama; KK=k+a0*m+a1*c; PPt=lift+m*(a0*Y0+a2*YY0+a3*YYY0)+c*(a1*Y0+a4*YY0+a5*YYY0); Y=PPt/KK; YYY=(Y-Y0)*a0-a2*YY0-YYY0*a3; YY=YY0+(1-Gama)*DeltT*YYY0+Gama*DeltT*YYY; Y0=Y; YY0=YY; YYY0=YYY; Message("\n ===================================================================================" ;Message("\n %-12s %-12s %-12s %-12s %-12s %-12s ","Flow_time","Y","lift_coeff","drag_coeff","lift","drag" ;Message("\n %12.8f %12.8f %12.8f %12.8f %12.8f %12.8f ",time,Y,lift_coeff,drag_coeff,lift,drag); if ((fp=fopen(filename,"a" )==NULL)Message("\n Warning: Unable to open %s for writing!!!\n",filename); else { Message("\n Writing datas to %s...",filename); fprintf(fp,"%12.8f %12.8f %12.8f %12.8f %12.8f %12.8f %12.8f %12.8f \n",time,Y,lift_coeff,drag_coeff,lift,drag,PPt,KK); fclose(fp); Message("\n Done!" ;Message("\n ===================================================================================" ;} calls=0; last_call=0; } vel[0]=0.0; vel[1]=YY; } |
新蟲 (初入文壇)
| 4 | 1/1 | 返回列表 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 一志愿南昌大學(xué)324求調(diào)劑 +6 | hanamiko 2026-03-27 | 6/300 |
|
|---|---|---|---|---|
|
[考研] 材料求調(diào)劑 一志愿哈工大總分298分,前三科223分 +5 | dongfang59 2026-03-27 | 5/250 |
|
|
[考研] 【求調(diào)劑】085601材料工程專碩 | 總分272 | +5 | 腳滑的守法公民 2026-03-27 | 5/250 |
|
|
[考研] 086000調(diào)劑 +3 | 7901117076 2026-03-26 | 3/150 |
|
|
[考研] 266求調(diào)劑 +11 | 陽陽哇塞 2026-03-27 | 12/600 |
|
|
[考研] 286求調(diào)劑 +4 | lim0922 2026-03-26 | 4/200 |
|
|
[考研] 276求調(diào)劑。有半年電池和半年高分子實習(xí)經(jīng)歷 +10 | 材料學(xué)257求調(diào)劑 2026-03-23 | 11/550 |
|
|
[考研] 329求調(diào)劑 +7 | 鈕恩雪 2026-03-25 | 7/350 |
|
|
[考研] 333求調(diào)劑 +6 | wfh030413@ 2026-03-23 | 6/300 |
|
|
[考研] 297求調(diào)劑 +6 | 田洪有 2026-03-26 | 6/300 |
|
|
[考研] 281求調(diào)劑 +6 | Koxui 2026-03-24 | 7/350 |
|
|
[考研] 尋找調(diào)劑 +5 | 倔強芒? 2026-03-21 | 8/400 |
|
|
[考研] 機械學(xué)碩總分317求調(diào)劑。。。 +4 | Acaciad 2026-03-25 | 4/200 |
|
|
[考研] 材料專碩 335 分求調(diào)劑 +4 | 拒絕冷暴力 2026-03-25 | 4/200 |
|
|
[考研] 0854電子信息求調(diào)劑 324 +4 | Promise-jyl 2026-03-23 | 4/200 |
|
|
[考研] 0703化學(xué)調(diào)劑,求導(dǎo)師收 +7 | 天天好運來上岸?/a> 2026-03-24 | 7/350 |
|
|
[考研] 一志愿吉大化學(xué)322求調(diào)劑 +4 | 17501029541 2026-03-23 | 6/300 |
|
|
[考研] 344求調(diào)劑 +3 | desto 2026-03-24 | 3/150 |
|
|
[考研] 一志愿河北工業(yè)大學(xué)0817化工278分求調(diào)劑 +7 | jhybd 2026-03-23 | 12/600 |
|
|
[考研] 276求調(diào)劑 +3 | YNRYG 2026-03-21 | 4/200 |
|