// File: /workspace/github_cpp_makefile_star2_O1/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 0x108c8(%rip), %r15d    # 0x15658
cvtsi2sd %r15d, %xmm7
divsd %xmm7, %xmm6
movsd %xmm6, 0x70(%rdi)
movapd %xmm3, %xmm6
subsd %xmm2, %xmm6
movl 0x108af(%rip), %r12d    # 0x1565c
xorps %xmm7, %xmm7
cvtsi2sd %r12d, %xmm7
divsd %xmm7, %xmm6
movsd %xmm6, 0x78(%rdi)
movapd %xmm5, %xmm6
movl 0x10897(%rip), %r13d    # 0x15660
xorps %xmm7, %xmm7
cvtsi2sd %r13d, %xmm7
subsd %xmm4, %xmm6
divsd %xmm7, %xmm6
movsd %xmm6, 0x80(%rdi)
addsd %xmm1, %xmm0
movsd 0xc39b(%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 0x103c9(%rip), %r14d    # 0x151e0
leaq -0xb0(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0xc3c7(%rip), %rsi      # 0x111f0
leaq 0xc3c4(%rip), %rdx      # 0x111f4
leaq -0xc0(%rbp), %rdi
callq 0x2e8e
leal (%r13,%r14,2), %ecx
leal (%r12,%r14,2), %edx
leal (%r15,%r14,2), %esi
leaq -0x230(%rbp), %rdi
leaq -0xc0(%rbp), %r8
callq 0x62d0
movq -0xc0(%rbp), %rdi
leaq -0xb0(%rbp), %rax
cmpq %rax, %rdi
je 0x4e7e
movq -0xb0(%rbp), %rsi
incq %rsi
callq 0x2200
movl $0x90, %edi
callq 0x21f0
movq %rax, %r14
leaq -0x230(%rbp), %rsi
movq %rax, %rdi
callq 0x6568
movq %r14, (%rbx)
movl 0x107b4(%rip), %r15d    # 0x15658
movl 0x10335(%rip), %r12d    # 0x151e0
movl 0x107aa(%rip), %r13d    # 0x1565c
movl 0x107a7(%rip), %r14d    # 0x15660
leaq -0x90(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0xc32a(%rip), %rsi      # 0x111f5
leaq 0xc328(%rip), %rdx      # 0x111fa
leaq -0xa0(%rbp), %rdi
callq 0x2e8e
leal (%r14,%r12,2), %ecx
leal (%r13,%r12,2), %edx
leal (%r15,%r12,2), %esi
leaq -0x110(%rbp), %rdi
leaq -0xa0(%rbp), %r8
callq 0x68cc
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x4f20
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x2200
movl $0x50, %edi
callq 0x21f0
movq %rax, %r14
leaq -0x110(%rbp), %rsi
movq %rax, %rdi
callq 0x6aae
movq %r14, 0x8(%rbx)
movq 0x106e9(%rip), %rax     # 0x15630
subq 0x106da(%rip), %rax     # 0x15628
movq %rax, %rcx
sarq $0x2, %rcx
testq %rax, %rax
movq $-0x1, %rdi
cmovnsq %rcx, %rdi
callq 0x2030
movq %rax, 0x10(%rbx)
movq 0x106b5(%rip), %rax     # 0x15628
cmpq %rax, 0x106b6(%rip)     # 0x15630
je 0x5066
movl $0x8, %edx
xorl %r14d, %r14d
leaq -0x80(%rbp), %r12
movq %r14, -0x30(%rbp)
movl 0x106c2(%rip), %ecx     # 0x15658
movq %rcx, -0x38(%rbp)
movl 0x1023f(%rip), %r15d    # 0x151e0
movl 0x106b4(%rip), %r13d    # 0x1565c
movl 0x106b1(%rip), %r14d    # 0x15660
leaq -0x70(%rbp), %rcx
movq %rcx, -0x80(%rbp)
movq -0x8(%rax,%rdx), %rsi
movq %rdx, -0x40(%rbp)
movq (%rax,%rdx), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x391e
leal (%r14,%r15,2), %ecx
leal (%r13,%r15,2), %edx
movq -0x38(%rbp), %rax
leal (%rax,%r15,2), %esi
leaq -0x1a0(%rbp), %r13
movq %r13, %rdi
movq %r12, %r15
movq %r12, %r8
callq 0x68cc
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x500e
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x2200
movl $0x50, %edi
callq 0x21f0
movq %rax, %r12
movq %rax, %rdi
movq %r13, %rsi
callq 0x6aae
movq -0x30(%rbp), %r14
movq 0x10(%rbx), %rax
movq %r12, (%rax,%r14,8)
movq %r13, %rdi
callq 0x6c20
incq %r14
movq 0x105ec(%rip), %rcx     # 0x15630
movq 0x105dd(%rip), %rax     # 0x15628
subq %rax, %rcx
sarq $0x5, %rcx
movq -0x40(%rbp), %rdx
addq $0x20, %rdx
cmpq %r14, %rcx
movq %r15, %r12
ja 0x4f8c
movq 0x105db(%rip), %rax     # 0x15648
subq 0x105cc(%rip), %rax     # 0x15640
movq %rax, %rcx
sarq $0x2, %rcx
testq %rax, %rax
movq $-0x1, %rdi
cmovnsq %rcx, %rdi
callq 0x2030
movq %rax, 0x18(%rbx)
movq 0x105a7(%rip), %rax     # 0x15640
cmpq %rax, 0x105a8(%rip)     # 0x15648
je 0x518c
movl $0x8, %edx
xorl %r14d, %r14d
leaq -0x60(%rbp), %r12
movq %r14, -0x30(%rbp)
movl 0x1059c(%rip), %ecx     # 0x15658
movq %rcx, -0x38(%rbp)
movl 0x10119(%rip), %r15d    # 0x151e0
movl 0x1058e(%rip), %r13d    # 0x1565c
movl 0x1058b(%rip), %r14d    # 0x15660
leaq -0x50(%rbp), %rcx
movq %rcx, -0x60(%rbp)
movq -0x8(%rax,%rdx), %rsi
movq %rdx, -0x40(%rbp)
movq (%rax,%rdx), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x391e
leal (%r14,%r15,2), %ecx
leal (%r13,%r15,2), %edx
movq -0x38(%rbp), %rax
leal (%rax,%r15,2), %esi
leaq -0x1a0(%rbp), %r13
movq %r13, %rdi
movq %r12, %r15
movq %r12, %r8
callq 0x62d0
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x5134
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x2200
movl $0x90, %edi
callq 0x21f0
movq %rax, %r12
movq %rax, %rdi
movq %r13, %rsi
callq 0x6568
movq -0x30(%rbp), %r14
movq 0x18(%rbx), %rax
movq %r12, (%rax,%r14,8)
movq %r13, %rdi
callq 0x67be
incq %r14
movq 0x104de(%rip), %rcx     # 0x15648
movq 0x104cf(%rip), %rax     # 0x15640
subq %rax, %rcx
sarq $0x5, %rcx
movq -0x40(%rbp), %rdx
addq $0x20, %rdx
cmpq %r14, %rcx
movq %r15, %r12
ja 0x50b2
movq (%rbx), %rax
movslq (%rax), %rcx
testq %rcx, %rcx
jle 0x529f
cvtsi2sdl 0x1003d(%rip), %xmm0 # 0x151e0
movl 0x4(%rax), %edx
xorpd 0xc022(%rip), %xmm0     # 0x111d0
xorl %esi, %esi
movsd 0xbfd0(%rip), %xmm6     # 0x11188
testl %edx, %edx
jle 0x5293
movl 0x8(%rax), %edi
xorps %xmm1, %xmm1
cvtsi2sd %esi, %xmm1
addsd 0xbfb6(%rip), %xmm1     # 0x11188
xorl %r8d, %r8d
testl %edi, %edi
jle 0x5287
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 %r14d, %r14d
movsd 0x70(%rbx), %xmm3
movapd %xmm0, %xmm4
mulsd %xmm3, %xmm4
addsd 0x40(%rbx), %xmm4
mulsd %xmm1, %xmm3
addsd %xmm4, %xmm3
movsd %xmm3, (%r9,%r14,8)
movsd 0x78(%rbx), %xmm3
movapd %xmm0, %xmm4
mulsd %xmm3, %xmm4
addsd 0x50(%rbx), %xmm4
mulsd %xmm2, %xmm3
addsd %xmm4, %xmm3
movsd %xmm3, (%r10,%r14,8)
movsd 0x80(%rbx), %xmm3
movapd %xmm0, %xmm4
mulsd %xmm3, %xmm4
addsd 0x60(%rbx), %xmm4
xorps %xmm5, %xmm5
cvtsi2sd %r14d, %xmm5
addsd %xmm6, %xmm5
mulsd %xmm3, %xmm5
addsd %xmm4, %xmm5
movsd %xmm5, (%r11,%r14,8)
incq %r14
cmpq %r14, %rdi
jne 0x5210
incq %r8
cmpq %rdx, %r8
jne 0x51d5
incq %rsi
cmpq %rcx, %rsi
jne 0x51b8
movslq 0x103b2(%rip), %rax     # 0x15658
movslq 0xff33(%rip), %r15      # 0x151e0
leaq (%rax,%r15,2), %r14
movq %r14, %rax
shlq $0x3, %rax
testl %r14d, %r14d
movq $-0x1, %rdi
cmovnsq %rax, %rdi
callq 0x2030
movq %rax, 0x88(%rbx)
testl %r14d, %r14d
jle 0x536b
addq %r15, %r15
movslq 0x10377(%rip), %rax     # 0x1565c
movslq %r15d, %rcx
addq %rcx, %rax
movq %rax, %rsi
shlq $0x3, %rsi
testl %eax, %eax
movq $-0x1, %rdx
cmovsq %rdx, %rsi
movq %rsi, -0x38(%rbp)
movslq 0x10356(%rip), %rsi     # 0x15660
addq %rcx, %rsi
movq %rsi, %r15
shlq $0x2, %r15
testl %esi, %esi
cmovsq %rdx, %r15
movl %r14d, %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 0x5362
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 0x5343
incq %r14
cmpq -0x30(%rbp), %r14
jne 0x5327
movq %rbx, %rdi
callq 0x54c8
leaq -0x110(%rbp), %rdi
callq 0x6c20
leaq -0x230(%rbp), %rdi
callq 0x67be
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 0x549e
movq %rax, %rbx
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x54b4
movq -0x90(%rbp), %rsi
incq %rsi
jmp 0x53e0
jmp 0x53ea
movq %rax, %rbx
movl $0x90, %esi
movq %r14, %rdi
callq 0x2200
jmp 0x54b4
movq %rax, %rbx
jmp 0x54b4
movq %rax, %rbx
movq -0xc0(%rbp), %rdi
leaq -0xb0(%rbp), %rax
cmpq %rax, %rdi
je 0x54c0
movq -0xb0(%rbp), %rsi
incq %rsi
callq 0x2200
jmp 0x54c0
jmp 0x54a5
jmp 0x54a5
movq %rax, %rbx
movl $0x90, %esi
movq %r12, %rdi
callq 0x2200
jmp 0x543c
movq %rax, %rbx
leaq -0x1a0(%rbp), %rdi
callq 0x67be
jmp 0x54a8
movq %rax, %rbx
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x54a8
movq -0x50(%rbp), %rsi
jmp 0x549b
jmp 0x54a5
jmp 0x54a5
movq %rax, %rbx
movl $0x50, %esi
movq %r12, %rdi
callq 0x2200
jmp 0x5479
movq %rax, %rbx
leaq -0x1a0(%rbp), %rdi
callq 0x6c20
jmp 0x54a8
movq %rax, %rbx
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x54a8
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x2200
jmp 0x54a8
movq %rax, %rbx
leaq -0x110(%rbp), %rdi
callq 0x6c20
leaq -0x230(%rbp), %rdi
callq 0x67be
movq %rbx, %rdi
callq 0x2340