use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.
the class GeometryViewer method setGeometry.
/**
* Sets the geometry property (cbit.vcell.geometry.Geometry) value.
* @param geometry The new value for the property.
* @see #getGeometry
*/
public void setGeometry(Geometry newValue) {
if (ivjGeometry != newValue) {
try {
Geometry oldValue = getGeometry();
if (oldValue != null) {
oldValue.getGeometrySpec().removePropertyChangeListener(this);
}
if (newValue != null) {
newValue.getGeometrySpec().addPropertyChangeListener(this);
}
ivjGeometry = newValue;
if (ivjGeometry != null) {
refreshSize();
getImagePlaneManagerPanel1().setSourceDataInfo(null);
refreshSourceDataInfo();
getGeometrySubVolumePanel().setGeometry(ivjGeometry);
getCurveRendererGeometry1().setGeometry(ivjGeometry);
surfaceViewer.setGeometry(ivjGeometry);
resolvedLocationTablePanel.setGeometrySurfaceDescription(ivjGeometry.getGeometrySurfaceDescription());
if (ivjGeometry.getDimension() == 0) {
getJButtonChangeDomain().setEnabled(false);
tabbedPane.setVisible(false);
getJButtonReplace().setText(REPLACE_GEOMETRY_NONSPATIAL_LABEL);
getJButtonExport().setEnabled(false);
// compartmental
getIvjButtonEditImage().setEnabled(false);
} else {
getJButtonReplace().setText(REPLACE_GEOMETRY_SPATIAL_LABEL);
getJButtonChangeDomain().setEnabled(true);
getJButtonExport().setEnabled(documentWindowManager != null);
getIvjButtonEditImage().setEnabled(true);
tabbedPane.setVisible(true);
}
if (getGeometryOwner() instanceof SimulationContext) {
SimulationContext sc = (SimulationContext) getGeometryOwner();
boolean replaceEnabled = false;
switch(sc.getApplicationType()) {
case RULE_BASED_STOCHASTIC:
replaceEnabled = false;
break;
case NETWORK_DETERMINISTIC:
case NETWORK_STOCHASTIC:
replaceEnabled = true;
break;
}
getJButtonReplace().setEnabled(replaceEnabled);
}
updateSurfaceView();
}
firePropertyChange("geometry", oldValue, newValue);
} catch (java.lang.Throwable ivjExc) {
handleException(ivjExc);
}
}
;
}
use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.
the class GeometryViewer method resample.
private void resample() {
AsynchClientTask precomputeCurrentGeometryTask = new AsynchClientTask("computing surfaces for existing geometry", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
if (getGeometry().getGeometrySurfaceDescription().getRegionImage() == null) {
getGeometry().precomputeAll(new GeometryThumbnailImageFactoryAWT(), true, true);
}
}
};
AsynchClientTask sampleSizeTask = new AsynchClientTask("specify sample size", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
VCImage currSampledImage = getGeometry().getGeometrySpec().getSampledImage().getCurrentValue();
int currNumSamples = currSampledImage.getNumXYZ();
ISize currSize = new ISize(currSampledImage.getNumX(), currSampledImage.getNumY(), currSampledImage.getNumZ());
ISize sampleSize_times_ten = GeometrySpec.calulateResetSamplingSize(3, getGeometry().getExtent(), currNumSamples * 10);
ISize sampleSize_div_ten = GeometrySpec.calulateResetSamplingSize(3, getGeometry().getExtent(), currNumSamples / 10);
ISize sampleSize_1e2 = GeometrySpec.calulateResetSamplingSize(3, getGeometry().getExtent(), (int) 1e2);
ISize sampleSize_1e3 = GeometrySpec.calulateResetSamplingSize(3, getGeometry().getExtent(), (int) 1e3);
ISize sampleSize_1e4 = GeometrySpec.calulateResetSamplingSize(3, getGeometry().getExtent(), (int) 1e4);
ISize sampleSize_1e5 = GeometrySpec.calulateResetSamplingSize(3, getGeometry().getExtent(), (int) 1e5);
ISize sampleSize_1e6 = GeometrySpec.calulateResetSamplingSize(3, getGeometry().getExtent(), (int) 1e6);
ISize sampleSize_1e7 = GeometrySpec.calulateResetSamplingSize(3, getGeometry().getExtent(), (int) 1e7);
ISize sampleSize_1e8 = GeometrySpec.calulateResetSamplingSize(3, getGeometry().getExtent(), (int) 1e8);
String[] columnNames = new String[] { "description", "num samples", "(X,Y,Z)" };
Object[][] rowData = new Object[][] { new Object[] { "same size", new Integer(currSize.getXYZ()), currSize }, new Object[] { "10 times smaller", new Integer(sampleSize_div_ten.getXYZ()), sampleSize_div_ten }, new Object[] { "10 times bigger", new Integer(sampleSize_times_ten.getXYZ()), sampleSize_times_ten }, new Object[] { " 100 samples", new Integer(sampleSize_1e2.getXYZ()), sampleSize_1e2 }, new Object[] { " 1,000 samples", new Integer(sampleSize_1e3.getXYZ()), sampleSize_1e3 }, new Object[] { " 10,000 samples", new Integer(sampleSize_1e4.getXYZ()), sampleSize_1e4 }, new Object[] { " 100,000 samples", new Integer(sampleSize_1e5.getXYZ()), sampleSize_1e5 }, new Object[] { " 1,000,000 samples", new Integer(sampleSize_1e6.getXYZ()), sampleSize_1e6 }, new Object[] { " 10,000,000 samples", new Integer(sampleSize_1e7.getXYZ()), sampleSize_1e7 }, new Object[] { "100,000,000 samples", new Integer(sampleSize_1e8.getXYZ()), sampleSize_1e8 } };
int[] selectedRows = DialogUtils.showComponentOKCancelTableList(GeometryViewer.this, "sample size", columnNames, rowData, ListSelectionModel.SINGLE_SELECTION);
ISize sampleSize = (ISize) rowData[selectedRows[0]][2];
hashTable.put("sampleSize", sampleSize);
}
};
AsynchClientTask resampleTask = new AsynchClientTask("resample geometry", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
ISize sampleSize = (ISize) hashTable.get("sampleSize");
Geometry newGeometry = RayCaster.resampleGeometry(new GeometryThumbnailImageFactoryAWT(), getGeometry(), sampleSize);
hashTable.put("newGeometry", newGeometry);
}
};
AsynchClientTask setGeometryTask = new AsynchClientTask("loading geometry", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
Geometry newGeometry = (Geometry) hashTable.get("newGeometry");
if (getGeometryOwner() instanceof SimulationContext) {
((SimulationContext) getGeometryOwner()).setGeometry(newGeometry);
} else if (getGeometryOwner() instanceof MathModel) {
((MathModel) getGeometryOwner()).getMathDescription().setGeometry(newGeometry);
} else {
throw new RuntimeException("unexpected geometry owner, could not set resampled geometry");
}
}
};
ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { precomputeCurrentGeometryTask, sampleSizeTask, resampleTask, setGeometryTask }, false);
}
use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.
the class ChooseFile method showGeometryModelXMLFileChooser.
// // Check structure sized and select a simulation to export to SBML
// if (isSbml) {
// // get user choice of structure and its size and computes absolute sizes of compartments using the StructureSizeSolver.
// Structure[] structures = bioModel.getModel().getStructures();
// // get the nonspatial simulationContexts corresponding to names in applicableAppNameList
// // This is needed in ApplnSelectionAndStructureSizeInputPanel
//
// SimulationContext[] applicableSimContexts = applicableSimContext.toArray(new SimulationContext[applicableSimContext.size()]);
//
// String strucName = null;
// double structSize = 1.0;
// int structSelection = -1;
// int option = JOptionPane.CANCEL_OPTION;
// Simulation chosenSimulation = null;
//
// ApplnSelectionAndStructureSizeInputPanel applnStructInputPanel = null;
// while (structSelection < 0) {
// applnStructInputPanel = new ApplnSelectionAndStructureSizeInputPanel();
// applnStructInputPanel.setSimContexts(applicableSimContexts);
// applnStructInputPanel.setStructures(structures);
// applnStructInputPanel.setPreferredSize(new java.awt.Dimension(350, 400));
// applnStructInputPanel.setMaximumSize(new java.awt.Dimension(350, 400));
// option = DialogUtils.showComponentOKCancelDialog(currentWindow, applnStructInputPanel, "Select Application and Specify Structure Size to Export:");
// structSelection = applnStructInputPanel.getStructSelectionIndex();
// if (option == JOptionPane.CANCEL_OPTION || option == JOptionPane.CLOSED_OPTION) {
// break;
// } else if (option == JOptionPane.OK_OPTION && structSelection < 0) {
// DialogUtils.showErrorDialog(currentWindow, "Please select a structure and set its size");
// }
// }
//
// if (option == JOptionPane.OK_OPTION) {
// applnStructInputPanel.applyStructureNameAndSizeValues();
// strucName = applnStructInputPanel.getSelectedStructureName();
// chosenSimContext = applnStructInputPanel.getSelectedSimContext();
// hashTable.put("selectedSimContext", chosenSimContext);
//
// GeometryContext geoContext = chosenSimContext.getGeometryContext();
// if (!fileFilter.getDescription().equals(FileFilters.FILE_FILTER_SBML_31_SPATIAL.getDescription())) {
// // calculate structure Sizes only if appln is not spatial
// structSize = applnStructInputPanel.getStructureSize();
// // Invoke StructureSizeEvaluator to compute absolute sizes of compartments if all sizes are not set
// if ( (geoContext.isAllSizeSpecifiedNull() && geoContext.isAllVolFracAndSurfVolSpecifiedNull()) ||
// ((strucName == null || structSize <= 0.0) && (geoContext.isAllSizeSpecifiedNull() && geoContext.isAllVolFracAndSurfVolSpecified())) ||
// (!geoContext.isAllSizeSpecifiedPositive() && geoContext.isAllVolFracAndSurfVolSpecifiedNull()) ||
// (!geoContext.isAllSizeSpecifiedPositive() && !geoContext.isAllVolFracAndSurfVolSpecified()) ||
// (geoContext.isAllSizeSpecifiedNull() && !geoContext.isAllVolFracAndSurfVolSpecified()) ) {
// DialogUtils.showErrorDialog(currentWindow, "Cannot export to SBML without compartment sizes being set. This can be automatically " +
// " computed if the absolute size of at least one compartment and the relative sizes (Surface-to-volume-ratio/Volume-fraction) " +
// " of all compartments are known. Sufficient information is not available to perform this computation." +
// "\n\nThis can be fixed by going back to the application '" + chosenSimContext.getName() + "' and setting structure sizes in the 'StructureMapping' tab.");
// throw UserCancelException.CANCEL_XML_TRANSLATION;
// }
// if (!geoContext.isAllSizeSpecifiedPositive() && geoContext.isAllVolFracAndSurfVolSpecified()) {
// Structure chosenStructure = chosenSimContext.getModel().getStructure(strucName);
// StructureMapping chosenStructMapping = chosenSimContext.getGeometryContext().getStructureMapping(chosenStructure);
// StructureSizeSolver.updateAbsoluteStructureSizes(chosenSimContext, chosenStructure, structSize, chosenStructMapping.getSizeParameter().getUnitDefinition());
// }
// } else {
// if (!geoContext.isAllUnitSizeParameterSetForSpatial()) {
// DialogUtils.showErrorDialog(currentWindow, "Cannot export to SBML without compartment size ratios being set." +
// "\n\nThis can be fixed by going back to the application '" + chosenSimContext.getName() + "' and setting structure" +
// " size ratios in the 'StructureMapping' tab.");
// throw UserCancelException.CANCEL_XML_TRANSLATION;
// }
// }
//
// // Select simulation whose overrides need to be exported
// // If simContext doesn't have simulations, don't pop up simulationSelectionPanel
// Simulation[] sims = bioModel.getSimulations(chosenSimContext);
// // display only those simulations that have overrides in the simulationSelectionPanel.
// Vector<Simulation> orSims = new Vector<Simulation>();
// for (int s = 0; (sims != null) && (s < sims.length); s++) {
// if (sims[s].getMathOverrides().hasOverrides()) {
// orSims.addElement(sims[s]);
// }
// }
// Simulation[] overriddenSims = (Simulation[])BeanUtils.getArray(orSims, Simulation.class);
// if (overriddenSims.length > 0) {
// SimulationSelectionPanel simSelectionPanel = new SimulationSelectionPanel();
// simSelectionPanel.setPreferredSize(new java.awt.Dimension(600, 400));
// simSelectionPanel.setMaximumSize(new java.awt.Dimension(600, 400));
// simSelectionPanel.setSimulations(overriddenSims);
// int simOption = DialogUtils.showComponentOKCancelDialog(currentWindow, simSelectionPanel, "Select Simulation whose overrides should be exported:");
// if (simOption == JOptionPane.OK_OPTION) {
// chosenSimulation = simSelectionPanel.getSelectedSimulation();
// if (chosenSimulation != null) {
// hashTable.put("selectedSimulation", chosenSimulation);
// }
// } else if (simOption == JOptionPane.CANCEL_OPTION || simOption == JOptionPane.CLOSED_OPTION) {
// // User did not choose a simulation whose overrides are required to be exported.
// // Without that information, cannot export successfully into SBML,
// // Hence canceling the entire export to SBML operation.
// throw UserCancelException.CANCEL_XML_TRANSLATION;
// }
// }
// } else if (option == JOptionPane.CANCEL_OPTION || option == JOptionPane.CLOSED_OPTION) {
// // User did not choose to set size for any structure.
// // Without that information, cannot export successfully into SBML,
// // Hence canceling the entire export to SBML operation.
// throw UserCancelException.CANCEL_XML_TRANSLATION;
// }
//
// if (chosenSimulation != null) {
// // rename file to contain exported simulation.
// String ext = FilenameUtils.getExtension(selectedFileName);
// String base = FilenameUtils.getBaseName(selectedFileName);
// String path = FilenameUtils.getPath(selectedFileName);
// base += "_" + TokenMangler.mangleToSName(chosenSimulation.getName());
// selectedFileName = path + base + ext;
// selectedFile.renameTo(new File(selectedFileName));
// }
// resetPreferredFilePath(selectedFile, userPreferences);
// return selectedFile;
// }
/**
* Export to Geometry
* Creation date: (5/31/2004 6:04:14 PM)
* @param hashTable java.util.Hashtable
* @param clientWorker cbit.vcell.desktop.controls.ClientWorker
*/
private File showGeometryModelXMLFileChooser(Hashtable<String, Object> hashTable) throws java.lang.Exception {
Geometry geom = (Geometry) hashTable.get("documentToExport");
JFrame currentWindow = (JFrame) hashTable.get("currentWindow");
UserPreferences userPreferences = (UserPreferences) hashTable.get("userPreferences");
TopLevelWindowManager topLevelWindowManager = (TopLevelWindowManager) hashTable.get("topLevelWindowManager");
Component comp = (Component) hashTable.get("component");
comp = (comp == null ? (currentWindow == null ? (topLevelWindowManager == null ? null : topLevelWindowManager.getComponent()) : currentWindow) : comp);
File defaultPath = userPreferences.getCurrentDialogPath();
VCFileChooser fileChooser = new VCFileChooser(defaultPath);
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
fileChooser.setMultiSelectionEnabled(false);
// fileChooser.addChoosableFileFilter(FileFilters.FILE_FILTER_VCML);
fileChooser.addChoosableFileFilter(FileFilters.FILE_FILTER_PDF);
if (geom.getDimension() > 0) {
fileChooser.addChoosableFileFilter(FileFilters.FILE_FILTER_AVS);
fileChooser.addChoosableFileFilter(FileFilters.FILE_FILTER_STL);
fileChooser.addChoosableFileFilter(FileFilters.FILE_FILTER_PLY);
}
// remove all selector
fileChooser.removeChoosableFileFilter(fileChooser.getAcceptAllFileFilter());
// set the default file filter...
fileChooser.setFileFilter(FileFilters.FILE_FILTER_VCML);
fileChooser.setSelectedFile(new java.io.File(TokenMangler.fixTokenStrict(geom.getName())));
fileChooser.setDialogTitle("Export Virtual Cell Geometry As...");
if (fileChooser.showSaveDialog(comp) != JFileChooser.APPROVE_OPTION) {
// user didn't choose save
throw UserCancelException.CANCEL_FILE_SELECTION;
} else {
File selectedFile = fileChooser.getSelectedFile();
javax.swing.filechooser.FileFilter fileFilter = fileChooser.getFileFilter();
if (selectedFile == null) {
// no file selected (no name given)
throw UserCancelException.CANCEL_FILE_SELECTION;
} else {
// /
String selectedFileName = recordAndRemoveExtension(selectedFile.getPath());
String n = selectedFile.getPath().toLowerCase();
if (fileFilter == FileFilters.FILE_FILTER_VCML && !n.endsWith(".vcml")) {
selectedFile = new File(selectedFileName + ".vcml");
} else if (fileFilter == FileFilters.FILE_FILTER_PDF && !n.endsWith(".pdf")) {
selectedFile = new File(selectedFileName + ".pdf");
}
if (fileFilter == null) {
throw new Exception("No file save type was selected.");
}
checkForOverwrites(selectedFile, comp, userPreferences);
// put the filter in the hash so the export task knows what to do...
hashTable.put("fileFilter", fileFilter);
resetPreferredFilePath(selectedFile, userPreferences);
return selectedFile;
}
}
}
use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.
the class DeleteOldDocument method run.
/**
* Insert the method's description here.
* Creation date: (5/31/2004 6:04:14 PM)
* @param hashTable java.util.Hashtable
* @param clientWorker cbit.vcell.desktop.controls.ClientWorker
*/
public void run(Hashtable<String, Object> hashTable) throws java.lang.Exception {
DocumentWindowManager dwm = (DocumentWindowManager) fetch(hashTable, DOCUMENT_WINDOW_MANAGER);
VCDocument currentDocument = dwm.getVCDocument();
DocumentManager documentManager = (DocumentManager) fetch(hashTable, DOCUMENT_MANAGER);
switch(currentDocument.getDocumentType()) {
case BIOMODEL_DOC:
{
// make the info
BioModel oldBioModel = (BioModel) currentDocument;
BioModelInfo oldBioModelInfo = documentManager.getBioModelInfo(oldBioModel.getVersion().getVersionKey());
// delete document
documentManager.delete(oldBioModelInfo);
break;
}
case MATHMODEL_DOC:
{
// make the info
MathModel oldMathModel = (MathModel) currentDocument;
MathModelInfo oldMathModelInfo = documentManager.getMathModelInfo(oldMathModel.getVersion().getVersionKey());
// delete document
documentManager.delete(oldMathModelInfo);
break;
}
case GEOMETRY_DOC:
{
// make the info
Geometry oldGeometry = (Geometry) currentDocument;
GeometryInfo oldGeometryInfo = documentManager.getGeometryInfo(oldGeometry.getVersion().getVersionKey());
// delete document
documentManager.delete(oldGeometryInfo);
break;
}
default:
break;
}
}
use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.
the class RunSims method run.
/**
* Insert the method's description here.
* Creation date: (5/31/2004 6:04:14 PM)
* @param hashTable java.util.Hashtable
* @param clientWorker cbit.vcell.desktop.controls.ClientWorker
*/
public void run(Hashtable<String, Object> hashTable) throws java.lang.Exception {
DocumentWindowManager documentWindowManager = (DocumentWindowManager) hashTable.get(CommonTask.DOCUMENT_WINDOW_MANAGER.name);
ClientSimManager clientSimManager = (ClientSimManager) hashTable.get("clientSimManager");
// DocumentManager documentManager = (DocumentManager)hashTable.get(CommonTask.DOCUMENT_MANAGER.name);
JobManager jobManager = (JobManager) hashTable.get("jobManager");
Simulation[] simulations = (Simulation[]) hashTable.get("simulations");
Hashtable<Simulation, Throwable> failures = new Hashtable<Simulation, Throwable>();
if (simulations != null && simulations.length > 0) {
// we need to get the new ones if a save occurred...
if (hashTable.containsKey(SaveDocument.DOC_KEY)) {
VCDocument savedDocument = (VCDocument) hashTable.get(SaveDocument.DOC_KEY);
Simulation[] allSims = null;
if (savedDocument instanceof BioModel) {
allSims = ((BioModel) savedDocument).getSimulations();
} else if (savedDocument instanceof MathModel) {
allSims = ((MathModel) savedDocument).getSimulations();
}
Vector<Simulation> v = new Vector<Simulation>();
for (int i = 0; i < simulations.length; i++) {
for (int j = 0; j < allSims.length; j++) {
if (simulations[i].getName().equals(allSims[j].getName())) {
v.add(allSims[j]);
break;
}
}
}
simulations = (Simulation[]) BeanUtils.getArray(v, Simulation.class);
}
for (Simulation sim : simulations) {
try {
int dimension = sim.getMathDescription().getGeometry().getDimension();
if (clientSimManager.getSimulationStatus(sim).isCompleted()) {
// completed
String warningMessage = VCellErrorMessages.getErrorMessage(VCellErrorMessages.RunSims_1, sim.getName());
String result = DialogUtils.showWarningDialog(documentWindowManager.getComponent(), warningMessage, new String[] { UserMessage.OPTION_OK, UserMessage.OPTION_CANCEL }, UserMessage.OPTION_OK);
if (result == null || !result.equals(UserMessage.OPTION_OK)) {
continue;
}
}
DataProcessingInstructions dataProcessingInstructions = sim.getDataProcessingInstructions();
try {
if (dataProcessingInstructions != null) {
dataProcessingInstructions.getSampleImageFieldData(sim.getVersion().getOwner());
}
} catch (Exception ex) {
DialogUtils.showErrorDialog(documentWindowManager.getComponent(), "Problem found in simulation '" + sim.getName() + "':\n" + ex.getMessage());
continue;
}
if (dimension > 0) {
MeshSpecification meshSpecification = sim.getMeshSpecification();
boolean bCellCentered = sim.hasCellCenteredMesh();
if (meshSpecification != null && !meshSpecification.isAspectRatioOK(bCellCentered)) {
String warningMessage = VCellErrorMessages.getErrorMessage(VCellErrorMessages.RunSims_2, sim.getName(), "\u0394x=" + meshSpecification.getDx(bCellCentered) + "\n" + "\u0394y=" + meshSpecification.getDy(bCellCentered) + (dimension < 3 ? "" : "\n\u0394z=" + meshSpecification.getDz(bCellCentered)));
String result = DialogUtils.showWarningDialog(documentWindowManager.getComponent(), warningMessage, new String[] { UserMessage.OPTION_OK, UserMessage.OPTION_CANCEL }, UserMessage.OPTION_OK);
if (result == null || !result.equals(UserMessage.OPTION_OK)) {
continue;
}
}
if (sim.getSolverTaskDescription().getSolverDescription().equals(SolverDescription.Smoldyn)) {
if (!isSmoldynTimeStepOK(sim)) {
double s = smoldynTimestepVars.getSpatialResolution();
double dMax = smoldynTimestepVars.getMaxDiffusion();
double condn = (s * s) / (2.0 * dMax);
String warningMessage = VCellErrorMessages.getErrorMessage(VCellErrorMessages.RunSims_3, Double.toString(s), Double.toString(dMax), Double.toString(condn));
DialogUtils.showErrorDialog(documentWindowManager.getComponent(), warningMessage);
continue;
}
}
// check the number of regions if the simulation mesh is coarser.
Geometry mathGeometry = sim.getMathDescription().getGeometry();
ISize newSize = meshSpecification.getSamplingSize();
ISize defaultSize = mathGeometry.getGeometrySpec().getDefaultSampledImageSize();
if (!sim.getSolverTaskDescription().getSolverDescription().isChomboSolver()) {
int defaultTotalVolumeElements = mathGeometry.getGeometrySurfaceDescription().getVolumeSampleSize().getXYZ();
int newTotalVolumeElements = meshSpecification.getSamplingSize().getXYZ();
if (defaultTotalVolumeElements > newTotalVolumeElements) {
// coarser
Geometry resampledGeometry = (Geometry) BeanUtils.cloneSerializable(mathGeometry);
GeometrySurfaceDescription geoSurfaceDesc = resampledGeometry.getGeometrySurfaceDescription();
geoSurfaceDesc.setVolumeSampleSize(newSize);
geoSurfaceDesc.updateAll();
if (mathGeometry.getGeometrySurfaceDescription().getGeometricRegions() == null) {
mathGeometry.getGeometrySurfaceDescription().updateAll();
}
int defaultNumGeometricRegions = mathGeometry.getGeometrySurfaceDescription().getGeometricRegions().length;
int numGeometricRegions = geoSurfaceDesc.getGeometricRegions().length;
if (numGeometricRegions != defaultNumGeometricRegions) {
String warningMessage = VCellErrorMessages.getErrorMessage(VCellErrorMessages.RunSims_4, newSize.getX() + (dimension > 1 ? " x " + newSize.getY() : "") + (dimension > 2 ? " x " + newSize.getZ() : ""), sim.getName(), numGeometricRegions, defaultNumGeometricRegions);
String result = PopupGenerator.showWarningDialog(documentWindowManager.getComponent(), warningMessage, new String[] { UserMessage.OPTION_OK, UserMessage.OPTION_CANCEL }, UserMessage.OPTION_OK);
if (result == null || !result.equals(UserMessage.OPTION_OK)) {
continue;
}
}
}
if (mathGeometry.getGeometrySpec().hasImage()) {
// if it's an image.
if (defaultSize.getX() + 1 < newSize.getX() || defaultSize.getY() + 1 < newSize.getY() || defaultSize.getZ() + 1 < newSize.getZ()) {
// finer
String defaultSizeString = (defaultSize.getX() + 1) + (dimension > 1 ? " x " + (defaultSize.getY() + 1) : "") + (dimension > 2 ? " x " + (defaultSize.getZ() + 1) : "");
String warningMessage = VCellErrorMessages.getErrorMessage(VCellErrorMessages.RunSims_5, newSize.getX() + (dimension > 1 ? " x " + newSize.getY() : "") + (dimension > 2 ? " x " + newSize.getZ() : ""), sim.getName(), defaultSizeString, defaultSizeString);
String result = DialogUtils.showWarningDialog(documentWindowManager.getComponent(), warningMessage, new String[] { UserMessage.OPTION_OK, UserMessage.OPTION_CANCEL }, UserMessage.OPTION_OK);
if (result == null || !result.equals(UserMessage.OPTION_OK)) {
continue;
}
}
}
}
boolean bGiveWarning = false;
for (int i = 0; i < sim.getScanCount(); i++) {
if (sim.getSolverTaskDescription().getSolverDescription().equals(SolverDescription.SundialsPDE)) {
SimulationJob simJob = new SimulationJob(sim, i, null);
if (simJob.getSimulationSymbolTable().hasTimeVaryingDiffusionOrAdvection()) {
bGiveWarning = true;
break;
}
}
}
if (bGiveWarning) {
String warningMessage = VCellErrorMessages.RunSims_6;
String result = DialogUtils.showWarningDialog(documentWindowManager.getComponent(), warningMessage, new String[] { UserMessage.OPTION_OK, UserMessage.OPTION_CANCEL }, UserMessage.OPTION_OK);
if (result == null || !result.equals(UserMessage.OPTION_OK)) {
continue;
}
}
}
SimulationInfo simInfo = sim.getSimulationInfo();
if (simInfo != null) {
//
// translate to common ancestral simulation (oldest mathematically equivalent simulation)
//
SimulationStatus simulationStatus = jobManager.startSimulation(simInfo.getAuthoritativeVCSimulationIdentifier(), sim.getScanCount());
// updateStatus
clientSimManager.updateStatusFromStartRequest(sim, simulationStatus);
} else {
// this should really not happen...
throw new RuntimeException(">>>>>>>>>> trying to run an unsaved simulation...");
}
} catch (Throwable exc) {
exc.printStackTrace(System.out);
failures.put(sim, exc);
}
}
}
// we deal with individual request failures here, passing down only other things (that break the whole thing down) to dispatcher
if (!failures.isEmpty()) {
Enumeration<Simulation> en = failures.keys();
while (en.hasMoreElements()) {
Simulation sim = en.nextElement();
Throwable exc = (Throwable) failures.get(sim);
// // updateStatus
// SimulationStatus simulationStatus = clientSimManager.updateStatusFromStartRequest(sim, true, exc.getMessage());
// notify user
PopupGenerator.showErrorDialog(documentWindowManager, "Failed to start simulation'" + sim.getName() + "'\n" + exc.getMessage());
}
}
}
Aggregations