From e5540f62785c9e41df050e8b914f796c4d38f8dc Mon Sep 17 00:00:00 2001 From: JackHsu Date: Thu, 8 Aug 2019 14:08:42 +0800 Subject: [PATCH] added some vertex buffer stuff, not completed. --- acc/mhd_solver/stencil_process.sps | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/acc/mhd_solver/stencil_process.sps b/acc/mhd_solver/stencil_process.sps index 0d0fbad..446d253 100644 --- a/acc/mhd_solver/stencil_process.sps +++ b/acc/mhd_solver/stencil_process.sps @@ -95,7 +95,7 @@ truelove_density(in Scalar lnrho){ return accretion_rho; } - +Scalar accretion_profile(int3 globalVertexIdx, in Scalar lnrho){ // QUESTION: do I need to define grid_pos, sink_pos and distance again // if the sink_gravity kernel will also be called once LSINK swtich is on? Seems redundant. @@ -109,25 +109,24 @@ accretion_profile(int3 globalVertexIdx, in Scalar lnrho){ const Scalar accretion_distance = length(grid_pos - sink_pos); if ((accretion_distance) <= profile_range){ // calculate accretion according to chosen criterion for the grid cell. - accretion = truelove_density(lnrho); + accretion_density = truelove_density(lnrho); } else { - accretion = Scalar(0.0); + accretion_density = Scalar(0.0); } - return accretion;// the returned value is effectively mass, doesn't seem right since MIIKKA said mass will be summed up in vertex buffer. But I'll keep it as it untill we discuss this. + return accretion_density; } - - -update_accretion_buffer(){ -// 1. reduce accretion density from the density field. +// Note for update_accretion_buffer: 1. reduce accretion density from the density field. // 2. Add the accretion mass, which is calculated from accretion density times volume of each cell and sum them into accretion buffer. +Scalar +update_accretion_buffer(in Scalar lnrho, out Scalar out_accretion){ + lnrho = log(exp(lnrho) - accretion_profile(lnrho)); + // This subtracts the accretion_density from the density field. + out_accretion = Scalar (0.0); //Initilize the buffer? + out_accretion = out_accretion + (accretion_profile(lnrho) * dsx * dsy * dsz); + // Not sure if this is correct, but it's suppose to add the accretion "mass" into vertex buffer and sum them all up. + - - - - - - - + return } #endif //TODO: basic structure of this part is as follows