-
Notifications
You must be signed in to change notification settings - Fork 0
/
InitialCondition.c
44 lines (37 loc) · 1.22 KB
/
InitialCondition.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
This small code is just an example for using the Basilisk code [SessileDrop_testWithBasilisk.ipynb](SessileDrop_testWithBasilisk.ipynb).
This code reads the data file generated by [SessileDrop_testWithBasilisk.ipynb](SessileDrop_testWithBasilisk.ipynb) and use the Basilisk function [distance](http://basilisk.fr/src/distance.h).
*/
#include "axi.h"
#include "fractions.h"
#include "distance.h"
#include "navier-stokes/centered.h"
scalar f[], * interfaces = {f};
char filename[80];
int main(int argc, char const *argv[]) {
L0 = atoi(argv[1]);
sprintf(filename, "%s", argv[2]);
origin (-0.01, 0.0);
init_grid (1 << (12));
coord* InitialShape;
FILE * fp = fopen(filename,"rb");
if ( fp == NULL ){
fprintf(ferr, "There is no file named %s\n", filename);
return 1;
}
InitialShape = input_xy(fp);
fclose (fp);
scalar d[];
distance (d, InitialShape);
/**
The distance function is defined at the center of each cell, we have
to calculate the value of this function at each vertex. */
vertex scalar phi[];
foreach_vertex(){
phi[] = (d[] + d[-1] + d[0,-1] + d[-1,-1])/4.;
}
/**
We can now initialize the volume fraction of the domain. */
fractions (phi, f);
output_facets (f, ferr);
}