Search in sources :

Example 1 with ComsolServiceFactory

use of org.vcell.solver.comsol.service.ComsolServiceFactory in project vcell by virtualcell.

the class ComsolSolver method initialize.

@Override
protected void initialize() throws SolverException {
    try {
        this.vccModel = ComsolModelBuilder.getVCCModel(getSimulationJob());
        // write mesh file
        File meshFile = new File(getSaveDirectory(), simTask.getSimulationJob().getSimulationJobID() + SimDataConstants.MESHFILE_EXTENSION);
        try (FileOutputStream fos = new FileOutputStream(meshFile)) {
            simTask.getSimulation().getMathDescription().getGeometry().getGeometrySurfaceDescription().updateAll();
            CartesianMesh mesh = CartesianMesh.createSimpleCartesianMesh(simTask.getSimulation().getMathDescription().getGeometry());
            mesh.write(new PrintStream(new BufferedOutputStream(fos)));
        } catch (Exception e) {
            e.printStackTrace(System.out);
            throw new SolverException(e.getMessage());
        }
        ComsolServiceFactory factory = ComsolServiceFactory.instance;
        if (factory == null) {
            throw new RuntimeException("no Comsol Service available");
        }
        this.comsolService = factory.newComsolService();
    } catch (ExpressionException e) {
        e.printStackTrace();
        throw new SolverException("failed to generate VCell Comsol Model in ComsolSolver: " + e.getMessage(), e);
    }
}
Also used : PrintStream(java.io.PrintStream) CartesianMesh(cbit.vcell.solvers.CartesianMesh) FileOutputStream(java.io.FileOutputStream) SolverException(cbit.vcell.solver.SolverException) ComsolServiceFactory(org.vcell.solver.comsol.service.ComsolServiceFactory) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream) IOException(java.io.IOException) ExpressionException(cbit.vcell.parser.ExpressionException) SolverException(cbit.vcell.solver.SolverException) ExpressionException(cbit.vcell.parser.ExpressionException)

Aggregations

ExpressionException (cbit.vcell.parser.ExpressionException)1 SolverException (cbit.vcell.solver.SolverException)1 CartesianMesh (cbit.vcell.solvers.CartesianMesh)1 BufferedOutputStream (java.io.BufferedOutputStream)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 PrintStream (java.io.PrintStream)1 ComsolServiceFactory (org.vcell.solver.comsol.service.ComsolServiceFactory)1