Struggling to get started

329 views
Skip to first unread message

Phil Rosenberg

unread,
Mar 12, 2021, 1:31:27 PM3/12/21
to basilisk-fr
Hi
I've been trying to get started using Basilisk. I have used Gerris before, but a long time ago and I consider myself a decent C++ programmer, so I was hoping to pick things up quite quickly. I followed the tutorial and then ran the von-karman example, all seemed to be going well.

Then I tried my own example. My intention was to define a cold region of air in my simulation and have this sink under the impact of gravity. The air would not be so cold as to  need its density specifying as different (i.e. Bousinesq approximation).

I coded up what I thought would work and basically nothing happened. My air parcel just stayed static. I then recoded it up basing it on the example at http://basilisk.fr/freeconvection.c, but still nothing happens.

I have no idea what I'm doing wrong. Perhaps someone could give me some pointers?

My minimal code is below. Sorry that google seems to have removed the indents.

Thanks for any help

Phil

#include "navier-stokes/centered.h"
//navier stokes centred creates glabal variables:
//scalar p[]; pressure at each grid point
//vector u[]; velocity at each grid point
//vector a[]; external acceleration at each grid point
#include "tracer.h"


scalar temperature[];
scalar * tracers = {temperature};
face vector av[];

int main() {
a = av; //I think this makes a point to av, so when we modify av to solver sees the change in a
init_grid(1 << 8);
run();
}

event init (t = 0)
{
//initiate a region in the top left with temperature = 3, eveywhere else it's 1
foreach()
{
temperature[] = x < 0.8 || y < 0.8 ? 1 : 3;
}
}

//this event should update a to match the advected temperature
event gravity(i++)
{
coord Del = { 0 , 1, 0};
foreach_face()
{
av.x[] = Del.x* (((temperature[]+temperature[-1])/2));
}
}

//end after 500 time units
event end (t = 500.0)
{
printf ("i = %d t = %g\n", i, t);
return 1;
}


//output some parameters
event logfile (i++)
{
fprintf (stderr, "%d %g %d %d\n", i, t, mgp.i, mgu.i);
}


//make some movies
event movies (t += 2.0)
{
output_ppm (temperature, file = "temperature.mp4");
output_ppm (p, file = "pressure.mp4");
output_ppm (a.y, file = "gravity.mp4");
}

j.a.v...@gmail.com

unread,
Mar 12, 2021, 2:15:55 PM3/12/21
to basilisk-fr
Hallo Phil, 

For the centered solver, the computation of the acceleration
vector fields must be done by overloading the `acceleration`
event as exemplified.

I also took the liberty of moving the page you linked, as it
should not have been there. If you are interested in a similar example
you could look here:


Antoon
Op vrijdag 12 maart 2021 om 19:31:27 UTC+1 schreef philip.r...@ncas.ac.uk:

Phil Rosenberg

unread,
Mar 16, 2021, 8:51:43 AM3/16/21
to basilisk-fr
Fantastic, thank-you Antoon

Simply changing the name of the event gravity, to acceleration (as you suggested) made the simulation function.

I'm obviously still getting to grips with how things work in Basilisk, so all this stuff with events is new to me. As a newbie, I still can't find anything (either in the centred.c code, nor the wiki) that indicates that I need to overload the acceleration event. In fact I'm now rather unsure as to whether my overload is called instead of, or as well as the one in centred.c. I'm guessing as well as, because the event in centred.c seems to be responsible for calculating the grid centred acceleraions from the grid face accelerations.

I do appreciate that no open source developer likes writing documentation (I've been there as a dev on the PLPlot library) but maybe if there was some description on the wiki of the "standard" events called by the solvers which can be overloaded or even how one can find them, then newbies would have a better chance of success.

Thanks again for the help. I have a feeling it won't be my only request :-)
All my best
Phil

Youssef Saade

unread,
Mar 16, 2021, 8:58:55 AM3/16/21
to basil...@googlegroups.com

Hi Phil,

Basilisk is a very well documented code I'd say. Doing the tutorial(s), and getting familiar with Basilisk C will get you well started. Here is a page that clarifies the events order:

http://basilisk.fr/Basilisk%20C#event-inheritance

Best,

Youssef

--
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/cd18adea-eb09-476a-9019-ed74f68debaan%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages