Streamline Plot Issues

68 views
Skip to first unread message

parastoo Aghababaei

unread,
Nov 18, 2025, 3:57:16 AM (10 days ago) Nov 18
to basilisk-fr

Dear all,

I have recently started working with Basilisk. In my latest code, when I simulate the rise of a bubble in a liquid and plot the streamlines, I notice that streamlines are also drawn inside the bubble. Although I used the relative velocity (moving to the bubble’s reference frame) to calculate the streamlines, they still appear inside the bubble.

I would greatly appreciate it if you could provide me with some guidance on this issue.

// Streamline visualization
event streamline_plot (t += 0.05; t <= tmax) {
  view(fov = 12, tx = -0.5, ty = 0.1, width = 1920, height = 900);
  clear();
  //  Compute bubble rise velocity
  double xb = 0., sb = 0., vbx = 0.;
  foreach(reduction(+:xb) reduction(+:vbx) reduction(+:sb)) {
    double cellVol = (1 - f[]) * dv();
    xb += x * cellVol;
    vbx += u.x[] * cellVol;
    sb += cellVol;
  }
  double U_bubble = (sb > 1e-12) ? vbx / sb : 0.0;

  
  scalar urx[], ury[];
  vector ur[];
  ur.x = urx;
  ur.y = ury;
  foreach() {
    ur.x[] = u.x[] - U_bubble;
    ur.y[] = u.y[];
    // Set relative velocity to zero inside bubble to avoid internal streamlines
    if (f[] < 0.5) {  // Gas phase
      ur.x[] = 0.;
      ur.y[] = 0.;
    }
  }
  boundary({ur.x, ur.y});

  // Set BCs for psi (axis at bottom y=0 -> psi=0)
  scalar psi[];
  psi[bottom] = dirichlet(0.0);  // Axis of symmetry

  //  Solve for axisymmetric streamfunction using relative velocity
  axistream(ur, psi);

  //   Check psi range for debugging
  double psi_min = 1e9, psi_max = -1e9;
  foreach(reduction(min:psi_min) reduction(max:psi_max)) {
    psi_min = min(psi_min, psi[]);
    psi_max = max(psi_max, psi[]);
  }
  fprintf(stderr, "t=%g U_bubble=%g psi_min=%g psi_max=%g\n",
          t, U_bubble, psi_min, psi_max);

  //  Draw interface and streamlines
  draw_vof("f", lw = 2, lc = {1,0,0});
  if (psi_max - psi_min > 1e-12) {
    isoline("psi", n = 28, min = psi_min * 0.98, max = psi_max * 0.98,
            lc = {0,0,0}, lw = 1.2);
  } else {
    fprintf(stderr, "psi nearly constant -> check BCs/velocity field\n");
  }
  box();
  sprintf(nameOut, "output/streamlines_t%.3f.png", t);
  save(nameOut);
}streamlines_t0.050.png

Reply all
Reply to author
Forward
0 new messages