Search in sources :

Example 6 with SolverStatus

use of cbit.vcell.solver.server.SolverStatus in project vcell by virtualcell.

the class CVodeSolverStandalone method initialize.

/**
 *  This method takes the place of the old runUnsteady()...
 */
protected void initialize() throws SolverException {
    fireSolverStarting(SimulationMessage.MESSAGE_SOLVEREVENT_STARTING_INIT);
    super.initialize();
    String inputFilename = getInputFilename();
    setSolverStatus(new SolverStatus(SolverStatus.SOLVER_RUNNING, SimulationMessage.MESSAGE_SOLVER_RUNNING_INPUT_FILE));
    fireSolverStarting(SimulationMessage.MESSAGE_SOLVEREVENT_STARTING_INPUT_FILE);
    PrintWriter pw = null;
    try {
        pw = new java.io.PrintWriter(inputFilename);
        CVodeFileWriter cvodeFileWriter = new CVodeFileWriter(pw, simTask, bMessaging);
        cvodeFileWriter.write();
    } catch (Exception e) {
        setSolverStatus(new SolverStatus(SolverStatus.SOLVER_ABORTED, SimulationMessage.solverAborted("CVODE solver could not generate input file: " + e.getMessage())));
        e.printStackTrace(System.out);
        throw new SolverException("CVODE solver could not generate input file: " + e.getMessage());
    } finally {
        if (pw != null) {
            pw.close();
        }
    }
    setSolverStatus(new SolverStatus(SolverStatus.SOLVER_RUNNING, SimulationMessage.MESSAGE_SOLVER_RUNNING_START));
    setMathExecutable(new MathExecutable(getMathExecutableCommand(), getSaveDirectory()));
}
Also used : PrintWriter(java.io.PrintWriter) SolverException(cbit.vcell.solver.SolverException) MathExecutable(cbit.vcell.solvers.MathExecutable) SolverStatus(cbit.vcell.solver.server.SolverStatus) IOException(java.io.IOException) SolverException(cbit.vcell.solver.SolverException) PrintWriter(java.io.PrintWriter)

Example 7 with SolverStatus

use of cbit.vcell.solver.server.SolverStatus in project vcell by virtualcell.

the class AbstractJavaSolver method runSolver.

/**
 * Insert the method's description here.
 * Creation date: (6/26/2001 3:08:31 PM)
 */
public void runSolver() {
    try {
        fieldRunning = true;
        setSolverStatus(new SolverStatus(SolverStatus.SOLVER_STARTING, SimulationMessage.MESSAGE_SOLVER_STARTING_INIT));
        fireSolverStarting(SimulationMessage.MESSAGE_SOLVEREVENT_STARTING_INIT);
        initialize();
        setSolverStatus(new SolverStatus(SolverStatus.SOLVER_RUNNING, SimulationMessage.MESSAGE_SOLVER_RUNNING_START));
        fireSolverProgress(getProgress());
        integrate();
        setSolverStatus(new SolverStatus(SolverStatus.SOLVER_FINISHED, SimulationMessage.MESSAGE_SOLVER_FINISHED));
        fireSolverFinished();
    } catch (SolverException integratorException) {
        lg.error(integratorException.getMessage(), integratorException);
        SimulationMessage simulationMessage = SimulationMessage.solverAborted(integratorException.getMessage());
        setSolverStatus(new SolverStatus(SolverStatus.SOLVER_ABORTED, simulationMessage));
        fireSolverAborted(simulationMessage);
    } catch (IOException ioException) {
        lg.error(ioException.getMessage(), ioException);
        SimulationMessage simulationMessage = SimulationMessage.solverAborted(ioException.getMessage());
        setSolverStatus(new SolverStatus(SolverStatus.SOLVER_ABORTED, simulationMessage));
        fireSolverAborted(simulationMessage);
    } catch (UserStopException userStopException) {
        lg.error(userStopException.getMessage(), userStopException);
        setSolverStatus(new SolverStatus(SolverStatus.SOLVER_STOPPED, SimulationMessage.solverStopped(userStopException.getMessage())));
        fireSolverStopped();
    } catch (Exception e) {
        lg.error("AbstractJavaSolver.runSolver() : Caught Throwable instead of SolverException -- THIS EXCEPTION SHOULD NOT HAPPEN!", e);
        SimulationMessage simulationMessage = SimulationMessage.solverAborted(e.getMessage());
        setSolverStatus(new SolverStatus(SolverStatus.SOLVER_ABORTED, simulationMessage));
        fireSolverAborted(simulationMessage);
    } finally {
        fieldRunning = false;
    }
}
Also used : SimulationMessage(cbit.vcell.solver.server.SimulationMessage) SolverException(cbit.vcell.solver.SolverException) IOException(java.io.IOException) UserStopException(cbit.vcell.solver.UserStopException) SolverStatus(cbit.vcell.solver.server.SolverStatus) UserStopException(cbit.vcell.solver.UserStopException) IOException(java.io.IOException) SolverException(cbit.vcell.solver.SolverException)

