| 9 | 1/1 | 返回列表 |
| 查看: 2895 | 回復: 8 | |||
[交流]
UDF的問題 已有2人參與
|
|
UDF的內容如下: #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”轉換為“real” 連著出了好幾個問題,現在都已經暈乎了,求助。。。! |


新蟲 (小有名氣)




專家顧問 (著名寫手)
![]() |
專家經驗: +60 |

專家顧問 (著名寫手)
![]() |
專家經驗: +60 |
| 9 | 1/1 | 返回列表 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研]
|
y7czhao 2026-03-26 | 9/450 |
|
|---|---|---|---|---|
|
[考研] 085404求調劑,總分309,本科經歷較為豐富 +4 | 來財aa 2026-03-25 | 4/200 |
|
|
[考研] 壓國家一區(qū)線,求導師收留,有恩必謝! +3 | 迷人的哈哈 2026-03-28 | 3/150 |
|
|
[考研] 265求調劑 +8 | 小木蟲085600 2026-03-27 | 8/400 |
|
|
[考研] 復試調劑,一志愿南農083200食品科學與工程 +5 | XQTJZ 2026-03-26 | 5/250 |
|
|
[考研] 0703一志愿9,初試成績:338,四六級已過,有科研經歷,求調劑! +3 | Zuhui0306 2026-03-25 | 3/150 |
|
|
[考研] 303求調劑 +7 | 安憶靈 2026-03-22 | 8/400 |
|
|
[考研] 085600材料與化工306 +10 | z1z2z3879 2026-03-21 | 11/550 |
|
|
[考研] 材料求調劑 +8 | @taotao 2026-03-21 | 8/400 |
|
|
[考研] 材料求調劑 +5 | .m.. 2026-03-25 | 5/250 |
|
|
[考研] 352求調劑 +4 | 大米飯! 2026-03-22 | 4/200 |
|
|
[考研] 297求調劑 +6 | 田洪有 2026-03-26 | 6/300 |
|
|
[考研] 一志愿河工大 081700 276求調劑 +4 | 地球繞著太陽轉 2026-03-23 | 4/200 |
|
|
[考研] 347求調劑 +4 | L when 2026-03-25 | 4/200 |
|
|
[考研] 0854人工智能方向招收調劑 +4 | 章小魚567 2026-03-24 | 4/200 |
|
|
[考研] 食品專碩 一志愿雙一流 328 +3 | xiaom99 2026-03-21 | 4/200 |
|
|
[考研] 0703化學調劑,求導師收 +7 | 天天好運來上岸?/a> 2026-03-24 | 7/350 |
|
|
[考研] 300求調劑,材料科學英一數二 +5 | leaflight 2026-03-24 | 5/250 |
|
|
[考研] 341求調劑(一志愿湖南大學070300) +5 | 番茄頭--- 2026-03-22 | 6/300 |
|
|
[考研] 求老師收我 +3 | zzh16938784 2026-03-23 | 3/150 |
|