bubble.c

  name="google_ads_frame" marginwidth="0" marginheight="0" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-5572165936844014&dt=1194442938015&lmt=1194190197&format=336x280_as&output=html&correlator=1194442937843&url=file%3A%2F%2F%2FC%3A%2FDocuments%2520and%2520Settings%2Flhh1%2F%E6%A1%8C%E9%9D%A2%2FCLanguage.htm&color_bg=FFFFFF&color_text=000000&color_link=000000&color_url=FFFFFF&color_border=FFFFFF&ad_type=text&ga_vid=583001034.1194442938&ga_sid=1194442938&ga_hid=1942779085&flash=9&u_h=768&u_w=1024&u_ah=740&u_aw=1024&u_cd=32&u_tz=480&u_java=true" frameborder="0" width="336" scrolling="no" height="280" allowtransparency="allowtransparency"> #include <stdio.h>
#include <stdlib.h>

void bubble_sort(int array[], int size)
 {
   int temp, i, j;

   for (i = 0; i < size; i++)
    for (j = 0; j < size; j++)
      if (array[i] < array[j])
        {
          temp = array[i];
          array[i] = array[j];
          array[j] = temp;
        }
  }

void main(void)
 {
   int values[30], i;

   for (i = 0; i < 30; i++)
     values[i] = rand() % 100;

   bubble_sort(values, 30);

   for (i = 0; i < 30; i++)
     printf("%d ", values[i]);
 }

 

我正在编辑【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); }】
06-07
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值