Exemple #1
0
int main(int argc, char *argv[]){

  int    nbParts=20000;
  float  minMax[3][2]={{-1,1},{-1,1},{-1,1}};
  float  cellSize=2*0.02*1.001;// 2*particle radius + 0.1%
  float  dt=0.002,simTime=5;
  float  dtFrame=0.02; //0.04 <=> 25 frames per seconds
  int    nbDtPerFrame,i;
  char   filename[]="toto.par";
  float  mass;
  System *sys;
  clock_t time;

/*
  FILE *file;
  float r[3];

  file=fopen("filter.plt","w");
  fprintf(file,"VARIABLES = x w\n");
  r[1]=r[2]=0;
  for(i=0;i<=100;i++){
    r[0]=i/100.;
    fprintf(file,"%e\t%e\n",i/100.,kernelPoly6(r,1));
  }
  fclose(file);
  return 0;*/


  nbDtPerFrame=dtFrame/dt;
  sys=createSystem(nbParts,minMax);
  tmpAddWalls_1(sys);
  setGrid(sys, cellSize);
  //printGrid(sys); //test nico
  //return 0;
  mass=1000*(minMax[0][1]-minMax[0][0])*(minMax[1][1]-minMax[1][0])*(minMax[2][1]-minMax[2][0])/nbParts;
  setParticles(sys,0,nbParts-1,mass/4); //for water, ro0=1000kg/m3, so 1000 parts/Liter => mi=1e-3kg
  setForces(sys);
  generateParFile(sys,filename,CREATE);

  i=0;
  time=clock();
  while(sys->time<=simTime){
    printf("time = %e (i=%d)\n",sys->time,i);fflush(stdout);
    updateSys(sys,dt);
    if((++i)%nbDtPerFrame==0)
      generateParFile(sys,filename,UPDATE);
  }
  time=clock()-time;

  generateParFile(sys,filename,CLOSE);
  deleteSystem(sys);

  updateSys(NULL,0);
#ifdef USE_MULTI_THREADING
  cleanThreads();
#endif
  printf("done in %f sec!\n", (double)(time)/CLOCKS_PER_SEC);
  return 0;
}
Exemple #2
0
/*
 * Main function. Parses command line arguments and launchs the simulator.
 */
int main (int argc, char **argv){
  int opt;

  // Default values
  NodesFct f = BasicBroadcast;
  int nb_nodes = 4;
  int nb_rounds = 20;

  // Parsing arguments
  while(-1 != (opt = getopt(argc, argv, "N:R:hibtpLTX"))){
    switch(opt){
      case 'N':
        nb_nodes = atoi(optarg);
        break;
      case 'R':
        nb_rounds = atoi(optarg);
        break;
      case 'h':
        display_help(stdout, argv[0]);
        return 0;
      case 'b':
        f = BasicBroadcast;
        break;
      case 't':
        f = TreeBroadcast;
        break;
      case 'p':
        f = PipelineBroadcast;
        break;
      case 'L':
        f = TOBLatencyBroadcast;
        break;
      case 'T':
        f = TOBThroughputBroadcast;
        break;
      case 'X':
        f = TOBThroughputRodBroadcast;
        break;
      default: /* WTF ? */
        fprintf(stderr, "Argument error...\n");
        display_help(stderr, argv[0]);
        exit(EXIT_FAILURE);
      }
  }

  // Do the simulation
  initSystem(nb_nodes, nb_rounds, f);
  LaunchSimulation();
  deleteSystem();
  return 0;
}
Exemple #3
0
/*
   Calls parseAirports, parseSchedules, and calcRouteTimes if the required files exists.
 */
void timeRoutes(char* airports, char* schedules, char* routes) {
    FILE *airportFile, *scheduleFile, *routeFile;
    char* read = "r";
    airportFile = fopen(airports,read);
    if(!airportFile) {
	fprintf(stderr,"Cannot open file with list of airport names.");
	exit(EXIT_FAILURE);
    }
    flightSys_t* s = createSystem();
    if(s==NULL) {
	printf("createSystem unimplemented\n");
	return;
    }
    printf("***Parse and echo airports***\n");
    parseAirports(s,airportFile);
    fclose(airportFile);
    printAirports(s);
 
  scheduleFile = fopen(schedules,read);
    if(!scheduleFile) {
	fprintf(stderr,"Cannot open file with schedule.");
	exit(EXIT_FAILURE);
    }
    printf("\n***Parse and echo schedules***\n");
    parseSchedule(s,scheduleFile);  
    fclose(scheduleFile);
    routeFile = fopen(routes,read);
    if(!routeFile) {
	fprintf(stderr,"Cannot open file with routes.");
	exit(EXIT_FAILURE);
    }
    printf("\n***Parse and calculate route times***\n");
    calcRouteTimes(s,routeFile);
    fclose(routeFile);

    deleteSystem(s);
}
void EntityWorld::deleteSystem( SystemType p_type )
{
	deleteSystem( (SystemType::SystemTypeIdx)p_type.getIndex() );
}
// ==== CONTEXT MENU ====
// system table context menu -> Delete
void MainWindow::on_actionDeleteSystem_triggered(){
    deleteSystem();
}
// Delete button -> clicked
void MainWindow::on_systemDeleteButton_clicked(){
    deleteSystem();
}