| 查看: 2821 | 回复: 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” 连着出了好几个问题,现在都已经晕乎了,求助!!!!! |
» 猜你喜欢
基金申报
已经有5人回复
基金委咋了?2026年的指南还没有出来?
已经有7人回复
国自然申请面上模板最新2026版出了吗?
已经有17人回复
纳米粒子粒径的测量
已经有8人回复
疑惑?
已经有5人回复
计算机、0854电子信息(085401-058412)调剂
已经有5人回复
Materials Today Chemistry审稿周期
已经有5人回复
溴的反应液脱色
已经有7人回复
推荐一本书
已经有12人回复
常年博士招收(双一流,工科)
已经有4人回复


2楼2015-11-03 16:48:11

3楼2015-11-03 18:44:31

4楼2015-11-04 11:42:11

5楼2015-11-04 15:55:15

6楼2015-11-05 08:53:32
死天
专家顾问 (著名写手)
-

专家经验: +60 - 应助: 399 (硕士)
- 金币: 3648.9
- 红花: 89
- 帖子: 1336
- 在线: 443.8小时
- 虫号: 2643057
- 注册: 2013-09-09
- 专业: 流体力学
- 管辖: 仿真模拟
7楼2015-11-05 12:21:16

8楼2015-11-11 15:10:00
死天
专家顾问 (著名写手)
-

专家经验: +60 - 应助: 399 (硕士)
- 金币: 3648.9
- 红花: 89
- 帖子: 1336
- 在线: 443.8小时
- 虫号: 2643057
- 注册: 2013-09-09
- 专业: 流体力学
- 管辖: 仿真模拟
9楼2015-11-11 18:42:32











;
回复此楼