Example #1
0
int main()
{
  clock_t start, end;
 
    struct timeval t1, t2;
    double timecost;

    // start timer
    gettimeofday(&t1, NULL);

	int i;
	Allocate_Memory();
	Init();
	for(i = 0;i < no_steps;i++)
	{
	  CalculateFlux();
	  CalculateFPFM();
	  CalculateResult();
	}
	Save_Results();
	Free();

	 // stop timer
    gettimeofday(&t2, NULL);

    // compute and print time cost in ms
    timecost = (t2.tv_sec - t1.tv_sec) * 1000.0;    // sec to ms
    timecost += (t2.tv_usec - t1.tv_usec) / 1000.0; // us to ms
    printf("Code time cost: %f\n", timecost);
	return 0;
}
/**
Initializes game object by copying settings from source_game and allocates resources.
Does not RESET game state.
*/
void Game_Engine::Copy_Initialize(Game_Engine* source_game)
{

	//set init flag
	is_initialized = true;

	//initialize values common to all derivate objects
	Initialize_Common();

	//copy settings
	Copy_Settings(source_game);

	//allocate resources
	Allocate_Memory();

}
//allocate memory and initialize variables
void Game_Engine::Initialize()
{

	//set init flag
	is_initialized = true;

	//initialize values common to all derivate objects
	Initialize_Common();

	//initialize settings
	Init_Settings();

	//allocate resources
	Allocate_Memory();
	
	//reset game state
	Game_Reset();
}
int main()
{
  R=287.0;
  gama=1.4;
  L=2.5;
  B=0.1;
  H=1.5;
  
  cfl=0.25;
//   cout<<"\nGive CFL number ...?";
//   cin>>cfl;  
  
  
  ReadFolder.append("./Data/");
  WriteFolder.append("./Data/");
  FILE *final = fopen( "./Data/change.dat","w" );
  fclose(final);
  
//   cout<<"Give number of cells along x-directions   ......?";
//   cin>>x_cell;
//   cout<<"Give number of cells along y-directions   ......?";
//   cin>>y_cell;
//   cout<<"Give number of cells along z-directions   ......?";
//   cin>>z_cell;
//   x_cell=10;
//   y_cell=3;
//   z_cell=10;
  Read_grid_size();
//   Read_grid_size_single();
  x_cell+=2;    y_cell+=2;    z_cell+=2;
  
  
  xy_cell=x_cell*y_cell;
  xyz_cell=x_cell*y_cell*z_cell;
  
//   printf("%i\n",x_cell);
//   printf("%i\n",xy_cell);
//   printf("%i\n",xyz_cell);
  
  Allocate_Memory();  
  
//   Calculate_Nodes();
//   Calculate_Nodes_Compression_Ramp();
//   Calculate_Nodes_Compression_Expansion_Ramp();
//   Calculate_Nodes_Convergent_Duct();
  Calculate_Nodes_Circular_Arc();
//   Calculate_Nodes_Compression_Ramp_exponential_y();
  Calculate_cellcenter();
  Calculate_facenormal();
  Calculate_cellvolume();
  
  cout<<"Enter number of iterations ...?";
  cin>>Iteration;
//   Iteration=3;
  int k;
//   Initial_Condition();
  Read_grid_double_output ();
  
  for (k=0;k<=Iteration;k++)
  {
    Iter=k;
    
   if((k%1000)==0)
   {
      Write_Timestep();
      
//    Write_First_row ();
   }
   
    Boundary_Conditions_wall ();
//     Boundary_Conditions_subsonic_wall ();
    Calculate_Mach ();
    Calculate_Timestep ();
    Calculate_dt_min ();
    Calculate_Q ();
    Calculate_Fluxvectors ();
//     Calculate_Q_new ();
    Calculate_Q_new_avg ();
    Calculate_Primitive ();
    Calculate_Change ();
//     Calculate_error ();
//     Calculate_error_compression ();
    Extra_Iterations ();
  }
  Write_grid_double_output ();

  
//   Write_Timestep();
  return 0;
}
void Game_Engine::Settings_Apply_Changes()
{
	Clear_Memory();
	Allocate_Memory();
	Game_Reset();
}