use of cbit.vcell.solver.VCSimulationDataIdentifier in project vcell by virtualcell.
the class MathModelWindowManager method simStatusChanged.
/**
* Insert the method's description here.
* Creation date: (5/14/2004 11:08:35 AM)
* @param newMathModel cbit.vcell.mathmodel.MathModel
*/
// private void setMathModel(MathModel newMathModel) {
// resetGeometryListeners((getMathModel() != null?(getMathModel().getMathDescription() != null?getMathModel().getMathDescription().getGeometry():null):null),
// (newMathModel != null?(newMathModel.getMathDescription() != null?newMathModel.getMathDescription().getGeometry():null):null));
//
// resetMathDescriptionListeners(
// (getMathModel() != null?getMathModel().getMathDescription():null),
// (newMathModel != null?newMathModel.getMathDescription():null));
// if (getMathModel() != null) {
// getMathModel().removePropertyChangeListener(this);
// }
// mathModel = newMathModel;
// if (getMathModel() != null) {
// getMathModel().addPropertyChangeListener(this);
// }
// }
// private void resetMathDescriptionListeners(MathDescription oldMathDescription,MathDescription newMathDescription){
// if(oldMathDescription != null){
// oldMathDescription.removePropertyChangeListener(this);
// }
// if(newMathDescription != null){
// newMathDescription.addPropertyChangeListener(this);
// }
// }
// /**
// * Insert the method's description here.
// * Creation date: (6/14/2004 10:55:40 PM)
// * @param newDocument cbit.vcell.document.VCDocument
// */
// private void showDataViewerPlotsFrame(final javax.swing.JInternalFrame plotFrame) {
// dataViewerPlotsFramesVector.add(plotFrame);
// showFrame(plotFrame);
// plotFrame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter() {
// public void internalFrameClosing(javax.swing.event.InternalFrameEvent e) {
// dataViewerPlotsFramesVector.remove(plotFrame);
// }
// });
// }
// /**
// * Insert the method's description here.
// * Creation date: (6/14/2004 10:55:40 PM)
// * @param newDocument cbit.vcell.document.VCDocument
// */
// public void showDataViewerPlotsFrames(javax.swing.JInternalFrame[] plotFrames) {
// for (int i = 0; i < plotFrames.length; i++){
// showDataViewerPlotsFrame(plotFrames[i]);
// }
// }
/**
* Insert the method's description here.
* Creation date: (6/9/2004 3:58:21 PM)
* @param newJobStatus cbit.vcell.messaging.db.SimulationJobStatus
* @param progress java.lang.Double
* @param timePoint java.lang.Double
*/
public void simStatusChanged(SimStatusEvent simStatusEvent) {
// ** events are only generated from server side job statuses **
KeyValue simKey = simStatusEvent.getVCSimulationIdentifier().getSimulationKey();
// do we have the sim?
Simulation[] sims = getMathModel().getSimulations();
if (sims == null) {
// we don't have it
return;
}
Simulation simulation = null;
for (int i = 0; i < sims.length; i++) {
if (simKey.equals(sims[i].getKey()) || ((sims[i].getSimulationVersion() != null) && simKey.equals(sims[i].getSimulationVersion().getParentSimulationReference()))) {
simulation = sims[i];
break;
}
}
if (simulation == null) {
// we don't have it
return;
}
// we have it; get current server side status
SimulationStatus simStatus = getRequestManager().getServerSimulationStatus(simulation.getSimulationInfo());
// if failed, notify
if (simStatusEvent.isNewFailureEvent()) {
String qualifier = "";
if (simulation.getScanCount() > 1) {
qualifier += "One job from ";
}
PopupGenerator.showErrorDialog(this, qualifier + "Simulation '" + simulation.getName() + "' failed\n" + simStatus.getDetails());
}
// update status display
ClientSimManager simManager = simulationWorkspace.getClientSimManager();
simManager.updateStatusFromServer(simulation);
// is there new data?
if (simStatusEvent.isNewDataEvent()) {
fireNewData(new DataEvent(this, new VCSimulationDataIdentifier(simulation.getSimulationInfo().getAuthoritativeVCSimulationIdentifier(), simStatusEvent.getJobIndex())));
}
}
use of cbit.vcell.solver.VCSimulationDataIdentifier in project vcell by virtualcell.
the class ExportServiceImpl method fireExportCompleted.
/**
* Insert the method's description here.
* Creation date: (4/1/2001 11:20:45 AM)
* @deprecated
*/
protected ExportEvent fireExportCompleted(long jobID, VCDataIdentifier vcdID, String format, String location, ExportSpecs exportSpecs) {
User user = null;
Object object = jobRequestIDs.get(new Long(jobID));
if (object != null) {
user = (User) object;
}
TimeSpecs timeSpecs = (exportSpecs != null) ? exportSpecs.getTimeSpecs() : (null);
VariableSpecs varSpecs = (exportSpecs != null) ? exportSpecs.getVariableSpecs() : (null);
final KeyValue dataKey;
if (vcdID instanceof VCSimulationDataIdentifier) {
dataKey = ((VCSimulationDataIdentifier) vcdID).getSimulationKey();
} else if (vcdID instanceof ExternalDataIdentifier) {
dataKey = ((ExternalDataIdentifier) vcdID).getSimulationKey();
} else {
throw new RuntimeException("unexpected VCDataIdentifier");
}
ExportEvent event = new ExportEvent(this, jobID, user, vcdID.getID(), dataKey, ExportEvent.EXPORT_COMPLETE, format, location, null, timeSpecs, varSpecs);
fireExportEvent(event);
return event;
}
use of cbit.vcell.solver.VCSimulationDataIdentifier in project vcell by virtualcell.
the class FiniteVolumeFileWriter method writeFieldData.
/**
* # Field Data
* FIELD_DATA_BEGIN
* #id, name, varname, time filename
* 0 _VCell_FieldData_0 FRAP_binding_ALPHA rfB 0.1 \\users\\fgao\\SimID_22489731_0_FRAP_binding_ALPHA_rfB_0_1.fdat
* FIELD_DATA_END
* @throws FileNotFoundException
* @throws ExpressionException
* @throws DataAccessException
*/
private void writeFieldData() throws FileNotFoundException, ExpressionException, DataAccessException {
FieldDataIdentifierSpec[] fieldDataIDSpecs = simTask.getSimulationJob().getFieldDataIdentifierSpecs();
if (fieldDataIDSpecs == null || fieldDataIDSpecs.length == 0) {
return;
}
String secondarySimDataDir = PropertyLoader.getProperty(PropertyLoader.secondarySimDataDirInternalProperty, null);
DataSetControllerImpl dsci = new DataSetControllerImpl(null, workingDirectory.getParentFile(), secondarySimDataDir == null ? null : new File(secondarySimDataDir));
printWriter.println("# Field Data");
printWriter.println("FIELD_DATA_BEGIN");
printWriter.println("#id, type, new name, name, varname, time, filename");
FieldFunctionArguments psfFieldFunc = null;
Variable var = simTask.getSimulationJob().getSimulationSymbolTable().getVariable(Simulation.PSF_FUNCTION_NAME);
if (var != null) {
FieldFunctionArguments[] ffas = FieldUtilities.getFieldFunctionArguments(var.getExpression());
if (ffas == null || ffas.length == 0) {
throw new DataAccessException("Point Spread Function " + Simulation.PSF_FUNCTION_NAME + " can only be a single field function.");
} else {
Expression newexp = new Expression(ffas[0].infix());
if (!var.getExpression().compareEqual(newexp)) {
throw new DataAccessException("Point Spread Function " + Simulation.PSF_FUNCTION_NAME + " can only be a single field function.");
}
psfFieldFunc = ffas[0];
}
}
int index = 0;
HashSet<FieldDataIdentifierSpec> uniqueFieldDataIDSpecs = new HashSet<FieldDataIdentifierSpec>();
uniqueFieldDataNSet = new HashSet<FieldDataNumerics>();
for (int i = 0; i < fieldDataIDSpecs.length; i++) {
if (!uniqueFieldDataIDSpecs.contains(fieldDataIDSpecs[i])) {
FieldFunctionArguments ffa = fieldDataIDSpecs[i].getFieldFuncArgs();
File newResampledFieldDataFile = new File(workingDirectory, SimulationData.createCanonicalResampleFileName((VCSimulationDataIdentifier) simTask.getSimulationJob().getVCDataIdentifier(), fieldDataIDSpecs[i].getFieldFuncArgs()));
uniqueFieldDataIDSpecs.add(fieldDataIDSpecs[i]);
VariableType varType = fieldDataIDSpecs[i].getFieldFuncArgs().getVariableType();
SimDataBlock simDataBlock = dsci.getSimDataBlock(null, fieldDataIDSpecs[i].getExternalDataIdentifier(), fieldDataIDSpecs[i].getFieldFuncArgs().getVariableName(), fieldDataIDSpecs[i].getFieldFuncArgs().getTime().evaluateConstant());
VariableType dataVarType = simDataBlock.getVariableType();
if (varType.equals(VariableType.UNKNOWN)) {
varType = dataVarType;
} else if (!varType.equals(dataVarType)) {
throw new IllegalArgumentException("field function variable type (" + varType.getTypeName() + ") doesn't match real variable type (" + dataVarType.getTypeName() + ")");
}
if (psfFieldFunc != null && psfFieldFunc.equals(ffa)) {
psfFieldIndex = index;
}
String fieldDataID = "_VCell_FieldData_" + index;
printWriter.println(index + " " + varType.getTypeName() + " " + fieldDataID + " " + ffa.getFieldName() + " " + ffa.getVariableName() + " " + ffa.getTime().infix() + " " + newResampledFieldDataFile);
uniqueFieldDataNSet.add(new FieldDataNumerics(SimulationData.createCanonicalFieldFunctionSyntax(ffa.getFieldName(), ffa.getVariableName(), ffa.getTime().evaluateConstant(), ffa.getVariableType().getTypeName()), fieldDataID));
index++;
}
}
if (psfFieldIndex >= 0) {
printWriter.println("PSF_FIELD_DATA_INDEX " + psfFieldIndex);
}
printWriter.println("FIELD_DATA_END");
printWriter.println();
}
use of cbit.vcell.solver.VCSimulationDataIdentifier in project vcell by virtualcell.
the class ClientPDEDataContext method setDataManager.
/**
* Insert the method's description here.
* Creation date: (10/3/00 5:03:43 PM)
*/
// public abstract void refreshIdentifiers();
/**
* This method is called from SimResultsViewer.updateScanParamChoices(),
* which is going to update results view upon a choice of scanned parameters.
*/
public void setDataManager(PDEDataManager newDataManager) throws DataAccessException {
VCDataIdentifier oldid = dataManager.getVCDataIdentifier();
VCDataIdentifier newid = newDataManager.getVCDataIdentifier();
if (oldid instanceof VCSimulationDataIdentifier && newid instanceof VCSimulationDataIdentifier && ((VCSimulationDataIdentifier) oldid).getVcSimID().equals(((VCSimulationDataIdentifier) newid).getVcSimID())) {
PDEDataManager oldPDataManager = dataManager;
dataManager = newDataManager;
DataIdentifier[] dis = getDataManager().getDataIdentifiers();
double[] times = getDataManager().getDataSetTimes();
setDataIdentifiers(dis);
setTimePoints(times);
externalRefresh();
setVCDataIdentifier(dataManager.getVCDataIdentifier());
firePropertyChange(SimDataConstants.PDE_DATA_MANAGER_CHANGED, oldPDataManager, newDataManager);
} else {
throw new RuntimeException("DataManager change not allowed: oldID = " + oldid + " newID = " + newid);
}
}
use of cbit.vcell.solver.VCSimulationDataIdentifier in project vcell by virtualcell.
the class DataSetControllerImpl method fieldFunctionSubstitution.
private Expression fieldFunctionSubstitution(OutputContext outputContext, final VCDataIdentifier vcdID, Expression functionExpression) throws ExpressionException, DataAccessException, IOException, MathException {
SimResampleInfoProvider simResampleInfoProvider = null;
Expression origExpression = new Expression(functionExpression);
if (vcdID instanceof VCSimulationDataIdentifier) {
simResampleInfoProvider = ((VCSimulationDataIdentifier) vcdID);
} else if (vcdID instanceof VCSimulationDataIdentifierOldStyle) {
simResampleInfoProvider = ((VCSimulationDataIdentifierOldStyle) vcdID);
} else if (vcdID instanceof ExternalDataIdentifier) {
simResampleInfoProvider = ((ExternalDataIdentifier) vcdID);
} else {
return origExpression;
}
FieldFunctionArguments[] fieldfuncArgumentsArr = FieldUtilities.getFieldFunctionArguments(origExpression);
if (fieldfuncArgumentsArr == null || fieldfuncArgumentsArr.length == 0) {
return origExpression;
}
String[] origSymbols = origExpression.getSymbols();
Vector<SymbolTableEntry> originalSymbolTablEntrryV = new Vector<SymbolTableEntry>();
for (int i = 0; origSymbols != null && i < origSymbols.length; i++) {
if (!originalSymbolTablEntrryV.contains(origExpression.getSymbolBinding(origSymbols[i]))) {
originalSymbolTablEntrryV.add(origExpression.getSymbolBinding(origSymbols[i]));
}
}
Expression exp = new Expression(origExpression);
//
// Handle Field Data Function field(...)
//
double[][] resampledFieldDatas = null;
HashMap<String, Integer> substSymbolIndexH = new HashMap<String, Integer>();
// if(fieldfuncArgumentsArr != null && fieldfuncArgumentsArr.length > 0){
FieldDataIdentifierSpec[] fieldDataIdentifierSpecArr = getFieldDataIdentifierSpecs(fieldfuncArgumentsArr, simResampleInfoProvider.getOwner());
// Substitute Field Data Functions for simple symbols for lookup-------
for (int i = 0; i < fieldfuncArgumentsArr.length; i += 1) {
for (int j = 0; j < fieldDataIdentifierSpecArr.length; j++) {
if (fieldfuncArgumentsArr[i].equals(fieldDataIdentifierSpecArr[j].getFieldFuncArgs())) {
String substFieldName = fieldfuncArgumentsArr[i].getFieldName() + "_" + fieldfuncArgumentsArr[i].getVariableName() + "_" + fieldfuncArgumentsArr[i].getTime().evaluateConstant();
substFieldName = TokenMangler.fixTokenStrict(substFieldName);
if (exp.hasSymbol(substFieldName)) {
throw new DataAccessException("Substitute Field data name is not unique");
}
String fieldFuncString = SimulationData.createCanonicalFieldFunctionSyntax(fieldDataIdentifierSpecArr[j].getExternalDataIdentifier().getName(), fieldfuncArgumentsArr[i].getVariableName(), fieldfuncArgumentsArr[i].getTime().evaluateConstant(), fieldfuncArgumentsArr[i].getVariableType().getTypeName());
exp.substituteInPlace(new Expression(fieldFuncString), new Expression(substFieldName));
substSymbolIndexH.put(substFieldName, i);
break;
}
}
}
// ----------------------------------------------------------------------
boolean[] bResample = new boolean[fieldDataIdentifierSpecArr.length];
Arrays.fill(bResample, true);
writeFieldFunctionData(outputContext, fieldDataIdentifierSpecArr, bResample, getMesh(simResampleInfoProvider), simResampleInfoProvider, getMesh(simResampleInfoProvider).getNumMembraneElements(), FVSolverStandalone.HESM_KEEP_AND_CONTINUE);
resampledFieldDatas = new double[fieldfuncArgumentsArr.length][];
for (int i = 0; i < fieldfuncArgumentsArr.length; i += 1) {
// File resampledFile =
// new File(getUserDir(vcsdID.getOwner()),
// vcsdID.getID()+
// FieldDataIdentifierSpec.getDefaultFieldDataFileNameForSimulation(fieldfuncArgumentsArr[i])
// );
// File resampledFile = new File(getPrimaryUserDir(simResampleInfoProvider.getOwner(), true),
// SimulationData.createCanonicalResampleFileName(
// simResampleInfoProvider, fieldfuncArgumentsArr[i]));
File resampledFile = ((SimulationData) getVCData(simResampleInfoProvider)).getFieldDataFile(simResampleInfoProvider, fieldfuncArgumentsArr[i]);
resampledFieldDatas[i] = DataSet.fetchSimData(fieldfuncArgumentsArr[i].getVariableName(), resampledFile);
}
// }
// Rebind all the symbols
String[] dependentIDs = exp.getSymbols();
VariableSymbolTable varSymbolTable = new VariableSymbolTable();
for (int i = 0; dependentIDs != null && i < dependentIDs.length; i++) {
SymbolTableEntry newSymbolTableEntry = null;
for (int j = 0; j < originalSymbolTablEntrryV.size(); j++) {
if (originalSymbolTablEntrryV.elementAt(j).getName().equals(dependentIDs[i])) {
newSymbolTableEntry = originalSymbolTablEntrryV.elementAt(j);
break;
}
}
if (newSymbolTableEntry == null) {
if (substSymbolIndexH.containsKey(dependentIDs[i])) {
int resampledDataIndex = substSymbolIndexH.get(dependentIDs[i]).intValue();
FieldDataParameterVariable fieldDataParameterVariable = new FieldDataParameterVariable(dependentIDs[i], resampledFieldDatas[resampledDataIndex]);
newSymbolTableEntry = fieldDataParameterVariable;
}
}
if (newSymbolTableEntry == null) {
throw new DataAccessException("Field Data Couldn't find substituted expression while evaluating function");
}
varSymbolTable.addVar(newSymbolTableEntry);
}
exp.bindExpression(varSymbolTable);
return exp;
}
Aggregations