// File: 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
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x90(%rbp)
movq 0x6823(%rip), %rdi      # 0xafd8
leaq 0x299c(%rip), %rsi      # 0x7158
callq 0x21a0
movq %rax, %rdi
movq 0x67fd(%rip), %rsi      # 0xafc8
callq 0x21d0
movq -0x90(%rbp), %rax
movq -0x10(%rbp), %rcx
movsd 0x30(%rcx), %xmm0
movsd %xmm0, 0x58(%rax)
movq -0x10(%rbp), %rcx
movl 0x8(%rcx), %ecx
movl %ecx, 0x70(%rax)
movq -0x10(%rbp), %rcx
movl 0xc(%rcx), %ecx
movl %ecx, 0x74(%rax)
movq -0x10(%rbp), %rcx
movsd 0x38(%rcx), %xmm0
movsd %xmm0, 0x60(%rax)
movq -0x10(%rbp), %rcx
movsd 0x40(%rcx), %xmm0
movsd %xmm0, 0x68(%rax)
movq -0x10(%rbp), %rcx
movl 0x4(%rcx), %ecx
movl %ecx, 0x78(%rax)
movq -0x10(%rbp), %rcx
movl 0x10(%rcx), %ecx
movl %ecx, 0x7c(%rax)
movq -0x10(%rbp), %rcx
movl 0x14(%rcx), %ecx
movl %ecx, 0x80(%rax)
movq -0x10(%rbp), %rcx
movl 0x1c(%rcx), %ecx
movl %ecx, 0x84(%rax)
movq -0x10(%rbp), %rcx
movl 0x20(%rcx), %ecx
movl %ecx, 0x88(%rax)
movq -0x10(%rbp), %rcx
movl 0x24(%rcx), %ecx
movl %ecx, 0x8c(%rax)
movslq 0x80(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rcx
movq -0x90(%rbp), %rax
movq %rcx, (%rax)
movslq 0x80(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rcx
movq -0x90(%rbp), %rax
movq %rcx, 0x8(%rax)
movslq 0x80(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rcx
movq -0x90(%rbp), %rax
movq %rcx, 0x10(%rax)
movslq 0x80(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rcx
movq -0x90(%rbp), %rax
movq %rcx, 0x18(%rax)
movslq 0x80(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rcx
movq -0x90(%rbp), %rax
movq %rcx, 0x20(%rax)
movslq 0x80(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rcx
movq -0x90(%rbp), %rax
movq %rcx, 0x28(%rax)
movslq 0x80(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rcx
movq -0x90(%rbp), %rax
movq %rcx, 0x30(%rax)
movslq 0x80(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rcx
movq -0x90(%rbp), %rax
movq %rcx, 0x38(%rax)
movslq 0x80(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rcx
movq -0x90(%rbp), %rax
movq %rcx, 0x40(%rax)
movl $0x0, -0x14(%rbp)
movq -0x90(%rbp), %rcx
movl -0x14(%rbp), %eax
cmpl 0x80(%rcx), %eax
jge 0x4c86
movq -0x90(%rbp), %rax
movslq 0x7c(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rsi
movq -0x90(%rbp), %rax
movq (%rax), %rcx
movslq -0x14(%rbp), %rdx
movq %rsi, (%rcx,%rdx,8)
movslq 0x7c(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rsi
movq -0x90(%rbp), %rax
movq 0x8(%rax), %rcx
movslq -0x14(%rbp), %rdx
movq %rsi, (%rcx,%rdx,8)
movslq 0x7c(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rsi
movq -0x90(%rbp), %rax
movq 0x10(%rax), %rcx
movslq -0x14(%rbp), %rdx
movq %rsi, (%rcx,%rdx,8)
movslq 0x7c(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rsi
movq -0x90(%rbp), %rax
movq 0x18(%rax), %rcx
movslq -0x14(%rbp), %rdx
movq %rsi, (%rcx,%rdx,8)
movslq 0x7c(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rsi
movq -0x90(%rbp), %rax
movq 0x20(%rax), %rcx
movslq -0x14(%rbp), %rdx
movq %rsi, (%rcx,%rdx,8)
movslq 0x7c(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rsi
movq -0x90(%rbp), %rax
movq 0x28(%rax), %rcx
movslq -0x14(%rbp), %rdx
movq %rsi, (%rcx,%rdx,8)
movslq 0x7c(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rsi
movq -0x90(%rbp), %rax
movq 0x30(%rax), %rcx
movslq -0x14(%rbp), %rdx
movq %rsi, (%rcx,%rdx,8)
movslq 0x7c(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rsi
movq -0x90(%rbp), %rax
movq 0x38(%rax), %rcx
movslq -0x14(%rbp), %rdx
movq %rsi, (%rcx,%rdx,8)
movslq 0x7c(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, %rdx
movq -0x90(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x14(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x4a49
movq -0x90(%rbp), %rax
movslq 0x7c(%rax), %rax
movl $0x8, %ecx
movq %rcx, -0xb0(%rbp)
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
movq %rax, -0xa8(%rbp)
cmovoq %rax, %rdi
callq 0x2030
movq -0xb0(%rbp), %rcx
movq %rax, %rdx
movq -0x90(%rbp), %rax
movq %rdx, 0x48(%rax)
movslq 0x80(%rax), %rax
mulq %rcx
movq %rax, %rdi
movq -0xa8(%rbp), %rax
cmovoq %rax, %rdi
callq 0x2030
movq %rax, %rcx
movq -0x90(%rbp), %rax
movq %rcx, 0x50(%rax)
movl 0x80(%rax), %ecx
movl %ecx, -0xa0(%rbp)
movl 0x7c(%rax), %ecx
movl %ecx, -0x9c(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rsi
addq $0x50, %rsi
leaq -0x30(%rbp), %rdi
callq 0x5a20
movq -0x10(%rbp), %rsi
addq $0x68, %rsi
leaq -0x48(%rbp), %rdi
callq 0x5b10
jmp 0x4d3e
movq -0x98(%rbp), %rcx
movl -0x9c(%rbp), %edx
movl -0xa0(%rbp), %esi
movq -0x90(%rbp), %rdi
leaq -0x30(%rbp), %r8
leaq -0x48(%rbp), %r9
callq 0x4f80
jmp 0x4d67
leaq -0x48(%rbp), %rdi
callq 0x25f0
leaq -0x30(%rbp), %rdi
callq 0x2650
movq -0x90(%rbp), %rax
movl 0x80(%rax), %ecx
movl %ecx, -0xc0(%rbp)
movl 0x7c(%rax), %ecx
movl %ecx, -0xbc(%rbp)
movq 0x28(%rax), %rax
movq %rax, -0xb8(%rbp)
movq -0x10(%rbp), %rsi
addq $0x50, %rsi
leaq -0x70(%rbp), %rdi
callq 0x5a20
movq -0x10(%rbp), %rsi
subq $-0x80, %rsi
leaq -0x88(%rbp), %rdi
callq 0x5b10
jmp 0x4dc7
movq -0xb8(%rbp), %rcx
movl -0xbc(%rbp), %edx
movl -0xc0(%rbp), %esi
movq -0x90(%rbp), %rdi
leaq -0x70(%rbp), %r8
leaq -0x88(%rbp), %r9
callq 0x4f80
jmp 0x4df3
leaq -0x88(%rbp), %rdi
callq 0x25f0
leaq -0x70(%rbp), %rdi
callq 0x2650
movl $0x0, -0x14(%rbp)
movq -0x90(%rbp), %rcx
movl -0x14(%rbp), %eax
cmpl 0x80(%rcx), %eax
jge 0x4f64
movq -0x90(%rbp), %rax
movl -0x14(%rbp), %ecx
imull 0x74(%rax), %ecx
cvtsi2sd %ecx, %xmm0
movq 0x50(%rax), %rax
movslq -0x14(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl $0x0, -0x18(%rbp)
movq -0x90(%rbp), %rcx
movl -0x18(%rbp), %eax
cmpl 0x7c(%rcx), %eax
jge 0x4f54
movq -0x90(%rbp), %rax
movl -0x18(%rbp), %ecx
imull 0x70(%rax), %ecx
cvtsi2sd %ecx, %xmm0
movq 0x48(%rax), %rcx
movslq -0x18(%rbp), %rdx
movsd %xmm0, (%rcx,%rdx,8)
movq 0x20(%rax), %rcx
movslq -0x14(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x18(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movsd %xmm0, -0xc8(%rbp)
movq 0x28(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd 0x2281(%rip), %xmm1     # 0x7138
callq 0x22d0
movq -0x90(%rbp), %rax
movaps %xmm0, %xmm1
movsd -0xc8(%rbp), %xmm0
mulsd %xmm1, %xmm0
movq 0x18(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x4e4b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x4f18
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x25f0
leaq -0x30(%rbp), %rdi
callq 0x2650
jmp 0x4f6d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x4f49
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x25f0
leaq -0x70(%rbp), %rdi
callq 0x2650
jmp 0x4f6d
jmp 0x4f56
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x4e0f
addq $0xd0, %rsp
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x22e0
nopw %cs:(%rax,%rax)