Пример #1
0
/** 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;
}
static int tclcommand_analyze_fluid_parse_momentum_gpu(Tcl_Interp* interp, int argc, char *argv[]) {
  char buffer[TCL_DOUBLE_SPACE];
  double host_mom[3];

  lb_calc_fluid_momentum_GPU(host_mom);
  
  Tcl_PrintDouble(interp, host_mom[0], buffer);
  Tcl_AppendResult(interp, buffer, " ", (char *)NULL);
  Tcl_PrintDouble(interp, host_mom[1], buffer);
  Tcl_AppendResult(interp, buffer, " ", (char *)NULL);
  Tcl_PrintDouble(interp, host_mom[2], buffer);
  Tcl_AppendResult(interp, buffer, (char *)NULL);

  return TCL_OK;
}