int tclcommand_lbboundary(ClientData data, Tcl_Interp *interp, int argc, char **argv) { #if defined (LB_BOUNDARIES) || defined (LB_BOUNDARIES_GPU) int status = TCL_ERROR, c_num; if ( lattice_switch == LATTICE_OFF ) { fprintf (stderr ,"WARNING: Specifying boundaries before using lbfluid assumes a CPU implementation of the LB.\n"); fprintf (stderr ,"WARNING: This will lead to unexpected behavior if a GPU LB fluid is later used since the boundaries wont exist.\n"); } if (argc < 2) return tclcommand_lbboundary_print_all(interp); if(ARG_IS_S(1, "wall")) { status = tclcommand_lbboundary_wall(generate_lbboundary(),interp, argc - 2, argv + 2); if (lattice_switch & LATTICE_LB_GPU) { mpi_bcast_lbboundary(-3); } else mpi_bcast_lbboundary(-1); } else if(ARG_IS_S(1, "sphere")) { status = tclcommand_lbboundary_sphere(generate_lbboundary(),interp, argc - 2, argv + 2); if (lattice_switch & LATTICE_LB_GPU) { mpi_bcast_lbboundary(-3); } else mpi_bcast_lbboundary(-1); } else if(ARG_IS_S(1, "cylinder")) { status = tclcommand_lbboundary_cylinder(generate_lbboundary(),interp, argc - 2, argv + 2); if (lattice_switch & LATTICE_LB_GPU) { mpi_bcast_lbboundary(-3); } else mpi_bcast_lbboundary(-1); } else if(ARG_IS_S(1, "rhomboid")) { status = tclcommand_lbboundary_rhomboid(generate_lbboundary(),interp, argc - 2, argv + 2); if (lattice_switch & LATTICE_LB_GPU) { mpi_bcast_lbboundary(-3); } else mpi_bcast_lbboundary(-1); } else if(ARG_IS_S(1, "pore")) { status = tclcommand_lbboundary_pore(generate_lbboundary(),interp, argc - 2, argv + 2); if (lattice_switch & LATTICE_LB_GPU) { mpi_bcast_lbboundary(-3); } else mpi_bcast_lbboundary(-1); } else if(ARG_IS_S(1, "stomatocyte")) { status = tclcommand_lbboundary_stomatocyte(generate_lbboundary(),interp, argc - 2, argv + 2); if (lattice_switch & LATTICE_LB_GPU) { mpi_bcast_lbboundary(-3); } else mpi_bcast_lbboundary(-1); } else if(ARG_IS_S(1, "hollow_cone")) { status = tclcommand_lbboundary_hollow_cone(generate_lbboundary(),interp, argc - 2, argv + 2); if (lattice_switch & LATTICE_LB_GPU) { mpi_bcast_lbboundary(-3); } else mpi_bcast_lbboundary(-1); } else if(ARG_IS_S(1, "force")) { if(argc != 3 || Tcl_GetInt(interp, argv[2], &(c_num)) == TCL_ERROR) { Tcl_AppendResult(interp, "Usage: lbboundary force $n",(char *) NULL); return (TCL_ERROR); } if(c_num < 0 || c_num >= n_lb_boundaries) { Tcl_AppendResult(interp, "Error in lbboundary force: The selected boundary does not exist",(char *) NULL); return (TCL_ERROR); } #if defined (LB) || defined (LB_GPU) char buffer[3*TCL_DOUBLE_SPACE+3]; double force[3]; status = lbboundary_get_force(c_num, force); for (int i = 0; i < 3; i++) { Tcl_PrintDouble(interp, force[i], buffer); Tcl_AppendResult(interp, buffer, " ", (char *)NULL); } #endif } else if(ARG_IS_S(1, "delete")) { if(argc < 3) { /* delete all */ mpi_bcast_lbboundary(-2); status = TCL_OK; } else { if (lattice_switch & LATTICE_LB_GPU) { Tcl_AppendResult(interp, "Cannot delete individual lb boundaries",(char *) NULL); return(TCL_ERROR); } if(Tcl_GetInt(interp, argv[2], &(c_num)) == TCL_ERROR) return (TCL_ERROR); if(c_num < 0 || c_num >= n_lb_boundaries) { Tcl_AppendResult(interp, "Can not delete non existing lbboundary",(char *) NULL); return (TCL_ERROR); } mpi_bcast_lbboundary(c_num); status = TCL_OK; } } else if(argc == 2 && Tcl_GetInt(interp, argv[1], &c_num) == TCL_OK) { tclcommand_printLbBoundaryToResult(interp, c_num); status = TCL_OK; } else { Tcl_AppendResult(interp, "possible lbboundary parameters: wall, sphere, cylinder, rhomboid, pore, stomatocyte, hollow_cone, delete {c} to delete lbboundary",(char *) NULL); return (TCL_ERROR); } return gather_runtime_errors(interp, status); #else /* !defined(LB_BOUNDARIES) || !defined(LB_BOUNDARIES_GPU */ Tcl_AppendResult(interp, "LB_BOUNDARIES/LB_BOUNDARIES_GPU not compiled in!" ,(char *) NULL); return (TCL_ERROR); #endif /* LB_BOUNDARIES or LB_BOUNDARIES_GPU */ }
int tclcommand_lbboundary_cpu(Tcl_Interp *interp, int argc, char **argv) { #ifdef LB_BOUNDARIES int status, c_num; double force[3]; char buffer[3*TCL_DOUBLE_SPACE+3]; if (argc < 2) return tclcommand_lbboundary_print_all(interp); if(!strncmp(argv[1], "wall", strlen(argv[1]))) { status = tclcommand_lbboundary_wall(generate_lbboundary(),interp, argc - 2, argv + 2); mpi_bcast_lbboundary(-1); } else if(!strncmp(argv[1], "sphere", strlen(argv[1]))) { status = tclcommand_lbboundary_sphere(generate_lbboundary(),interp, argc - 2, argv + 2); mpi_bcast_lbboundary(-1); } else if(!strncmp(argv[1], "cylinder", strlen(argv[1]))) { status = tclcommand_lbboundary_cylinder(generate_lbboundary(),interp, argc - 2, argv + 2); mpi_bcast_lbboundary(-1); } else if(!strncmp(argv[1], "pore", strlen(argv[1]))) { status = tclcommand_lbboundary_pore(generate_lbboundary(),interp, argc - 2, argv + 2); mpi_bcast_lbboundary(-1); } else if(!strncmp(argv[1], "force", strlen(argv[1]))) { if (argc != 3 || Tcl_GetInt(interp, argv[2], &(c_num)) == TCL_ERROR) { Tcl_AppendResult(interp, "Usage: lbboundary force $n",(char *) NULL); return (TCL_ERROR); } if(c_num < 0 || c_num >= n_lb_boundaries) { Tcl_AppendResult(interp, "Error in lbboundary force: The selected boundary does not exist",(char *) NULL); return (TCL_ERROR); } else { status = lbboundary_get_force(c_num, force); for (int i = 0; i < 3; i++) { Tcl_PrintDouble(interp, force[i], buffer); Tcl_AppendResult(interp, buffer, " ", (char *)NULL); } return TCL_OK; } } else if(!strncmp(argv[1], "delete", strlen(argv[1]))) { if(argc < 3) { /* delete all */ mpi_bcast_lbboundary(-2); status = TCL_OK; } else { if(Tcl_GetInt(interp, argv[2], &(c_num)) == TCL_ERROR) return (TCL_ERROR); if(c_num < 0 || c_num >= n_lb_boundaries) { Tcl_AppendResult(interp, "Can not delete non existing lbboundary",(char *) NULL); return (TCL_ERROR); } mpi_bcast_lbboundary(c_num); status = TCL_OK; } } else if (argc == 2 && Tcl_GetInt(interp, argv[1], &c_num) == TCL_OK) { tclcommand_printLbBoundaryToResult(interp, c_num); status = TCL_OK; } else { Tcl_AppendResult(interp, "possible lb_boundaries: wall sphere cylinder lbboundary pore delete {c} to delete lbboundary or lb_boundaries",(char *) NULL); return (TCL_ERROR); } // lb_init_boundaries(); return mpi_gather_runtime_errors(interp, status); #else /* !defined(LB_BOUNDARIES) */ Tcl_AppendResult(interp, "LB_BOUNDARIES not compiled in!" ,(char *) NULL); return (TCL_ERROR); #endif /* LB_BOUNDARIES */ }