// File: /workspace/github_cpp_makefile_star2_O3/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 0x1ff7(%rip), %rsi      # 0x61f8
movl $0x7, %edx
movq %r15, %rdi
callq 0x21d0
movq %r15, %rdi
movl %r14d, %esi
callq 0x2270
leaq 0x1fe0(%rip), %rsi      # 0x6200
movl $0x4, %edx
movq %rax, %rdi
callq 0x21d0
leaq -0xb0(%rbp), %rdi
leaq -0x2d(%rbp), %rdx
movq %r13, %rsi
callq 0x48ee
leaq 0x1fbe(%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 0x4280
movq %rdx, -0x2b0(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x2a0(%rbp)
jmp 0x4289
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, %edi
cmpq %r14, %rcx
je 0x42dd
movq -0x2a0(%rbp), %rdi
movq -0x88(%rbp), %rsi
cmpq %rdi, %rax
jbe 0x4300
leaq -0x78(%rbp), %r9
movl $0xf, %edi
cmpq %r9, %rsi
je 0x42fb
movq -0x78(%rbp), %rdi
cmpq %rdi, %rax
jbe 0x430e
leaq -0x2b0(%rbp), %rdi
callq 0x20b0
jmp 0x431e
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 0x433f
movq %rsi, -0x58(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x48(%rbp)
jmp 0x4347
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 0x437c
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x21a0
movq -0x2b0(%rbp), %rdi
cmpq %r14, %rdi
je 0x4397
movq -0x2a0(%rbp), %rsi
incq %rsi
callq 0x21a0
leaq -0xa0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x43b6
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 0x1e33(%rip), %rsi      # 0x6211
leaq -0x2b0(%rbp), %rdi
movl $0x1b, %edx
callq 0x21d0
leaq 0x1e37(%rip), %rsi      # 0x622d
leaq -0x2b0(%rbp), %rdi
movl $0xc, %edx
callq 0x21d0
leaq 0x1e2c(%rip), %rsi      # 0x623a
leaq -0x2b0(%rbp), %rdi
movl $0x6, %edx
callq 0x21d0
leaq 0x1e1b(%rip), %rsi      # 0x6241
leaq -0x2b0(%rbp), %rdi
movl $0x19, %edx
callq 0x21d0
leaq 0x1e1d(%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 0x1f95(%rip), %rsi      # 0x63fd
movl $0x1, %edx
movq %rax, %rdi
callq 0x21d0
movq %r14, %rdi
movl %r12d, %esi
callq 0x2270
movq %rax, %r14
leaq 0x1ddd(%rip), %rsi      # 0x6267
movl $0x2, %edx
movq %rax, %rdi
callq 0x21d0
leaq 0x1e59(%rip), %rsi      # 0x62f7
movl $0x1, %edx
movq %r14, %rdi
callq 0x21d0
leaq 0x1db8(%rip), %rsi      # 0x626a
leaq -0x2b0(%rbp), %rdi
movl $0xe, %edx
callq 0x21d0
leaq -0x2b0(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x2270
leaq 0x1e14(%rip), %rsi      # 0x62ed
movl $0x7, %edx
movq %rax, %rdi
callq 0x21d0
cmpl $0x0, -0x2c(%rbp)
jle 0x4521
xorl %r15d, %r15d
leaq -0x2b0(%rbp), %r13
leaq 0x1f00(%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 0x44fd
leaq 0x1dcf(%rip), %rsi      # 0x62f7
leaq -0x2b0(%rbp), %rdi
movl $0x1, %edx
callq 0x21d0
leaq 0x1d39(%rip), %rsi      # 0x6279
leaq -0x2b0(%rbp), %rdi
movl $0xe, %edx
callq 0x21d0
leaq -0x2b0(%rbp), %rdi
movl %r12d, %esi
callq 0x2270
leaq 0x1d86(%rip), %rsi      # 0x62ed
movl $0x7, %edx
movq %rax, %rdi
callq 0x21d0
testl %r12d, %r12d
jle 0x45ad
xorl %r15d, %r15d
leaq -0x2b0(%rbp), %r13
leaq 0x1e73(%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 0x458a
leaq 0x1d43(%rip), %rsi      # 0x62f7
leaq -0x2b0(%rbp), %rdi
movl $0x1, %edx
callq 0x21d0
leaq 0x1cbc(%rip), %rsi      # 0x6288
leaq -0x2b0(%rbp), %rdi
movl $0xe, %edx
callq 0x21d0
leaq -0x2b0(%rbp), %rdi
movl $0x1, %esi
callq 0x2270
leaq 0x1cf8(%rip), %rsi      # 0x62ed
movl $0x7, %edx
movq %rax, %rdi
callq 0x21d0
leaq -0x2b0(%rbp), %rdi
xorl %esi, %esi
callq 0x2270
leaq 0x1ce0(%rip), %rsi      # 0x62f7
movl $0x1, %edx
movq %rax, %rdi
callq 0x21d0
leaq 0x1c6c(%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 0x1ca1(%rip), %rsi      # 0x62f7
movl $0x1, %edx
movq %rax, %rdi
callq 0x21d0
leaq 0x1c39(%rip), %rsi      # 0x62a3
leaq -0x2b0(%rbp), %rdi
movl $0x1c, %edx
callq 0x21d0
leaq 0x1c3e(%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 0x46fa
xorl %r14d, %r14d
leaq -0x2b0(%rbp), %r13
leaq 0x1c40(%rip), %r15      # 0x62f7
cmpl $0x0, -0x2c(%rbp)
jle 0x46f1
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 0x46c0
incq %r14
cmpq -0x60(%rbp), %r14
jne 0x46b7
leaq 0x1bd5(%rip), %rsi      # 0x62d6
leaq -0x2b0(%rbp), %rdi
movl $0x1e, %edx
callq 0x21d0
movl -0x34(%rbp), %eax
testl %eax, %eax
jle 0x47a5
xorl %r15d, %r15d
leaq 0x1bce(%rip), %r13      # 0x62f5
cmpl $0x0, -0x2c(%rbp)
jle 0x479c
xorl %r12d, %r12d
movq -0x68(%rbp), %rax
movq (%rax,%r12,8), %rax
movq (%rax,%r15,8), %rax
movsd (%rax), %xmm0
addsd 0x1aa8(%rip), %xmm0     # 0x61f0
leaq -0x2b0(%rbp), %rdi
callq 0x2240
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1c97(%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 0x4730
incq %r15
cmpq -0x60(%rbp), %r15
jne 0x4727
leaq -0x2b0(%rbp), %rdi
callq 0x21f0
movq 0x4818(%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 0x4800
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x21a0
movq 0x47b1(%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 0x48ae
movq %rax, %rbx
leaq -0x78(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4857
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x21a0
jmp 0x4857
movq %rax, %rbx
movq -0x2b0(%rbp), %rdi
cmpq %r14, %rdi
je 0x4877
movq -0x2a0(%rbp), %rsi
incq %rsi
callq 0x21a0
jmp 0x4877
movq %rax, %rbx
leaq -0xa0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x48c7
movq -0xa0(%rbp), %rsi
jmp 0x48bf
jmp 0x4892
movq %rax, %rbx
jmp 0x48c7
jmp 0x489f
jmp 0x489f
jmp 0x489f
jmp 0x489f
movq %rax, %rbx
leaq -0x2b0(%rbp), %rdi
callq 0x2200
leaq -0x48(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x48c7
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x21a0
movq 0x46ea(%rip), %rsi      # 0x8fb8
leaq -0x438(%rbp), %rdi
callq 0x2130
leaq -0x3b8(%rbp), %rdi
callq 0x20c0
movq %rbx, %rdi
callq 0x2280