Example 8 with SolverStatus

use of cbit.vcell.solver.server.SolverStatus in project vcell by virtualcell.

the class IDASolverStandalone method initialize.

/**
 *  This method takes the place of the old runUnsteady()...
 */
protected void initialize() throws SolverException {
    fireSolverStarting(SimulationMessage.MESSAGE_SOLVEREVENT_STARTING_INIT);
    super.initialize();
    String inputFilename = getInputFilename();
    setSolverStatus(new SolverStatus(SolverStatus.SOLVER_RUNNING, SimulationMessage.MESSAGE_SOLVER_RUNNING_INPUT_FILE));
    fireSolverStarting(SimulationMessage.MESSAGE_SOLVEREVENT_STARTING_INPUT_FILE);
    PrintWriter pw = null;
    try {
        pw = new PrintWriter(inputFilename);
        IDAFileWriter idaFileWriter = new IDAFileWriter(pw, simTask, bMessaging);
        idaFileWriter.write();
    } catch (Exception e) {
        setSolverStatus(new SolverStatus(SolverStatus.SOLVER_ABORTED, SimulationMessage.solverAborted("Could not generate input file: " + e.getMessage())));
        e.printStackTrace(System.out);
        throw new SolverException("IDA solver could not generate input file: " + e.getMessage());
    } finally {
        if (pw != null) {
            pw.close();
        }
    }
    setSolverStatus(new SolverStatus(SolverStatus.SOLVER_RUNNING, SimulationMessage.MESSAGE_SOLVER_RUNNING_START));
    setMathExecutable(new MathExecutable(getMathExecutableCommand(), getSaveDirectory()));
}
Also used : SolverException(cbit.vcell.solver.SolverException) MathExecutable(cbit.vcell.solvers.MathExecutable) SolverStatus(cbit.vcell.solver.server.SolverStatus) IOException(java.io.IOException) SolverException(cbit.vcell.solver.SolverException) PrintWriter(java.io.PrintWriter)

Example 9 with SolverStatus

use of cbit.vcell.solver.server.SolverStatus in project vcell by virtualcell.

the class MovingBoundarySolver method initialize.

/**
 * This method was created by a SmartGuide.
 */
protected void initialize() throws SolverException {
    writeFunctionsFile();
    setSolverStatus(new SolverStatus(SolverStatus.SOLVER_RUNNING, SimulationMessage.MESSAGE_SOLVER_RUNNING_INIT));
    fireSolverStarting(SimulationMessage.MESSAGE_SOLVEREVENT_STARTING_INIT);
    setSolverStatus(new SolverStatus(SolverStatus.SOLVER_RUNNING, SimulationMessage.MESSAGE_SOLVER_RUNNING_START));
    try (PrintWriter pw = new PrintWriter(inputFilename)) {
        MovingBoundaryFileWriter mbfw = new MovingBoundaryFileWriter(pw, simTask, resampledGeometry, bMessaging, getBaseName());
        mbfw.write();
    } catch (Exception e) {
        throw new SolverException("Can't open input file " + inputFilename, e);
    }
    setMathExecutable(new MathExecutable(getMathExecutableCommand(), getSaveDirectory()));
}
Also used : SolverException(cbit.vcell.solver.SolverException) SolverStatus(cbit.vcell.solver.server.SolverStatus) IOException(java.io.IOException) SolverException(cbit.vcell.solver.SolverException) PrintWriter(java.io.PrintWriter)

