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;
}
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;
}
Aggregations