// Reads the next double. // Generates an error if next token is not double. public double readDouble() { if (!es.hasNextDouble()) { UTIL.errorMsg("Expected double. Instead: " + es.next()); } return(es.nextDouble()); }
// Reads the next integer. // Generates an error if next token is not integer. public int readInt() { if (!es.hasNextInt()) { UTIL.errorMsg("Expected integer. Instead: " + es.next()); } return(es.nextInt()); }
// Construct FE data scanner. // fileIn - name of the file containing data. public FeScanner(String fileIn) { try { es = new Scanner(fileIn); } catch (Exception E) { UTIL.errorMsg("Input file not found: " + fileIn); } es.useDelimiters(new char[] { ' ', '=', '\t' }); }
public StreamWriter getPrinter(String fileOut) { try { PR = new StreamWriter(new BufferedStream(new FileStream(fileOut, FileMode.Create, FileAccess.Write))); //PR.AutoFlush = true; } catch (Exception E) { UTIL.errorMsg("Cannot open output file: " + fileOut); } return(PR); }
public Scanner(String fileIn) { fileName = fileIn; try { es = new StreamReader(new BufferedStream(new FileStream(fileName, FileMode.Open, FileAccess.Read))); } catch (Exception E) { UTIL.errorMsg("File not found: " + fileIn); } read(); }
// Moves to line which follows a line with the word. public void moveAfterLineWithWord(String word) { while (es.hasNext()) { String varname = es.next().ToLower(); if (varname.Equals("#")) { es.readLine(); continue; } if (varname.Equals(word)) { es.readLine(); return; } } UTIL.errorMsg("moveAfterLineWithWord cannot find: " + word); }
// Construct Gauss integration rule. // nGauss - number of Gauss points in each direction // (excluding 14-point rule), // nDim - number of dimensions public GaussRule(int nGauss, int nDim) { if (!((nGauss >= 1 && nGauss <= 3) || nGauss == 14)) { UTIL.errorMsg("nGauss has forbidden value: " + nGauss); } if (!(nDim >= 1 && nDim <= 3)) { UTIL.errorMsg("GaussRule: nDim has forbidden value: " + nDim); } if (nGauss == 14) { nIntPoints = 14; } else { nIntPoints = 1; for (int i = 0; i < nDim; i++) { nIntPoints *= nGauss; } } xii = new double[nIntPoints]; wi = new double[nIntPoints]; if (nDim > 1) { eti = new double[nIntPoints]; } if (nDim > 2) { zei = new double[nIntPoints]; } if (nGauss == 14) { for (int i = 0; i < nGauss; i++) { xii[i] = X14[i]; eti[i] = Y14[i]; zei[i] = Z14[i]; wi[i] = (i < 8) ? Wa : Wb; } } else { int ip = 0; int n = nGauss - 1; switch (nDim) { case 1: for (int i = 0; i < nGauss; i++) { xii[ip] = X[n][i]; wi[ip++] = W[n][i]; } break; case 2: for (int i = 0; i < nGauss; i++) { for (int j = 0; j < nGauss; j++) { xii[ip] = X[n][i]; eti[ip] = X[n][j]; wi[ip++] = W[n][i] * W[n][j]; } } break; case 3: for (int i = 0; i < nGauss; i++) { for (int j = 0; j < nGauss; j++) { for (int k = 0; k < nGauss; k++) { xii[ip] = X[n][i]; eti[ip] = X[n][j]; zei[ip] = X[n][k]; wi[ip++] = W[n][i] * W[n][j] * W[n][k]; } } } break; } } }