| 9 | 1/1 | 返回列表 |
| 查看: 2896 | 回復(fù): 8 | |||
木風(fēng)10086新蟲 (小有名氣)
|
[交流]
UDF的問題 已有2人參與
|
|
UDF的內(nèi)容如下: #include "udf.h" #include <stdio.h> #include "dynamesh_tools.h" static int nozzle_tid = 10; static real g_c = 9.81; static real loc = 0.0; static real initial_weight = 10.0; static real burn_rate = 0.0; static real current_time = -1.0; static real thrust_prev = 0.0; static real missile_velocity = 0.0; static real missile_weight (real time) { return (initial_weight - burn_rate * time); } DEFINE_ON_DEMAND(reset_velocity) { missile_velocity = 0.0; thrust_prev = 0.0; current_time = -1.0; } DEFINE_CG_MOTION(missile_1dof, dt, cg_vel, cg_omega, time, dtime) { #if 1 FILE *fp; #endif /* reset velocities */ NV_S (cg_vel, =, 0.0); NV_S (cg_omega, =, 0.0); if (!Data_Valid_P ()) return; /* Give rocket time to establish thrust for specified time */ if (time < 0.1) Message (" NO MOTION YET: TIME LESS THAN 0.1 SECONDS " ; if (time < 0.1) return; /* update missile velocity only if we are at the next new time level */ if ((time - 0.1*dtime) > current_time) { Domain *domain; Thread *t; face_t f; real force0, force1, force; real area, total, v_avg, dv; real w0, w1, mass_flow; /* update time stamp */ current_time = time; /* get nozzle exit thread (from predefined thread id) */ domain = THREAD_DOMAIN (DT_THREAD ((Dynamic_Thread *)dt)); if (NULLP (t = Lookup_Thread (domain, nozzle_tid))) return; /* compute average exit velocity (weighted by area) */ v_avg = 0.0; total = 0.0; begin_f_loop (f, t) { area = NV_MAG (F_AREA_CACHE (f, t)); #if RP_3D v_avg += area * ND_MAG (F_U (f, t), F_V (f, t), F_W (f, t)); #else v_avg += area * ND_MAG (F_U (f, t), F_V (f, t), 0.0); #endif total += area; } end_f_loop (f, t) v_avg /= total; /* subtract off missile_velocity to get relative velocity */ /* ??? v_avg = v_avg - missile_velocity; */ /* compute thrust from mdot and v_e note: assume nozzle_exit is type mass-flow-exit */ if (THREAD_VAR(t).mfi.flow_spec == MASS_FLOW_TYPE) mass_flow = THREAD_VAR(t).mfi.mass_flow; else { real mass_flow; /* if mass_flux given as profile, then sum up area * mass_flux over face thread, else, mass_flux is constant */ if (IS_PROFILE (THREAD_VAR (t).mfi.mass_flux)) { begin_f_loop (f, t) mass_flow = NV_MAG (F_AREA_CACHE (f, t)) * F_VAR (f, t, THREAD_VAR (t).mfi.mass_flux); end_f_loop (f, t) } else { mass_flow = THREAD_VAR(t).mfi.mass_flux.constant * total; } #if RP_2D if (rp_axi) mass_flow *= 2.0 * M_PI; #endif } force = v_avg * F_VAR (0, t, THREAD_VAR(t).mfi.mass_flux) / total; /* compute change in velocity (use trapezoidal rule) */ w0 = missile_weight (time - dtime); force0 = (thrust_prev - w0 * g_c) / w0; w1 = missile_weight (time); force1 = (force - w1 * g_c) / w1; dv = MAX (0.0, 0.5 * dtime * (force0 + force1)); missile_velocity += dv; loc += missile_velocity * dtime; thrust_prev = force; #if 1 if( (fp=fopen("silo.dat","a" ) !=NULL ){ float check = F_FLUX(f,t)+F_GRID_FLUX(f,t); fprintf(fp,"%f %f %f %f %f %f \n", time,missile_velocity,loc,v_avg,F_FLUX(f,t),F_GRID_FLUX(f,t)); fclose(fp); } #endif Message ("time = %12.5e, x_vel = %12.5e, force = %12.5e, loc(m)= %1.5e\n", time, missile_velocity, 0.5*(force0 + force1), loc); } /* set missile velocity */ cg_vel[0] = missile_velocity; } 編譯型UDF,build后的提示如下: silo.c ..\..\src\silo.c(94) : error C2440: “=”: 無法從“Profile”轉(zhuǎn)換為“real” 連著出了好幾個問題,現(xiàn)在都已經(jīng)暈乎了,求助。。。! |

新蟲 (小有名氣)

新蟲 (小有名氣)

新蟲 (小有名氣)

新蟲 (小有名氣)

新蟲 (小有名氣)

專家顧問 (著名寫手)
![]() |
專家經(jīng)驗: +60 |
新蟲 (小有名氣)

專家顧問 (著名寫手)
![]() |
專家經(jīng)驗: +60 |
| 9 | 1/1 | 返回列表 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研]
|
孅華 2026-03-22 | 17/850 |
|
|---|---|---|---|---|
|
[考研] 275求調(diào)劑 +10 | Micky11223 2026-03-25 | 13/650 |
|
|
[考研] 086000調(diào)劑 +3 | 7901117076 2026-03-26 | 3/150 |
|
|
[考研] 287求調(diào)劑 +10 | land xuxu 2026-03-26 | 10/500 |
|
|
[考研] 314求調(diào)劑 +3 | 溪云珂 2026-03-26 | 3/150 |
|
|
[考研] 求調(diào)劑323材料與化工 +7 | 1124361 2026-03-24 | 7/350 |
|
|
[考研] 求調(diào)劑 +6 | 林之夕 2026-03-24 | 6/300 |
|
|
[考研] 321求調(diào)劑 +6 | wasdssaa 2026-03-26 | 6/300 |
|
|
[考研] 086000生物與醫(yī)藥292求調(diào)劑 +6 | 小小陳小小 2026-03-22 | 9/450 |
|
|
[考研] 309求調(diào)劑 +4 | gajsj 2026-03-25 | 5/250 |
|
|
[考研] 一志愿中南大學(xué)化學(xué)學(xué)碩0703總分337求調(diào)劑 +7 | niko- 2026-03-22 | 7/350 |
|
|
[考研] 考研一志愿蘇州大學(xué)初始315(英一)求調(diào)劑 +3 | sbdksD 2026-03-24 | 4/200 |
|
|
[考研] 296求調(diào)劑 +4 | 汪!?! 2026-03-25 | 7/350 |
|
|
[考研] 【2026考研調(diào)劑】制藥工程 284分 求相關(guān)專業(yè)調(diào)劑名額 +4 | 袁奐奐 2026-03-25 | 8/400 |
|
|
[考研] 求調(diào)劑 +6 | 研研,接電話 2026-03-24 | 7/350 |
|
|
[考研] 材料專碩331求調(diào)劑 +4 | 鮮當(dāng)牛 2026-03-24 | 4/200 |
|
|
[考研] 307求調(diào)劑 +3 | 余意卿 2026-03-21 | 6/300 |
|
|
[考研] 一志愿山東大學(xué)藥學(xué)學(xué)碩求調(diào)劑 +3 | 開開心心沒煩惱 2026-03-23 | 4/200 |
|
|
[考研] 070300,一志愿北航320求調(diào)劑 +3 | Jerry0216 2026-03-22 | 5/250 |
|
|
[考研] 求調(diào)劑 +3 | .m.. 2026-03-21 | 4/200 |
|