use of gov.sandia.n2a.backend.internal.EventStep in project n2a by frothga.
the class Input method getRow.
public Holder getRow(Instance context, Type op1, boolean time) {
Simulator simulator = Simulator.getSimulator(context);
// If we can't cache a line from the requested stream, then semantics of this function are lost, so give up.
if (simulator == null)
return null;
Holder H = null;
try {
// get an input holder
String path = ((Text) operands[0].eval(context)).value;
H = simulator.inputs.get(path);
if (H == null) {
H = new Holder();
if (// not ideal; reading stdin should be reserved for headless operation
path.isEmpty())
// not ideal; reading stdin should be reserved for headless operation
H.stream = new BufferedReader(new InputStreamReader(System.in));
else
H.stream = new BufferedReader(new FileReader(new File(path).getAbsoluteFile()));
// sqrt (epsilon for time representation (currently double)), about 1e-8
H.epsilon = Math.sqrt(Math.ulp(1.0));
if (simulator.currentEvent instanceof EventStep)
H.epsilon = Math.min(H.epsilon, ((EventStep) simulator.currentEvent).dt / 1000);
simulator.inputs.put(path, H);
}
if (op1 instanceof Scalar)
H.getRow(((Scalar) op1).value, time);
else
H.getRow(0, time);
} catch (IOException e) {
return null;
}
return H;
}
Aggregations