bview scripting

271 views
Skip to first unread message

Palas Kumar Farsoiya

unread,
Mar 5, 2018, 3:09:47 AM3/5/18
to basilisk-fr
Hi Stephane,

How to run a loop over many basilisk snapshot files to extract interface and write into files. I am able to do for one file by

draw_vof("f");
save("interface.gnu");

I want to loop it over. 

Regards,
Palas


Wojciech Aniszewski

unread,
Mar 5, 2018, 3:36:53 AM3/5/18
to Palas Kumar Farsoiya, basilisk-fr


On Mon, Mar 05, 2018 at 12:09:47AM -0800, Palas Kumar Farsoiya wrote:
> How to run a loop over many basilisk snapshot files to extract interface
> and write into files. I am able to do for one file by

Short answer: learn BASH. Write a Bash script which will loop over dumpfiles,
and for each of them call bview-server2D and feed it with your drawing commands.
Was done for bview and works.
Wojtek

--
/^..^\ Wojciech (Wojtek) ANISZEWSKI ► Post-doctoral Researcher
( (••) ) [Fr: vôitek anichévsky] ► Sorbonne University
(|)_._(|)~ [Eng: voyteck aanishevsky] ► Institut ∂'Alembert
GPG key ► Web [English] https://tinyurl.com/y73t4xsg [2015]
ID:AC66485E ► [Polish ] https://tinyurl.com/yckark7n [2014]
signature.asc
Message has been deleted

Stephane Popinet

unread,
Mar 5, 2018, 3:43:50 AM3/5/18
to basil...@googlegroups.com
> How to run a loop over many basilisk snapshot files to extract interface
> and write into files. I am able to do for one file by
>
> draw_vof("f");
> save("interface.gnu");
>
> I want to loop it over.

You could try something like:

#!/bin/bash

for f in file1 file2 ....; do
cat <<EOF | bview-server2D
restore ($file);
clear();
draw_vof ("f");
save ($file.gnu);
EOF
done

This won't work exactly as is but you get the idea.

Stephane

jose.lopez...@gmail.com

unread,
Mar 5, 2018, 4:55:38 AM3/5/18
to basilisk-fr
Hi Palas,

You can also do it with the the dirent.h library doing something like

#include <dirent.h>
#include "utils.h"

char LEV[20] = "L13";
int we = 300;
char dirname[80];
char filesave[80];
char fileload[80];
char fileserie[80];

char *fsve;

scalar f[];
scalar vort[];
scalar uf[];
vector u[];

    ncounter = 0;
int main(){
  sprintf(dirname,"../../visco/We%d", we);
  DIR* dirFile = opendir(dirname);
  struct dirent* hFile;

  sprintf(fileserie,"dump1_%d", ncounter);
 
  while (( hFile = readdir( dirFile )) != NULL ) {
   
    if ( !strcmp( hFile->d_name, "."  )) continue;
    if ( !strcmp( hFile->d_name, ".." )) continue;
    if ( ( hFile->d_name[0] == '.' )) continue;
   
    if (strstr( hFile->d_name, fileserie) ) {
      fsve = strchr(hFile->d_name, ch);
      printf("file %s\n", hFile->d_name);
      sprintf(fileload,"%s/%s", dirname,hFile->d_name);

       restore(file = fileload);
       printf("restore hecho!\n");
       foreach()
     double omega =((u.y[1,0]-u.y[-1,0]) - (u.x[0,1]-u.x[0,-1]))/(2*Delta);
     vort[] = (f[] == 1 ? omega : nodata);
     boundary({vort});
     sprintf(filesave,"visco/processed_we_%d_%s_n_%d", (int)we, LEV, ncounter);
       dump(file = filesave);ncounter += 1; 
    }
  }
}


Cheers

Jose

Palas Kumar Farsoiya

unread,
Mar 5, 2018, 8:18:20 AM3/5/18
to basilisk-fr
Hi Stephane,

I tried this below script but it is stopping at starting file, just the initial file is generated but the loop doesn't complete. I don't think it is some bash issue.

#!/bin/bash 

for file in snapshot-*; 
do 
cat <<EOF|bview-server3D 
restore ("$file");
clear();
draw_vof ("f");
save ("$file.gnu");
EOF
done


Stephane Popinet

unread,
Mar 5, 2018, 11:02:09 AM3/5/18
to basil...@googlegroups.com
> initial file is generated but the loop doesn't complete. I don't think
> it is some bash issue.

Well, it is really. The script should be:

#!/bin/bash

for file in snapshot-*; do
cat <<EOF
restore ("$file");
clear();
draw_vof ("f");
save ("$file.gnu");
EOF
done | bview-server3D

Palas Kumar Farsoiya

unread,
Mar 6, 2018, 5:06:47 AM3/6/18
to basilisk-fr
Thanks Stephane, it worked. I am trying to track the interface at one x and y point to get a signal of oscillating interface. Can you give me some idea how to do that.
Reply all
Reply to author
Forward
0 new messages