// File: /workspace/github_cpp_makefile_star2_O2/tlestang[P]IW_gene/write_vtk.cpp
// Function: write_fluid_vtk(int, int, int, double**, double***, char const*)
void write_fluid_vtk(int time, int Dx, int Dy, double **T, double ***u, const char* folderName)
// Writes the normalized velocities u and v. (u/Uref and v/Uref)
{

  /// Create filename
  stringstream fileName;

  fileName << "fluid_t" << time << ".vtk";

  string output_filename = string(folderName) + "/vtk_fluid/" + fileName.str();

  ofstream output_file;
  double rho0 = 1.0; double u0 = 0.01;

  /// Open file
  output_file.open(output_filename.c_str());

  /// Write VTK header
  output_file << "# vtk DataFile Version 3.0\n";
  output_file << "fluid_state\n";
  output_file << "ASCII\n";
  output_file << "DATASET RECTILINEAR_GRID\n";
  output_file << "DIMENSIONS " << Dx << " " << Dy << " 1" << "\n";
  output_file << "X_COORDINATES " << Dx << " float\n";
  for(int i = 0; i < Dx; ++i)
    output_file << i << " ";
  output_file << "\n";
  output_file << "Y_COORDINATES " << Dy  << " float\n";
  for(int j = 0; j < Dy ; ++j)
    output_file << j  << " ";
  output_file << "\n";
  output_file << "Z_COORDINATES " << 1 << " float\n";
  output_file << 0 << "\n";
  output_file << "POINT_DATA " << (Dx) * (Dy) << "\n";

  /// Write density difference
  output_file << "SCALARS temperature float 1\n";
  output_file << "LOOKUP_TABLE default\n";
  for(int Y =0; Y < Dy ; ++Y)
    for(int X = 0; X < Dx; ++X)
      output_file <<  T[X][Y] << "\n";

  /// Write velocity
  output_file << "VECTORS velocity_vector float\n";
  for(int Y = 0; Y < Dy ; ++Y)
    for(int X = 0; X < Dx; ++X)
      output_file << u[X][Y][0] -u0 << " " << u[X][Y][1] << " 0\n";

  /// Close file
  output_file.close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x418, %rsp            # imm = 0x418
movq %r9, %r13
movq %r8, -0x48(%rbp)
movq %rcx, -0x50(%rbp)
movl %edx, -0x2c(%rbp)
movl %esi, -0x38(%rbp)
movl %edi, %r15d
leaq -0x438(%rbp), %rdi
callq 0x20f0
leaq -0x428(%rbp), %rdi
leaq 0x1126(%rip), %rsi      # 0x51f8
callq 0x2150
movq %rax, %rdi
movl %r15d, %esi
callq 0x2240
leaq 0x1117(%rip), %rsi      # 0x5200
movq %rax, %rdi
callq 0x2150
leaq -0x90(%rbp), %rdi
leaq -0x39(%rbp), %rdx
movq %r13, %rsi
callq 0x45f2
leaq 0x10fa(%rip), %rdx      # 0x5205
leaq -0x2b0(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x45c9
leaq -0x420(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x21f0
leaq -0xb0(%rbp), %rdi
leaq -0x2b0(%rbp), %rsi
leaq -0x70(%rbp), %rdx
callq 0x4558
leaq -0x70(%rbp), %rdi
callq 0x20b0
leaq -0x2b0(%rbp), %rdi
callq 0x20b0
leaq -0x90(%rbp), %rdi
callq 0x20b0
leaq -0x2b0(%rbp), %rdi
callq 0x2230
movq -0xb0(%rbp), %rsi
leaq -0x2b0(%rbp), %rdi
pushq $0x10
popq %rdx
callq 0x2040
leaq 0x1082(%rip), %rsi      # 0x5211
leaq -0x2b0(%rbp), %rdi
callq 0x2150
leaq 0x108b(%rip), %rsi      # 0x522d
leaq -0x2b0(%rbp), %rdi
callq 0x2150
leaq 0x1085(%rip), %rsi      # 0x523a
leaq -0x2b0(%rbp), %rdi
callq 0x2150
leaq 0x1079(%rip), %rsi      # 0x5241
leaq -0x2b0(%rbp), %rdi
callq 0x2150
leaq 0x1080(%rip), %rsi      # 0x525b
leaq -0x2b0(%rbp), %rdi
callq 0x2150
movq %rax, %rdi
movl -0x38(%rbp), %esi
callq 0x2240
leaq 0x1204(%rip), %rsi      # 0x53fd
movq %rax, %rdi
callq 0x2150
movq %rax, %rdi
movl -0x2c(%rbp), %esi
callq 0x2240
leaq 0x1054(%rip), %rsi      # 0x5267
movq %rax, %rdi
callq 0x2150
leaq 0x10d5(%rip), %rsi      # 0x52f7
movq %rax, %rdi
callq 0x2150
leaq 0x1039(%rip), %rsi      # 0x526a
leaq -0x2b0(%rbp), %rdi
callq 0x2150
movq %rax, %rdi
movl -0x38(%rbp), %esi
callq 0x2240
leaq 0x109e(%rip), %rsi      # 0x52ed
movq %rax, %rdi
callq 0x2150
xorl %r13d, %r13d
movl -0x38(%rbp), %eax
testl %eax, %eax
movl $0x0, %r14d
cmovgl %eax, %r14d
leaq -0x2b0(%rbp), %r12
leaq 0x1186(%rip), %r15      # 0x53fd
cmpl %r13d, %r14d
je 0x4297
movq %r12, %rdi
movl %r13d, %esi
callq 0x2240
movq %rax, %rdi
movq %r15, %rsi
callq 0x2150
incl %r13d
jmp 0x4277
leaq 0x1059(%rip), %rsi      # 0x52f7
leaq -0x2b0(%rbp), %rdi
callq 0x2150
leaq 0xfc8(%rip), %rsi       # 0x5279
leaq -0x2b0(%rbp), %rdi
callq 0x2150
movq %rax, %rdi
movl -0x2c(%rbp), %esi
callq 0x2240
leaq 0x101e(%rip), %rsi      # 0x52ed
movq %rax, %rdi
callq 0x2150
xorl %r13d, %r13d
movl -0x2c(%rbp), %eax
testl %eax, %eax
movl $0x0, %ebx
cmovgl %eax, %ebx
leaq -0x2b0(%rbp), %r12
leaq 0x1108(%rip), %r15      # 0x53fd
cmpl %r13d, %ebx
je 0x4315
movq %r12, %rdi
movl %r13d, %esi
callq 0x2240
movq %rax, %rdi
movq %r15, %rsi
callq 0x2150
incl %r13d
jmp 0x42f5
leaq 0xfdb(%rip), %rsi       # 0x52f7
leaq -0x2b0(%rbp), %rdi
callq 0x2150
leaq 0xf59(%rip), %rsi       # 0x5288
leaq -0x2b0(%rbp), %rdi
callq 0x2150
pushq $0x1
popq %rsi
movq %rax, %rdi
callq 0x2240
leaq 0xfa0(%rip), %rsi       # 0x52ed
movq %rax, %rdi
callq 0x2150
leaq -0x2b0(%rbp), %rdi
xorl %esi, %esi
callq 0x2240
leaq 0xf8d(%rip), %rsi       # 0x52f7
movq %rax, %rdi
callq 0x2150
leaq 0xf1e(%rip), %rsi       # 0x5297
leaq -0x2b0(%rbp), %rdi
callq 0x2150
movl -0x2c(%rbp), %esi
imull -0x38(%rbp), %esi
movq %rax, %rdi
callq 0x2240
leaq 0xf5c(%rip), %rsi       # 0x52f7
movq %rax, %rdi
callq 0x2150
leaq 0xef9(%rip), %rsi       # 0x52a3
leaq -0x2b0(%rbp), %rdi
callq 0x2150
leaq 0xf03(%rip), %rsi       # 0x52c0
leaq -0x2b0(%rbp), %rdi
callq 0x2150
movl %ebx, %eax
movq %rax, -0x38(%rbp)
movl %r14d, %r13d
xorl %ebx, %ebx
leaq -0x2b0(%rbp), %r15
leaq 0xf15(%rip), %r12       # 0x52f7
cmpq -0x38(%rbp), %rbx
je 0x441a
xorl %r14d, %r14d
cmpq %r14, %r13
je 0x4415
movq -0x50(%rbp), %rax
movq (%rax,%r14,8), %rax
movsd (%rax,%rbx,8), %xmm0
movq %r15, %rdi
callq 0x2210
movq %rax, %rdi
movq %r12, %rsi
callq 0x2150
incq %r14
jmp 0x43eb
incq %rbx
jmp 0x43e2
leaq 0xeb5(%rip), %rsi       # 0x52d6
leaq -0x2b0(%rbp), %rdi
callq 0x2150
xorl %ebx, %ebx
leaq 0xfc7(%rip), %r15       # 0x53fd
leaq 0xeb8(%rip), %r12       # 0x52f5
cmpq -0x38(%rbp), %rbx
je 0x44a8
xorl %r14d, %r14d
cmpq %r14, %r13
je 0x44a3
movq -0x48(%rbp), %rax
movq (%rax,%r14,8), %rax
movq (%rax,%rbx,8), %rax
movsd (%rax), %xmm0
addsd 0xd8d(%rip), %xmm0      # 0x51f0
leaq -0x2b0(%rbp), %rdi
callq 0x2210
movq %rax, %rdi
movq %r15, %rsi
callq 0x2150
movq -0x48(%rbp), %rcx
movq (%rcx,%r14,8), %rcx
movq (%rcx,%rbx,8), %rcx
movsd 0x8(%rcx), %xmm0
movq %rax, %rdi
callq 0x2210
movq %rax, %rdi
movq %r12, %rsi
callq 0x2150
incq %r14
jmp 0x4446
incq %rbx
jmp 0x443d
leaq -0x2b0(%rbp), %rdi
callq 0x21b0
leaq -0x2b0(%rbp), %rdi
callq 0x21c0
leaq -0xb0(%rbp), %rdi
callq 0x20b0
leaq -0x438(%rbp), %rdi
callq 0x2110
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x4538
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x20b0
jmp 0x4500
movq %rax, %rbx
leaq -0x2b0(%rbp), %rdi
callq 0x20b0
jmp 0x4511
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
jmp 0x453f
jmp 0x451c
movq %rax, %rbx
jmp 0x4544
jmp 0x4529
jmp 0x4529
jmp 0x4529
jmp 0x4529
movq %rax, %rbx
leaq -0x2b0(%rbp), %rdi
callq 0x21c0
leaq -0xb0(%rbp), %rdi
callq 0x20b0
leaq -0x438(%rbp), %rdi
callq 0x2110
movq %rbx, %rdi
callq 0x2250