// File: /workspace/github_cpp_makefile_star2_O2/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 0x2f02(%rip), %rdi      # 0x5fd8
leaq 0x108b(%rip), %rsi      # 0x4168
callq 0x2170
movq %rax, %rdi
callq 0x20c0
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), %r15
movl %r15d, 0x7c(%rbx)
movslq 0x14(%r14), %rax
movq %rax, -0x30(%rbp)
leaq (,%rax,8), %r12
testq %rax, %rax
movl %eax, 0x80(%rbx)
movl 0x1c(%r14), %eax
movl %eax, 0x84(%rbx)
movl 0x20(%r14), %eax
movl %eax, 0x88(%rbx)
movq %r14, -0x38(%rbp)
movl 0x24(%r14), %eax
movl %eax, 0x8c(%rbx)
pushq $-0x1
popq %r14
cmovsq %r14, %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
leaq (,%r15,8), %r13
movq %r15, -0x40(%rbp)
testq %r15, %r15
movq %rax, 0x40(%rbx)
cmovsq %r14, %r13
xorl %r15d, %r15d
movq -0x30(%rbp), %rax
testl %eax, %eax
movl $0x0, %r14d
cmovgl %eax, %r14d
movq %r13, %rdi
callq 0x2030
cmpq %r15, %r14
je 0x329c
movq (%rbx), %rcx
movq %rax, (%rcx,%r15,8)
movq %r13, %rdi
callq 0x2030
movq 0x8(%rbx), %rcx
movq %rax, (%rcx,%r15,8)
movq %r13, %rdi
callq 0x2030
movq 0x10(%rbx), %rcx
movq %rax, (%rcx,%r15,8)
movq %r13, %rdi
callq 0x2030
movq 0x18(%rbx), %rcx
movq %rax, (%rcx,%r15,8)
movq %r13, %rdi
callq 0x2030
movq 0x20(%rbx), %rcx
movq %rax, (%rcx,%r15,8)
movq %r13, %rdi
callq 0x2030
movq 0x28(%rbx), %rcx
movq %rax, (%rcx,%r15,8)
movq %r13, %rdi
callq 0x2030
movq 0x30(%rbx), %rcx
movq %rax, (%rcx,%r15,8)
movq %r13, %rdi
callq 0x2030
movq 0x38(%rbx), %rcx
movq %rax, (%rcx,%r15,8)
movq %r13, %rdi
callq 0x2030
movq 0x40(%rbx), %rcx
movq %rax, (%rcx,%r15,8)
incq %r15
jmp 0x31fc
movq %rax, 0x48(%rbx)
movq %r12, %rdi
callq 0x2030
movq %rax, 0x50(%rbx)
movq 0x20(%rbx), %r15
movq -0x38(%rbp), %r14
leaq 0x50(%r14), %r13
leaq -0xa0(%rbp), %r12
movq %r12, %rdi
movq %r13, %rsi
callq 0x39d4
leaq 0x68(%r14), %rsi
leaq -0x88(%rbp), %rdi
callq 0x3a2c
leaq -0xa0(%rbp), %r8
leaq -0x88(%rbp), %r12
movq %rbx, %rdi
movq -0x40(%rbp), %rdx
movq %r15, %rcx
movq %r8, %r15
movq %r12, %r9
callq 0x3412
movq %r12, %rdi
callq 0x24fe
movq %r15, %rdi
callq 0x253c
movl 0x7c(%rbx), %r15d
movq 0x28(%rbx), %rax
movq %rax, -0x30(%rbp)
leaq -0x70(%rbp), %r12
movq %r12, %rdi
movq %r13, %rsi
callq 0x39d4
subq $-0x80, %r14
leaq -0x58(%rbp), %rdi
movq %r14, %rsi
callq 0x3a2c
leaq -0x70(%rbp), %r14
leaq -0x58(%rbp), %r12
movq %rbx, %rdi
movl %r15d, %edx
movq -0x30(%rbp), %rcx
movq %r14, %r8
movq %r12, %r9
callq 0x3412
movq %r12, %rdi
callq 0x24fe
movq %r14, %rdi
callq 0x253c
movslq 0x80(%rbx), %rax
movl 0x74(%rbx), %ecx
movl %ecx, -0x38(%rbp)
movq 0x50(%rbx), %rdx
movslq 0x7c(%rbx), %rsi
xorl %edi, %edi
cmpq %rax, %rdi
jge 0x33ed
movl -0x38(%rbp), %r8d
imull %edi, %r8d
cvtsi2sd %r8d, %xmm0
movsd %xmm0, (%rdx,%rdi,8)
movl 0x70(%rbx), %r8d
movq 0x48(%rbx), %r9
movq 0x18(%rbx), %r10
movq 0x20(%rbx), %r11
movq 0x28(%rbx), %r14
xorl %r15d, %r15d
xorl %r12d, %r12d
cmpq %rsi, %r12
jge 0x33e8
cvtsi2sd %r15d, %xmm0
movsd %xmm0, (%r9,%r12,8)
movq (%r11,%rdi,8), %r13
movq (%r14,%rdi,8), %rcx
movsd (%rcx,%r12,8), %xmm0
mulsd %xmm0, %xmm0
mulsd (%r13,%r12,8), %xmm0
movq (%r10,%rdi,8), %rcx
movsd %xmm0, (%rcx,%r12,8)
incq %r12
addl %r8d, %r15d
jmp 0x33ad
incq %rdi
jmp 0x337c
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x33fe
movq %rax, %rbx
movq %r12, %rdi
callq 0x253c
movq %rbx, %rdi
callq 0x2270
nop