main (int argc, char *argv[]){ int i,j,k; manager_init(); parse_util_args(argc, argv); iparam_set("LQUAD",3); iparam_set("MQUAD",3); iparam_set("NQUAD",3); iparam_set("MODES",iparam("LQUAD")-1); char *buf = (char*) calloc(BUFSIZ, sizeof(char)); char *fname = (char*) calloc(BUFSIZ, sizeof(char)); get_string("Enter name of input file", buf); sprintf(fname, strtok(buf, "\n")); Grid *grid = new Grid(fname); Grid *grida = new Grid(grid); grida->RenumberPrisms(); grida->FixPrismOrientation(); grid->ImportPrismOrientation(grida); grida->RemovePrisms(); grida->RemoveHexes(); grida->FixTetOrientation(); grid->ImportTetOrientation(grida); Element_List *U = grid->gen_aux_field(); int nel = U->nel; get_string("Enter name of output file", buf); sprintf(fname, strtok(buf, "\n")); FILE *fout = fopen(fname, "w"); int Nfields, Nbdry; get_int ("Enter number of fields", &Nfields); get_int ("Enter number of boundaries (including default)", &Nbdry); char **eqn = (char**) calloc(Nfields, sizeof(char*)); for(i=0;i<Nfields;++i){ eqn[i] = (char*)calloc(BUFSIZ, sizeof(char)); } Bndry *Bc; Bndry **Vbc = (Bndry**) calloc(Nfields, sizeof(Bndry*)); char *bndryeqn = (char*) calloc(BUFSIZ, sizeof(char)); int **bcmatrix = imatrix(0, U->nel-1, 0, Max_Nfaces-1); izero(U->nel*Max_Nfaces, bcmatrix[0], 1); int nb; char type; char curved, curvetype; Curve *cur; int curveid = 0; for(nb=0;nb<Nbdry;++nb){ if(nb != Nbdry-1){ fprintf(stderr, "#\nBoundary: %d\n#\n", nb+1); get_string("Enter function which has roots at boundary", bndryeqn); fprintf(stderr, "#\n"); } else{ fprintf(stderr, "#\nDefault Boundary:\n#\n"); } get_char("Enter character type\n(v=velocity)\n" "(W=wall)\n(O=outflow)\n(s=flux (Compressible only))\n", &type); fprintf(stderr, "#\n"); switch(type){ case 'W': case 'O': break; case 'v': case 's': for(i=0;i<Nfields;++i){ get_string("Enter function definition", eqn[i]); fprintf(stderr, "\n"); } } get_char("Is this boundary curved (y/n)?", &curved); if(curved == 'y'){ ++curveid; get_char("Enter curve type\n(S=sphere)\n(C=cylinder)\n(T=taurus)\n", &curvetype); switch(curvetype){ case 'S':{ double cx, cy, cz, cr; get_double("Enter center x-coord", &cx); get_double("Enter center y-coord", &cy); get_double("Enter center z-coord", &cz); get_double("Enter radius", &cr); cur = (Curve*) calloc(1, sizeof(Curve)); cur->type = T_Sphere; cur->info.sph.xc = cx; cur->info.sph.yc = cy; cur->info.sph.zc = cz; cur->info.sph.radius = cr; cur->id = curveid; break; } case 'C':{ double cx, cy, cz, cr; double ax, ay, az; get_double("Enter point on axis x-coord", &cx); get_double("Enter point on axis y-coord", &cy); get_double("Enter point on axis z-coord", &cz); get_double("Enter axis vector x-coord", &ax); get_double("Enter axis vector y-coord", &ay); get_double("Enter axis vector z-coord", &az); get_double("Enter radius", &cr); cur = (Curve*) calloc(1, sizeof(Curve)); cur->type = T_Cylinder; cur->info.cyl.xc = cx; cur->info.cyl.yc = cy; cur->info.cyl.zc = cz; cur->info.cyl.ax = ax; cur->info.cyl.ay = ay; cur->info.cyl.az = az; cur->info.cyl.radius = cr; cur->id = curveid; break; } } } if(nb == Nbdry-1) break; double res; Element *E; for(E=U->fhead;E;E=E->next){ for(i=0;i<E->Nfaces;++i){ for(j=0;j<E->Nfverts(i);++j){ vector_def("x y z",bndryeqn); vector_set(1, &(E->vert[E->fnum(i,j)].x), &(E->vert[E->fnum(i,j)].y), &(E->vert[E->fnum(i,j)].z), &res); if(fabs(res)> TOL) break; } if(j==E->Nfverts(i)){ if(curved == 'y'){ E->curve = (Curve*) calloc(1, sizeof(Curve)); memcpy(E->curve, cur, sizeof(Curve)); E->curve->face = i; } switch(type){ case 'W': case 'O': for(j=0;j<Nfields;++j){ Bc = E->gen_bndry(type, i, 0.); Bc->type = type; add_bc(&Vbc[j], Bc); } bcmatrix[E->id][i] = 1; break; case 'v': case 's': for(j=0;j<Nfields;++j){ Bc = E->gen_bndry(type, i, eqn[j]); Bc->type = type; add_bc(&Vbc[j], Bc); } bcmatrix[E->id][i] = 1; break; } } } } } char is_periodic; get_char("Is there periodicity in the x-direction (y/n)?", &is_periodic); if(is_periodic == 'y') get_double("Enter periodic length",&XPERIOD); get_char("Is there periodicity in the y-direction (y/n)?", &is_periodic); if(is_periodic == 'y') get_double("Enter periodic length",&YPERIOD); get_char("Is there periodicity in the z-direction (y/n)?", &is_periodic); if(is_periodic == 'y') get_double("Enter periodic length",&ZPERIOD); // Do remaining connections Element *E, *F; for(E=U->fhead;E;E=E->next) for(i=0;i<E->Nfaces;++i) if(!bcmatrix[E->id][i]) for(F=E;F;F=F->next) for(j=0;j<F->Nfaces;++j) if(!bcmatrix[F->id][j]) if(neighbourtest(E,i,F,j) && !(E->id == F->id && i==j)){ bcmatrix[E->id][i] = 2; bcmatrix[F->id][j] = 2; set_link(E,i,F,j); break; } // if the default bc is curved the make default bndries curved if(curved == 'y'){ for(E=U->fhead;E;E=E->next) for(i=0;i<E->Nfaces;++i) if(!bcmatrix[E->id][i]){ E->curve = (Curve*) calloc(1, sizeof(Curve)); memcpy(E->curve, cur, sizeof(Curve)); E->curve->face = i; } } fprintf(fout, "****** PARAMETERS *****\n"); fprintf(fout, " SolidMes \n"); fprintf(fout, " 3 DIMENSIONAL RUN\n"); fprintf(fout, " 0 PARAMETERS FOLLOW\n"); fprintf(fout, "0 Lines of passive scalar data follows2 CONDUCT; 2RHOCP\n"); fprintf(fout, " 0 LOGICAL SWITCHES FOLLOW\n"); fprintf(fout, "Dummy line from old nekton file\n"); fprintf(fout, "**MESH DATA** x,y,z, values of vertices 1,2,3,4.\n"); fprintf(fout, "%d 3 1 NEL NDIM NLEVEL\n", U->nel); for(E=U->fhead;E;E=E->next){ switch(E->identify()){ case Nek_Tet: fprintf(fout, "Element %d Tet\n", E->id+1); break; case Nek_Pyr: fprintf(fout, "Element %d Pyr\n", E->id+1); break; case Nek_Prism: fprintf(fout, "Element %d Prism\n", E->id+1); break; case Nek_Hex: fprintf(fout, "Element %d Hex\n", E->id+1); break; } for(i=0;i<E->Nverts;++i) fprintf(fout, "%lf ", E->vert[i].x); fprintf(fout, "\n"); for(i=0;i<E->Nverts;++i) fprintf(fout, "%lf ", E->vert[i].y); fprintf(fout, "\n"); for(i=0;i<E->Nverts;++i) fprintf(fout, "%lf ", E->vert[i].z); fprintf(fout, "\n"); } fprintf(fout, "***** CURVED SIDE DATA ***** \n"); fprintf(fout, "%d Number of curve types\n", curveid); for(i=0;i<curveid;++i){ int flag = 0; for(E=U->fhead;!flag && E;E=E->next){ if(E->curve && E->curve->type != T_Straight){ if(E->curve->id == i+1){ switch(E->curve->type){ case T_Sphere: fprintf(fout, "Sphere\n"); fprintf(fout, "%lf %lf %lf %lf %c\n", E->curve->info.sph.xc, E->curve->info.sph.yc, E->curve->info.sph.zc, E->curve->info.sph.radius, 'a'+i+1); flag = 1; break; case T_Cylinder: fprintf(fout, "Cylinder\n"); fprintf(fout, "%lf %lf %lf %lf %lf %lf %lf %c\n", E->curve->info.cyl.xc, E->curve->info.cyl.yc, E->curve->info.cyl.zc, E->curve->info.cyl.ax, E->curve->info.cyl.ay, E->curve->info.cyl.az, E->curve->info.cyl.radius, 'a'+i+1); flag = 1; break; } } } } } int ncurvedsides = 0; for(E=U->fhead;E;E=E->next){ if(E->curve && E->curve->type != T_Straight) ++ncurvedsides; } fprintf(fout, "%d Curved sides follow\n", ncurvedsides); for(E=U->fhead;E;E=E->next) if(E->curve && E->curve->type != T_Straight) fprintf(fout, "%d %d %c\n", E->curve->face+1, E->id+1, 'a'+E->curve->id); fprintf(fout, "***** BOUNDARY CONDITIONS ***** \n"); fprintf(fout, "***** FLUID BOUNDARY CONDITIONS ***** \n"); for(E=U->fhead;E;E=E->next){ for(j=0;j<E->Nfaces;++j){ if(bcmatrix[E->id][j] == 2){ fprintf(fout, "E %d %d %d %d\n", E->id+1, j+1, E->face[j].link->eid+1, E->face[j].link->id+1); } else if(bcmatrix[E->id][j] == 1){ for(i=0;i<Nfields;++i) for(Bc=Vbc[i];Bc;Bc=Bc->next){ if(Bc->elmt == E && Bc->face == j){ if(i==0) switch(Bc->type){ case 'W': fprintf(fout, "W %d %d 0. 0. 0.\n", E->id+1, j+1); break; case 'O': fprintf(fout, "O %d %d 0. 0. 0.\n", E->id+1, j+1); break; case 'v': fprintf(fout, "v %d %d 0. 0. 0.\n", E->id+1, j+1); break; case 's': fprintf(fout, "s %d %d 0. 0. 0.\n", E->id+1, j+1); break; } if(Bc->type == 's' || Bc->type == 'v') fprintf(fout, "%c=%s\n", 'u'+i,Bc->bstring); break; } } } else{ switch(type){ case 'W': fprintf(fout, "W %d %d 0. 0. 0.\n", E->id+1, j+1); break; case 'O': fprintf(fout, "O %d %d 0. 0. 0.\n", E->id+1, j+1); break; case 'v': fprintf(fout, "v %d %d 0. 0. 0.\n", E->id+1, j+1); break; case 's': fprintf(fout, "s %d %d 0. 0. 0.\n", E->id+1, j+1); break; } if(type == 's' || type == 'v') for(i=0;i<Nfields;++i) fprintf(fout, "%c=%s\n", 'u'+i,eqn[i]); } } } char bufa[BUFSIZ]; fprintf(fout, "***** NO THERMAL BOUNDARY CONDITIONS *****\n"); get_char("Are you using a field file restart (y/n)?", &type); if(type == 'y'){ fprintf(fout, "%d INITIAL CONDITIONS *****\n",1); get_string("Enter name of restart file:", buf); fprintf(fout, "Restart\n"); fprintf(fout, "%s\n", buf); } else{ fprintf(fout, "%d INITIAL CONDITIONS *****\n",1+Nfields); fprintf(fout, "Given\n"); for(i=0;i<Nfields;++i){ sprintf(bufa, "Field %d ", i+1); get_string(bufa, buf); fprintf(fout, "%s\n", buf); } } fprintf(fout, "***** DRIVE FORCE DATA ***** PRESSURE GRAD, FLOW, Q\n"); get_char("Are you using a forcing function (y/n)?", &type); if(type == 'y'){ fprintf(fout, "%d Lines of Drive force data follow\n", Nfields); for(i=0;i<Nfields;++i){ sprintf(bufa, "FF%c = ", 'X'+i); get_string(bufa,buf); fprintf(fout, "FF%c = %s\n",'X'+i, buf); } } else{ fprintf(fout, "0 Lines of Drive force data follow\n"); } fprintf(fout, "***** Variable Property Data ***** Overrrides Parameter data.\n"); fprintf(fout, " 1 Lines follow.\n"); fprintf(fout, " 0 PACKETS OF DATA FOLLOW\n"); fprintf(fout, "***** HISTORY AND INTEGRAL DATA *****\n"); get_char("Are you using history points (y/n)?", &type); if(type == 'y'){ int npoints; get_int ("Enter number of points", &npoints); fprintf(fout, " %d POINTS. Hcode, I,J,H,IEL\n", npoints); for(i=0;i<npoints;++i){ sprintf(bufa, "Enter element number for point %d", i+1); get_int(bufa,&j); sprintf(bufa, "Enter vertex number for point %d", i+1); get_int(bufa, &k); fprintf(fout, "UVWP H %d 1 1 %d\n", k, j); } } else{ fprintf(fout, " 0 POINTS. Hcode, I,J,H,IEL\n"); } fprintf(fout, " ***** OUTPUT FIELD SPECIFICATION *****\n"); fprintf(fout, " 0 SPECIFICATIONS FOLLOW\n"); return 0; }
void Execution_Tracer::trace(Squeak_Interpreter* si) { int pc = si->instructionPointer() - si->method_obj()->as_u_char_p(); add_bc(si->method(), si->roots.receiver, pc, si->activeContext_obj()->is_this_context_a_block_context(), si->bcCount); }