#include <math.h>

#include "mesh.cuh"
#include "material.cuh"
#include "constants.cuh"

void material_init(struct material *mat);
void mesh_init(struct mesh *m);

void mesh_material_init(struct mesh *me, struct material *ma) {
	mesh_init(me);
	material_init(ma);
}

void mesh_init(struct mesh *m) {
	m->lx = LX;
	m->ly = LY;
	m->vmax = LX*LY;
	m->nelx = NELX;
	m->nely = NELY;
	m->volfrac = VOLFRAC;
	m->ax = (double)LX / (double)NELX;
	m->by = (double)LY / (double)NELY;
	m->area = m->ax*m->by;
	m->penal = PENAL;
	m->prho = PRHO;
	m->rmin = RMIN;
	m->ft = FT;

	m->alpha = ALPHA;
	m->beta = BETA;
	m->ninp = NINP;
	m->nout = NOUT;

	m->fixed_count = 0;
}

void material_init(struct material *mat) {
	mat->e0 = E0;
	mat->emin = 0.000001;
	mat->rho0 = RHO0;
	mat->rhomin = 0.000001;
	mat->nu = NU;

}


	.file	"tmpxft_0022d88b_00000000-6_mesh_material_init.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2013:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2013:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z9mesh_initP4mesh
	.type	_Z9mesh_initP4mesh, @function
_Z9mesh_initP4mesh:
.LFB2009:
	.cfi_startproc
	endbr64
	movq	.LC0(%rip), %rax
	movsd	.LC4(%rip), %xmm0
	movl	$2, 88(%rdi)
	movq	%rax, (%rdi)
	movq	.LC1(%rip), %rax
	movsd	%xmm0, 40(%rdi)
	movq	%rax, 8(%rdi)
	movq	.LC2(%rip), %rax
	movsd	%xmm0, 48(%rdi)
	movq	%rax, 16(%rdi)
	movabsq	$34359738392, %rax
	movq	%rax, 24(%rdi)
	movq	.LC3(%rip), %rax
	movsd	%xmm0, 56(%rdi)
	movq	%rax, 32(%rdi)
	movq	.LC5(%rip), %rax
	movsd	%xmm0, 72(%rdi)
	movsd	.LC7(%rip), %xmm0
	movq	%rax, 64(%rdi)
	movq	.LC6(%rip), %rax
	movsd	%xmm0, 96(%rdi)
	movq	%rax, 80(%rdi)
	movabsq	$4294967297, %rax
	movq	%rax, 112(%rdi)
	xorl	%eax, %eax
	movl	%eax, 120(%rdi)
	movsd	%xmm0, 104(%rdi)
	ret
	.cfi_endproc
.LFE2009:
	.size	_Z9mesh_initP4mesh, .-_Z9mesh_initP4mesh
	.globl	_Z13material_initP8material
	.type	_Z13material_initP8material, @function
_Z13material_initP8material:
.LFB2010:
	.cfi_startproc
	endbr64
	movq	.LC8(%rip), %rax
	movsd	.LC9(%rip), %xmm0
	movq	%rax, (%rdi)
	movq	.LC10(%rip), %rax
	movsd	%xmm0, 8(%rdi)
	movq	%rax, 16(%rdi)
	movq	.LC11(%rip), %rax
	movsd	%xmm0, 24(%rdi)
	movq	%rax, 32(%rdi)
	ret
	.cfi_endproc
.LFE2010:
	.size	_Z13material_initP8material, .-_Z13material_initP8material
	.globl	_Z18mesh_material_initP4meshP8material
	.type	_Z18mesh_material_initP4meshP8material, @function
_Z18mesh_material_initP4meshP8material:
.LFB2008:
	.cfi_startproc
	endbr64
	call	_Z9mesh_initP4mesh
	movq	%rsi, %rdi
	jmp	_Z13material_initP8material
	.cfi_endproc
