-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInitialCondition.c
More file actions
56 lines (47 loc) · 1.45 KB
/
InitialCondition.c
File metadata and controls
56 lines (47 loc) · 1.45 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
/**
This small code is just an example for using the MATLAB code [InitialCondition.m](InitialCondition.m).
This code reads the data file generated by InitialCondition.m 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};
int main(int argc, char const *argv[]) {
L0 = atoi(argv[1]);
origin (-0.11, 0.0);
init_grid (1 << (12));
// refine(x > -0.1 && x < 0.1 && level < 10);
coord* InitialShape;
char filename[80], FacetName[80];
sprintf(filename,"f_Testing.dat");
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);
// foreach(){
// fprintf(ferr, "x = %g, y = %g, d = %g\n", x, y, d[]);
// }
/**
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);
sprintf(filename,"Init_f");
dump (file = filename);
sprintf(FacetName, "f_facets.dat");
FILE * fp1 = fopen (FacetName, "w");
output_facets (f, fp);
fclose (fp1);
}