/////////////////////////////////////////////////////////////////////////////// /// FFD routines for GLUT keyboard callback routines /// ///\param para Pointer to FFD parameters ///\param var Pointer to all variables ///\param BINDEX Pointer to bounary index ///\param key Character of the key /// ///\return No return needed /////////////////////////////////////////////////////////////////////////////// void ffd_key_func(PARA_DATA *para, REAL **var, int **BINDEX, unsigned char key) { // Set control variable according to key input switch(key) { // Restart the simulation case '0': if(set_initial_data(para, var, BINDEX)) exit(1); break; // Quit case 'q': case 'Q': free_data(var); exit(0); break; // Draw velocity case '1': para->outp->screen = 1; break; // Draw temperature case '2': para->outp->screen = 2; break; // Draw contaminant concentration case '3': para->outp->screen = 3; break; // Start to calcualte mean value case 'm': case 'M': para->outp->cal_mean = 1; para->mytime->step_current = 0; printf("start to calculate mean properties.\n"); break; // Save the results case 's': case 'S': if(para->outp->cal_mean == 1) average_time(para, var); write_tecplot_data(para, var, "result"); break; // Reduce the drawed length of veloity case 'k': case 'K': para->outp->v_length --; break; // Increase the drawed length of velocity case 'l': case 'L': para->outp->v_length ++; break; } } // End of ffd_key_func()
MILPP::MILPP(double* c, int nr_cols, double* A, int nr_rows, char* s, double* b) { set_initial_data(); initialize(nr_cols, nr_rows); /* Assign vector of coefficients for objective function */ assign_obj_coefs(c); assign_rows_lower_bounds((double*)calloc(get_num_cols(), sizeof(double))); assign_rows_upper_bounds(b); assign_rows_senses(s); /* Fill the constraint matrix */ for (size_t i = 0; i < get_num_rows(); i++) for (size_t j = 0; j < get_num_cols(); j++) { double v = (A + i * get_num_cols())[j]; if (!v) continue; cons_matrix_.set_coefficient(i, j, v); col_to_row_mapping_[j]->insert(i); row_to_col_mapping_[i]->insert(j); } }
/////////////////////////////////////////////////////////////////////////////// /// 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( )
MILPP::MILPP(int nr_cols, int nr_rows) { set_initial_data(); initialize(nr_cols, nr_rows); }
/** Default constructor. */ MILPP::MILPP() { set_initial_data(); }