// File: /workspace/github_cpp_makefile_star2_O3/suhasjains[P]AMR-Solver/src/block.cpp
// Function: myOctree::Block::Block(double, double, double, double, double, double)
Block::Block( double x1, double x2, double y1, double y2, double z1, double z2 ) : x_min(x1), x_max(x2), y_min(y1), y_max(y2), z_min(z1), z_max(z2) {
//  		std::cerr << "Parametrized constructor of block is working" << std::endl;

	max_gradient = 0.0;

        dx = ( x_max - x_min ) / iNx;
        dy = ( y_max - y_min ) / iNy;
        dz = ( z_max - z_min ) / iNz;

	//std::cerr << dz << std::endl;

        //printf("dx=%g, dy=%g, dz=%g \n", dx, dy, dz);

        x_centre = (x_min + x_max ) / 2.0;
        y_centre = (y_min + y_max ) / 2.0;
        z_centre = (z_min + z_max ) / 2.0;

        //dynamical allocation of the objects
        VecField mesh_field(iNx+2*pad,iNy+2*pad,iNz+2*pad, "mesh");
        mesh = new VecField(mesh_field);
        
        Field field_field(iNx+2*pad,iNy+2*pad,iNz+2*pad, "field");
	field = new Field(field_field);

	scalarfields = new Field* [scalar_fields.size()];
	for(int i = 0; i<scalar_fields.size() ; i++) {
        	Field field_field(iNx+2*pad,iNy+2*pad,iNz+2*pad, scalar_fields[i]);
	       	scalarfields[i] = new Field(field_field);	
	}       

	vectorfields = new VecField* [vector_fields.size()];
	for(int i = 0; i<vector_fields.size() ; i++) {
        	VecField vec_field(iNx+2*pad,iNy+2*pad,iNz+2*pad, vector_fields[i]);
	       	vectorfields[i] = new VecField(vec_field);	
	}       

	//std::cerr << "Hi" << z_max << std::endl;
	
	//storing cell centre locations in mesh vector field
	for(int i=0;i<mesh->Nx;i++) {
		for(int j=0;j<mesh->Ny;j++) {
			for(int k=0;k<mesh->Nz;k++) {
				mesh->x[i][j][k] = x_min - pad*dx + dx*(i + 0.5);	 
				mesh->y[i][j][k] = y_min - pad*dy + dy*(j + 0.5);	 
				mesh->z[i][j][k] = z_min - pad*dz + dz*(k + 0.5);	 
			}
		}
	}

	//dynamic allocation of domain masking - stored here because it is common for all fields. 
	flag = new Mask** [iNx+2*pad];
	for(int i=0;i<(iNx+2*pad);i++) {
		flag[i] = new Mask* [iNy+2*pad];
 		for(int j=0;j<(iNy+2*pad);j++) {
                  	flag[i][j] = new Mask [iNz+2*pad];
           	}
        }

	set_domain_masking();

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
movq %rdi, %rbx
movsd %xmm0, 0x40(%rdi)
movsd %xmm1, 0x48(%rdi)
movsd %xmm2, 0x50(%rdi)
movsd %xmm3, 0x58(%rdi)
movsd %xmm4, 0x60(%rdi)
movsd %xmm5, 0x68(%rdi)
movq $0x0, 0x20(%rdi)
movapd %xmm1, %xmm6
subsd %xmm0, %xmm6
movl 0x106dc(%rip), %r15d    # 0x15668
cvtsi2sd %r15d, %xmm7
divsd %xmm7, %xmm6
movsd %xmm6, 0x70(%rdi)
movapd %xmm3, %xmm6
subsd %xmm2, %xmm6
movl 0x106c3(%rip), %r12d    # 0x1566c
xorps %xmm7, %xmm7
cvtsi2sd %r12d, %xmm7
divsd %xmm7, %xmm6
movsd %xmm6, 0x78(%rdi)
movapd %xmm5, %xmm6
movl 0x106ab(%rip), %r13d    # 0x15670
xorps %xmm7, %xmm7
cvtsi2sd %r13d, %xmm7
subsd %xmm4, %xmm6
divsd %xmm7, %xmm6
movsd %xmm6, 0x80(%rdi)
addsd %xmm1, %xmm0
movsd 0xc19f(%rip), %xmm1     # 0x11188
mulsd %xmm1, %xmm0
movsd %xmm0, 0x28(%rdi)
addsd %xmm3, %xmm2
mulsd %xmm1, %xmm2
movsd %xmm2, 0x30(%rdi)
addsd %xmm5, %xmm4
mulsd %xmm1, %xmm4
movsd %xmm4, 0x38(%rdi)
movl 0x101d5(%rip), %r14d    # 0x151e8
leaq -0xb0(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0xc1cb(%rip), %rsi      # 0x111f0
leaq 0xc1c8(%rip), %rdx      # 0x111f4
leaq -0xc0(%rbp), %rdi
callq 0x2e92
leal (%r13,%r14,2), %ecx
leal (%r12,%r14,2), %edx
leal (%r15,%r14,2), %esi
leaq -0x230(%rbp), %rdi
leaq -0xc0(%rbp), %r8
callq 0x63ac
movq -0xc0(%rbp), %rdi
leaq -0xb0(%rbp), %rax
cmpq %rax, %rdi
je 0x507a
movq -0xb0(%rbp), %rsi
incq %rsi
callq 0x2210
movl $0x90, %edi
callq 0x2200
movq %rax, %r14
leaq -0x230(%rbp), %rsi
movq %rax, %rdi
callq 0x661e
movq %r14, (%rbx)
movl 0x105c8(%rip), %r15d    # 0x15668
movl 0x10141(%rip), %r12d    # 0x151e8
movl 0x105be(%rip), %r13d    # 0x1566c
movl 0x105bb(%rip), %r14d    # 0x15670
leaq -0x90(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0xc12e(%rip), %rsi      # 0x111f5
leaq 0xc12c(%rip), %rdx      # 0x111fa
leaq -0xa0(%rbp), %rdi
callq 0x2e92
leal (%r14,%r12,2), %ecx
leal (%r13,%r12,2), %edx
leal (%r15,%r12,2), %esi
leaq -0x110(%rbp), %rdi
leaq -0xa0(%rbp), %r8
callq 0x697c
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x511c
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x2210
movl $0x50, %edi
callq 0x2200
movq %rax, %r14
leaq -0x110(%rbp), %rsi
movq %rax, %rdi
callq 0x6b38
movq %r14, 0x8(%rbx)
movq 0x104fd(%rip), %r14     # 0x15640
movq 0x104ee(%rip), %r15     # 0x15638
movq %r14, %rax
subq %r15, %rax
movq %rax, %rcx
sarq $0x2, %rcx
testq %rax, %rax
movq $-0x1, %rdi
cmovnsq %rcx, %rdi
callq 0x2030
movq %rax, 0x10(%rbx)
cmpq %r15, %r14
je 0x525f
movq %r15, %rdx
movl $0x8, %ecx
xorl %r14d, %r14d
leaq -0x80(%rbp), %r15
movq %r14, -0x30(%rbp)
movl 0x104d8(%rip), %eax     # 0x15668
movq %rax, -0x38(%rbp)
movl 0x1004d(%rip), %r13d    # 0x151e8
movl 0x104ca(%rip), %r14d    # 0x1566c
movl 0x104c7(%rip), %r12d    # 0x15670
leaq -0x70(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x8(%rdx,%rcx), %rsi
movq %rcx, -0x40(%rbp)
movq (%rdx,%rcx), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x39ba
leal (%r12,%r13,2), %ecx
leal (%r14,%r13,2), %edx
movq -0x38(%rbp), %rax
leal (%rax,%r13,2), %esi
leaq -0x1a0(%rbp), %r14
movq %r14, %rdi
movq %r15, %r13
movq %r15, %r8
callq 0x697c
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x5207
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x2210
movl $0x50, %edi
callq 0x2200
movq %rax, %r12
movq %rax, %rdi
movq %r14, %rsi
callq 0x6b38
movq %r14, %rdi
movq -0x30(%rbp), %r14
movq 0x10(%rbx), %rax
movq %r12, (%rax,%r14,8)
callq 0x6caa
incq %r14
movq 0x10403(%rip), %rax     # 0x15640
movq 0x103f4(%rip), %rdx     # 0x15638
subq %rdx, %rax
sarq $0x5, %rax
movq -0x40(%rbp), %rcx
addq $0x20, %rcx
cmpq %r14, %rax
movq %r13, %r15
ja 0x5186
movq 0x103f2(%rip), %r14     # 0x15658
movq 0x103e3(%rip), %r15     # 0x15650
movq %r14, %rax
subq %r15, %rax
movq %rax, %rcx
sarq $0x2, %rcx
testq %rax, %rax
movq $-0x1, %rdi
cmovnsq %rcx, %rdi
callq 0x2030
movq %rax, 0x18(%rbx)
cmpq %r15, %r14
je 0x5382
movq %r15, %rdx
movl $0x8, %ecx
xorl %r14d, %r14d
leaq -0x60(%rbp), %r15
movq %r14, -0x30(%rbp)
movl 0x103b5(%rip), %eax     # 0x15668
movq %rax, -0x38(%rbp)
movl 0xff2a(%rip), %r13d     # 0x151e8
movl 0x103a7(%rip), %r14d    # 0x1566c
movl 0x103a4(%rip), %r12d    # 0x15670
leaq -0x50(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x8(%rdx,%rcx), %rsi
movq %rcx, -0x40(%rbp)
movq (%rdx,%rcx), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x39ba
leal (%r12,%r13,2), %ecx
leal (%r14,%r13,2), %edx
movq -0x38(%rbp), %rax
leal (%rax,%r13,2), %esi
leaq -0x1a0(%rbp), %r14
movq %r14, %rdi
movq %r15, %r13
movq %r15, %r8
callq 0x63ac
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x532a
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x2210
movl $0x90, %edi
callq 0x2200
movq %rax, %r12
movq %rax, %rdi
movq %r14, %rsi
callq 0x661e
movq %r14, %rdi
movq -0x30(%rbp), %r14
movq 0x18(%rbx), %rax
movq %r12, (%rax,%r14,8)
callq 0x6870
incq %r14
movq 0x102f8(%rip), %rax     # 0x15658
movq 0x102e9(%rip), %rdx     # 0x15650
subq %rdx, %rax
sarq $0x5, %rax
movq -0x40(%rbp), %rcx
addq $0x20, %rcx
cmpq %r14, %rax
movq %r13, %r15
ja 0x52a9
movq (%rbx), %rax
movslq (%rax), %rcx
movslq 0xfe59(%rip), %r14      # 0x151e8
testq %rcx, %rcx
jle 0x5499
cvtsi2sd %r14d, %xmm0
movl 0x4(%rax), %edx
xorpd 0xbe28(%rip), %xmm0     # 0x111d0
xorl %esi, %esi
movsd 0xbdd6(%rip), %xmm6     # 0x11188
testl %edx, %edx
jle 0x548d
movl 0x8(%rax), %edi
xorps %xmm1, %xmm1
cvtsi2sd %esi, %xmm1
addsd 0xbdbc(%rip), %xmm1     # 0x11188
xorl %r8d, %r8d
testl %edi, %edi
jle 0x5481
movq 0x10(%rax), %r9
movq 0x18(%rax), %r10
movq (%r9,%rsi,8), %r9
xorps %xmm2, %xmm2
cvtsi2sd %r8d, %xmm2
movq (%r9,%r8,8), %r9
addsd %xmm6, %xmm2
movq (%r10,%rsi,8), %r10
movq (%r10,%r8,8), %r10
movq 0x20(%rax), %r11
movq (%r11,%rsi,8), %r11
movq (%r11,%r8,8), %r11
xorl %r15d, %r15d
movsd 0x70(%rbx), %xmm3
movapd %xmm0, %xmm4
mulsd %xmm3, %xmm4
addsd 0x40(%rbx), %xmm4
mulsd %xmm1, %xmm3
addsd %xmm4, %xmm3
movsd %xmm3, (%r9,%r15,8)
movsd 0x78(%rbx), %xmm3
movapd %xmm0, %xmm4
mulsd %xmm3, %xmm4
addsd 0x50(%rbx), %xmm4
mulsd %xmm2, %xmm3
addsd %xmm4, %xmm3
movsd %xmm3, (%r10,%r15,8)
movsd 0x80(%rbx), %xmm3
movapd %xmm0, %xmm4
mulsd %xmm3, %xmm4
addsd 0x60(%rbx), %xmm4
xorps %xmm5, %xmm5
cvtsi2sd %r15d, %xmm5
addsd %xmm6, %xmm5
mulsd %xmm3, %xmm5
addsd %xmm4, %xmm5
movsd %xmm5, (%r11,%r15,8)
incq %r15
cmpq %r15, %rdi
jne 0x540a
incq %r8
cmpq %rdx, %r8
jne 0x53cf
incq %rsi
cmpq %rcx, %rsi
jne 0x53b2
movslq 0x101c8(%rip), %rax     # 0x15668
leaq (%rax,%r14,2), %r12
movq %r12, %rax
shlq $0x3, %rax
testl %r12d, %r12d
movq $-0x1, %rdi
cmovnsq %rax, %rdi
callq 0x2030
movq %rax, 0x88(%rbx)
testl %r12d, %r12d
jle 0x555e
addq %r14, %r14
movslq 0x10194(%rip), %rax     # 0x1566c
movslq %r14d, %rcx
addq %rcx, %rax
movq %rax, %rsi
shlq $0x3, %rsi
testl %eax, %eax
movq $-0x1, %rdx
cmovsq %rdx, %rsi
movq %rsi, -0x38(%rbp)
movslq 0x10173(%rip), %rsi     # 0x15670
addq %rcx, %rsi
movq %rsi, %r15
shlq $0x2, %r15
testl %esi, %esi
cmovsq %rdx, %r15
movl %r12d, %ecx
movq %rcx, -0x30(%rbp)
movl %eax, %r13d
xorl %r14d, %r14d
movq -0x38(%rbp), %rdi
callq 0x2030
movq 0x88(%rbx), %rcx
movq %rax, (%rcx,%r14,8)
testl %r13d, %r13d
jle 0x5555
xorl %r12d, %r12d
movq %r15, %rdi
callq 0x2030
movq 0x88(%rbx), %rcx
movq (%rcx,%r14,8), %rcx
movq %rax, (%rcx,%r12,8)
incq %r12
cmpq %r12, %r13
jne 0x5536
incq %r14
cmpq -0x30(%rbp), %r14
jne 0x551a
movq %rbx, %rdi
callq 0x56bc
leaq -0x110(%rbp), %rdi
callq 0x6caa
leaq -0x230(%rbp), %rdi
callq 0x6870
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movl $0x50, %esi
movq %r14, %rdi
jmp 0x5691
movq %rax, %rbx
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x56a7
movq -0x90(%rbp), %rsi
incq %rsi
jmp 0x55d3
jmp 0x55dd
movq %rax, %rbx
movl $0x90, %esi
movq %r14, %rdi
callq 0x2210
jmp 0x56a7
movq %rax, %rbx
jmp 0x56a7
movq %rax, %rbx
movq -0xc0(%rbp), %rdi
leaq -0xb0(%rbp), %rax
cmpq %rax, %rdi
je 0x56b3
movq -0xb0(%rbp), %rsi
incq %rsi
callq 0x2210
jmp 0x56b3
jmp 0x5698
jmp 0x5698
movq %rax, %rbx
movl $0x90, %esi
movq %r12, %rdi
callq 0x2210
jmp 0x562f
movq %rax, %rbx
leaq -0x1a0(%rbp), %rdi
callq 0x6870
jmp 0x569b
movq %rax, %rbx
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x569b
movq -0x50(%rbp), %rsi
jmp 0x568e
jmp 0x5698
jmp 0x5698
movq %rax, %rbx
movl $0x50, %esi
movq %r12, %rdi
callq 0x2210
jmp 0x566c
movq %rax, %rbx
leaq -0x1a0(%rbp), %rdi
callq 0x6caa
jmp 0x569b
movq %rax, %rbx
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x569b
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x2210
jmp 0x569b
movq %rax, %rbx
leaq -0x110(%rbp), %rdi
callq 0x6caa
leaq -0x230(%rbp), %rdi
callq 0x6870
movq %rbx, %rdi
callq 0x2350
nop