我正在编辑【basilisk】代码,遇到了 【
bubble.c:120: warning: Basilisk C parse error near `foreach_embed(){
coord n, p'
bubble.c: In function ‘properties_1’:
bubble.c:105:3: warning: implicit declaration of function ‘cm_update’ [-Wimplicit-function-declaration]
bubble.c:106:3: warning: implicit declaration of function ‘fm_update’ [-Wimplicit-function-declaration]
bubble.c:111:12: warning: unused variable ‘fluid_mu’ [-Wunused-variable]
bubble.c:111:12: warning: unused variable ‘fluid_mu’ [-Wunused-variable]
bubble.c:116:51: error: ‘mu_fluid’ undeclared (first use in this function)
bubble.c:116:51: note: each undeclared identifier is reported only once for each function it appears in
bubble.c:119:3: warning: implicit declaration of function ‘foreach_embed’ [-Wimplicit-function-declaration]
bubble.c:119:18: error: expected ‘;’ before ‘{’ token
bubble.c:127:1: warning: no return statement in function returning non-void [-Wreturn-type]
bubble.c: In function ‘_init_solver’:
bubble.c:130:35: error: ‘force_expr0’ undeclared (first use in this function)
解释各个问题】
,请帮我检查并改正错误点。我的原始代码如下:
【i#include "axi.h"
#include "navier-stokes/centered.h"
#include "two-phase.h"
#include "navier-stokes/conserving.h"
#include "embed.h"
#include "tension.h"
#include "reduced.h"
#include "view.h"
double bubble_radius = 1.;
double box_size = 20.;
double end_time = 7.5;
coord particle_vel = {0}; // 粒子速度
coord particle_pos; // 粒子位置
double rho_p, particle_vol; // 粒子密度和体积
double radius = 0.1;
face vector muv[];
int MAXLEVEL = 9;
int main (int argc, char **argv)
{
size (box_size);
#if !TREE
N = 1 << MAXLEVEL;
#endif
mu = muv;
rho1 = 1.;
rho2 = 0.01;
TOLERANCE = 1e-4 [*];
f.sigma = 10.0;
G.x = -2.5;
mu1 = 0.4472;
mu2 = 0.02236;
particle_pos = (coord){ 0.0, box_size*0.2+6.*bubble_radius }; // 粒子初始位置
rho_p = 2.0;
run();
}
event init (t = 0)
{
#if TREE
refine (sq(2.*bubble_radius) - sq(x - box_size*0.2) - sq(y) > 0 &&
level < MAXLEVEL);
#endif
fraction (f, - (sq(bubble_radius) - sq(x - box_size*0.2) - sq(y)));
#if TREE
refine (sq(2.*radius) - sq(x - particle_pos.x) - sq(y-particle_pos.y) > 0 &&
level < MAXLEVEL);
#endif
solid(cs, fs, sqrt(sq(x - particle_pos.x) + sq(y - particle_pos.y)) - radius);
}
#if TREE
event adapt (i++) {
adapt_wavelet ({f, u}, (double[]){0.01,0.01,0.01,0.01},
maxlevel = MAXLEVEL);
particle_vol = 0.;
foreach(reduction(+:particle_vol))
particle_vol += (1. - cs[])*dv();
}
#endif
event extract (t = 0; t += 0.01; t <= end_time)
{
double yb = 0., vb = 0., vbx = 0., area = 0.;
foreach (reduction(+:yb) reduction(+:vb) reduction(+:vbx)
reduction(+:area)) {
double dvb = (1. - f[])*dv();
vb += dvb; // 气泡体积
yb += x*dvb; // 气泡位置
vbx += u.x[]*dvb; // 气泡速度
if (f[] > 1e-6 && f[] < 1. - 1e-6) {
coord n = interface_normal (point, f), p;
double alpha = plane_alpha (f[], n);
// 气泡界面面积
area += y*pow(Delta, dimension - 1)*plane_area_center (n, alpha, &p);
}
}
if (i == 0)
fprintf (stderr, "t vbx vb vbo area dt\n");
fprintf (stderr,"%g %g %g %g %g %g\n",
t,
vbx/vb,
2.*pi*vb,
2.*pi*statsf(f).sum,
2.*pi*area,
dt);
}
event properties (i++) {
#if EMBED
cm_update(cm, cs, fs);
fm_update(fm, cs, fs);
#endif
foreach() {
double fluid_rho = f[] * rho1 + (1 - f[]) * rho2;
double fluid_mu = f[] * mu1 + (1 - f[]) * mu2;
rho[] = cs[] * fluid_rho + (1 - cs[]) * rho_p;
}
foreach_face(x) {
double cs_face = (cs[] + cs[-1])/2.;
muv.x[] = fm.x[] * (cs_face * mu_fluid + (1 - cs_face) * 1e6);
}
foreach_embed(){
coord n, p;
double area = embed_geometry(point, &p, &n);
if (area > 0) {
u.x.boundary[embed] = dirichlet(particle_vel.x); // 固体表面x方向速度为0
u.y.boundary[embed] = dirichlet(0); // 固体表面y方向速度为0
}
}
}
event force (i++) {
coord Fp, Fmu;
embed_force(p, u, mu, &Fp, &Fmu); // 计算流体作用在固体上的压力和粘性力
coord total_force = {0};
total_force.x = Fp.x + Fmu.x; // 总力的x分量
double real_volume = 2.0*M_PI*particle_vol;
foreach_dimension() {
particle_vel.x += dt*total_force.x/(rho_p*real_volume); // a = F/m
particle_pos.x += dt*particle_vel.x; // dx = v·dt
}
// 更新固体区域位置(随粒子移动)
solid(cs, fs, sqrt(sq(x - particle_pos.x) + sq(y - particle_pos.y)) - radius);
if (i == 0)
fprintf (stderr, " total_force.x particle_vel.x particle_pos.x");
fprintf (stderr,"%g %g %g %g %g\n",
t,
2*pi*total_force.x,
2*pi*particle_vel.x,
2*pi*particle_pos.x,
dt);
}
event pictures (t = end)
{
char name[80];
#if 0
sprintf (name, "dump-1");
dump (name);
#endif
view (fov = 9, quat = {0.707,0.707,0,0},
ty = -0.6,
width = 400, height = 800);
draw_vof ("f");
draw_vof ("cs");
mirror ({0,1}) {
squares ("u.x", spread = -1, linear = true, map = cool_warm);
draw_vof ("f");
draw_vof ("cs");
}
sprintf (name, "final-1.png");
save (name);
}】