use of org.vcell.vis.io.VtuVarInfo in project vcell by virtualcell.
the class PDEDataViewerPostProcess method createPostProcessPDEDataContext.
public static PostProcessDataPDEDataContext createPostProcessPDEDataContext(final ClientPDEDataContext parentPDEDataContext) throws Exception {
final DataOperationResults.DataProcessingOutputInfo dataProcessingOutputInfo = (DataOperationResults.DataProcessingOutputInfo) parentPDEDataContext.doDataOperation(new DataOperation.DataProcessingOutputInfoOP(parentPDEDataContext.getVCDataIdentifier(), false, parentPDEDataContext.getDataManager().getOutputContext()));
if (dataProcessingOutputInfo == null) {
return null;
}
DataSetControllerProvider dataSetControllerProvider = new DataSetControllerProvider() {
@Override
public DataSetController getDataSetController() throws DataAccessException {
return new DataSetController() {
// DataIdentifier[] dataIdentifiers;
@Override
public ExportEvent makeRemoteFile(OutputContext outputContext, ExportSpecs exportSpecs) throws DataAccessException, RemoteProxyException {
throw new DataAccessException("Not implemented");
}
@Override
public TimeSeriesJobResults getTimeSeriesValues(OutputContext outputContext, VCDataIdentifier vcdataID, TimeSeriesJobSpec timeSeriesJobSpec) throws RemoteProxyException, DataAccessException {
// return parentPDEDataContext.getDataManager().getTimeSeriesValues(timeSeriesJobSpec);
DataOperation.DataProcessingOutputTimeSeriesOP dataProcessingOutputTimeSeriesOP = new DataOperation.DataProcessingOutputTimeSeriesOP(vcdataID, timeSeriesJobSpec, outputContext, getDataSetTimes(vcdataID));
DataOperationResults.DataProcessingOutputTimeSeriesValues dataopDataProcessingOutputTimeSeriesValues = (DataOperationResults.DataProcessingOutputTimeSeriesValues) parentPDEDataContext.doDataOperation(dataProcessingOutputTimeSeriesOP);
return dataopDataProcessingOutputTimeSeriesValues.getTimeSeriesJobResults();
}
@Override
public SimDataBlock getSimDataBlock(OutputContext outputContext, VCDataIdentifier vcdataID, String varName, double time) throws RemoteProxyException, DataAccessException {
// return parentPDEDataContext.getDataManager().getSimDataBlock(varName, time);
DataOperationResults.DataProcessingOutputDataValues dataProcessingOutputValues = (DataOperationResults.DataProcessingOutputDataValues) parentPDEDataContext.doDataOperation(new DataOperation.DataProcessingOutputDataValuesOP(vcdataID, varName, TimePointHelper.createSingleTimeTimePointHelper(time), DataIndexHelper.createAllDataIndexesDataIndexHelper(), outputContext, null));
PDEDataInfo pdeDataInfo = new PDEDataInfo(vcdataID.getOwner(), vcdataID.getID(), varName, time, Long.MIN_VALUE);
SimDataBlock simDataBlock = new SimDataBlock(pdeDataInfo, dataProcessingOutputValues.getDataValues()[0], VariableType.POSTPROCESSING);
return simDataBlock;
}
@Override
public boolean getParticleDataExists(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
// TODO Auto-generated method stub
return false;
}
@Override
public ParticleDataBlock getParticleDataBlock(VCDataIdentifier vcdataID, double time) throws DataAccessException, RemoteProxyException {
// TODO Auto-generated method stub
return null;
}
@Override
public ODESimData getODEData(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
// TODO Auto-generated method stub
return null;
}
@Override
public CartesianMesh getMesh(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
// throw new DataAccessException("PostProcessData mesh not available at this level");
return null;
}
@Override
public PlotData getLineScan(OutputContext outputContext, VCDataIdentifier vcdataID, String variable, double time, SpatialSelection spatialSelection) throws RemoteProxyException, DataAccessException {
throw new DataAccessException("Remote getLineScan method should not be called for PostProcess");
}
@Override
public AnnotatedFunction[] getFunctions(OutputContext outputContext, VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
return outputContext.getOutputFunctions();
}
@Override
public double[] getDataSetTimes(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
return dataProcessingOutputInfo.getVariableTimePoints();
}
@Override
public DataSetTimeSeries getDataSetTimeSeries(VCDataIdentifier vcdataID, String[] variableNames) throws DataAccessException, RemoteProxyException {
// TODO Auto-generated method stub
return null;
}
@Override
public DataSetMetadata getDataSetMetadata(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
// TODO Auto-generated method stub
return null;
}
@Override
public DataIdentifier[] getDataIdentifiers(OutputContext outputContext, VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
// return parentPDEDataContext.getDataIdentifiers();
ArrayList<DataIdentifier> postProcessDataIDs = new ArrayList<DataIdentifier>();
if (outputContext != null && outputContext.getOutputFunctions() != null) {
for (int i = 0; i < outputContext.getOutputFunctions().length; i++) {
if (outputContext.getOutputFunctions()[i].isPostProcessFunction()) {
postProcessDataIDs.add(new DataIdentifier(outputContext.getOutputFunctions()[i].getName(), VariableType.POSTPROCESSING, null, false, outputContext.getOutputFunctions()[i].getDisplayName()));
}
}
}
// get 'state' variables
for (int i = 0; i < dataProcessingOutputInfo.getVariableNames().length; i++) {
if (dataProcessingOutputInfo.getPostProcessDataType(dataProcessingOutputInfo.getVariableNames()[i]).equals(PostProcessDataType.image)) {
DataIdentifier dataIdentifier = new DataIdentifier(dataProcessingOutputInfo.getVariableNames()[i], VariableType.POSTPROCESSING, null, false, dataProcessingOutputInfo.getVariableNames()[i]);
postProcessDataIDs.add(dataIdentifier);
}
}
if (postProcessDataIDs.size() > 0) {
return postProcessDataIDs.toArray(new DataIdentifier[0]);
}
return null;
}
@Override
public FieldDataFileOperationResults fieldDataFileOperation(FieldDataFileOperationSpec fieldDataFileOperationSpec) throws RemoteProxyException, DataAccessException {
// TODO Auto-generated method stub
return null;
}
@Override
public DataOperationResults doDataOperation(DataOperation dataOperation) throws DataAccessException, RemoteProxyException {
// TODO Auto-generated method stub
return parentPDEDataContext.doDataOperation(dataOperation);
}
@Override
public VtuFileContainer getEmptyVtuMeshFiles(VCDataIdentifier vcdataID, int timeIndex) throws DataAccessException {
// TODO Auto-generated method stub
return null;
}
@Override
public double[] getVtuMeshData(OutputContext outputContext, VCDataIdentifier vcdataID, VtuVarInfo var, double time) throws RemoteProxyException, DataAccessException {
// TODO Auto-generated method stub
return null;
}
@Override
public VtuVarInfo[] getVtuVarInfos(OutputContext outputContext, VCDataIdentifier vcDataIdentifier) {
// TODO Auto-generated method stub
return null;
}
@Override
public double[] getVtuTimes(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
// TODO Auto-generated method stub
return null;
}
@Override
public NFSimMolecularConfigurations getNFSimMolecularConfigurations(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
// TODO Auto-generated method stub
return null;
}
};
}
};
VCDataManager postProcessVCDataManager = new VCDataManager(dataSetControllerProvider);
PDEDataManager postProcessPDEDataManager = new PDEDataManager(((ClientPDEDataContext) parentPDEDataContext).getDataManager().getOutputContext(), postProcessVCDataManager, parentPDEDataContext.getVCDataIdentifier());
PostProcessDataPDEDataContext postProcessDataPDEDataContext = new PostProcessDataPDEDataContext(postProcessPDEDataManager);
return postProcessDataPDEDataContext;
}
use of org.vcell.vis.io.VtuVarInfo in project vcell by virtualcell.
the class ClientSimManager method showSimulationResults0.
private AsynchClientTask[] showSimulationResults0(final boolean isLocal, final ViewerType viewerType) {
// Create the AsynchClientTasks
ArrayList<AsynchClientTask> taskList = new ArrayList<AsynchClientTask>();
taskList.add(new AsynchClientTaskFunction(h -> {
h.put(H_LOCAL_SIM, isLocal);
h.put(H_VIEWER_TYPE, viewerType);
}, "setLocal", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING));
final DocumentWindowManager documentWindowManager = getDocumentWindowManager();
AsynchClientTask retrieveResultsTask = new AsynchClientTask("Retrieving results", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@SuppressWarnings("unchecked")
public void run(Hashtable<String, Object> hashTable) throws Exception {
Simulation[] simsToShow = (Simulation[]) hashTable.get("simsArray");
for (int i = 0; i < simsToShow.length; i++) {
final Simulation sim = simsToShow[i];
final VCSimulationIdentifier vcSimulationIdentifier = sim.getSimulationInfo().getAuthoritativeVCSimulationIdentifier();
final SimulationWindow simWindow = documentWindowManager.haveSimulationWindow(vcSimulationIdentifier);
OutputContext outputContext = (OutputContext) hashTable.get("outputContext");
if (simWindow == null && (viewerType == ViewerType.BothNativeAndPython || viewerType == ViewerType.NativeViewer_only)) {
try {
// make the manager and wire it up
DataViewerController dataViewerController = null;
if (!isLocal) {
dataViewerController = documentWindowManager.getRequestManager().getDataViewerController(outputContext, sim, 0);
// For changes in time or variable
documentWindowManager.addDataListener(dataViewerController);
} else {
// ---- preliminary : construct the localDatasetControllerProvider
File primaryDir = ResourceUtil.getLocalRootDir();
User usr = sim.getVersion().getOwner();
DataSetControllerImpl dataSetControllerImpl = new DataSetControllerImpl(null, primaryDir, null);
ExportServiceImpl localExportServiceImpl = new ExportServiceImpl();
LocalDataSetControllerProvider localDSCProvider = new LocalDataSetControllerProvider(usr, dataSetControllerImpl, localExportServiceImpl);
VCDataManager vcDataManager = new VCDataManager(localDSCProvider);
File localSimDir = ResourceUtil.getLocalSimDir(User.tempUser.getName());
LocalVCDataIdentifier vcDataId = new LocalVCSimulationDataIdentifier(vcSimulationIdentifier, 0, localSimDir);
DataManager dataManager = null;
if (sim.isSpatial()) {
dataManager = new PDEDataManager(outputContext, vcDataManager, vcDataId);
} else {
dataManager = new ODEDataManager(outputContext, vcDataManager, vcDataId);
}
dataViewerController = new SimResultsViewerController(dataManager, sim);
dataSetControllerImpl.addDataJobListener(documentWindowManager);
}
// make the viewer
Hashtable<VCSimulationIdentifier, DataViewerController> dataViewerControllers = (Hashtable<VCSimulationIdentifier, DataViewerController>) hashTable.get(H_DATA_VIEWER_CONTROLLERS);
if (dataViewerControllers == null) {
dataViewerControllers = new Hashtable<VCSimulationIdentifier, DataViewerController>();
hashTable.put(H_DATA_VIEWER_CONTROLLERS, dataViewerControllers);
}
dataViewerControllers.put(vcSimulationIdentifier, dataViewerController);
} catch (Throwable exc) {
exc.printStackTrace(System.out);
saveFailure(hashTable, sim, exc);
}
}
try {
if (viewerType == ViewerType.PythonViewer_only || viewerType == ViewerType.BothNativeAndPython) {
VtkManager vtkManager = null;
if (!isLocal) {
vtkManager = documentWindowManager.getRequestManager().getVtkManager(outputContext, new VCSimulationDataIdentifier(vcSimulationIdentifier, 0));
} else {
// ---- preliminary : construct the localDatasetControllerProvider
File primaryDir = ResourceUtil.getLocalRootDir();
User usr = sim.getVersion().getOwner();
DataSetControllerImpl dataSetControllerImpl = new DataSetControllerImpl(null, primaryDir, null);
ExportServiceImpl localExportServiceImpl = new ExportServiceImpl();
LocalDataSetControllerProvider localDSCProvider = new LocalDataSetControllerProvider(usr, dataSetControllerImpl, localExportServiceImpl);
VCDataManager vcDataManager = new VCDataManager(localDSCProvider);
File localSimDir = ResourceUtil.getLocalSimDir(User.tempUser.getName());
VCSimulationDataIdentifier simulationDataIdentifier = new LocalVCSimulationDataIdentifier(vcSimulationIdentifier, 0, localSimDir);
vtkManager = new VtkManager(outputContext, vcDataManager, simulationDataIdentifier);
}
//
// test ability to read data
//
VtuVarInfo[] vtuVarInfos = vtkManager.getVtuVarInfos();
double[] times = vtkManager.getDataSetTimes();
//
// create the SimulationDataSetRef
//
VCDocument modelDocument = null;
if (documentWindowManager instanceof BioModelWindowManager) {
modelDocument = ((BioModelWindowManager) documentWindowManager).getBioModel();
} else if (documentWindowManager instanceof MathModelWindowManager) {
modelDocument = ((MathModelWindowManager) documentWindowManager).getMathModel();
}
SimulationDataSetRef simulationDataSetRef = VCellClientDataServiceImpl.createSimulationDataSetRef(sim, modelDocument, 0, isLocal);
// Hashtable<VCSimulationIdentifier, SimulationDataSetRef> simDataSetRefs = (Hashtable<VCSimulationIdentifier, SimulationDataSetRef>)hashTable.get(H_SIM_DATASET_REFS);
// if (simDataSetRefs == null) {
// simDataSetRefs = new Hashtable<VCSimulationIdentifier, SimulationDataSetRef>();
// hashTable.put(H_SIM_DATASET_REFS, simDataSetRefs);
// }
// simDataSetRefs.put(vcSimulationIdentifier, simulationDataSetRef);
File visitExe = VCellConfiguration.getFileProperty(PropertyLoader.visitExe);
if (visitExe != null) {
VisitSupport.launchVisTool(visitExe, simulationDataSetRef);
}
}
} catch (Throwable exc) {
exc.printStackTrace(System.out);
saveFailure(hashTable, sim, exc);
}
}
}
};
taskList.add(retrieveResultsTask);
AsynchClientTask displayResultsTask = new AsynchClientTask("Showing results", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@SuppressWarnings("unchecked")
public void run(Hashtable<String, Object> hashTable) throws Exception {
boolean isLocal = fetch(hashTable, H_LOCAL_SIM, Boolean.class, true);
SimulationWindow.LocalState localState = isLocal ? LocalState.LOCAL : LocalState.SERVER;
Hashtable<Simulation, Throwable> failures = (Hashtable<Simulation, Throwable>) hashTable.get(H_FAILURES);
Simulation[] simsToShow = (Simulation[]) hashTable.get("simsArray");
for (int i = 0; i < simsToShow.length; i++) {
final Simulation sim = simsToShow[i];
if (failures != null && failures.containsKey(sim)) {
continue;
}
final VCSimulationIdentifier vcSimulationIdentifier = simsToShow[i].getSimulationInfo().getAuthoritativeVCSimulationIdentifier();
final SimulationWindow simWindow = documentWindowManager.haveSimulationWindow(vcSimulationIdentifier);
if (simWindow != null) {
ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(documentWindowManager.getComponent());
ChildWindow childWindow = childWindowManager.getChildWindowFromContext(simWindow);
if (childWindow == null) {
childWindow = childWindowManager.addChildWindow(simWindow.getDataViewer(), simWindow);
childWindow.pack();
childWindow.setIsCenteredOnParent();
childWindow.show();
}
setFinalWindow(hashTable, childWindow);
simWindow.setLocalState(localState);
} else {
// wire it up the viewer
Hashtable<VCSimulationIdentifier, DataViewerController> dataViewerControllers = (Hashtable<VCSimulationIdentifier, DataViewerController>) hashTable.get(H_DATA_VIEWER_CONTROLLERS);
DataViewerController viewerController = dataViewerControllers.get(vcSimulationIdentifier);
Throwable ex = (failures == null ? null : failures.get(sim));
if (viewerController != null && ex == null) {
// no failure
DataViewer viewer = viewerController.createViewer();
getSimWorkspace().getSimulationOwner().getOutputFunctionContext().addPropertyChangeListener(viewerController);
documentWindowManager.addExportListener(viewer);
// For data related activities such as calculating statistics
documentWindowManager.addDataJobListener(viewer);
viewer.setSimulationModelInfo(new SimulationWorkspaceModelInfo(getSimWorkspace().getSimulationOwner(), sim.getName()));
viewer.setDataViewerManager(documentWindowManager);
SimulationWindow newWindow = new SimulationWindow(vcSimulationIdentifier, sim, getSimWorkspace().getSimulationOwner(), viewer);
BeanUtils.addCloseWindowKeyboardAction(newWindow.getDataViewer());
documentWindowManager.addResultsFrame(newWindow);
setFinalWindow(hashTable, viewer);
newWindow.setLocalState(localState);
}
}
}
StringBuffer failMessage = new StringBuffer();
if (failures != null) {
if (!failures.isEmpty()) {
failMessage.append("Error, " + failures.size() + " of " + simsToShow.length + " sim results failed to display:\n");
Enumeration<Simulation> en = failures.keys();
while (en.hasMoreElements()) {
Simulation sim = en.nextElement();
Throwable exc = (Throwable) failures.get(sim);
failMessage.append("'" + sim.getName() + "' - " + exc.getMessage());
}
}
}
if (failMessage.length() > 0) {
PopupGenerator.showErrorDialog(ClientSimManager.this.getDocumentWindowManager(), failMessage.toString());
}
}
};
if (viewerType == ViewerType.BothNativeAndPython || viewerType == ViewerType.NativeViewer_only) {
taskList.add(displayResultsTask);
}
// Dispatch the tasks using the ClientTaskDispatcher.
AsynchClientTask[] taskArray = new AsynchClientTask[taskList.size()];
taskList.toArray(taskArray);
return taskArray;
}
use of org.vcell.vis.io.VtuVarInfo in project vcell by virtualcell.
the class VCellProxyHandler method getVariableList.
@Override
public List<VariableInfo> getVariableList(SimulationDataSetRef simulationDataSetRef) throws cbit.vcell.client.pyvcellproxy.ThriftDataAccessException {
try {
VtkManager vtkManager = vcellClientDataService.getVtkManager(simulationDataSetRef);
VtuVarInfo[] vtuVarInfos = vtkManager.getVtuVarInfos();
ArrayList<VariableInfo> varInfoList = new ArrayList<VariableInfo>();
for (VtuVarInfo vtuVarInfo : vtuVarInfos) {
DomainType variableDomainType = null;
switch(vtuVarInfo.variableDomain) {
case VARIABLEDOMAIN_MEMBRANE:
{
variableDomainType = DomainType.MEMBRANE;
break;
}
case VARIABLEDOMAIN_VOLUME:
{
variableDomainType = DomainType.VOLUME;
break;
}
case VARIABLEDOMAIN_POINT:
{
System.err.println("VCellProxyHandler.getVariableList() skipping Point Variable " + vtuVarInfo.name + " ... implement later.");
// skip point variables now.
continue;
}
default:
{
break;
}
}
DataType dataType = null;
switch(vtuVarInfo.dataType) {
case CellData:
{
dataType = DataType.CELLDATA;
break;
}
case PointData:
{
dataType = DataType.POINTDATA;
break;
}
}
String unitsLabel = "<unknown unit>";
if (vtuVarInfo.bMeshVariable) {
// skip "mesh variables" like size, vcRegionArea, etc, globalIndex, etc.
continue;
}
VariableInfo variableInfo = new VariableInfo(vtuVarInfo.name, vtuVarInfo.displayName, vtuVarInfo.domainName, variableDomainType, unitsLabel, vtuVarInfo.bMeshVariable, dataType);
variableInfo.setExpressionString(vtuVarInfo.functionExpression);
varInfoList.add(variableInfo);
}
return varInfoList;
} catch (Exception e) {
e.printStackTrace();
throw new ThriftDataAccessException("failed to retrieve variable list for data set.");
}
}
use of org.vcell.vis.io.VtuVarInfo in project vcell by virtualcell.
the class DataSetControllerImpl method getVtuVarInfos.
public VtuVarInfo[] getVtuVarInfos(ComsolSimFiles comsolFiles, OutputContext outputContext, VCDataIdentifier vcdataID) throws DataAccessException {
try {
DataIdentifier[] dataIdentifiers = getDataIdentifiers(outputContext, vcdataID);
if (dataIdentifiers == null) {
return null;
}
ArrayList<VtuVarInfo> vtuVarInfos = new ArrayList<VtuVarInfo>();
for (DataIdentifier di : dataIdentifiers) {
String name = di.getName();
String displayName = di.getDisplayName();
if (di.getDomain() != null) {
System.err.println("DataSetControllerImpl.getVtuVarInfos(comsol): need to support proper domain names now");
}
String domainName = "domain";
VariableDomain variableDomain = null;
VariableType variableType = di.getVariableType();
if (variableType.equals(VariableType.VOLUME) || variableType.equals(VariableType.VOLUME_REGION)) {
variableDomain = VariableDomain.VARIABLEDOMAIN_VOLUME;
} else if (variableType.equals(VariableType.MEMBRANE) || variableType.equals(VariableType.MEMBRANE_REGION)) {
variableDomain = VariableDomain.VARIABLEDOMAIN_MEMBRANE;
} else if (variableType.equals(VariableType.POINT_VARIABLE)) {
variableDomain = VariableDomain.VARIABLEDOMAIN_POINT;
} else if (variableType.equals(VariableType.CONTOUR) || variableType.equals(VariableType.CONTOUR_REGION)) {
variableDomain = VariableDomain.VARIABLEDOMAIN_CONTOUR;
} else if (variableType.equals(VariableType.NONSPATIAL)) {
variableDomain = VariableDomain.VARIABLEDOMAIN_UNKNOWN;
} else if (variableType.equals(VariableType.POSTPROCESSING)) {
variableDomain = VariableDomain.VARIABLEDOMAIN_POSTPROCESSING;
} else {
System.err.print("skipping var " + di + ", unsupported data type");
}
String functionExpression = null;
boolean bMeshVariable = false;
if (name.toUpperCase().contains("SIZE")) {
System.err.println("Skipping Moving Boundary variable '" + name + "' because it is a size ... change later");
continue;
}
vtuVarInfos.add(new VtuVarInfo(name, displayName, domainName, variableDomain, functionExpression, DataType.PointData, bMeshVariable));
}
return vtuVarInfos.toArray(new VtuVarInfo[0]);
} catch (Exception e) {
lg.error(e.getMessage(), e);
throw new DataAccessException("failed to retrieve VTK variable list: " + e.getMessage(), e);
}
}
use of org.vcell.vis.io.VtuVarInfo in project vcell by virtualcell.
the class DataSetControllerImpl method getVtuVarInfos.
public VtuVarInfo[] getVtuVarInfos(VCellSimFiles vcellFiles, OutputContext outputContext, VCDataIdentifier vcdataID) throws DataAccessException {
try {
CartesianMeshVtkFileWriter cartesianMeshVTKFileWriter = new CartesianMeshVtkFileWriter();
VtuVarInfo[] vtuVarInfos = cartesianMeshVTKFileWriter.getVtuVarInfos(vcellFiles, outputContext, getVCData(vcdataID));
return vtuVarInfos;
} catch (Exception e) {
lg.error(e.getMessage(), e);
throw new DataAccessException("failed to retrieve VTK variable list: " + e.getMessage(), e);
}
}
Aggregations