Search in sources :

Example 1 with SimulationDataSetRef

use of cbit.vcell.client.pyvcellproxy.SimulationDataSetRef in project vcell by virtualcell.

the class VCellClientDataServiceImpl method createSimulationDataSetRef.

public static SimulationDataSetRef createSimulationDataSetRef(Simulation simulation, VCDocument modelDocument, int jobIndex, boolean isLocal) {
    SimulationDataSetRef simulationDataSetReference = new SimulationDataSetRef();
    Origin origin = simulation.getMathDescription().getGeometry().getOrigin();
    Extent extent = simulation.getMathDescription().getGeometry().getExtent();
    SimulationInfo simInfo = simulation.getSimulationInfo();
    simulationDataSetReference.setSimName(simInfo.getName());
    // String simName = simInfo.getName();
    // if (jobIndex!=0){
    // simName = simName + " job#"+String.valueOf(jobIndex);
    // }
    final String modelId;
    final boolean isMathModel;
    final String modelName;
    final String simContextName;
    if (modelDocument != null) {
        modelId = modelDocument.getVersion().getVersionKey().toString();
        isMathModel = (modelDocument instanceof MathModel);
        modelName = modelDocument.getName();
        if (modelDocument instanceof BioModel && simulation.getSimulationOwner() != null) {
            simContextName = simulation.getSimulationOwner().getName();
        } else {
            simContextName = null;
        }
    } else {
        modelId = "no id";
        isMathModel = false;
        modelName = "no model";
        simContextName = null;
    }
    simulationDataSetReference.setSimId(simInfo.getAuthoritativeVCSimulationIdentifier().getSimulationKey().toString());
    simulationDataSetReference.setModelId(modelId);
    simulationDataSetReference.setUsername(simInfo.getVersion().getOwner().getName());
    simulationDataSetReference.setUserkey(simInfo.getVersion().getOwner().getID().toString());
    simulationDataSetReference.setIsMathModel(isMathModel);
    simulationDataSetReference.setJobIndex(jobIndex);
    simulationDataSetReference.setModelName(modelName);
    simulationDataSetReference.setOriginXYZ(Arrays.asList(new Double[] { origin.getX(), origin.getY(), origin.getZ() }));
    simulationDataSetReference.setExtentXYZ(Arrays.asList(new Double[] { extent.getX(), extent.getY(), extent.getZ() }));
    if (simContextName != null) {
        simulationDataSetReference.setSimulationContextName(simContextName);
    }
    simulationDataSetReference.setSimName(simInfo.getName());
    boolean movingBoundarySolver = simulation.getSolverTaskDescription().getSolverDescription().isMovingBoundarySolver();
    simulationDataSetReference.setIsTimeVaryingMesh(movingBoundarySolver);
    simulationDataSetReference.setIsLocal(isLocal);
    return simulationDataSetReference;
}
Also used : Origin(org.vcell.util.Origin) MathModel(cbit.vcell.mathmodel.MathModel) Extent(org.vcell.util.Extent) BioModel(cbit.vcell.biomodel.BioModel) SimulationDataSetRef(cbit.vcell.client.pyvcellproxy.SimulationDataSetRef) SimulationInfo(cbit.vcell.solver.SimulationInfo)

Example 2 with SimulationDataSetRef

use of cbit.vcell.client.pyvcellproxy.SimulationDataSetRef in project vcell by virtualcell.

the class VCellClientDataServiceImpl method getSimsFromOpenModels.

