static void findIntegerPolynomial(const BigReal &r, int digits, int verbose) { const int xdigits = (int)r.getDecimalDigits()+1; bool solutionFound = false; for(int degree = 2; !solutionFound && (degree <= 30); degree++) { BigRealVector x(degree+1); x[0] = BIGREAL_1; for(int i = 1; i <= degree; i++) { x[i] = rProd(r,x[i-1],xdigits); } if(verbose&VERBOSE_DATA) { tcout << _T("Trying degree ") << iparam(2) << degree << endl; tcout << _T("x:") << dparam(xdigits) << x << endl; } PSLQ pslq(x,digits,verbose); if(pslq.solve(6)) { tcout << _T("Found integer polynomial of degree ") << iparam(2) << degree << _T(".") << _T(" c(0)..c(") << degree << _T("):") << iparam(1) << pslq.getSolution() << endl; solutionFound = true; } else { if(verbose) { tcout << _T("No solution of degree ") << iparam(1) << degree << endl; } } } if(!solutionFound) { tcout << _T("No solution of degree [2..30] found.") << endl; } }
static void findIntegerRelation(const Array<BigReal> &a, int digits, int verbose) { BigRealVector x(a.size()); for(size_t i = 0; i < a.size(); i++) { x[i] = a[i]; } PSLQ pslq(x,digits,verbose); if(pslq.solve(6)) { tcout << _T("Integer relation:") << iparam(1) << pslq.getSolution() << endl; return; } else { tcout << _T("No solution found.") << endl; } }
static void setup (FileList *f, Element_List **U){ int i,k; Curve *curve; ReadParams (f->rea.fp); //option_set("FAMOFF", 1); if((i=iparam("NORDER-req"))!=UNSET){ iparam_set("LQUAD",i); iparam_set("MQUAD",i); } *U = ReadMesh(f->rea.fp, strtok(f->rea.name,".")); /* Generate the list of elements */ U[0]->Cat_mem(); if(option("variable")) ReadOrderFile (strtok(f->rea.name,"."),*U); if(f->mesh.name) Get_Body(f->mesh.fp); return; }
bool PSLQ::solve(UINT maxDigits) { const BigReal maxNorm = rSqrt(sqr(e(1,maxDigits+1)-1)*m_x.getDimension(),10); const BigRealMatrix H = createH(); m_A = createHermiteReducingMatrix(H); BigRealMatrix AHQ = m_A * H; // N x (N-1)-matrix tcout << _T("Digits in calculation :") << iparam(3) << m_digits << endl << _T("Max number of digits in solution:") << iparam(3) << maxDigits << endl << _T("Max bound :") << dparam(5) << maxNorm << endl; for(;;) { m_minBound = rQuot(BIGREAL_1, getMaxDiagElement(AHQ), 10); if(m_minBound > maxNorm) { return false; // we are out of digits } const int r = findPivotRow(AHQ); // Step 1: Exchange. r = [0..N-2] if(m_verbose&VERBOSE_PIVOT) { tcout << _T("Pivotrow:") << r << endl; } m_A.swapRows(r, r+1); AHQ.swapRows(r, r+1); if(r != m_n - 2) { // Step 2: Corner #ifdef TEST_ROTATION BigRealMatrix AHQTest = AHQ; AHQTest *= RotationMatrix1(AHQTest, r); #endif // TEST_ROTATION AHQ *= RotationMatrix(AHQ, r); } // Step 3: Reduction #ifdef TEST_REDUCEEXACT if(m_verbose&VERBOSE_MATRIX) { const BigRealMatrix D0 = createHermiteReducingMatrix0(AHQ); const BigRealMatrix D0AHQ = D0 * AHQ; tcout << _T("Hermite reducing Matrix D0:") << endl << dparam(8) << D0; tcout << _T("D0*AHQ:") << endl << dparam(8) << D0AHQ; } #endif const BigRealMatrix D = createHermiteReducingMatrix(AHQ); if(m_verbose&VERBOSE_MATRIX) { tcout << _T("Hermite reducing Matrix D:") << endl << iparam(6) << D; } m_A = D * m_A; AHQ = D * AHQ; if(m_verbose&VERBOSE_MATRIX) { tcout << _T("AHQ:") << endl << dparam(8) << AHQ; tcout << _T("A:" ) << endl << iparam(16) << m_A; } // Step 4: check Termination try { const BigRealMatrix Ainv = round(inverse(m_A)); const BigRealVector y = m_x * Ainv; const int z = getZeroComponent(y); if(z >= 0) { if(m_verbose&VERBOSE_INVA) { tcout << _T("inv(A):") << endl << iparam(12) << Ainv; } if(m_verbose&VERBOSE_DATA) { tcout << _T("column:") << z << endl; } m_solution = Ainv.getColumn(z); return true; } } catch(Exception e) { return false; // Occurs when m_A is singular (Exception comes from inverse(m_A)) } } }
static void parse_util_args (int argc, char *argv[], FileList *f) { char c; int i; char fname[FILENAME_MAX]; if (argc == 0) { fputs (usage, stderr); exit (1); } option_set("SingMesh",0); while (--argc && (*++argv)[0] == '-') { while (c = *++argv[0]) /* more to parse... */ switch (c) { case 'b': option_set("Body",1); break; case 'e': if (*++argv[0]) option_set("ELMTID", atoi(*argv)); else { option_set("ELMTID", atoi(*++argv)); argc--; } while(*++argv[0]); /* skip over whole number */ case 'R': option_set("Range",1); break; case 'g': option_set("SingMesh",1); break; case 's': option_set("Spre",1); break; case 'q': option_set("Qpts",1); break; case 'f': option_set("FEstorage",1); break; case 'S': option_set("SMformat",1); break; default: fprintf(stderr, "%s: unknown option -- %c\n", prog, c); break; } } #if DIM ==2 if(iparam("NORDER-req") == UNSET) iparam_set("NORDER-req",8); #endif /* open the .rea file */ if ((*argv)[0] == '-') { f->rea.fp = stdin; } else { strcpy (fname, *argv); if ((f->rea.fp = fopen(fname, "r")) == (FILE*) NULL) { sprintf(fname, "%s.rea", *argv); if ((f->rea.fp = fopen(fname, "r")) == (FILE*) NULL) { fprintf(stderr, "%s: unable to open the input file -- %s or %s\n", prog, *argv, fname); exit(1); } } f->rea.name = strdup(fname); } if (option("verbose")) { fprintf (stderr, "%s: in = %s, rea = %s, out = %s\n", prog, f->in.name ? f->in.name : "<stdin>", f->rea.name, f->out.name ? f->out.name : "<stdout>"); } return; }
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; }
Element_List *Grid::gen_aux_field(){ int L, qa, qb, qc=0, k; char buf[BUFSIZ]; char buf_a[BUFSIZ]; Element **new_E; register int i; option_set("NZ",1); option_set("NZTOT",1); /* set up modes and quadrature points */ if(!( L = iparam("MODES"))) {fputs("ReadMesh: Number of modes not specified\n",stderr);exit(-1);} /* note quadrature order reset for variable order runs */ if(qa = iparam("LQUAD")); else qa = L + 1; if(qb = iparam("MQUAD")); else qb = L; if(qc = iparam("NQUAD")); else qc = L; iparam_set("ELEMENTS", nel); /* Set up a new element vector */ QGmax = max(max(qa,qb),qc); LGmax = L; new_E = (Element**) malloc(nel*sizeof(Element*)); Coord X; X.x = dvector(0,Max_Nverts-1); X.y = dvector(0,Max_Nverts-1); X.z = dvector(0,Max_Nverts-1); /* Read in mesh information */ for(k = 0; k < nel; k++) { for(i=0;i<nverts[k];++i){ X.x[i] = xcoords[vertids[k][vertexmap[k][i]]]; X.y[i] = ycoords[vertids[k][vertexmap[k][i]]]; X.z[i] = zcoords[vertids[k][vertexmap[k][i]]]; } switch(nverts[k]){ case 4: new_E[k] = new Tet(k,'u', L, qa, qb, qb, &X); break; case 8: new_E[k] = new Hex(k,'u', L, qa, qa, qa, &X); break; case 6: new_E[k] = new Prism(k,'u', L, qa, qa, qb, &X); break; case 5: new_E[k] = new Pyr(k,'u', L, qa, qa, qb, &X); break; } } for(k = 0; k < nel-1; ++k) new_E[k]->next = new_E[k+1]; new_E[k]->next = (Element*) NULL; Element_List* E_List = (Element_List*) new Element_List(new_E, nel); E_List->Cat_mem(); Tri_work(); Quad_work(); for(k = 0; k < nel; ++k) new_E[k]->set_curved_elmt(E_List); for(k = 0; k < nel; ++k) new_E[k]->set_geofac(); return E_List; }
void solve_boundary(Element_List **V, Element_List **Vf, double *rhs, double *u0, Bsystem **Vbsys){ int eDIM = V[0]->flist[0]->dim(); const int nsolve = Vbsys[eDIM]->nsolve; int info; Bsystem *B = Vbsys[0], *PB = Vbsys[eDIM]; if(nsolve){ const int bwidth = PB->Gmat->bwidth_a; if(B->rslv){ /* recursive Static condensation solver */ Rsolver *R = PB->rslv; int nrecur = R->nrecur; int aslv = R->rdata[nrecur-1].cstart, bw = R->Ainfo.bwidth_a; Recur_setrhs(R,rhs); if(PB->singular) rhs[PB->singular-1] = 0.0; if(B->smeth == direct){ if(aslv) if(2*bw < aslv){ /* banded matrix */ error_msg(error in solve_boundary_pressure); } else /* symmetric matrix */ dsptrs('L', aslv, 1, R->A.inva, R->A.pivota, rhs, aslv, info); } else{ error_msg(Implement recursive iterative solver); /*Recur_Bsolve_CG(PB,rhs,U->flist[0]->type);*/ } Recur_backslv(R,rhs,'n'); } else{ if(PB->singular) rhs[PB->singular-1] = 0.0; if(B->smeth == iterative){ if(iparam("ITER_PCR")){ Bsolve_Stokes_PCR(V, Vbsys, rhs); } else Bsolve_Stokes_PCG(V, Vbsys, rhs); } else{ if(B->lambda->wave){ if(3*bwidth < nsolve){ /* banded matrix */ error_msg(pack non-symmetrix solver not completed); } else /* symmetric matrix */ dgetrs('N', nsolve,1, *PB->Gmat->inva, nsolve, PB->Gmat->pivota, rhs, nsolve,info); } else{ if(2*bwidth < nsolve) /* banded matrix */ dpbtrs('L', nsolve, bwidth-1, 1, *PB->Gmat->inva, bwidth, rhs, nsolve, info); else /* symmetric matrix */ dsptrs('L', nsolve,1, *PB->Gmat->inva, PB->Gmat->pivota, rhs, nsolve,info); } } } } /* add intial conditions for pressure and internal velocity solve*/ dvadd(PB->nglobal,u0,1,rhs,1,rhs,1); ScatrBndry_Stokes(rhs,V,Vbsys); }
void Analyser (Domain *omega, int step, double time) { FILE *fp[2]; int nfields = omega->U->fhead->dim()+1; int i; Element_List **V; char fname[FILENAME_MAX]; double step_length; dparam_set("t", time); V = (Element_List**) malloc(nfields*sizeof(Element_List*)); /* .......... Field Files ......... */ V[0] = omega->U; V[1] = omega->V; V[2] = omega->W; V[3] = omega->P; if(init){ verbose = option("verbose"); iostep = iparam("IOSTEP"); hisstep = option("hisstep"); if(!hisstep) hisstep = iparam("HISSTEP"); nsteps = iparam("NSTEPS"); timeavg = option("timeavg"); if (omega->his_list) hisHeader (omega); init = 0; } /* .......... General Output ......... */ step_length = (clock()-last_time)/(double)CLOCKS_PER_SEC; last_time = clock(); ROOTONLY fprintf(stdout, "Time step = %d, Time = %g Cpu-Time = %g\n", step, time, step_length); fflush(stdout); if (step == 0){ /* Everything else is for step > 0 */ if (omega->his_list) /* Do initial history point */ History (omega, time); return; } if ((step % hisstep) == 0){ if (omega->his_list){ History (omega, time); fflush(omega->his_file); } forces(omega,step,time); if (option ("SurInflow") == 1) { surf_inflow(omega,step,time); } ROOTONLY fflush(omega->fce_file); /* flush stdout at step as well */ ROOTONLY fflush(stdout); if(option("SurForce")||option("SurInflow")){ cnt_srf_elements(omega); } if(verbose){ if(omega->soln) for(i=0;i<nfields;++i) V[i]->Terror(omega->soln[i]); else V[0]->Terror("0.0"); } } if(option("SurForce")||option("SurInflow")){ int a = cnt_srf_elements(omega); } if (step % iostep == 0 && step < nsteps) { if (option ("checkpt")) { DO_PARALLEL{ if(option("SLICES")&&check_number<100){ sprintf (fname, "%s_%d.chk.hdr.%d", omega->name, check_number, pllinfo.procid); fp[0] = fopen(fname,"w"); sprintf (fname, "%s_%d.chk.dat.%d", omega->name, check_number, pllinfo.procid); fp[1] = fopen(fname,"w"); ++check_number; } else{ sprintf (fname, "%s.chk.hdr.%d", omega->name, pllinfo.procid); fp[0] = fopen(fname,"w"); sprintf (fname, "%s.chk.dat.%d", omega->name, pllinfo.procid); fp[1] = fopen(fname,"w"); } Writefld (fp, omega->name, step, time, nfields, V); fclose(fp[0]); fclose(fp[1]); } else{ if(option("SLICES")&&check_number<100){ sprintf (fname, "%s_%d.chk", omega->name,check_number); ++check_number; } else sprintf (fname, "%s.chk", omega->name); fp[1] = fp[0] = fopen(fname,"w"); Writefld (fp, omega->name, step, time, nfields, V); fclose(fp[0]); } }