Search in sources :

Example 21 with Text

use of gov.sandia.n2a.language.type.Text in project n2a by frothga.

the class ReadMatrix method open.

public Matrix open(Instance context) {
    Simulator simulator = Simulator.instance.get();
    // absence of simulator indicates analysis phase, so opening files is unnecessary
    if (simulator == null)
        return null;
    String path = ((Text) operands[0].eval(context)).value;
    Object A = simulator.holders.get(path);
    if (A == null) {
        A = Matrix.factory(simulator.jobDir.resolve(path));
        simulator.holders.put(path, A);
    } else if (!(A instanceof Matrix)) {
        Backend.err.get().println("ERROR: Reopening file as a different resource type.");
        throw new Backend.AbortRun();
    }
    return (Matrix) A;
}
Also used : Backend(gov.sandia.n2a.plugins.extpoints.Backend) Matrix(gov.sandia.n2a.language.type.Matrix) Text(gov.sandia.n2a.language.type.Text) Simulator(gov.sandia.n2a.backend.internal.Simulator)

Aggregations

Text (gov.sandia.n2a.language.type.Text)21 Matrix (gov.sandia.n2a.language.type.Matrix)12 Scalar (gov.sandia.n2a.language.type.Scalar)12 Constant (gov.sandia.n2a.language.Constant)10 Operator (gov.sandia.n2a.language.Operator)10 Type (gov.sandia.n2a.language.Type)10 AccessVariable (gov.sandia.n2a.language.AccessVariable)7 Visitor (gov.sandia.n2a.language.Visitor)7 BuildMatrix (gov.sandia.n2a.language.BuildMatrix)6 Input (gov.sandia.n2a.language.function.Input)6 Output (gov.sandia.n2a.language.function.Output)6 ReadMatrix (gov.sandia.n2a.language.function.ReadMatrix)6 Simulator (gov.sandia.n2a.backend.internal.Simulator)5 EquationSet (gov.sandia.n2a.eqset.EquationSet)5 Variable (gov.sandia.n2a.eqset.Variable)5 Add (gov.sandia.n2a.language.operator.Add)5 Event (gov.sandia.n2a.language.function.Event)4 MatrixDense (gov.sandia.n2a.linear.MatrixDense)4 Backend (gov.sandia.n2a.plugins.extpoints.Backend)3 ConnectionMatrix (gov.sandia.n2a.eqset.EquationSet.ConnectionMatrix)2