@Override
public List<SimulationDataSetRef> getSimsFromOpenModels() {
    ArrayList<SimulationDataSetRef> simulationDataSetRefs = new ArrayList<SimulationDataSetRef>();
    for (TopLevelWindowManager windowManager : vcellClient.getMdiManager().getWindowManagers()) {
        Simulation[] simulations = null;
        VCDocument modelDocument = null;
        if (windowManager instanceof BioModelWindowManager) {
            BioModelWindowManager selectedBioWindowManager = (BioModelWindowManager) windowManager;
            BioModel bioModel = selectedBioWindowManager.getBioModel();
            simulations = bioModel.getSimulations();
            modelDocument = bioModel;
        // simOwnerCount = bioModel.getNumSimulationContexts();
        } else if (windowManager instanceof MathModelWindowManager) {
            MathModelWindowManager selectedMathWindowManager = (MathModelWindowManager) windowManager;
            MathModel mathModel = selectedMathWindowManager.getMathModel();
            simulations = mathModel.getSimulations();
            modelDocument = mathModel;
        // simOwnerCount = 1;
        }
        if (simulations != null) {
            for (Simulation simulation : simulations) {
                if (!isVtkSupported(simulation)) {
                    continue;
                }
                Origin origin = simulation.getMathDescription().getGeometry().getOrigin();
                Extent extent = simulation.getMathDescription().getGeometry().getExtent();
                SimulationInfo simInfo = simulation.getSimulationInfo();
                SimulationStatus simStatus = vcellClient.getRequestManager().getServerSimulationStatus(simInfo);
                for (int jobIndex = 0; jobIndex < simulation.getScanCount(); jobIndex++) {
                    if (simStatus != null && simStatus.getHasData()) {
                        SimulationDataSetRef simulationDataSetReference = VCellClientDataServiceImpl.createSimulationDataSetRef(simulation, modelDocument, jobIndex, false);
                        simulationDataSetRefs.add(simulationDataSetReference);
                    }
                }
            }
        }
    }
    File localSimDir = ResourceUtil.getLocalSimDir(User.tempUser.getName());
    String[] simtaskFilenames = localSimDir.list((dir, name) -> (name.endsWith(".simtask.xml")));
    for (String simtaskFilename : simtaskFilenames) {
        try {
            SimulationTask simTask = XmlHelper.XMLToSimTask(org.apache.commons.io.FileUtils.readFileToString(new File(localSimDir, simtaskFilename)));
            VCDocument modelDocument = null;
            SimulationDataSetRef simulationDataSetReference = VCellClientDataServiceImpl.createSimulationDataSetRef(simTask.getSimulation(), modelDocument, simTask.getSimulationJob().getJobIndex(), true);
            simulationDataSetRefs.add(simulationDataSetReference);
        } catch (ExpressionException | XmlParseException | IOException e) {
            e.printStackTrace();
        }
    }
    return simulationDataSetRefs;
}
Also used : Origin(org.vcell.util.Origin) MathModel(cbit.vcell.mathmodel.MathModel) SimulationTask(cbit.vcell.messaging.server.SimulationTask) VCDocument(org.vcell.util.document.VCDocument) TopLevelWindowManager(cbit.vcell.client.TopLevelWindowManager) Extent(org.vcell.util.Extent) ArrayList(java.util.ArrayList) XmlParseException(cbit.vcell.xml.XmlParseException) IOException(java.io.IOException) SimulationDataSetRef(cbit.vcell.client.pyvcellproxy.SimulationDataSetRef) MathModelWindowManager(cbit.vcell.client.MathModelWindowManager) ExpressionException(cbit.vcell.parser.ExpressionException) Simulation(cbit.vcell.solver.Simulation) BioModelWindowManager(cbit.vcell.client.BioModelWindowManager) SimulationStatus(cbit.vcell.server.SimulationStatus) BioModel(cbit.vcell.biomodel.BioModel) File(java.io.File) SimulationInfo(cbit.vcell.solver.SimulationInfo)

Aggregations

BioModel (cbit.vcell.biomodel.BioModel)2 SimulationDataSetRef (cbit.vcell.client.pyvcellproxy.SimulationDataSetRef)2 MathModel (cbit.vcell.mathmodel.MathModel)2 SimulationInfo (cbit.vcell.solver.SimulationInfo)2 Extent (org.vcell.util.Extent)2 Origin (org.vcell.util.Origin)2 BioModelWindowManager (cbit.vcell.client.BioModelWindowManager)1 MathModelWindowManager (cbit.vcell.client.MathModelWindowManager)1 TopLevelWindowManager (cbit.vcell.client.TopLevelWindowManager)1 SimulationTask (cbit.vcell.messaging.server.SimulationTask)1 ExpressionException (cbit.vcell.parser.ExpressionException)1 SimulationStatus (cbit.vcell.server.SimulationStatus)1 Simulation (cbit.vcell.solver.Simulation)1 XmlParseException (cbit.vcell.xml.XmlParseException)1 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 VCDocument (org.vcell.util.document.VCDocument)1