Is possible to extract a 1D flow from a 2D simulation?

140 views
Skip to first unread message

Alessandro Della Pia

unread,
Apr 17, 2020, 1:30:33 PM4/17/20
to basilisk-fr
Dear Basilisk users,
I am dealing with a 2D two-phase flow simulation under viscous, intertial, gravitational and surface tension effects.
The physical scenario is the following: a liquid jet (directed along x direction) injected into still air.

I was wondering if there is a way to extract, at every iteration, a 1D flow in the liquid jet from the simulation.
In particular, I would like to calculate, at every x, the mean value of a generic quantity (e.g. u.x) inside the liquid jet and then print the values into a file,
obtaining in such a way a 1D equivalent flow field of the liquid jet.

With the following code:

float avg =0;
int N = 1;

foreach() {
(if f[] > 0 && x == x_current)
avg += u.x;
N +=1;
}
avg=avg/N;

I should be able to evaluate the mean u.x value at x_current.
But how to save this value into a vector?
And, moreover, I think that run this code for every "x_current" and for every iteration will be absolutely not efficient.

Do you know if there is any function in BASILISK that can help me? Or do you have any suggestions?

Thanks a lot for your help.
Alessandro


Mani Chandan Naru

unread,
Apr 17, 2020, 2:23:21 PM4/17/20
to Alessandro Della Pia, basilisk-fr
Hi Alessandro,

Profile functions defined at http://basilisk.fr/sandbox/Antoonvh/profile6.h will help you to get mean values. They will be automatically printed to stdout or you can specify another file to print. 

You can create a new field which stores the values of the variable only in those cells of a jet and zero else where and you can pass that field through the profile function defined in the code as mentioned above.

Definitely doing this at every time step is not computationally feasible. You can also choose at which x values you need to compute the mean values (Instead of doing it for every x)


Regards,
Mani


--
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 on the web visit https://groups.google.com/d/msgid/basilisk-fr/ceb6793a-f696-4f0b-992c-1298d2b378c3%40googlegroups.com.

can

unread,
Apr 17, 2020, 2:44:46 PM4/17/20
to basilisk-fr
To unsubscribe from this group and stop receiving emails from it, send an email to basil...@googlegroups.com.

Alessandro Della Pia

unread,
Apr 19, 2020, 11:29:21 AM4/19/20
to basilisk-fr
Dear Mani and Can,
thank you very much for your help.


event my_profile (i=0) {
scalar u_jet[];
foreach()
u_jet[] = f[]*u.x[];
boundary({u_jet);
scalar * list = {u_jet};
profile (list, x, "prof");
}

In this way, u_jet is u.x in those cells where the jet is present, 0 outside. The problem is that giving such a field to Antoon's function results in a wrong calculation of the mean value, because the total number of cells where u_jet is stored is still equal to u.x one.
I don't know if it is possible to define a scalar field only where f[] = 1 and then give it to Antoon's function.
Do you have any idea to solve this problem?

Thanks again for your precious help.
Regards,
Alessandro
To unsubscribe from this group and stop receiving emails from it, send an email to basil...@googlegroups.com.

Antoon van Hooft

unread,
Apr 19, 2020, 1:00:27 PM4/19/20
to basilisk-fr
Hallo,

Defining u_jet was a smart move. If field f is also in the `list`, you can
make a division in post-processing to get a first-order accurate f-weighted average.

Antoon

Mani Chandan Naru

unread,
Apr 19, 2020, 1:10:56 PM4/19/20
to Alessandro Della Pia, basilisk-fr

Hi Alessandro,

Have a look inside the profile function and modify a bit inside that function where you normalize the profile values with the area over which you have computed the mean values.

http://basilisk.fr/sandbox/Antoonvh/profile6.h#interface_average

Kind regards,

Mani


To unsubscribe from this group and stop receiving emails from it, send an email to basilisk-fr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/basilisk-fr/f134d985-997e-4d68-8aac-3d29eb22717e%40googlegroups.com.

Mani Chandan Naru

unread,
Apr 19, 2020, 1:13:31 PM4/19/20
to Antoon van Hooft, basilisk-fr

Hi Anoon,

I didn't check your reply. It is easier and straight forward to just use the "f" profiles as a diagnostic as you recommended.
Kind regards,
Mani


--
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 on the web visit https://groups.google.com/d/msgid/basilisk-fr/1c917d6f-88ac-48b9-a16f-551641e99f2a%40googlegroups.com.

Alessandro Della Pia

unread,
Apr 20, 2020, 12:32:11 PM4/20/20
to basilisk-fr

Dear Antoon,
your smart solution is exactly what I need.
Thanks a lot!

Dear Mani,
thanks very much for your help.

Cheers,
Alessandro

alessandr...@gmail.com

unread,
May 24, 2024, 5:03:37 AMMay 24
to basilisk-fr
Dear all,
I was used to compile the following lines of codes in "file.c"
with "CC='mpicc -D_MPI=16' make file.tst":

#include "navier-stokes/centered.h"
#include "two-phase.h"
#include "navier-stokes/conserving.h"
#include "tension.h"
#include "profile6.h"

Today I tried again, but I got the following error related to the "profile6.h" function 

./profile6.h:22: error: non-local variable 'g' is modified by this foreach loop:
./profile6.h:22: error: use a loop-local variable, a reduction operation
./profile6.h:22: error: or a serial loop to get rid of this error

Note that the error disappears if I do "make file.tst".
Therefore, it seems to me there is some problem with profile6.h function when simulating on parallel processes.
Do you have any idea what is going on?

Thanks in advance,
Alessandro

Stephane Popinet

unread,
May 24, 2024, 5:13:06 AMMay 24
to basil...@googlegroups.com
Hi Alessandro,

Did you look at line 22 of profile6.h? (which, by the way, we have no
idea what it is, or where you found it)

Did you try to understand the message about the "non-local variable" and
the various suggestions on how to fix the problem?

See also the "Important note" here:

http://basilisk.fr/sandbox/documentation

and:

http://basilisk.fr/Basilisk%20C#parallel-programming

cheers,

Stephane
> --
> 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
> <mailto:basilisk-fr...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/basilisk-fr/d4492155-81d4-4f74-98b6-2312c92439adn%40googlegroups.com <https://groups.google.com/d/msgid/basilisk-fr/d4492155-81d4-4f74-98b6-2312c92439adn%40googlegroups.com?utm_medium=email&utm_source=footer>.
OpenPGP_0x78F22AD6304D74BE.asc
OpenPGP_signature.asc

alessandr...@gmail.com

unread,
May 24, 2024, 7:07:14 AMMay 24
to basilisk-fr
Hi Stephane,
thank you for your suggestions. 
"profile6.h" is a library in Antoon Sandbox: sorry for not specifying it in the previous message. 


I checked the "important note" and realized that "profile6.h" was indeed modified with respect to the version I was using.
With this new version, my code is working correctly.

Thank you again for your help,
Alessandro

Reply all
Reply to author
Forward
0 new messages