sandbox/yonghui/smalltest/output

    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
    
    /**
    It's a remanding page of code to output data * /
    
    /**
    ## output image & video*/
    
    output_ppm (u.x, file = "name.png", linear = true,n=512,min=-1.,max=1.);
    
    output_ppm (u.x, file = "name.mp4", linear = true,n=512,min=-1.,max=1.);
    
    output_field ((scalar *){u}, fopen ("velo_3D", "w"), N, linear = true);
    
    output_facets (f, stderr); //in log 
    
    scalar l[];
    foreach()
      l[] = level;
    output_field ({l}, stdout, N);
    
    
    clear();//view.h
    view (fov = 27.1723, quat = {-0.707795,-0.108707,-0.69171,0.0934929}, 
          tx = -0.545947, ty = -0.00320332, bg = {0.3,0.4,0.6}, width = 640, height = 320);
    box();
    isosurface ("d", color = "level", min = 5, max = 10);
    squares("u.x", linear = true, min =0, max =0.25);
    draw_vof("f");
    save("view_3D.png");
    
    char legend[1000]; //time
    sprintf(legend, "t = %0.2g", t);
    draw_string(legend, 1, size = 30., lw = 2.);
    
    /**
    ## data file*/
    
    FILE * fp1;
    fp1 = fopen ("name", "w");
    fprintf(fp1,"%d %g %g %g\n" , i, t, dt, interpolate(u.x, L0/2., L0/2.));  
    
    fprintf(stderr,"%d %g\n",i,t);   //log
    
    fprintf(stdout,"%d %g\n",i,t);   //out
    
    /**
    ##for loop*/
    for (double xx = 0.; xx <= 1.; xx += 1./100. ){
      double yy = L0/2.;
      uu = interpolate(u.x , xx, yy);
      vv = interpolate(u.y , xx, yy);
      pp = interpolate(p , xx, yy);
      fprintf(fp2,"%g %g %g %g %g\n", t, xx, uu, vv, pp);
    }