.LFE2008:
	.size	_Z18mesh_material_initP4meshP8material, .-_Z18mesh_material_initP4meshP8material
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2036:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	movq	%rax, %rdi
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2036:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC0:
	.long	0
	.long	1077411840
	.align 8
.LC1:
	.long	0
	.long	1075838976
	.align 8
.LC2:
	.long	0
	.long	1080557568
	.align 8
.LC3:
	.long	-858993459
	.long	1071434956
	.align 8
.LC4:
	.long	0
	.long	1072693248
	.align 8
.LC5:
	.long	0
	.long	1074266112
	.align 8
.LC6:
	.long	0
	.long	1073741824
	.align 8
.LC7:
	.long	858993459
	.long	1069757235
	.align 8
.LC8:
	.long	0
	.long	1076101120
	.align 8
.LC9:
	.long	-1598689907
	.long	1051772663
	.align 8
.LC10:
	.long	1202590843
	.long	1065646817
	.align 8
.LC11:
	.long	858993459
	.long	1070805811
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include <math.h>

#include "mesh.cuh"
#include "material.cuh"
#include "constants.cuh"

void material_init(struct material *mat);
void mesh_init(struct mesh *m);

void mesh_material_init(struct mesh *me, struct material *ma) {
	mesh_init(me);
	material_init(ma);
}

void mesh_init(struct mesh *m) {
	m->lx = LX;
	m->ly = LY;
	m->vmax = LX*LY;
	m->nelx = NELX;
	m->nely = NELY;
	m->volfrac = VOLFRAC;
	m->ax = (double)LX / (double)NELX;
	m->by = (double)LY / (double)NELY;
	m->area = m->ax*m->by;
	m->penal = PENAL;
	m->prho = PRHO;
	m->rmin = RMIN;
	m->ft = FT;

	m->alpha = ALPHA;
	m->beta = BETA;
	m->ninp = NINP;
	m->nout = NOUT;

	m->fixed_count = 0;
}

void material_init(struct material *mat) {
	mat->e0 = E0;
	mat->emin = 0.000001;
	mat->rho0 = RHO0;
	mat->rhomin = 0.000001;
	mat->nu = NU;

}


	.text
	.file	"mesh_material_init.hip"
	.globl	_Z18mesh_material_initP4meshP8material # -- Begin function _Z18mesh_material_initP4meshP8material
	.type	_Z18mesh_material_initP4meshP8material,@function
_Z18mesh_material_initP4meshP8material: # @_Z18mesh_material_initP4meshP8material
	.cfi_startproc
# %bb.0:
	movabsq	$4627448617123184640, %rax      # imm = 0x4038000000000000
	movq	%rax, (%rdi)
	movabsq	$4620693217682128896, %rax      # imm = 0x4020000000000000
	movq	%rax, 8(%rdi)
	movabsq	$4640959416005296128, %rax      # imm = 0x4068000000000000
	movq	%rax, 16(%rdi)
	movabsq	$34359738392, %rax              # imm = 0x800000018
	movq	%rax, 24(%rdi)
	movabsq	$4601778099247172813, %rax      # imm = 0x3FDCCCCCCCCCCCCD
	movq	%rax, 32(%rdi)
	movabsq	$4607182418800017408, %rax      # imm = 0x3FF0000000000000
	movq	%rax, 40(%rdi)
	movq	%rax, 48(%rdi)
	movq	%rax, 56(%rdi)
	movabsq	$4613937818241073152, %rcx      # imm = 0x4008000000000000
	movq	%rcx, 64(%rdi)
	movq	%rax, 72(%rdi)
	movabsq	$4611686018427387904, %rax      # imm = 0x4000000000000000
	movq	%rax, 80(%rdi)
	movl	$2, 88(%rdi)
	movabsq	$4594572339843380019, %rax      # imm = 0x3FC3333333333333
	movq	%rax, 96(%rdi)
	movq	%rax, 104(%rdi)
	movabsq	$4294967297, %rax               # imm = 0x100000001
	movq	%rax, 112(%rdi)
	movl	$0, 120(%rdi)
	movabsq	$4621819117588971520, %rax      # imm = 0x4024000000000000
	movq	%rax, (%rsi)
	movabsq	$4517329193108106637, %rax      # imm = 0x3EB0C6F7A0B5ED8D
	movq	%rax, 8(%rsi)
	movabsq	$4576918229304087675, %rcx      # imm = 0x3F847AE147AE147B
	movq	%rcx, 16(%rsi)
	movq	%rax, 24(%rsi)
	movabsq	$4599075939470750515, %rax      # imm = 0x3FD3333333333333
	movq	%rax, 32(%rsi)
	retq
