/** Calculate total momentum of the system (particles & LB fluid) * inputs are bools to include particles and fluid in the linear momentum calculation * @param momentum Result for this processor (Output) */ std::vector<double> calc_linear_momentum(int include_particles, int include_lbfluid) { double momentum_particles[3] = { 0., 0., 0. }; std::vector<double> linear_momentum(3,0.0); if (include_particles) { mpi_gather_stats(4, momentum_particles, NULL, NULL, NULL); linear_momentum[0] += momentum_particles[0]; linear_momentum[1] += momentum_particles[1]; linear_momentum[2] += momentum_particles[2]; } if (include_lbfluid) { double momentum_fluid[3] = { 0., 0., 0. }; #ifdef LB if(lattice_switch & LATTICE_LB) { mpi_gather_stats(6, momentum_fluid, NULL, NULL, NULL); } #endif #ifdef LB_GPU if(lattice_switch & LATTICE_LB_GPU) { lb_calc_fluid_momentum_GPU(momentum_fluid); } #endif linear_momentum[0] += momentum_fluid[0]; linear_momentum[1] += momentum_fluid[1]; linear_momentum[2] += momentum_fluid[2]; } return linear_momentum; }
void master_pressure_calc(int v_comp) { if(v_comp) mpi_gather_stats(3, total_pressure.data.e, total_p_tensor.data.e, total_pressure_non_bonded.data_nb.e, total_p_tensor_non_bonded.data_nb.e); else mpi_gather_stats(2, total_pressure.data.e, total_p_tensor.data.e, total_pressure_non_bonded.data_nb.e, total_p_tensor_non_bonded.data_nb.e); total_pressure.init_status = 1+v_comp; total_p_tensor.init_status = 1+v_comp; total_pressure_non_bonded.init_status_nb = 1+v_comp; total_p_tensor_non_bonded.init_status_nb = 1+v_comp; }
/** Calculate total momentum of the system (particles & LB fluid) * @param momentum Rsult for this processor (Output) */ void momentum_calc(double *momentum) { double momentum_fluid[3] = { 0., 0., 0. }; double momentum_particles[3] = { 0., 0., 0. }; mpi_gather_stats(4, momentum_particles, NULL, NULL, NULL); #ifdef LB mpi_gather_stats(6, momentum_fluid, NULL, NULL, NULL); #endif momentum[0] = momentum_fluid[0] + momentum_particles[0]; momentum[1] = momentum_fluid[1] + momentum_particles[1]; momentum[2] = momentum_fluid[2] + momentum_particles[2]; }
int lbboundary_get_force(int no, double* f) { #if defined (LB_BOUNDARIES) || defined (LB_BOUNDARIES_GPU) double* forces = (double *) Utils::malloc(3*n_lb_boundaries*sizeof(double)); if (lattice_switch & LATTICE_LB_GPU) { #if defined (LB_BOUNDARIES_GPU) && defined (LB_GPU) lb_gpu_get_boundary_forces(forces); f[0]=-forces[3*no+0]; f[1]=-forces[3*no+1]; f[2]=-forces[3*no+2]; #else return ES_ERROR; #endif } else { #if defined (LB_BOUNDARIES) && defined (LB) mpi_gather_stats(8, forces, NULL, NULL, NULL); f[0]=forces[3*no+0]*lbpar.agrid/lbpar.tau/lbpar.tau; f[1]=forces[3*no+1]*lbpar.agrid/lbpar.tau/lbpar.tau; f[2]=forces[3*no+2]*lbpar.agrid/lbpar.tau/lbpar.tau; #else return ES_ERROR; #endif } free(forces); #endif return 0; }
int lbboundary_get_force(int no, double* f) { #if defined (LB_BOUNDARIES) || defined (LB_BOUNDARIES_GPU) double* forces=malloc(3*n_lb_boundaries*sizeof(double)); if (lattice_switch & LATTICE_LB_GPU) { #if defined (LB_BOUNDARIES_GPU) && defined (LB_GPU) lb_gpu_get_boundary_forces(forces); // ***** I THINK BECAUSE OF THE WAY YOU DEFINE THE FORCES YOU WANT TO PRINT THE NEGATIVE f[0]=-forces[3*no+0]; f[1]=-forces[3*no+1]; f[2]=-forces[3*no+2]; #else return ES_ERROR; #endif } else { #if defined (LB_BOUNDARIES) && defined (LB) mpi_gather_stats(8, forces, NULL, NULL, NULL); f[0]=forces[3*no+0]*lbpar.agrid/lbpar.tau/lbpar.tau; f[1]=forces[3*no+1]*lbpar.agrid/lbpar.tau/lbpar.tau; f[2]=forces[3*no+2]*lbpar.agrid/lbpar.tau/lbpar.tau; #else return ES_ERROR; #endif } free(forces); #endif return 0; }
static void lb_master_calc_densprof(double *profile, int pdir, int x1, int x2) { /* this is a quick and dirty hack to issue slave calls with parameters */ int params[3] = { pdir, x1, x2 }; mpi_gather_stats(9, profile, params, NULL, NULL); }
int lbboundary_get_force(int no, double* f) { double* forces=malloc(3*n_lb_boundaries*sizeof(double)); mpi_gather_stats(8, forces, NULL, NULL, NULL); f[0]=forces[3*no+0]/lbpar.tau/lbpar.tau*lbpar.agrid; f[1]=forces[3*no+1]/lbpar.tau/lbpar.tau*lbpar.agrid; f[2]=forces[3*no+2]/lbpar.tau/lbpar.tau*lbpar.agrid; free(forces); return 0; }
static int tclcommand_analyze_fluid_parse_temp(Tcl_Interp *interp, int argc, char *argv[]) { char buffer[TCL_DOUBLE_SPACE]; double temp; mpi_gather_stats(7, &temp, NULL, NULL, NULL); Tcl_PrintDouble(interp, temp, buffer); Tcl_AppendResult(interp, buffer, (char *)NULL); return TCL_OK; }
static int tclcommand_analyze_fluid_parse_mass(Tcl_Interp *interp, int argc, char** argv) { char buffer[TCL_DOUBLE_SPACE]; double mass; mpi_gather_stats(5, &mass, NULL, NULL, NULL); Tcl_PrintDouble(interp, mass, buffer); Tcl_AppendResult(interp, buffer, (char *)NULL); return TCL_OK; }
static void lb_master_calc_velprof(double *result, int vcomp, int pdir, int x1, int x2) { /* this is a quick and dirty hack to issue slave calls with parameters */ int params[4]; params[0] = vcomp; params[1] = pdir; params[2] = x1; params[3] = x2; mpi_gather_stats(8, result, params, NULL, NULL); }
static int tclcommand_analyze_fluid_parse_momentum(Tcl_Interp* interp, int argc, char *argv[]) { char buffer[TCL_DOUBLE_SPACE]; double mom[3]; mpi_gather_stats(6, mom, NULL, NULL, NULL); Tcl_PrintDouble(interp, mom[0], buffer); Tcl_AppendResult(interp, buffer, " ", (char *)NULL); Tcl_PrintDouble(interp, mom[1], buffer); Tcl_AppendResult(interp, buffer, " ", (char *)NULL); Tcl_PrintDouble(interp, mom[2], buffer); Tcl_AppendResult(interp, buffer, (char *)NULL); return TCL_OK; }
void master_energy_calc() { mpi_gather_stats(1, total_energy.data.e, NULL, NULL, NULL); total_energy.init_status=1; }