#include "axi.h" #include "navier-stokes/centered.h" #include "two-phase.h" #include "log-conform.h" #include "curvature.h" #define RHO_r 0.001 #define MU_r 0.001 #define RE 5. #define FR 2.26 #define LEVEL 7 #define BETA 0.1 #define WI 1.0 scalar lambdav[], mupv[]; u.n[right] = neumann(0); p[right] = dirichlet(0); u.t[left] = dirichlet(0); tau_qq[left] = dirichlet(0); f[left] = 0.; int main() { size (2.6); init_grid (1 << LEVEL); rho1 = 1.; rho2 = RHO_r; mu1 = BETA/RE; mu2 = MU_r/RE; mup = mupv; lambda = lambdav; DT = 2e-3; run(); } event init (t = 0) { scalar s = tau_p.x.x; s[left] = dirichlet(0.); fraction (f, - sq(x - 2.) - sq(y) + sq(0.5)); foreach() u.x[] = - f[]; } event acceleration (i++) { face vector av = a; foreach_face(x) av.x[] -= 1./sq(FR); } event properties (i++) { foreach() { mupv[] = (1. - BETA)clamp(f[],0,1)/RE; lambdav[] = WIclamp(f[],0,1); } } #if TREE event adapt (i++) { adapt_wavelet ({f, u.x, u.y}, (double[]){1e-2, 5e-3, 5e-3}, maxlevel = LEVEL, minlevel = LEVEL - 2); } #endif event logfile (i += 20; t <= 5) { scalar pos[]; position (f, pos, {0,1}); fprintf (stderr, "%g %g\n", t, 2.*statsf(pos).max); } #include "view.h" event viewing (i += 10) { view (width = 400, height = 400, fov = 20, ty = -0.5, quat = {0, 0, -0.707, 0.707}); clear(); draw_vof ("f", lw = 2); squares ("u.x", linear = true); box (notics = true); mirror ({0,1}) { draw_vof ("f", lw = 2); squares ("u.y", linear = true); box (notics = true); } save ("movie.mp4"); #if 0 static FILE * fp = popen ("bppm","w"); save (fp = fp); #endif }
时间: 2024-04-17 13:23:51 浏览: 127
ds768_axi_interconnect.rar_AXI_axi-interconnect_axi_interconnect
5星 · 资源好评率100%
根据您提供的代码,可以看出您正在进行两相流的模拟。这段代码使用了Basilisk库,并设置了流体和边界条件。
关于您提到的错误:“error: incompatible types when assigning to type ‘scalar’ from type ‘double’”,这是因为在`event init(t = 0)`中,您尝试将`dirichlet(0.)`赋值给`s[left]`,但是`s`是一个标量变量,而`dirichlet(0.)`返回的是一个双精度浮点数(`double`)。
要解决这个错误,您可以使用合适的边界条件宏来设置`s[left]`。如果您想将左边界`s[left]`设置为Dirichlet边界条件为0.0,您可以使用`boundary({s})`函数来设置边界条件。例如,将以下代码行:
```c
s[left] = dirichlet(0.);
```
替换为:
```c
boundary({s});
```
这将根据`s`的类型自动为左边界设置合适的边界条件。
请注意,根据您的需求,您可能需要根据实际情况调整其他参数和边界条件。这个更新后的代码示例仅仅解决了类型不匹配的错误。
阅读全文