void dataeditfrm::contmenu() { QMenu* contextMenu = new QMenu( this ); Q_CHECK_PTR( contextMenu ); QAction* add_row = new QAction( tr("&Add supplier"), this ); connect(add_row , SIGNAL(triggered()), this, SLOT(addrow())); contextMenu->addAction(add_row); QAction* del_row = new QAction( tr("&Delete supplier"), this ); connect(del_row , SIGNAL(triggered()), this, SLOT(removerow())); contextMenu->addAction(del_row); contextMenu->addSeparator(); QAction* checkaddr = new QAction( tr("&Check address"), this ); connect(checkaddr , SIGNAL(triggered()), this, SLOT(seladdress())); contextMenu->addAction(checkaddr); contextMenu->addSeparator(); QAction* sel_sup = new QAction( tr("&Select this supplier"), this ); connect(sel_sup , SIGNAL(triggered()), this, SLOT(acceptsp())); contextMenu->addAction(sel_sup); contextMenu->exec( QCursor::pos() ); delete contextMenu; }
/* auxiliary function required by mnewt */ int usrfun(FTYPE *U_target,FTYPE *pr0,int numnormterms,int whichcons, int primtoUcons, struct of_geom *ptrgeom, FTYPE *prguess, int n, FTYPE *beta, FTYPE **alpha,FTYPE*norm) { static FTYPE **alpha5; FTYPE prstart[NPR]; FTYPE *pr; static FTYPE U[NPR],U_curr[NPR]; struct of_state q; int i, j, k; int pl,pliter; int failreturn=0; void removerow(int row, FTYPE **alpha5,FTYPE**alpha); static int firstc=1; if (firstc) { firstc = 0; alpha5 = dmatrix(1, 5, 1, 5); } pr=prguess+1; // Doing this constrained iteration may lead to non-convergence, but then we adjust U if that happens until we converge. // store old pr PLOOP(pliter,pl) prstart[pl]=pr[pl]; // these checks seem to cause problems with convergence of any kind // GODMARK // we need to make sure densities are ok while iterating. #if(WHICHVEL==VEL3) if(0&&jonchecks) fixup1zone(pr,ptrgeom,0); // once pr lead to imaginary u^t, state is invalid and U cannot be found. // Thus, need to adjust pr while iterating to keep pr in line // essentially we are doing a constrained damped Newton's method. if(0&&jonchecks) failreturn=check_pr(pr,pr0,ptrgeom,-100); if(0&&jonchecks) if(failreturn>=1) FAILSTATEMENT("utoprim.c:usrfun()", "mnewt check:check_pr()", 2); // just check if(jonchecks) failreturn=check_pr(pr,pr0,ptrgeom,-2); #endif if(!failreturn){ // if didn't fail, we are guarenteed a good state and U. // problem here is that now pr is different and doesn't help // converge to Utarget, maybe kills possibility of convergence which // would later be just fixed at the end // so should probably adjust Utarget somehow to compensate for adjustment in pr. Use dudp to fix U_target along the way /* normalize error = beta to \rho u^t */ failreturn=get_state(pr, ptrgeom, &q); if(failreturn>=1) FAILSTATEMENT("utoprim.c:usrfun()", "get_state()", 1); failreturn=primtoU(primtoUcons,pr, &q, ptrgeom, U); // DEBUG: // dualfprintf(fail_file,"nprlist: %d %d %d %d\n",nprstart,nprend,nprlist[nprstart],nprlist[nprend]); // dualfprintf(fail_file,"1primtoUcons=%d ptrgeom.g=%21.15g\n",primtoUcons,ptrgeom->g); // for (pl = 0; pl < INVERTNPR ; pl++) // dualfprintf(fail_file,"pr[%d]=%21.15g U[%d]=%21.15g\n",pl,pr[pl],pl,U[pl]); if(failreturn>=1) FAILSTATEMENT("utoprim.c:usrfun()", "primtoU()", 1); #if(EOMTYPE==EOMGRMHD||EOMTYPE==EOMENTROPYGRMHD) PLOOP(pliter,pl) U_curr[pl]=U[pl]; #elif(EOMTYPE==EOMFFDE) // convert from normal U to iterative U fixUtarget(WHICHFFDEINVERSION,U,U_curr); #endif failreturn=dudp_calc(WHICHEOS, whichcons,GLOBALMAC(EOSextraglobal,ptrgeom->i,ptrgeom->j,ptrgeom->k),pr, &q, ptrgeom, alpha5); if(failreturn>=1) FAILSTATEMENT("utoprim.c:usrfun()", "dudp_calc()", 1); // convert from normal alpha to iterative alpha #if(EOMTYPE==EOMGRMHD||EOMTYPE==EOMENTROPYGRMHD) for (j = 0; j < INVERTNPR ; j++){ for (k = 0; k < INVERTNPR ; k++){ alpha[j+1][k+1]=alpha5[j+1][k+1]; } } #elif(EOMTYPE==EOMFFDE) #if(WHICHFFDEINVERSION==0) removerow(U2,alpha5,alpha); #elif(WHICHFFDEINVERSION==1) removerow(U1,alpha5,alpha); #elif(WHICHFFDEINVERSION==2) removerow(UU,alpha5,alpha); #endif #endif ///////////////////// // // normalize matrix // //////////////////// #if(NORMMETHOD==-1) *norm=1.0; #elif(NORMMETHOD==0) *norm=1.0/U_target[RHO]; #elif(NORMMETHOD==1) // more general normalization *norm=0.0; numnormterms=0; for (j = 0; j < INVERTNPR ; j++){ for (k = 0; k < INVERTNPR ; k++){ // GODMARK: correction: if(fabs(alpha[j + 1][k + 1])>NUMEPSILON){ // old version (bug) // if(alpha[j + 1][k + 1]>NUMEPSILON){ *norm+=fabs(alpha[j + 1][k + 1]); numnormterms++; } } } *norm=(FTYPE)(numnormterms)/(*norm); // (i.e. inverse of average) #endif for (j = 0; j < INVERTNPR ; j++) for (k = 0; k < INVERTNPR ; k++) alpha[j + 1][k + 1] *= (*norm); // below assumes alpha at U_curr isn't too different from at U_target // doesn't seem to work /* for (j = 0; j < INVERTNPR ; j++){ for (k = 0; k < INVERTNPR ; k++){ // should really use average alpha from initial pr and new pr, but try just new pr's dudp U_target[j]+=U_target[RHO]*alpha[j+1][k+1]*(pr[k]-prstart[k]); } } */ // determine normalized error for (k = 0; k < INVERTNPR ; k++) beta[k + 1] = (U_curr[k] - U_target[k]) *(*norm); // DEBUG: // dualfprintf(fail_file,"primtoUcons=%d\n",primtoUcons); // for (k = 0; k < INVERTNPR ; k++) // dualfprintf(fail_file,"pr[%d]=%21.15g U_curr[%d]=%21.15g U_target[%d]=%21.15g\n",k,pr[k],k,U_curr[k],k,U_target[k]); } else{ // error is huge if failed, a marker for failure for (k = 0; k < INVERTNPR ; k++) beta[k + 1] = 1.E30; } return (0); }