/****************************************************************************** main --- main routine ******************************************************************************/ int main() { int imax, jmax, kmax; para.geom = &geom; para.outp = &outp1; para.prob = &prob; para.mytime = &mytime; para.bc = &bc; para.solv = &solv; initial(¶); imax = geom.imax, jmax = geom.jmax, kmax = geom.kmax; if(!allocate_data( )) exit ( 1 ); clear_data(¶, var); set_grid(¶, var); set_bnd_vel(¶, var, VY, v); write_data1(¶, var, "grid"); FFD_solver(¶, var); free_data(var); getchar(); exit ( 0 ); } // End of main( )
/////////////////////////////////////////////////////////////////////////////// ///\brief Main program /// /// Initialize the simualtion and read input data from SCI,run the simulations, /// and write the results /// /// ///\return void No return needed /////////////////////////////////////////////////////////////////////////////// int main() { para.geom = &geom; para.outp = &outp1; para.prob = &prob; para.mytime = &mytime; para.bc = &bc; para.solv = &solv; initial(¶); if(!read_max(¶, var)) { printf("no file"); exit(1); } if(!allocate_data( )) exit ( 1 ); clear_data(¶, var,BINDEX); if(!read_input(¶, var,BINDEX)) { printf("no file"); exit(1); } init_data(¶, var,BINDEX); mark_cell(¶, var,BINDEX); if(para.solv->read_file==1) read_data(¶,var); FFD_solver(¶, var,BINDEX); write_SCI(¶, var, "output"); free_data(var); free_index(BINDEX); //getchar(); exit ( 0 ); } // End of main( )
/////////////////////////////////////////////////////////////////////////////// /// Main routine of FFD /// ///\para coupled simulation Integer to identify the simulation type /// ///\return 0 if no error occurred /////////////////////////////////////////////////////////////////////////////// int ffd(int cosimulation) { #ifndef _MSC_VER //Linux //Initialize glut library char fakeParam[] = "fake"; char *fakeargv[] = { fakeParam, NULL }; int fakeargc = 1; glutInit( &fakeargc, fakeargv ); #endif // Initialize the parameters para.geom = &geom; para.inpu = &inpu; para.outp = &outp1; para.prob = &prob; para.mytime = &mytime; para.bc = &bc; para.solv = &solv; para.sens = &sens; para.init = &init; // Stand alone simulation: 0; Cosimulaiton: 1 para.solv->cosimulation = cosimulation; if(initialize(¶)!=0) { ffd_log("ffd(): Could not initialize simulation parameters.", FFD_ERROR); return 1; } // Overwrite the mesh and simulation data using SCI generated file if(para.inpu->parameter_file_format == SCI) { if(read_sci_max(¶, var)!=0) { ffd_log("ffd(): Could not read SCI data.", FFD_ERROR); return 1; } } // Allocate memory for the variables if(allocate_memory(¶)!=0) { ffd_log("ffd(): Could not allocate memory for the simulation.", FFD_ERROR); return 1; } // Set the initial values for the simulation data if(set_initial_data(¶, var, BINDEX)) { ffd_log("ffd(): Could not set initial data.", FFD_ERROR); return 1; } // Read previous simulation data as initial values if(para.inpu->read_old_ffd_file==1) read_ffd_data(¶, var); ffd_log("ffd.c: Start FFD solver.", FFD_NORMAL); //write_tecplot_data(¶, var, "initial"); // Solve the problem if(para.outp->version==DEMO) { open_glut_window(); glutMainLoop(); } else if(FFD_solver(¶, var, BINDEX)!=0) { ffd_log("ffd(): FFD solver failed.", FFD_ERROR); return 1; } /*--------------------------------------------------------------------------- | Post Process ---------------------------------------------------------------------------*/ // Calculate mean value if(para.outp->cal_mean == 1) average_time(¶, var); if(write_unsteady(¶, var, "unsteady")!=0) { ffd_log("FFD_solver(): Could not write the file unsteady.plt.", FFD_ERROR); return 1; } if(write_tecplot_data(¶, var, "result")!=0) { ffd_log("FFD_solver(): Could not write the file result.plt.", FFD_ERROR); return 1; } if(para.outp->version == DEBUG) write_tecplot_all_data(¶, var, "result_all"); // Write the data in SCI format write_SCI(¶, var, "output"); // Free the memory free_data(var); free_index(BINDEX); // End the simulation if(para.outp->version==DEBUG || para.outp->version==DEMO) {}//getchar(); // Inform Modelica the stopping command has been received if(para.solv->cosimulation==1) { para.cosim->para->flag = 2; ffd_log("ffd(): Sent stopping signal to Modelica", FFD_NORMAL); } return 0; } // End of ffd( )