// File: tlestang[P]IW_gene/LatticeBoltzmann.cpp
// Function: LatticeBoltzmann::update()
void LatticeBoltzmann::update()
{
  ThermalSite **swapT;
  VelSite **swapVel;
  double om, a, dSpge;
  //ofstream lulu("spgegeometry.dat");
  	for (int x=0; x<dims[0]; x++)
	{
		for (int y=0; y<dims[1]; y++)
		{
		  if(velSites[x][y].isFluid())
		    {
		      
		  velSites[x][y].computeRhoAndU(rho[x][y], u[x][y]);
		  thermalSites[x][y].computeRhoAndU(T[x][y]);

		  
		  if(y>(spgeFirstNode-1))
		    {
		      if(y>ySpge){om = 0.001*omega[0];}
		      else{
			dSpge = ySpge-spgeFirstNode;
			a = (y-spgeFirstNode)/dSpge;
			om = (1.-0.999*a*a)*omega[0];
		      }
		    }
		  else{om = omega[0];}

		  // if(x==250)
		  //   {
		  //     lulu << y << " " << om << endl;
		  //   }
		  
		  velSites[x][y].collide(rho[x][y], T[x][y], u[x][y], om);
		  thermalSites[x][y].collide(rho[x][y], T[x][y], u[x][y], omega[1]);
		  
		  streamToNeighbors(x, y);
		    }
		}

	}

	w->HalfWayFreeSlipBC(velSites, velSites_);
	topo->HalfWayFreeSlipBC(velSites, velSites_);
	//wb->FreeSlipBC(velSites, velSites_);

	w->TemperatureBC(velSites_, thermalSites_, T, u);
	topo->TemperatureBC(velSites_, thermalSites_, T, u);
	//wb->TemperatureBC(velSites_, thermalSites_, T, u);


	swapT = thermalSites;
	thermalSites = thermalSites_;
	thermalSites_ = swapT;

	swapVel = velSites;
	velSites = velSites_;
	velSites_ = swapVel;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x40(%rbp), %rcx
movl -0x34(%rbp), %eax
cmpl (%rcx), %eax
jge 0x6a2c
movl $0x0, -0x38(%rbp)
movq -0x40(%rbp), %rcx
movl -0x38(%rbp), %eax
cmpl 0x4(%rcx), %eax
jge 0x6a1c
movq -0x40(%rbp), %rax
movq 0x60(%rax), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movslq -0x38(%rbp), %rax
imulq $0x88, %rax, %rax
addq %rax, %rdi
callq 0x3820
testb $0x1, %al
jne 0x67dd
jmp 0x6a0c
movq -0x40(%rbp), %rax
movq 0x60(%rax), %rcx
movslq -0x34(%rbp), %rdx
movq (%rcx,%rdx,8), %rdi
movslq -0x38(%rbp), %rcx
imulq $0x88, %rcx, %rcx
addq %rcx, %rdi
movq 0x48(%rax), %rcx
movslq -0x34(%rbp), %rdx
movq (%rcx,%rdx,8), %rsi
movslq -0x38(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rsi
movq 0x58(%rax), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movq (%rdi), %rax
callq *0x8(%rax)
movq -0x40(%rbp), %rax
movq 0x70(%rax), %rcx
movslq -0x34(%rbp), %rdx
movq (%rcx,%rdx,8), %rdi
movslq -0x38(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rdi
movq 0x50(%rax), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movslq -0x38(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq (%rdi), %rax
callq *0x20(%rax)
movq -0x40(%rbp), %rax
cvtsi2sdl -0x38(%rbp), %xmm0
movsd 0x38(%rax), %xmm1
movsd 0x27ae(%rip), %xmm2     # 0x9028
subsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x691c
movq -0x40(%rbp), %rax
cvtsi2sdl -0x38(%rbp), %xmm0
ucomisd 0x40(%rax), %xmm0
jbe 0x68b0
movq -0x40(%rbp), %rax
movsd 0x29ac(%rip), %xmm0     # 0x9250
mulsd 0x8(%rax), %xmm0
movsd %xmm0, -0x20(%rbp)
jmp 0x691a
movq -0x40(%rbp), %rax
movsd 0x40(%rax), %xmm0
subsd 0x38(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
cvtsi2sdl -0x38(%rbp), %xmm0
subsd 0x38(%rax), %xmm0
divsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movsd 0x2969(%rip), %xmm0     # 0x9248
mulsd -0x28(%rbp), %xmm0
movsd -0x28(%rbp), %xmm1
movq %xmm0, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm0
mulsd %xmm1, %xmm0
movsd 0x271c(%rip), %xmm1     # 0x9028
addsd %xmm1, %xmm0
mulsd 0x8(%rax), %xmm0
movsd %xmm0, -0x20(%rbp)
jmp 0x692a
movq -0x40(%rbp), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x20(%rbp)
movq -0x40(%rbp), %rax
movq 0x60(%rax), %rcx
movslq -0x34(%rbp), %rdx
movq (%rcx,%rdx,8), %rdi
movslq -0x38(%rbp), %rcx
imulq $0x88, %rcx, %rcx
addq %rcx, %rdi
movq 0x48(%rax), %rcx
movslq -0x34(%rbp), %rdx
movq (%rcx,%rdx,8), %rsi
movslq -0x38(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rsi
movq 0x50(%rax), %rcx
movslq -0x34(%rbp), %rdx
movq (%rcx,%rdx,8), %rdx
movslq -0x38(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rdx
movq 0x58(%rax), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movsd -0x20(%rbp), %xmm0
movq (%rdi), %rax
callq *0x10(%rax)
movq -0x40(%rbp), %rax
movq 0x70(%rax), %rcx
movslq -0x34(%rbp), %rdx
movq (%rcx,%rdx,8), %rdi
movslq -0x38(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rdi
movq 0x48(%rax), %rcx
movslq -0x34(%rbp), %rdx
movq (%rcx,%rdx,8), %rsi
movslq -0x38(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rsi
movq 0x50(%rax), %rcx
movslq -0x34(%rbp), %rdx
movq (%rcx,%rdx,8), %rdx
movslq -0x38(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rdx
movq 0x58(%rax), %rcx
movslq -0x34(%rbp), %r8
movq (%rcx,%r8,8), %rcx
movslq -0x38(%rbp), %r8
movq (%rcx,%r8,8), %rcx
movsd 0x10(%rax), %xmm0
movq (%rdi), %rax
callq *0x10(%rax)
movq -0x40(%rbp), %rdi
movl -0x34(%rbp), %esi
movl -0x38(%rbp), %edx
callq 0x6610
jmp 0x6a0e
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x67a1
jmp 0x6a1e
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x678b
movq -0x40(%rbp), %rax
movq 0x80(%rax), %rdi
movq 0x60(%rax), %rsi
movq 0x68(%rax), %rdx
callq 0x4170
movq -0x40(%rbp), %rax
movq 0x88(%rax), %rdi
movq 0x60(%rax), %rsi
movq 0x68(%rax), %rdx
callq 0x5500
movq -0x40(%rbp), %rax
movq 0x80(%rax), %rdi
movq 0x68(%rax), %rsi
movq 0x78(%rax), %rdx
movq 0x50(%rax), %rcx
movq 0x58(%rax), %r8
callq 0x42b0
movq -0x40(%rbp), %rax
movq 0x88(%rax), %rdi
movq 0x68(%rax), %rsi
movq 0x78(%rax), %rdx
movq 0x50(%rax), %rcx
movq 0x58(%rax), %r8
callq 0x5a40
movq -0x40(%rbp), %rax
movq 0x70(%rax), %rcx
movq %rcx, -0x10(%rbp)
movq 0x78(%rax), %rcx
movq %rcx, 0x70(%rax)
movq -0x10(%rbp), %rcx
movq %rcx, 0x78(%rax)
movq 0x60(%rax), %rcx
movq %rcx, -0x18(%rbp)
movq 0x68(%rax), %rcx
movq %rcx, 0x60(%rax)
movq -0x18(%rbp), %rcx
movq %rcx, 0x68(%rax)
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)