void ui_raz_clicked(void *cbdata) { init_fields(); VisItTimeStepChanged(); VisItUpdatePlots(); }
/* Called to handle case 3 from VisItDetectInput where we have console * input that needs to be processed in order to accomplish an action. */ void ProcessConsoleCommand(simulation_data *sim) { /* Read A Command */ char cmd[1000]; int iseof = (fgets(cmd, 1000, stdin) == NULL); if (iseof) { sprintf(cmd, "quit"); printf("quit\n"); } if (strlen(cmd)>0 && cmd[strlen(cmd)-1] == '\n') cmd[strlen(cmd)-1] = '\0'; if(strcmp(cmd, "quit") == 0) sim->done = 1; else if(strcmp(cmd, "halt") == 0) sim->runMode = SIM_STOPPED; else if(strcmp(cmd, "step") == 0) simulate_one_timestep(sim); else if(strcmp(cmd, "run") == 0) sim->runMode = SIM_RUNNING; else if(strcmp(cmd, "update") == 0) VisItUpdatePlots(); }
/* Callback function for control commands, which are the buttons in the * GUI's Simulation window. This type of command is handled automatically * provided that you have registered a command callback such as this. */ void SimControlCommandCallback(const char *cmd, const char *args, void *cbdata) { simulation_data *sim = (simulation_data *)cbdata; if(strcmp(cmd, "quit") == 0) sim->done = 1; else if(strcmp(cmd, "halt") == 0) sim->runMode = SIM_STOPPED; else if(strcmp(cmd, "step") == 0) { simulation_data_update(sim); simulation_advance(sim); VisItTimeStepChanged(); VisItUpdatePlots(); } else if(strcmp(cmd, "run") == 0) sim->runMode = SIM_RUNNING; if(sim->echo && sim->par_rank == 0) { fprintf(stderr, "Command '%s' completed.\n", cmd); fflush(stderr); } }
void simulate_one_timestep(simulation_data *sim) { ++sim->cycle; if(sim->cycle == NUMBER_OF_ITERATIONS) { sim->done = 1; } sim->time += .01; /* Simulate the current round of grid. */ if(calculate) data_simulate(&sim->grid, sim->par_rank, sim->par_size, sim->time); #ifdef VISIT_INSITU if(sim->updateplots) { VisItTimeStepChanged(); VisItUpdatePlots(); } if(sim->savingFiles) { char filename[100]; sprintf(filename, "/scratch/eiger/jfavre/updateplots1k%04d.jpg", sim->saveCounter); if(VisItSaveWindow(filename, 128, 128, VISIT_IMAGEFORMAT_JPEG) == VISIT_OKAY) { sim->saveCounter++; if(sim->par_rank == 0) printf("Saved %s\n", filename); } else if(sim->par_rank == 0) printf("The image could not be saved to %s\n", filename); } #endif }
/* Called to handle case 3 from VisItDetectInput where we have console * input that needs to be processed in order to accomplish an action. */ void ProcessConsoleCommand(simulation_data *sim) { /* Read A Command */ char cmd[1000]; if (sim->par_rank == 0) { if(VisItReadConsole(1000, cmd) == VISIT_ERROR) { sprintf(cmd, "quit"); printf("quit\n"); } } #ifdef PARALLEL /* Broadcast the command to all processors. */ MPI_Bcast(cmd, 1000, MPI_CHAR, 0, sim->par_comm); #endif if(strcmp(cmd, "quit") == 0) sim->done = 1; else if(strcmp(cmd, "halt") == 0) sim->runMode = SIM_STOPPED; else if(strcmp(cmd, "step") == 0) simulate_one_timestep(sim); else if(strcmp(cmd, "run") == 0) sim->runMode = SIM_RUNNING; else if(strcmp(cmd, "update") == 0) { VisItTimeStepChanged(); VisItUpdatePlots(); } }
/****************************************************************************** * * Purpose: This function simulates one time step * * Programmer: Brad Whitlock * Date: Mon Aug 13 11:42:47 PDT 2012 * * Modifications: * *****************************************************************************/ void simulate_one_timestep(simulation_data *sim) { ++sim->cycle; sim->time += (M_PI / 10.); if(sim->par_rank == 0) printf("Simulating time step: cycle=%d, time=%lg\n", sim->cycle, sim->time); VisItTimeStepChanged(); VisItUpdatePlots(); }
void ControlCommandCallback(const char *cmd, const char *args, void *cbdata) { simulation_data *sim = (simulation_data *)cbdata; if(strcmp(cmd, "halt") == 0) sim->runMode = SIM_STOPPED; else if(strcmp(cmd, "step") == 0) simulate_one_timestep(sim); else if(strcmp(cmd, "run") == 0) sim->runMode = SIM_RUNNING; else if(strcmp(cmd, "update") == 0) VisItUpdatePlots(); }
/* Called to handle case 3 from VisItDetectInput where we have console * input that needs to be processed in order to accomplish an action. */ void ProcessConsoleCommand(simulation_data *sim) { /* Read A Command */ char cmd[1000]; VisItUI_valueChanged("Mu", ui_Mu_changed, &sim); VisItUI_valueChanged("A", ui_A_changed, &sim); if (sim->par_rank == 0) { int iseof = (fgets(cmd, 1000, stdin) == NULL); if (iseof) { sprintf(cmd, "quit"); printf("quit\n"); } if (strlen(cmd)>0 && cmd[strlen(cmd)-1] == '\n') cmd[strlen(cmd)-1] = '\0'; } /* Broadcast the command to all processors. */ MPI_Bcast(cmd, 1000, MPI_CHAR, 0, MPI_COMM_WORLD); if(strcmp(cmd, "quit") == 0) sim->done = 1; else if(strcmp(cmd, "halt") == 0) sim->runMode = SIM_STOPPED; else if(strcmp(cmd, "step") == 0) simulate_one_timestep(sim); else if(strcmp(cmd, "run") == 0) sim->runMode = SIM_RUNNING; else if(strcmp(cmd, "raz") == 0) init_fields(); else if(strcmp(cmd, "update") == 0) { VisItTimeStepChanged(); VisItUpdatePlots(); } else if(strcmp(cmd, "saveon") == 0) sim->savingFiles = 1; else if(strcmp(cmd, "saveoff") == 0) sim->savingFiles = 0; else if(strcmp(cmd, "addplot") == 0) { VisItExecuteCommand("AddPlot(\"Pseudocolor\", \"zonal\")\n"); VisItExecuteCommand("DrawPlots()\n"); } }
void ControlCommandCallback(const char *cmd, const char *args, void *cbdata) { simulation_data *sim = (simulation_data *)cbdata; #define IS_COMMAND(C) (strcmp(cmd, C) == 0) if(IS_COMMAND("halt")) sim->runMode = SIM_STOPPED; else if(IS_COMMAND("step")) simulate_one_timestep(sim); else if(IS_COMMAND("run")) sim->runMode = SIM_RUNNING; else if(strcmp(cmd, "update") == 0) { VisItTimeStepChanged(); VisItUpdatePlots(); } }
/****************************************************************************** * * Purpose: This function simulates one time step * * Programmer: Brad Whitlock * Date: Wed Feb 1 10:10:18 PST 2012 * * Modifications: * *****************************************************************************/ void simulate_one_timestep(simulation_data *sim) { int i; ++sim->cycle; sim->time += (M_PI / 10.); if(sim->par_rank == 0) printf("Simulating time step: cycle=%d, time=%lg\n", sim->cycle, sim->time); /* Update the variables */ for(i = 0; i < sim->nDomains; ++i) Domain_update_variable(&sim->domains[i], sim->time); VisItTimeStepChanged(); VisItUpdatePlots(); }
void simulate_one_timestep(simulation_data *sim) { int i, ncells; ++sim->cycle; sim->time += (M_PI / 10.); if(sim->par_rank == 0) printf("Simulating time step: cycle=%d, time=%lg\n", sim->cycle, sim->time); quadmesh_2d_create_radial_wave(&sim->blankRectMesh, sim->time); quadmesh_2d_create_radial_wave(&sim->blankCurvMesh, -sim->time); memcpy(sim->blankUcdMesh.data, sim->blankRectMesh.data, sim->blankUcdMesh.ncells * sizeof(float)); for(i = 0; i < 9; ++i) quadmesh_2d_create_radial_wave(&sim->multidomain[i].m, sim->time); VisItTimeStepChanged(); VisItUpdatePlots(); }
/* Called to handle case 3 from VisItDetectInput where we have console * input that needs to be processed in order to accomplish an action. */ void ProcessConsoleCommand(simulation_data *sim) { int i; /* Read A Command */ char cmd[1000]; int iseof = (fgets(cmd, 1000, stdin) == NULL); if (iseof) { sprintf(cmd, "quit"); printf("quit\n"); } if (strlen(cmd)>0 && cmd[strlen(cmd)-1] == '\n') cmd[strlen(cmd)-1] = '\0'; if(strcmp(cmd, "quit") == 0) sim->done = 1; else if(strcmp(cmd, "halt") == 0) sim->runMode = SIM_STOPPED; else if(strcmp(cmd, "step") == 0) simulate_one_timestep(sim); else if(strcmp(cmd, "step25") == 0) { for (i = 0; i < 25; ++i) simulate_one_timestep(sim); } else if(strcmp(cmd, "run") == 0) sim->runMode = SIM_RUNNING; else if(strcmp(cmd, "update") == 0) { VisItTimeStepChanged(); VisItUpdatePlots(); } if (sim->echo) { fprintf(stderr, "Command %s completed.\n", cmd); fflush(stderr); } }
/************************************************************************** *Callback function for control commands, which are the buttons in the * GUI's Simulation window. This type of command is handled automatically * provided that you have registered a command callback such as this. **************************************************************************/ void ControlCommandCallback(const char *cmd, const char *args, void *cbdata) { simulation_data *sim = (simulation_data *)cbdata; if(strcmp(cmd, "halt") == 0) sim->runMode = SIM_STOPPED; else if(strcmp(cmd, "step") == 0) simulate_one_timestep(sim); else if(strcmp(cmd, "run") == 0) sim->runMode = SIM_RUNNING; else if(strcmp(cmd, "raz") == 0) { init_fields(); VisItUpdatePlots(); } else if(strcmp(cmd, "addplot") == 0) { VisItExecuteCommand("AddPlot(\"Pseudocolor\", \"zonal\")\n"); VisItExecuteCommand("DrawPlots()\n"); } }
/****************************************************************************** * * Purpose: This function simulates one time step * * Programmer: Brad Whitlock * Date: Fri Jan 12 13:37:17 PST 2007 * * Modifications: * *****************************************************************************/ void simulate_one_timestep(simulation_data *sim) { int i; float x0, x1; ++sim->cycle; sim->time += (M_PI / 10.); if(sim->par_rank == 0) printf("Simulating time step: cycle=%d, time=%lg\n", sim->cycle, sim->time); /* Update the curve */ x0 = sim->par_rank * M_PI * 2; x1 = (sim->par_rank+1) * M_PI * 2; for(i = 0; i < sim->npts; ++i) { float x, y, t, angle; t = ((float)(i)) / ((float)(sim->npts - 1)); x = x0 + (x1 - x0) * t; angle = x + sim->time; y = sin(angle); sim->x[i] = x; sim->y[i] = y; sim->nodal[i] = i; if(i < sim->npts-1) sim->zonal[i] = i; } for(i = 0; i < sim->npts-1; ++i) { sim->conn[3*i] = VISIT_CELL_BEAM; sim->conn[3*i+1] = i; sim->conn[3*i+2] = i+1; } VisItTimeStepChanged(); VisItUpdatePlots(); }
void mainloop_interactive(simulation_data *sim) { int blocking, visitstate = 0, err = 0; /* If we're not running by default then simulate once there's something * once VisIt connects. */ if(sim->runMode == SIM_STOPPED) simulation_data_update(sim); if (sim->par_rank == 0) { fprintf(stderr, "command> "); fflush(stderr); } do { blocking = (sim->runMode == SIM_RUNNING) ? 0 : 1; /* Get input from VisIt or timeout so the simulation can run. */ if(sim->par_rank == 0) { visitstate = VisItDetectInput(blocking, fileno(stdin)); } #ifdef PARALLEL /* Broadcast the return value of VisItDetectInput to all procs. */ MPI_Bcast(&visitstate, 1, MPI_INT, 0, sim->par_comm); #endif /* Do different things depending on the output from VisItDetectInput. */ switch(visitstate) { case 0: /* There was no input from VisIt, return control to sim. */ simulation_data_update(sim); simulation_advance(sim); VisItTimeStepChanged(); VisItUpdatePlots(); break; case 1: /* VisIt is trying to connect to sim. */ if(VisItAttemptToCompleteConnection() == VISIT_OKAY) { fprintf(stderr, "VisIt connected\n"); /* Install callbacks */ SetupCallbacks(sim); } else { /* Print the error message */ char *err = VisItGetLastError(); fprintf(stderr, "VisIt did not connect: %s\n", err); free(err); } break; case 2: /* VisIt wants to tell the engine something. */ if(!SimProcessVisItCommand(sim)) { /* Disconnect on an error or closed connection. */ VisItDisconnect(); /* Start running again if VisIt closes. */ /*sim->runMode = SIM_RUNNING;*/ } break; case 3: /* VisItDetectInput detected console input - do something with it. * NOTE: you can't get here unless you pass a file descriptor to * VisItDetectInput instead of -1. */ mainloop_interactive_console_command(sim); if (sim->par_rank == 0) { fprintf(stderr, "command> "); fflush(stderr); } break; default: fprintf(stderr, "Can't recover from error %d!\n", visitstate); err = 1; break; } } while(!sim->done && err == 0); }