// File: /workspace/github_cpp_makefile_star2_O3/Gilaverbuch[P]FD_2D_WAVE/Field.cpp
// Function: Field::Field(model_parameters&)
Field::Field(model_parameters & M){
	int i,j;
	std::cout << "Cuctum default constructor. Initializing modeling parameters and velocity profile" << std::endl;

	dt = M.dt;
	dx = M.dx;
	dy = M.dy;
	frequency = M.frequency;
	source_time_delay = M.source_time_delay;
	steps = M.nsteps; 
	elements_x = M.elements_x;
	elements_y = M.elements_y;
	x_source = M.x_s;
	y_source = M.y_s;
	print_every = M.print_int;

	U = new double *[elements_y];
	U_past = new double *[elements_y];
	U_future = new double *[elements_y]; 
	lambda = new double *[elements_y];
	rho = new double *[elements_y];	
	vel = new double *[elements_y];	
	epsilon = new double *[elements_y]; 
	RHS = new double *[elements_y];
	sig = new double *[elements_y];

	for (i=0; i<elements_y; i++){

		U[i] = new double [elements_x];
		U_past[i] = new double [elements_x];
		U_future[i] = new double [elements_x]; 
		lambda[i] = new double [elements_x];
		rho[i] = new double [elements_x];	
		vel[i] = new double [elements_x];	
		epsilon[i] = new double [elements_x]; 
		RHS[i] = new double [elements_x];
		sig[i] = new double [elements_x];

	}

	x = new double [elements_x];
	y = new double [elements_y];




	initialize(elements_y, elements_x, rho, M.x_range, M.density_range);
	initialize(elements_y, elements_x, vel, M.x_range, M.velocity_range);



	
	// calculating lambda and x and y
	for (i=0; i<elements_y; i++){
		y[i] = i * dy;
		for (j=0; j<elements_x; j++){
			x[j] = j * dx;
			lambda[i][j] = rho[i][j] * pow(vel[i][j],2);

		}	
	}



}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq 0x39de(%rip), %r15      # 0x6fd8
leaq 0x1b8f(%rip), %rsi      # 0x5190
movl $0x51, %edx
movq %r15, %rdi
callq 0x21b0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20d0
movsd 0x30(%r14), %xmm0
movsd %xmm0, 0x58(%rbx)
movl 0x8(%r14), %eax
movl %eax, 0x70(%rbx)
movl 0xc(%r14), %eax
movl %eax, 0x74(%rbx)
movsd 0x38(%r14), %xmm0
movsd %xmm0, 0x60(%rbx)
movsd 0x40(%r14), %xmm0
movsd %xmm0, 0x68(%rbx)
movl 0x4(%r14), %eax
movl %eax, 0x78(%rbx)
movslq 0x10(%r14), %rax
movq %rax, -0x38(%rbp)
movl %eax, 0x7c(%rbx)
movslq 0x14(%r14), %r15
leaq (,%r15,8), %r12
testq %r15, %r15
movl %r15d, 0x80(%rbx)
movl 0x1c(%r14), %eax
movl %eax, 0x84(%rbx)
movl 0x20(%r14), %eax
movl %eax, 0x88(%rbx)
movl 0x24(%r14), %eax
movl %eax, 0x8c(%rbx)
movq $-0x1, %r13
cmovsq %r13, %r12
movq %r12, %rdi
callq 0x2030
movq %rax, (%rbx)
movq %r12, %rdi
callq 0x2030
movq %rax, 0x8(%rbx)
movq %r12, %rdi
callq 0x2030
movq %rax, 0x10(%rbx)
movq %r12, %rdi
callq 0x2030
movq %rax, 0x18(%rbx)
movq %r12, %rdi
callq 0x2030
movq %rax, -0x30(%rbp)
movq %rax, 0x20(%rbx)
movq %r12, %rdi
callq 0x2030
movq %rax, 0x28(%rbx)
movq %r12, %rdi
callq 0x2030
movq %rax, 0x30(%rbx)
movq %r12, %rdi
callq 0x2030
movq %rax, 0x38(%rbx)
movq %r12, %rdi
callq 0x2030
movq %rax, 0x40(%rbx)
testq %r15, %r15
jle 0x37f7
movq %r14, -0x30(%rbp)
movq -0x38(%rbp), %rcx
leaq (,%rcx,8), %rax
testl %ecx, %ecx
movq %rax, -0x40(%rbp)
cmovnsq %rax, %r13
xorl %r14d, %r14d
movq %r13, %rdi
callq 0x2030
movq (%rbx), %rcx
movq %rax, (%rcx,%r14,8)
movq %r13, %rdi
callq 0x2030
movq 0x8(%rbx), %rcx
movq %rax, (%rcx,%r14,8)
movq %r13, %rdi
callq 0x2030
movq 0x10(%rbx), %rcx
movq %rax, (%rcx,%r14,8)
movq %r13, %rdi
callq 0x2030
movq 0x18(%rbx), %rcx
movq %rax, (%rcx,%r14,8)
movq %r13, %rdi
callq 0x2030
movq 0x20(%rbx), %rcx
movq %rax, (%rcx,%r14,8)
movq %r13, %rdi
callq 0x2030
movq 0x28(%rbx), %rcx
movq %rax, (%rcx,%r14,8)
movq %r13, %rdi
callq 0x2030
movq 0x30(%rbx), %rcx
movq %rax, (%rcx,%r14,8)
movq %r13, %rdi
callq 0x2030
movq 0x38(%rbx), %rcx
movq %rax, (%rcx,%r14,8)
movq %r13, %rdi
callq 0x2030
movq 0x40(%rbx), %rcx
movq %rax, (%rcx,%r14,8)
incq %r14
cmpq %r14, %r15
jne 0x374a
movq 0x20(%rbx), %rcx
movq -0x30(%rbp), %r14
movq -0x38(%rbp), %r15
movq -0x40(%rbp), %rax
jmp 0x3807
movq -0x38(%rbp), %r15
leaq (,%r15,8), %rax
movq -0x30(%rbp), %rcx
movq %rcx, -0x30(%rbp)
leaq -0x60(%rbp), %r13
testl %r15d, %r15d
movq $-0x1, %rdi
cmovnsq %rax, %rdi
callq 0x2030
movq %rax, 0x48(%rbx)
movq %r12, %rdi
callq 0x2030
movq %rax, 0x50(%rbx)
leaq 0x50(%r14), %r12
leaq -0x70(%rbp), %rdi
movq %r12, %rsi
callq 0x4284
leaq 0x68(%r14), %rsi
leaq -0xa0(%rbp), %rdi
callq 0x4304
leaq -0x70(%rbp), %r8
leaq -0xa0(%rbp), %r13
movq %rbx, %rdi
movl %r15d, %edx
movq -0x30(%rbp), %rcx
movq %r13, %r9
callq 0x39dc
movq (%r13), %rdi
testq %rdi, %rdi
je 0x3887
movq -0x90(%rbp), %rsi
subq %rdi, %rsi
callq 0x2180
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x389c
movq -0x60(%rbp), %rsi
subq %rdi, %rsi
callq 0x2180
movl 0x7c(%rbx), %r15d
movq 0x28(%rbx), %r13
leaq -0x58(%rbp), %rdi
movq %r12, %rsi
callq 0x4284
subq $-0x80, %r14
leaq -0x88(%rbp), %rdi
movq %r14, %rsi
callq 0x4304
leaq -0x58(%rbp), %r8
leaq -0x88(%rbp), %r14
movq %rbx, %rdi
movl %r15d, %edx
movq %r13, %rcx
movq %r14, %r9
callq 0x39dc
movq (%r14), %rdi
testq %rdi, %rdi
je 0x38f3
movq -0x78(%rbp), %rsi
subq %rdi, %rsi
callq 0x2180
movq -0x58(%rbp), %rdi
testq %rdi, %rdi
je 0x3908
movq -0x48(%rbp), %rsi
subq %rdi, %rsi
callq 0x2180
movslq 0x80(%rbx), %rax
testq %rax, %rax
jle 0x39a0
movl 0x74(%rbx), %ecx
movq 0x50(%rbx), %rdx
movl 0x7c(%rbx), %esi
movl 0x70(%rbx), %edi
movq 0x48(%rbx), %r8
movq 0x18(%rbx), %r9
movq %r9, -0x30(%rbp)
movq 0x20(%rbx), %r10
movq 0x28(%rbx), %r11
xorl %ebx, %ebx
movl %ecx, %r9d
imull %ebx, %r9d
xorps %xmm0, %xmm0
cvtsi2sd %r9d, %xmm0
movsd %xmm0, (%rdx,%rbx,8)
testl %esi, %esi
jle 0x3998
movq (%r10,%rbx,8), %r14
movq (%r11,%rbx,8), %r15
movq -0x30(%rbp), %r9
movq (%r9,%rbx,8), %r12
xorl %r13d, %r13d
xorl %r9d, %r9d
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
movsd %xmm0, (%r8,%r9,8)
movsd (%r15,%r9,8), %xmm0
mulsd %xmm0, %xmm0
mulsd (%r14,%r9,8), %xmm0
movsd %xmm0, (%r12,%r9,8)
incq %r9
addl %edi, %r13d
cmpq %r9, %rsi
jne 0x3969
incq %rbx
cmpq %rax, %rbx
jne 0x393b
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0x48(%rbp), %r13
movq %rax, %rbx
movq -0x58(%rbp), %rdi
jmp 0x39c3
movq %rax, %rbx
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x39d4
movq (%r13), %rsi
subq %rdi, %rsi
callq 0x2180
movq %rbx, %rdi
callq 0x2270