use of cbit.vcell.geometry.ChomboGeometryException in project vcell by virtualcell.
the class ChomboMeshSpecificationPanel method updateDisplay.
private void updateDisplay(boolean bSolverChanged) throws ChomboGeometryException, ChomboInvalidGeometryException {
if (!simulation.getSolverTaskDescription().getSolverDescription().isChomboSolver()) {
setVisible(false);
return;
}
Geometry geometry = simulation.getMathDescription().getGeometry();
Extent extent = geometry.getExtent();
int dimension = geometry.getDimension();
switch(dimension) {
case 0:
setVisible(false);
break;
case 1:
getGeometrySizeTextField().setText("" + extent.getX());
NyLabel.setVisible(false);
NyComboBox.setVisible(false);
NzLabel.setVisible(false);
NzComboBox.setVisible(false);
break;
case 2:
getGeometrySizeTextField().setText("(" + extent.getX() + ", " + extent.getY() + ")");
NzLabel.setVisible(false);
NzComboBox.setVisible(false);
break;
case 3:
getGeometrySizeTextField().setText("(" + extent.getX() + ", " + extent.getY() + ", " + extent.getZ() + ")");
break;
}
String error;
ChomboMeshRecommendation meshRecommendation = new ChomboMeshValidator(geometry.getDimension(), geometry.getExtent(), simulation.getSolverTaskDescription().getChomboSolverSpec().getBlockFactor()).computeMeshSpecs();
if (meshRecommendation.validate()) {
// remove ActionListener, here we only want to set values
removeComboBoxListener();
HComboBox.removeAll();
NxComboBox.removeAll();
NyComboBox.removeAll();
NzComboBox.removeAll();
for (ChomboMeshSpec meshSpec : meshRecommendation.validMeshSpecList) {
HComboBox.addItem((float) meshSpec.H);
NxComboBox.addItem(meshSpec.Nx[0]);
if (geometry.getDimension() > 1) {
NyComboBox.addItem(meshSpec.Nx[1]);
if (geometry.getDimension() == 3) {
NzComboBox.addItem(meshSpec.Nx[2]);
}
}
}
addComboBoxListener();
if (bSolverChanged) {
NxComboBox.setSelectedIndex(0);
} else {
ISize samplingSize = simulation.getMeshSpecification().getSamplingSize();
NxComboBox.setSelectedItem(samplingSize.getX());
// double check if existing mesh size is an option in drop down
Integer selectedNx = (Integer) NxComboBox.getSelectedItem();
Integer selectedNy = geometry.getDimension() > 1 ? (Integer) NyComboBox.getSelectedItem() : 1;
Integer selectedNz = geometry.getDimension() > 2 ? (Integer) NzComboBox.getSelectedItem() : 1;
boolean bMatchFound = selectedNx == samplingSize.getX() && (dimension < 2 || selectedNy == samplingSize.getY()) && (dimension < 3 || selectedNz == samplingSize.getZ());
if (!bMatchFound) {
NxComboBox.setSelectedIndex(0);
throw new ChomboGeometryException(ChomboMeshValidator.ERROR_MESSAGE_INCOMPATIBLE_MESH_SIZE);
}
}
} else {
throw new ChomboInvalidGeometryException(meshRecommendation);
}
}
use of cbit.vcell.geometry.ChomboGeometryException in project vcell by virtualcell.
the class MeshTabPanel method setSimulation.
/**
* Sets the meshSpecification property (cbit.vcell.mesh.MeshSpecification) value.
* @param meshSpecification The new value for the property.
* @throws ChomboInvalidGeometryException
* @throws ChomboGeometryException
* @see #getMeshSpecification
*/
public void setSimulation(Component parent, Simulation newValue) throws ChomboInvalidGeometryException {
Simulation oldValue = simulation;
if (oldValue != null) {
oldValue.getSolverTaskDescription().removePropertyChangeListener(eventListener);
}
simulation = newValue;
if (simulation != null) {
simulation.getSolverTaskDescription().addPropertyChangeListener(eventListener);
}
updateDisplay();
chomboSolverSpecPanel.setSimulation(simulation);
meshSpecificationPanel.setSimulation(simulation);
try {
chomboMeshSpecificationPanel.setSimulation(simulation);
} catch (ChomboGeometryException exc) {
exc.printStackTrace(System.out);
DialogUtils.showWarningDialog(parent, exc.getMessage());
}
}
Aggregations