Issue with mesh adaption in 2D axisymmetric simulation

40 views
Skip to first unread message

Juan Ng

unread,
Oct 5, 2025, 12:18:04 PM (8 days ago) Oct 5
to basilisk-fr
Starting with the example on Bénard–vonKármán Vortex Street for flow around a cylinder at Re=160, I tried to transform this into a 2D axisymmetric case by adding "#include axi.h". However, the simulation failed after just one time step and the error message was quite difficult to debug.

Can someone please have a look and tell me what am I missing?

The code:
// #include "axi.h" // Without axi.h, the code runs fine
#include "embed.h"
#include "navier-stokes/centered.h"
#include "view.h"
#include "tracer.h"

scalar f[];
scalar * tracers = {f};
double Re = 160.0;
int maxlevel = 9;

face vector muv[];

int main() {
L0 = 2. [1];
origin (-0.5, -0.5 * L0);
N = 256;
mu = muv;

run();
}

double D = 0.125, U0 = 1.0;
event properties(i++) {
foreach_face()
muv.x[] = fm.x[] * U0 * D / Re;
}

u.n[left] = dirichlet(U0);
p[left] = neumann(0.0);
pf[left] = neumann(0.0);
f[left] = fabs(y) < D /8 ? 1.0 : 0.0;

u.n[right] = neumann(0.0);
p[right] = dirichlet(0.0);
pf[right] = dirichlet(0.0);

u.n[embed] = dirichlet(0.0);
u.t[embed] = dirichlet(0.0);

event init(i = 0) {
solid(cs, fs, sqrt(sq(x) + sq(y)) - D/2);
foreach() {
u.x[] = cs[] ? U0 : 0.0;
}
}

event logfile (i++) {
if (i == 0)
fprintf (stderr,
"i\tt\tmgp.i\tmgu.i\n");
fprintf (stderr, "%d\t%g\t%d\t%d\n",
i ,t, mgp.i, mgu.i);
}

event movie (t += 0.1; t <= 20) {
scalar omega[], m[];
vorticity(u, omega);
foreach() {
m[] = cs[] - 0.5;
}
view ();
output_ppm(omega, file = "vort.mp4", box = {{-0.5, -0.5},
{0.5, 0.5}}, min = -10, max = 10, linear = true, mask = m);
output_ppm (f, file = "f.mp4", box = {{-0.5,-0.5},{0.5,0.5}},
linear = false, min = 0, max = 1, mask = m);
}

event adapt (i++) {
adapt_wavelet ({cs, u, f}, (double[]){1e-2, 1e-2, 1e-2, 1e-2},
maxlevel, 4);
}

How I ran my code:
CC99='mpicc -std=c99' qcc -O2 -Wall -grid=quadtree -D_MPI=1 main.c -lm -L$BASILISK/gl -lglutils -lfb_tiny -o main
mpirun --allow-run-as-root -np 4 ./main  > ./log

The error message is quite long:
/home/basilisk/src/embed.h:656: error: the dimensional constraints below are not compatible
/src/embed.h:656: 'int ig=0;NOT_UNUSED(ig);int jg=0;NOT_UNUSED(jg);
 
  double Delta = L0*(1./(1 << point.level));
  double Delta_x = Delta;

  double Delta_y = Delta;





  double x = ((ig + 1)/2. + (point.i - 2))*Delta + X0; NOT_UNUSED(x);

  double y = ((jg + 1)/2. + (point.j - 2))*Delta + Y0;



  NOT_UNUSED(y);



  double z = 0.;

  NOT_UNUSED(z);

  NOT_UNUSED(Delta);
  NOT_UNUSED(Delta_x);

  NOT_UNUSED(Delta_y);





  ;
  int level = point.level; NOT_UNUSED(level);



  struct { int x, y; } child = {
    2*((point.i+2)%2)-1, 2*((point.j+2)%2)-1
  };





  NOT_UNUSED(child);
  Point parent = point; NOT_UNUSED(parent);
  parent.level--;
  parent.i = (point.i + 2)/2;

  parent.j = (point.j + 2)/2;





  *val = 0.;
  if (cs[] >= 1. || cs[] <= 0.)
    return 0.;





  bool dirichlet = false;
  double grad = s.boundary[embed] (point, point, s, &dirichlet);
  if (!grad && !dirichlet)
    return 0.;





  coord n = facet_normal (point, cs, fs), p;
  double alpha = line_alpha (cs[], n);
  double area = line_length_center(n,alpha,&p);
  if (metric_embed_factor)
    area *= metric_embed_factor (point, p);





  double coef = 0.;
  if (dirichlet) {
    normalize (&n);
    grad = dirichlet_gradient (point, s, cs, n, p, grad, &coef);
  }




  double mua = 0., fa = 0.;
   {
    mua += mu.x[] + mu.x[1];
    fa += fm.x[] + fm.x[1];
  } {
    mua += mu.y[] + mu.y[0,1];
    fa += fm.y[] + fm.y[0,1];
  }
  *val = - mua/(fa + 1e-30)*grad*area/Delta;
  return - mua/(fa + 1e-30)*coef*area/Delta;'
        └─ [/src/embed.h:698: 'mua = 0.'] = [2,-1]
