passing point in foreach_face

61 views
Skip to first unread message

Daniel Fuster

unread,
Oct 16, 2025, 8:38:09 AMOct 16
to basilisk-fr
Hello Stephane

I realized that when passing a Point to a function in a foreach_face loop the code is not doing what I was expecting (but maybe is doing what it is supposed to do:).

Here is an example. You will see first that the x,y coordinate is shifted to the cell centered value within the function fun. What bothers me more is that d0[0,1] is not returning the same value at the top boundary.

Is this what the code is supposed to do or it is a bug?

thanks for your help,
Daniel

scalar d0[];

void fun (Point point, scalar d0) {

    printf("inside %g %g %g \n", x, y, d0[0,1]);
}

int main () {

  init_grid(16);

  foreach ()  
    d0[] = sqrt( sq(x) + sq(y) );

  foreach_face () {
    printf("%g %g %g \n", x, y, d0[0,1]);
    fun(point, d0);
    printf("\n");                                                                                                                                                                                          
  }
}



Stephane Popinet

unread,
Oct 18, 2025, 12:46:58 PMOct 18
to basil...@googlegroups.com
Hi Daniel,

What if you do instead:

foreach_dimension()
void fun_x (Point point, scalar d0) {
printf ("inside %g %g %g \n", x, y, d0[0,1]);
}

...

foreach_face() {
...
fun_x (point, d0);
...
}

Stephane


Daniel Fuster

unread,
Oct 18, 2025, 1:58:43 PMOct 18
to Stephane Popinet, basil...@googlegroups.com
Hi Stephane 

yes, that fixes the issue

thanks a lot

--
You received this message because you are subscribed to the Google Groups "basilisk-fr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to basilisk-fr...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/basilisk-fr/ed8fd335-c2aa-4fc2-a417-31705ce8d122%40basilisk.fr.
Reply all
Reply to author
Forward
0 new messages