// File: /workspace/github_cpp_makefile_star2_O1/suhasjains[P]AMR-Solver/src/poisson.cpp
// Function: amrsolver::jacobi(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void jacobi(int level, std::string name) {

	myOctree::create_lists_of_level_nodes();

	if(myOctree::level_nodes[level].empty()) {
        	std::cerr << "No blocks in level " << level << std::endl;
	 	exit(1);
	}

	double global_res = 1.0;

	long int loop = 0;

	//iteration loop
	while(loop <250 ) {
	//while(global_res > pow(10,-7)) {

		global_res = 0.0;
		
		//exchange ghost values
		exchange_ghost_val(level, name);

		//loop over all the nodes
		for (std::list<Octree*>::iterator it = level_nodes[level].begin(), end = level_nodes[level].end(); it != end; ++it) {
	
			for(int l = 0; l<myOctree::scalar_fields.size() ; l++) {
	
				Field *f = (*it)->get_block_data()->scalarfields[l];
							//	std::cerr << f->name << std::endl;
	
				if( f->name == name ) {
					
					global_res = jacobi_for_field(*it, f, global_res);	

				}	
			}
		}

		std::cout << "Residual " << global_res << std::endl;

		loop++;

	}	
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r14
movl %edi, %ebx
callq 0x3010
movl %ebx, -0x2c(%rbp)
movslq %ebx, %rax
leaq (%rax,%rax,2), %rax
leaq 0x79d8(%rip), %rcx      # 0x15250
leaq (%rcx,%rax,8), %rax
movq %rax, -0x40(%rbp)
cmpq %rax, (%rax)
je 0xd9da
leaq -0x58(%rbp), %rbx
xorl %r15d, %r15d
leaq 0x7d91(%rip), %r12      # 0x15628
movq %rbx, -0x68(%rbp)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq -0x68(%rbp), %r13
movq %r13, %rdi
callq 0x391e
movl -0x2c(%rbp), %edi
movq %r13, %rsi
callq 0x7394
movq %r15, -0x48(%rbp)
movq -0x68(%rbp), %rdi
cmpq %rbx, %rdi
je 0xd8d5
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x2200
movq -0x40(%rbp), %rax
movq (%rax), %r15
xorps %xmm0, %xmm0
cmpq %rax, %r15
je 0xd95c
movsd %xmm0, -0x38(%rbp)
movq 0x8(%r12), %rax
cmpq (%r12), %rax
je 0xd951
xorl %ebx, %ebx
movq 0x10(%r15), %rdi
callq 0x4064
movq 0x10(%rax), %rax
movq (%rax,%rbx,8), %r13
movq 0x20(%r13), %rdx
cmpq 0x8(%r14), %rdx
jne 0xd93c
testq %rdx, %rdx
je 0xd926
movq (%r14), %rsi
movq 0x18(%r13), %rdi
callq 0x2210
testl %eax, %eax
jne 0xd93c
movq 0x10(%r15), %rdi
movq %r13, %rsi
movsd -0x38(%rbp), %xmm0
callq 0xda2a
movsd %xmm0, -0x38(%rbp)
incq %rbx
movq 0x8(%r12), %rax
subq (%r12), %rax
sarq $0x5, %rax
cmpq %rbx, %rax
ja 0xd8f6
movq (%r15), %r15
cmpq -0x40(%rbp), %r15
jne 0xd8e9
jmp 0xd961
movsd %xmm0, -0x38(%rbp)
movl $0x9, %edx
movq 0x7663(%rip), %rbx      # 0x14fd0
movq %rbx, %rdi
leaq 0x3c49(%rip), %rsi      # 0x115c0
callq 0x2230
movq %rbx, %rdi
movsd -0x38(%rbp), %xmm0
callq 0x2300
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x21d0
movsbl %al, %esi
movq %r13, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2150
movq -0x48(%rbp), %r15
incq %r15
cmpq $0xfa, %r15
leaq -0x58(%rbp), %rbx
jne 0xd897
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x760f(%rip), %rdi      # 0x14ff0
leaq 0x3c03(%rip), %rsi      # 0x115eb
callq 0x21e0
movq %rax, %rdi
movl -0x2c(%rbp), %esi
callq 0x2330
movq %rax, %rdi
callq 0x2100
movl $0x1, %edi
callq 0x2250
movq %rax, %r14
movq -0x68(%rbp), %rdi
cmpq %rbx, %rdi
je 0xda22
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x2200
movq %r14, %rdi
callq 0x2340