Example 10 with SolverStatus

use of cbit.vcell.solver.server.SolverStatus in project vcell by virtualcell.

the class GibsonSolver method initialize.

/**
 *  This method takes the place of the old runUnsteady()...
 */
protected void initialize() throws SolverException {
    if (lg.isTraceEnabled())
        lg.trace("StochSolver.initialize()");
    fireSolverStarting(SimulationMessage.MESSAGE_SOLVEREVENT_STARTING_INIT);
    writeFunctionsFile();
    writeLogFile();
    String inputFilename = getInputFilename();
    if (lg.isTraceEnabled())
        lg.trace("StochSolver.initialize() baseName = " + getBaseName());
    setSolverStatus(new SolverStatus(SolverStatus.SOLVER_RUNNING, SimulationMessage.MESSAGE_SOLVER_RUNNING_INPUT_FILE));
    fireSolverStarting(SimulationMessage.MESSAGE_SOLVEREVENT_STARTING_INPUT_FILE);
    PrintWriter pw = null;
    try {
        pw = new PrintWriter(inputFilename);
        StochFileWriter stFileWriter = new StochFileWriter(pw, simTask, bMessaging);
        stFileWriter.write();
    } catch (Exception e) {
        setSolverStatus(new SolverStatus(SolverStatus.SOLVER_ABORTED, SimulationMessage.solverAborted("Could not generate input file: " + e.getMessage())));
        e.printStackTrace(System.out);
        throw new SolverException("solver input file exception: " + e.getMessage());
    } finally {
        if (pw != null) {
            pw.close();
        }
    }
    setSolverStatus(new SolverStatus(SolverStatus.SOLVER_RUNNING, SimulationMessage.MESSAGE_SOLVER_RUNNING_START));
    // get executable path+name.
    setMathExecutable(new MathExecutable(getMathExecutableCommand(), getSaveDirectory()));
// setMathExecutable(new cbit.vcell.solvers.MathExecutable(executableName + " gibson " + getBaseName() + ".stochInput" + " " + getBaseName() + ".stoch"));
}
Also used : SolverException(cbit.vcell.solver.SolverException) MathExecutable(cbit.vcell.solvers.MathExecutable) SolverStatus(cbit.vcell.solver.server.SolverStatus) IOException(java.io.IOException) ExpressionException(cbit.vcell.parser.ExpressionException) FileNotFoundException(java.io.FileNotFoundException) SolverException(cbit.vcell.solver.SolverException) MathException(cbit.vcell.math.MathException) PrintWriter(java.io.PrintWriter)

Aggregations

SolverStatus (cbit.vcell.solver.server.SolverStatus)25 IOException (java.io.IOException)14 SimulationJob (cbit.vcell.solver.SimulationJob)12 SimulationTask (cbit.vcell.messaging.server.SimulationTask)11 SolverException (cbit.vcell.solver.SolverException)11 File (java.io.File)11 PrintWriter (java.io.PrintWriter)8 FVSolverStandalone (cbit.vcell.solvers.FVSolverStandalone)7 Simulation (cbit.vcell.solver.Simulation)6 MathExecutable (cbit.vcell.solvers.MathExecutable)6 UserCancelException (org.vcell.util.UserCancelException)6 ImageException (cbit.image.ImageException)5 FieldDataIdentifierSpec (cbit.vcell.field.FieldDataIdentifierSpec)5 ExpressionException (cbit.vcell.parser.ExpressionException)5 FieldFunctionArguments (cbit.vcell.field.FieldFunctionArguments)4 TempSimulation (cbit.vcell.solver.TempSimulation)4 Solver (cbit.vcell.solver.server.Solver)4 MathException (cbit.vcell.math.MathException)3 ODEDataBlock (cbit.vcell.simdata.ODEDataBlock)3 SimulationData (cbit.vcell.simdata.SimulationData)3