package initialconditions; import java.lang.*; import java.io.*; import main.BetterTokenizer; import main.Cell; import main.GeneralInput; /** Increments the value of its node along each row. The lowest value is in the lefthand column with incrementally higher values in each subsequent cell.
Input Parameters:
Node
StartValue
EndValue

*/ public class IncrementingIC extends InitialCondition { /** Value which will be given to lefthand column */ float startValue; /** Value which will be given to righthand column */ float endValue; public IncrementingIC() { } public IncrementingIC(String n, int start_value, int end_value) { node = n; startValue = start_value; endValue = end_value; } public void setModel(Cell [] cells) { int x, y; try { float val = startValue; for(x = 0; x < Cell.arrayWidth; x++) { for(y = 0; y < Cell.arrayHeight; y++) { Cell cell = cells[y * Cell.arrayWidth + x]; cell.setInitialValue(node, val); } val += (endValue - startValue) / (Cell.arrayWidth - 1f); } } catch(Exception e) { System.out.println(e.toString()); return; } } protected void loadParameter(String info, BetterTokenizer tokenizer) throws Exception { if(info.equals("StartValue")) { GeneralInput.nextToken(tokenizer); startValue = (float)tokenizer.nval; } else if(info.equals("EndValue")) { GeneralInput.nextToken(tokenizer); endValue = (float)tokenizer.nval; } else super.loadParameter(info, tokenizer); } public void toString(PrintWriter pw, String indent) { super.toString(pw, indent); pw.println(indent + "&StartValue\t" + startValue); pw.println(indent + "&EndValue\t" + endValue); } }