// File: tlestang[P]IW_gene/LatticeBoltzmann.cpp
// Function: LatticeBoltzmann::LatticeBoltzmann(int const*, double const*, double, double, int, double)
LatticeBoltzmann::LatticeBoltzmann(const int d[2], const double omega_[2],
				   double coef_force_, double u0_, int h_, double N2_)
{

  dims[0] = d[0]; dims[1] = d[1];
  omega[0] = omega_[0];
  omega[1] = omega_[1];
  coef_force = coef_force_;
  u0 = u0_; N2 = N2_; h = h_;

  velSites = new VelSite*[dims[0]];
  velSites_ = new VelSite*[dims[0]];

  for (int i=0;i<dims[0];i++)
    {
      velSites[i] = new VelSite[dims[1]];
      velSites_[i] = new VelSite[dims[1]];
    }

  thermalSites = new ThermalSite*[dims[0]];
  thermalSites_ = new ThermalSite*[dims[0]];

  for (int i=0;i<dims[0];i++)
    {
      thermalSites[i] = new ThermalSite[dims[1]];
      thermalSites_[i] = new ThermalSite[dims[1]];
    }
  
  // allocate memory for T and rho
  T = new double*[dims[0]];
  for (int x=0; x<dims[0]; x++)
    T[x] = new double[dims[1]];

    rho = new double*[dims[0]];
  for (int x=0; x<dims[0]; x++)
    rho[x] = new double[dims[1]];
	
  // allocate memory for velocity
  u = new double**[dims[0]];
  for (int x=0; x<dims[0]; x++)
    {
      u[x] = new double*[dims[1]];
		
      for (int y=0; y<dims[1]; y++)
	u[x][y] = new double[2];
    }

  generateGeometry();
  
  w = new TopWall(d);
  topo = new Topography(d, h, u, velSites, velSites_);
  

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movsd %xmm0, -0x20(%rbp)
movsd %xmm1, -0x28(%rbp)
movl %ecx, -0x2c(%rbp)
movsd %xmm2, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rcx
movl (%rcx), %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rcx
movl 0x4(%rcx), %ecx
movl %ecx, 0x4(%rax)
movq -0x18(%rbp), %rcx
movsd (%rcx), %xmm0
movsd %xmm0, 0x8(%rax)
movq -0x18(%rbp), %rcx
movsd 0x8(%rcx), %xmm0
movsd %xmm0, 0x10(%rax)
movsd -0x20(%rbp), %xmm0
movsd %xmm0, 0x18(%rax)
movsd -0x28(%rbp), %xmm0
movsd %xmm0, 0x20(%rax)
movsd -0x38(%rbp), %xmm0
movsd %xmm0, 0x28(%rax)
cvtsi2sdl -0x2c(%rbp), %xmm0
movsd %xmm0, 0x30(%rax)
movslq (%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x3030
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x60(%rax)
movslq (%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x3030
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x68(%rax)
movl $0x0, -0x3c(%rbp)
movq -0x68(%rbp), %rcx
movl -0x3c(%rbp), %eax
cmpl (%rcx), %eax
jge 0x5f67
movq -0x68(%rbp), %rax
movslq 0x4(%rax), %rax
movq %rax, -0x78(%rbp)
movl $0x88, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
movq %rdi, -0x80(%rbp)
callq 0x3030
movq %rax, %rcx
movq -0x78(%rbp), %rax
movq %rcx, -0x70(%rbp)
cmpq $0x0, %rax
je 0x5e44
movq -0x70(%rbp), %rax
movq -0x78(%rbp), %rcx
imulq $0x88, %rcx, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, -0x90(%rbp)
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rdi
movq %rdi, -0x98(%rbp)
callq 0x3840
jmp 0x5e24
movq -0x90(%rbp), %rcx
movq -0x98(%rbp), %rax
addq $0x88, %rax
cmpq %rcx, %rax
movq %rax, -0x88(%rbp)
jne 0x5e0f
movq -0x68(%rbp), %rax
movq -0x70(%rbp), %rsi
movq 0x60(%rax), %rcx
movslq -0x3c(%rbp), %rdx
movq %rsi, (%rcx,%rdx,8)
movslq 0x4(%rax), %rax
movq %rax, -0xa8(%rbp)
movl $0x88, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
movq %rdi, -0xb0(%rbp)
callq 0x3030
movq %rax, %rcx
movq -0xa8(%rbp), %rax
movq %rcx, -0xa0(%rbp)
cmpq $0x0, %rax
je 0x5f00
movq -0xa0(%rbp), %rax
movq -0xa8(%rbp), %rcx
imulq $0x88, %rcx, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, -0xc0(%rbp)
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
callq 0x3840
jmp 0x5ee0
movq -0xc0(%rbp), %rcx
movq -0xc8(%rbp), %rax
addq $0x88, %rax
cmpq %rcx, %rax
movq %rax, -0xb8(%rbp)
jne 0x5ecb
movq -0xa0(%rbp), %rdx
movq -0x68(%rbp), %rax
movq 0x68(%rax), %rax
movslq -0x3c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x5d9b
movq -0x80(%rbp), %rsi
movq -0x70(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
callq 0x3400
jmp 0x6468
movq -0xb0(%rbp), %rsi
movq -0xa0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
callq 0x3400
jmp 0x6468
movq -0x68(%rbp), %rax
movslq (%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x3030
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x70(%rax)
movslq (%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x3030
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x78(%rax)
movl $0x0, -0x50(%rbp)
movq -0x68(%rbp), %rcx
movl -0x50(%rbp), %eax
cmpl (%rcx), %eax
jge 0x61ad
movq -0x68(%rbp), %rax
movslq 0x4(%rax), %rax
movq %rax, -0xd8(%rbp)
movl $0x70, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
movq %rdi, -0xe0(%rbp)
callq 0x3030
movq %rax, %rcx
movq -0xd8(%rbp), %rax
movq %rcx, -0xd0(%rbp)
cmpq $0x0, %rax
je 0x6086
movq -0xd0(%rbp), %rax
movq -0xd8(%rbp), %rcx
imulq $0x70, %rcx, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, -0xf0(%rbp)
movq %rax, -0xe8(%rbp)
movq -0xe8(%rbp), %rdi
movq %rdi, -0xf8(%rbp)
callq 0x3890
jmp 0x6068
movq -0xf0(%rbp), %rcx
movq -0xf8(%rbp), %rax
addq $0x70, %rax
cmpq %rcx, %rax
movq %rax, -0xe8(%rbp)
jne 0x6053
movq -0x68(%rbp), %rax
movq -0xd0(%rbp), %rsi
movq 0x70(%rax), %rcx
movslq -0x50(%rbp), %rdx
movq %rsi, (%rcx,%rdx,8)
movslq 0x4(%rax), %rax
movq %rax, -0x108(%rbp)
movl $0x70, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
movq %rdi, -0x110(%rbp)
callq 0x3030
movq %rax, %rcx
movq -0x108(%rbp), %rax
movq %rcx, -0x100(%rbp)
cmpq $0x0, %rax
je 0x6140
movq -0x100(%rbp), %rax
movq -0x108(%rbp), %rcx
imulq $0x70, %rcx, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, -0x120(%rbp)
movq %rax, -0x118(%rbp)
movq -0x118(%rbp), %rdi
movq %rdi, -0x128(%rbp)
callq 0x3890
jmp 0x6122
movq -0x120(%rbp), %rcx
movq -0x128(%rbp), %rax
addq $0x70, %rax
cmpq %rcx, %rax
movq %rax, -0x118(%rbp)
jne 0x610d
movq -0x100(%rbp), %rdx
movq -0x68(%rbp), %rax
movq 0x78(%rax), %rax
movslq -0x50(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x5fd0
movq -0xe0(%rbp), %rsi
movq -0xd0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
callq 0x3400
jmp 0x6468
movq -0x110(%rbp), %rsi
movq -0x100(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
callq 0x3400
jmp 0x6468
movq -0x68(%rbp), %rax
movslq (%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x3030
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x50(%rax)
movl $0x0, -0x54(%rbp)
movq -0x68(%rbp), %rcx
movl -0x54(%rbp), %eax
cmpl (%rcx), %eax
jge 0x6239
movq -0x68(%rbp), %rax
movslq 0x4(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x3030
movq %rax, %rdx
movq -0x68(%rbp), %rax
movq 0x50(%rax), %rax
movslq -0x54(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x61e7
movq -0x68(%rbp), %rax
movslq (%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x3030
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x48(%rax)
movl $0x0, -0x58(%rbp)
movq -0x68(%rbp), %rcx
movl -0x58(%rbp), %eax
cmpl (%rcx), %eax
jge 0x62c5
movq -0x68(%rbp), %rax
movslq 0x4(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x3030
movq %rax, %rdx
movq -0x68(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x58(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x6273
movq -0x68(%rbp), %rax
movslq (%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x3030
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x58(%rax)
movl $0x0, -0x5c(%rbp)
movq -0x68(%rbp), %rcx
movl -0x5c(%rbp), %eax
cmpl (%rcx), %eax
jge 0x639d
movq -0x68(%rbp), %rax
movslq 0x4(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x3030
movq %rax, %rdx
movq -0x68(%rbp), %rax
movq 0x58(%rax), %rax
movslq -0x5c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl $0x0, -0x60(%rbp)
movq -0x68(%rbp), %rcx
movl -0x60(%rbp), %eax
cmpl 0x4(%rcx), %eax
jge 0x638d
movl $0x10, %edi
callq 0x3030
movq %rax, %rdx
movq -0x68(%rbp), %rax
movq 0x58(%rax), %rax
movslq -0x5c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x60(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x6351
jmp 0x638f
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x62ff
movq -0x68(%rbp), %rdi
callq 0x6480
movl $0x18, %edi
callq 0x3220
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x130(%rbp)
movq -0x10(%rbp), %rsi
callq 0x3e40
jmp 0x63c8
movq -0x68(%rbp), %rax
movq -0x130(%rbp), %rcx
movq %rcx, 0x80(%rax)
movl $0x20, %edi
callq 0x3220
movq %rax, %rdi
movq -0x68(%rbp), %rax
movq %rdi, %rcx
movq %rcx, -0x138(%rbp)
movq -0x10(%rbp), %rsi
cvttsd2si 0x30(%rax), %edx
movq 0x58(%rax), %rcx
movq 0x60(%rax), %r8
movq 0x68(%rax), %r9
callq 0x4ab0
jmp 0x6411
movq -0x68(%rbp), %rax
movq -0x138(%rbp), %rcx
movq %rcx, 0x88(%rax)
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
movq -0x130(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
movl $0x18, %esi
callq 0x3230
jmp 0x6468
movq -0x138(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
movl $0x20, %esi
callq 0x3230
movq -0x48(%rbp), %rdi
callq 0x3380
nopw %cs:(%rax,%rax)