// File: /workspace/github_cpp_makefile_star2_O1/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 0x39e2(%rip), %r15      # 0x6fd8
leaq 0x1b93(%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, -0x30(%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)
movq %r14, -0x40(%rbp)
movl 0x24(%r14), %eax
movl %eax, 0x8c(%rbx)
movq $-0x1, %rax
cmovsq %rax, %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, 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 0x37e0
movq -0x30(%rbp), %rax
leaq (,%rax,8), %r13
testl %eax, %eax
movq $-0x1, %rax
cmovsq %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 0x3745
leaq -0x60(%rbp), %r15
movq -0x30(%rbp), %r13
leaq (,%r13,8), %rdi
testl %r13d, %r13d
movq $-0x1, %rax
cmovsq %rax, %rdi
callq 0x2030
movq %rax, 0x48(%rbx)
movq %r12, %rdi
callq 0x2030
movq %rax, 0x50(%rbx)
movq 0x20(%rbx), %r12
movq -0x40(%rbp), %r14
leaq 0x50(%r14), %rsi
leaq -0x70(%rbp), %rdi
movq %rsi, -0x38(%rbp)
callq 0x4252
leaq 0x68(%r14), %rsi
leaq -0xa0(%rbp), %rdi
callq 0x42d2
leaq -0x70(%rbp), %r8
leaq -0xa0(%rbp), %r15
movq %rbx, %rdi
movl %r13d, %edx
movq %r12, %rcx
movq %r15, %r9
callq 0x39c8
movq (%r15), %rdi
testq %rdi, %rdi
je 0x386f
movq -0x90(%rbp), %rsi
subq %rdi, %rsi
callq 0x2180
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x3884
movq -0x60(%rbp), %rsi
subq %rdi, %rsi
callq 0x2180
leaq -0x48(%rbp), %r12
movl 0x7c(%rbx), %r15d
movq 0x28(%rbx), %r13
leaq -0x58(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x4252
subq $-0x80, %r14
leaq -0x88(%rbp), %rdi
movq %r14, %rsi
callq 0x42d2
leaq -0x58(%rbp), %r8
leaq -0x88(%rbp), %r14
movq %rbx, %rdi
movl %r15d, %edx
movq %r13, %rcx
movq %r14, %r9
callq 0x39c8
movq (%r14), %rdi
testq %rdi, %rdi
je 0x38e0
movq -0x78(%rbp), %rsi
subq %rdi, %rsi
callq 0x2180
movq -0x58(%rbp), %rdi
testq %rdi, %rdi
je 0x38f5
movq -0x48(%rbp), %rsi
subq %rdi, %rsi
callq 0x2180
movslq 0x80(%rbx), %rax
testq %rax, %rax
jle 0x398d
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 0x3985
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 0x3956
incq %rbx
cmpq %rax, %rbx
jne 0x3928
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, %r15
movq %rax, %rbx
movq -0x58(%rbp), %rdi
jmp 0x39af
movq %rax, %rbx
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x39bf
movq (%r15), %rsi
subq %rdi, %rsi
callq 0x2180
movq %rbx, %rdi
callq 0x2270
nop