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

銅蟲(chóng) (小有名氣)
銅蟲(chóng) (小有名氣)
|
#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; } |
新蟲(chóng) (初入文壇)
| 4 | 1/1 | 返回列表 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 311(085601)求調(diào)劑 +4 | liziyeyeye 2026-03-28 | 4/200 |
|
|---|---|---|---|---|
|
[考研] 332求調(diào)劑 +3 | @MZB382400 2026-03-28 | 3/150 |
|
|
[考研] 材料與化工272求調(diào)劑 +9 | 阿斯蒂芬2004 2026-03-28 | 9/450 |
|
|
[考研] 317求調(diào)劑 +6 | 十閑wx 2026-03-24 | 6/300 |
|
|
[考研] 311求調(diào)劑 +4 | 冬十三 2026-03-24 | 4/200 |
|
|
[考研] 085602 307分 求調(diào)劑 +7 | 不知道叫什么! 2026-03-26 | 7/350 |
|
|
[考研] 291求調(diào)劑 +7 | 孅華 2026-03-22 | 7/350 |
|
|
[考研] 352分 化工與材料 +5 | 海納百川Ly 2026-03-27 | 5/250 |
|
|
[考研] 0856調(diào)劑 +5 | 求求讓我有書(shū)讀?/a> 2026-03-26 | 6/300 |
|
|
[考研] 化學(xué)308分求調(diào)劑 +8 | 你好明天你好 2026-03-23 | 9/450 |
|
|
[考研] 一志愿陜師大生物學(xué)071000,298分,求調(diào)劑 +5 | SYA! 2026-03-23 | 5/250 |
|
|
[考研] 333求調(diào)劑 +6 | wfh030413@ 2026-03-23 | 6/300 |
|
|
[考研] 【雙一流院校新能源、環(huán)境材料,材料加工與模擬招收大量調(diào)劑】 +4 | Higraduate 2026-03-22 | 8/400 |
|
|
[考研]
|
平樂(lè)樂(lè)樂(lè) 2026-03-26 | 4/200 |
|
|
[考研] 總分293求調(diào)劑 +6 | 加一一九 2026-03-25 | 8/400 |
|
|
[考研] 網(wǎng)絡(luò)空間安全0839招調(diào)劑 +4 | w320357296 2026-03-25 | 6/300 |
|
|
[考研] 300求調(diào)劑,材料科學(xué)英一數(shù)二 +5 | leaflight 2026-03-24 | 5/250 |
|
|
[基金申請(qǐng)] 請(qǐng)教下大家 2026年國(guó)家基金申請(qǐng)是雙盲審嗎? +3 | lishucheng1 2026-03-22 | 5/250 |
|
|
[考研] 335求調(diào)劑 +4 | yuyu宇 2026-03-23 | 5/250 |
|
|
[考研] 341求調(diào)劑(一志愿湖南大學(xué)070300) +5 | 番茄頭--- 2026-03-22 | 6/300 |
|