/src/viscosity-embed.h:111: 'rho[] + ((coord){0, dt*(mu.y[] + mu.y[0,1] + mu.x[] + mu.x[1])*( (cs[])*(cs[])) /(fm.y[] + fm.y[0,1] + fm.x[] + fm.x[1] + 1e-30)/(cm[] + 1e-30)}).y'
        └─ [/src/embed.h:698: 'mua = 0.'] = [0,-1]
i       t       mgp.i   mgu.i
0       0       0       0
[3f5abc76c9d0:02348] *** Process received signal ***
[3f5abc76c9d0:02348] Signal: Aborted (6)
[3f5abc76c9d0:02348] Signal code:  (-6)
[3f5abc76c9d0:02348] [ 0] /lib/x86_64-linux-gnu/libc.so.6(+0x3fdf0) [0x7f0bdad5edf0]
[3f5abc76c9d0:02348] [ 1] /lib/x86_64-linux-gnu/libc.so.6(+0x9495c) [0x7f0bdadb395c]
[3f5abc76c9d0:02348] [ 2] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x12) [0x7f0bdad5ecc2]
[3f5abc76c9d0:02348] [ 3] /lib/x86_64-linux-gnu/libc.so.6(abort+0x22) [0x7f0bdad474ac]
[3f5abc76c9d0:02348] [ 4] ./main(+0x96c6) [0x5588375416c6]
[3f5abc76c9d0:02348] [ 5] ./main(+0x9d99) [0x558837541d99]
[3f5abc76c9d0:02348] [ 6] ./main(+0x4099c) [0x55883757899c]
[3f5abc76c9d0:02348] [ 7] ./main(+0x4f78c) [0x55883758778c]
[3f5abc76c9d0:02348] [ 8] ./main(+0x4fb58) [0x558837587b58]
[3f5abc76c9d0:02348] [ 9] ./main(+0x20595) [0x558837558595]
[3f5abc76c9d0:02348] [10] ./main(+0x66f5d) [0x55883759ef5d]
[3f5abc76c9d0:02348] [11] ./main(+0x5b7b) [0x55883753db7b]
[3f5abc76c9d0:02348] [12] /lib/x86_64-linux-gnu/libc.so.6(+0x29ca8) [0x7f0bdad48ca8]
[3f5abc76c9d0:02348] [13] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x85) [0x7f0bdad48d65]
[3f5abc76c9d0:02348] [14] ./main(+0x5bb1) [0x55883753dbb1]
[3f5abc76c9d0:02348] *** End of error message ***
/home/basilisk/src/embed-tree.h:274: Assertion `coarse(cs)' failed.
[3f5abc76c9d0:02347] *** Process received signal ***
[3f5abc76c9d0:02347] Signal: Aborted (6)
[3f5abc76c9d0:02347] Signal code:  (-6)
[3f5abc76c9d0:02347] [ 0] /lib/x86_64-linux-gnu/libc.so.6(+0x3fdf0) [0x7f88a6c25df0]
[3f5abc76c9d0:02347] [ 1] /lib/x86_64-linux-gnu/libc.so.6(+0x9495c) [0x7f88a6c7a95c]
[3f5abc76c9d0:02347] [ 2] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x12) [0x7f88a6c25cc2]
[3f5abc76c9d0:02347] [ 3] /lib/x86_64-linux-gnu/libc.so.6(abort+0x22) [0x7f88a6c0e4ac]
[3f5abc76c9d0:02347] [ 4] ./main(+0x96c6) [0x55584ca9c6c6]
[3f5abc76c9d0:02347] [ 5] ./main(+0x9d99) [0x55584ca9cd99]
[3f5abc76c9d0:02347] [ 6] ./main(+0x4099c) [0x55584cad399c]
[3f5abc76c9d0:02347] [ 7] ./main(+0x4f78c) [0x55584cae278c]
[3f5abc76c9d0:02347] [ 8] ./main(+0x4fb58) [0x55584cae2b58]
[3f5abc76c9d0:02347] [ 9] ./main(+0x20595) [0x55584cab3595]
[3f5abc76c9d0:02347] [10] ./main(+0x66f5d) [0x55584caf9f5d]
[3f5abc76c9d0:02347] [11] ./main(+0x5b7b) [0x55584ca98b7b]
[3f5abc76c9d0:02347] [12] /lib/x86_64-linux-gnu/libc.so.6(+0x29ca8) [0x7f88a6c0fca8]
[3f5abc76c9d0:02347] [13] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x85) [0x7f88a6c0fd65]
[3f5abc76c9d0:02347] [14] ./main(+0x5bb1) [0x55584ca98bb1]
[3f5abc76c9d0:02347] *** End of error message ***
--------------------------------------------------------------------------
prterun noticed that process rank 1 with PID 2348 on node 3f5abc76c9d0 exited on
signal 6 (Aborted).
--------------------------------------------------------------------------

Reply all
Reply to author
Forward
0 new messages