.Lfunc_end0:
	.size	_Z18mesh_material_initP4meshP8material, .Lfunc_end0-_Z18mesh_material_initP4meshP8material
	.cfi_endproc
                                        # -- End function
	.globl	_Z9mesh_initP4mesh              # -- Begin function _Z9mesh_initP4mesh
	.type	_Z9mesh_initP4mesh,@function
_Z9mesh_initP4mesh:                     # @_Z9mesh_initP4mesh
	.cfi_startproc
# %bb.0:
	movabsq	$4627448617123184640, %rax      # imm = 0x4038000000000000
	movq	%rax, (%rdi)
	movabsq	$4620693217682128896, %rax      # imm = 0x4020000000000000
	movq	%rax, 8(%rdi)
	movabsq	$4640959416005296128, %rax      # imm = 0x4068000000000000
	movq	%rax, 16(%rdi)
	movabsq	$34359738392, %rax              # imm = 0x800000018
	movq	%rax, 24(%rdi)
	movabsq	$4601778099247172813, %rax      # imm = 0x3FDCCCCCCCCCCCCD
	movq	%rax, 32(%rdi)
	movabsq	$4607182418800017408, %rax      # imm = 0x3FF0000000000000
	movq	%rax, 40(%rdi)
	movq	%rax, 48(%rdi)
	movq	%rax, 56(%rdi)
	movabsq	$4613937818241073152, %rcx      # imm = 0x4008000000000000
	movq	%rcx, 64(%rdi)
	movq	%rax, 72(%rdi)
	movabsq	$4611686018427387904, %rax      # imm = 0x4000000000000000
	movq	%rax, 80(%rdi)
	movl	$2, 88(%rdi)
	movabsq	$4594572339843380019, %rax      # imm = 0x3FC3333333333333
	movq	%rax, 96(%rdi)
	movq	%rax, 104(%rdi)
	movabsq	$4294967297, %rax               # imm = 0x100000001
	movq	%rax, 112(%rdi)
	movl	$0, 120(%rdi)
	retq
.Lfunc_end1:
	.size	_Z9mesh_initP4mesh, .Lfunc_end1-_Z9mesh_initP4mesh
	.cfi_endproc
                                        # -- End function
	.globl	_Z13material_initP8material     # -- Begin function _Z13material_initP8material
	.type	_Z13material_initP8material,@function
_Z13material_initP8material:            # @_Z13material_initP8material
	.cfi_startproc
# %bb.0:
	movabsq	$4621819117588971520, %rax      # imm = 0x4024000000000000
	movq	%rax, (%rdi)
	movabsq	$4517329193108106637, %rax      # imm = 0x3EB0C6F7A0B5ED8D
	movq	%rax, 8(%rdi)
	movabsq	$4576918229304087675, %rcx      # imm = 0x3F847AE147AE147B
	movq	%rcx, 16(%rdi)
	movq	%rax, 24(%rdi)
	movabsq	$4599075939470750515, %rax      # imm = 0x3FD3333333333333
	movq	%rax, 32(%rdi)
	retq
.Lfunc_end2:
	.size	_Z13material_initP8material, .Lfunc_end2-_Z13material_initP8material
	.cfi_endproc
                                        # -- End function
	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_

	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.amdgpu_metadata
---
amdhsa.kernels:  []
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
