Search in sources :

Example 36 with SimulationJob

use of cbit.vcell.solver.SimulationJob in project vcell by virtualcell.

the class RunSimulation2DOp method runFVSolverStandalone.

private static void runFVSolverStandalone(File simulationDataDir, Simulation sim, ClientTaskStatusSupport progressListener) throws Exception {
    int jobIndex = 0;
    SimulationTask simTask = new SimulationTask(new SimulationJob(sim, jobIndex, null), 0);
    SolverUtilities.prepareSolverExecutable(sim.getSolverTaskDescription().getSolverDescription());
    FVSolverStandalone fvSolver = new FVSolverStandalone(simTask, simulationDataDir, false);
    fvSolver.startSolver();
    // fvSolver.runSolver();
    SolverStatus status = fvSolver.getSolverStatus();
    while (status.getStatus() != SolverStatus.SOLVER_FINISHED && status.getStatus() != SolverStatus.SOLVER_ABORTED && status.getStatus() != SolverStatus.SOLVER_STOPPED) {
        if (progressListener != null) {
            progressListener.setProgress((int) (fvSolver.getProgress() * 100));
            if (progressListener.isInterrupted()) {
                fvSolver.stopSolver();
                throw UserCancelException.CANCEL_GENERIC;
            }
        }
        try {
            Thread.sleep(1000);
        } catch (InterruptedException ex) {
            ex.printStackTrace(System.out);
        // catch interrupted exception and ignore it, otherwise it will popup a dialog in user interface saying"sleep interrupted"
        }
        status = fvSolver.getSolverStatus();
    }
    if (status.getStatus() != SolverStatus.SOLVER_FINISHED) {
        throw new Exception("Sover did not finish normally." + status);
    }
}
Also used : SimulationTask(cbit.vcell.messaging.server.SimulationTask) SolverStatus(cbit.vcell.solver.server.SolverStatus) SimulationJob(cbit.vcell.solver.SimulationJob) FVSolverStandalone(cbit.vcell.solvers.FVSolverStandalone) UserCancelException(org.vcell.util.UserCancelException)

Aggregations

SimulationJob (cbit.vcell.solver.SimulationJob)36 SimulationTask (cbit.vcell.messaging.server.SimulationTask)26 Simulation (cbit.vcell.solver.Simulation)22 File (java.io.File)15 IOException (java.io.IOException)13 SolverStatus (cbit.vcell.solver.server.SolverStatus)12 FieldDataIdentifierSpec (cbit.vcell.field.FieldDataIdentifierSpec)10 SimulationContext (cbit.vcell.mapping.SimulationContext)10 ExpressionException (cbit.vcell.parser.ExpressionException)8 UserCancelException (org.vcell.util.UserCancelException)8 BioModel (cbit.vcell.biomodel.BioModel)7 FVSolverStandalone (cbit.vcell.solvers.FVSolverStandalone)7 PrintWriter (java.io.PrintWriter)7 FieldFunctionArguments (cbit.vcell.field.FieldFunctionArguments)6 MathDescription (cbit.vcell.math.MathDescription)6 TempSimulation (cbit.vcell.solver.TempSimulation)6 XmlParseException (cbit.vcell.xml.XmlParseException)6 XMLStreamException (javax.xml.stream.XMLStreamException)6 Geometry (cbit.vcell.geometry.Geometry)5 ImageException (cbit.image.ImageException)4