// File: /workspace/github_cpp_makefile_star2_O1/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, -0x68(%rbp)
movq %rcx, -0x90(%rbp)
movl %edx, %r12d
movl %esi, -0x2c(%rbp)
movl %edi, %r14d
leaq -0x438(%rbp), %rdi
callq 0x2110
leaq -0x428(%rbp), %r15
leaq 0x1fe3(%rip), %rsi      # 0x61f8
movl $0x7, %edx
movq %r15, %rdi
callq 0x21d0
movq %r15, %rdi
movl %r14d, %esi
callq 0x2270
leaq 0x1fcc(%rip), %rsi      # 0x6200
movl $0x4, %edx
movq %rax, %rdi
callq 0x21d0
leaq -0xb0(%rbp), %rdi
leaq -0x2d(%rbp), %rdx
movq %r13, %rsi
callq 0x4904
leaq 0x1faa(%rip), %rsi      # 0x6205
leaq -0xb0(%rbp), %rdi
callq 0x22d0
leaq -0x2a0(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x4294
movq %rdx, -0x2b0(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x2a0(%rbp)
jmp 0x429d
movupd (%rcx), %xmm0
movupd %xmm0, (%r14)
movq 0x8(%rax), %rdx
movq %rdx, -0x2a8(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0x420(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0x2230
movq -0x2b0(%rbp), %rcx
movq -0x2a8(%rbp), %r8
movq -0x80(%rbp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %esi
cmpq %r14, %rcx
je 0x42f1
movq -0x2a0(%rbp), %rsi
cmpq %rsi, %rax
jbe 0x430e
leaq -0x78(%rbp), %rdi
movl $0xf, %esi
cmpq %rdi, -0x10(%rdi)
je 0x4309
movq -0x78(%rbp), %rsi
cmpq %rsi, %rax
jbe 0x4323
movq -0x88(%rbp), %rsi
leaq -0x2b0(%rbp), %rdi
callq 0x20b0
jmp 0x4333
leaq -0x88(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x21c0
leaq -0x48(%rbp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0x4354
movq %rsi, -0x58(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x48(%rbp)
jmp 0x435c
movupd (%rcx), %xmm0
movupd %xmm0, (%rdx)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, -0x50(%rbp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq -0x78(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4391
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x21a0
movq -0x2b0(%rbp), %rdi
cmpq %r14, %rdi
je 0x43ac
movq -0x2a0(%rbp), %rsi
incq %rsi
callq 0x21a0
leaq -0xa0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x43cb
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x21a0
leaq -0x2b0(%rbp), %rdi
callq 0x2260
movq -0x58(%rbp), %rsi
leaq -0x2b0(%rbp), %rdi
movl $0x10, %edx
callq 0x2050
leaq 0x1e1e(%rip), %rsi      # 0x6211
leaq -0x2b0(%rbp), %rdi
movl $0x1b, %edx
callq 0x21d0
leaq 0x1e22(%rip), %rsi      # 0x622d
leaq -0x2b0(%rbp), %rdi
movl $0xc, %edx
callq 0x21d0
leaq 0x1e17(%rip), %rsi      # 0x623a
leaq -0x2b0(%rbp), %rdi
movl $0x6, %edx
callq 0x21d0
leaq 0x1e06(%rip), %rsi      # 0x6241
leaq -0x2b0(%rbp), %rdi
movl $0x19, %edx
callq 0x21d0
leaq 0x1e08(%rip), %rsi      # 0x625b
leaq -0x2b0(%rbp), %rdi
movl $0xb, %edx
callq 0x21d0
leaq -0x2b0(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x2270
movq %rax, %r14
leaq 0x1f80(%rip), %rsi      # 0x63fd
movl $0x1, %edx
movq %rax, %rdi
callq 0x21d0
movq %r14, %rdi
movl %r12d, %esi
callq 0x2270
movq %rax, %r14
leaq 0x1dc8(%rip), %rsi      # 0x6267
movl $0x2, %edx
movq %rax, %rdi
callq 0x21d0
leaq 0x1e44(%rip), %rsi      # 0x62f7
movl $0x1, %edx
movq %r14, %rdi
callq 0x21d0
leaq 0x1da3(%rip), %rsi      # 0x626a
leaq -0x2b0(%rbp), %rdi
movl $0xe, %edx
callq 0x21d0
leaq -0x2b0(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x2270
leaq 0x1dff(%rip), %rsi      # 0x62ed
movl $0x7, %edx
movq %rax, %rdi
callq 0x21d0
cmpl $0x0, -0x2c(%rbp)
jle 0x4536
xorl %r15d, %r15d
leaq -0x2b0(%rbp), %r13
leaq 0x1eeb(%rip), %r14      # 0x63fd
movq %r13, %rdi
movl %r15d, %esi
callq 0x2270
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x21d0
incl %r15d
cmpl %r15d, -0x2c(%rbp)
jne 0x4512
leaq 0x1dba(%rip), %rsi      # 0x62f7
leaq -0x2b0(%rbp), %rdi
movl $0x1, %edx
callq 0x21d0
leaq 0x1d24(%rip), %rsi      # 0x6279
leaq -0x2b0(%rbp), %rdi
movl $0xe, %edx
callq 0x21d0
leaq -0x2b0(%rbp), %rdi
movl %r12d, %esi
callq 0x2270
leaq 0x1d71(%rip), %rsi      # 0x62ed
movl $0x7, %edx
movq %rax, %rdi
callq 0x21d0
testl %r12d, %r12d
jle 0x45c2
xorl %r15d, %r15d
leaq -0x2b0(%rbp), %r13
leaq 0x1e5e(%rip), %r14      # 0x63fd
movq %r13, %rdi
movl %r15d, %esi
callq 0x2270
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x21d0
incl %r15d
cmpl %r15d, %r12d
jne 0x459f
leaq 0x1d2e(%rip), %rsi      # 0x62f7
leaq -0x2b0(%rbp), %rdi
movl $0x1, %edx
callq 0x21d0
leaq 0x1ca7(%rip), %rsi      # 0x6288
leaq -0x2b0(%rbp), %rdi
movl $0xe, %edx
callq 0x21d0
leaq -0x2b0(%rbp), %rdi
movl $0x1, %esi
callq 0x2270
leaq 0x1ce3(%rip), %rsi      # 0x62ed
movl $0x7, %edx
movq %rax, %rdi
callq 0x21d0
leaq -0x2b0(%rbp), %rdi
xorl %esi, %esi
callq 0x2270
leaq 0x1ccb(%rip), %rsi      # 0x62f7
movl $0x1, %edx
movq %rax, %rdi
callq 0x21d0
leaq 0x1c57(%rip), %rsi      # 0x6297
leaq -0x2b0(%rbp), %rdi
movl $0xb, %edx
callq 0x21d0
movl %r12d, %esi
imull -0x2c(%rbp), %esi
leaq -0x2b0(%rbp), %rdi
callq 0x2270
leaq 0x1c8c(%rip), %rsi      # 0x62f7
movl $0x1, %edx
movq %rax, %rdi
callq 0x21d0
leaq 0x1c24(%rip), %rsi      # 0x62a3
leaq -0x2b0(%rbp), %rdi
movl $0x1c, %edx
callq 0x21d0
leaq 0x1c29(%rip), %rsi      # 0x62c0
leaq -0x2b0(%rbp), %rdi
movl $0x15, %edx
callq 0x21d0
movl %r12d, %eax
movq %rax, -0x60(%rbp)
movl -0x2c(%rbp), %ebx
movl %r12d, -0x34(%rbp)
testl %r12d, %r12d
jle 0x470f
xorl %r14d, %r14d
leaq -0x2b0(%rbp), %r13
leaq 0x1c2b(%rip), %r15      # 0x62f7
cmpl $0x0, -0x2c(%rbp)
jle 0x4706
xorl %r12d, %r12d
movq -0x90(%rbp), %rax
movq (%rax,%r12,8), %rax
movsd (%rax,%r14,8), %xmm0
movq %r13, %rdi
callq 0x2240
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x21d0
incq %r12
cmpq %r12, %rbx
jne 0x46d5
incq %r14
cmpq -0x60(%rbp), %r14
jne 0x46cc
leaq 0x1bc0(%rip), %rsi      # 0x62d6
leaq -0x2b0(%rbp), %rdi
movl $0x1e, %edx
callq 0x21d0
movl -0x34(%rbp), %eax
testl %eax, %eax
jle 0x47ba
xorl %r15d, %r15d
leaq 0x1bb9(%rip), %r13      # 0x62f5
cmpl $0x0, -0x2c(%rbp)
jle 0x47b1
xorl %r12d, %r12d
movq -0x68(%rbp), %rax
movq (%rax,%r12,8), %rax
movq (%rax,%r15,8), %rax
movsd (%rax), %xmm0
addsd 0x1a93(%rip), %xmm0     # 0x61f0
leaq -0x2b0(%rbp), %rdi
callq 0x2240
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1c82(%rip), %rsi      # 0x63fd
callq 0x21d0
movq -0x68(%rbp), %rax
movq (%rax,%r12,8), %rax
movq (%rax,%r15,8), %rax
movsd 0x8(%rax), %xmm0
movq %r14, %rdi
callq 0x2240
movl $0x3, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x21d0
incq %r12
cmpq %r12, %rbx
jne 0x4745
incq %r15
cmpq -0x60(%rbp), %r15
jne 0x473c
leaq -0x2b0(%rbp), %rdi
callq 0x21f0
movq 0x4803(%rip), %rax      # 0x8fd0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq -0x2a8(%rbp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, -0x2b0(%rbp,%rcx)
callq 0x2150
leaq -0x1b8(%rbp), %rdi
callq 0x20c0
leaq -0x48(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4815
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x21a0
movq 0x479c(%rip), %rsi      # 0x8fb8
leaq -0x438(%rbp), %rdi
callq 0x2130
leaq -0x3b8(%rbp), %rdi
callq 0x20c0
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x48c3
movq %rax, %rbx
leaq -0x78(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x486c
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x21a0
jmp 0x486c
movq %rax, %rbx
movq -0x2b0(%rbp), %rdi
cmpq %r14, %rdi
je 0x488c
movq -0x2a0(%rbp), %rsi
incq %rsi
callq 0x21a0
jmp 0x488c
movq %rax, %rbx
leaq -0xa0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x48dc
movq -0xa0(%rbp), %rsi
jmp 0x48d4
jmp 0x48a7
movq %rax, %rbx
jmp 0x48dc
jmp 0x48b4
jmp 0x48b4
jmp 0x48b4
jmp 0x48b4
movq %rax, %rbx
leaq -0x2b0(%rbp), %rdi
callq 0x2200
leaq -0x48(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x48dc
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x21a0
movq 0x46d5(%rip), %rsi      # 0x8fb8
leaq -0x438(%rbp), %rdi
callq 0x2130
leaq -0x3b8(%rbp), %rdi
callq 0x20c0
movq %rbx, %rdi
callq 0x2280
nop