use of org.vcell.vis.io.ChomboFiles in project vcell by virtualcell.
the class RasterExporter method makeVTKUnstructuredData_Chombo.
public ExportOutput[] makeVTKUnstructuredData_Chombo(OutputContext outputContext, final JobRequest jobRequest, User user, DataServerImpl dataServerImpl, ExportSpecs exportSpecs, File tmpDir, FileDataContainerManager fileDataContainerManager) throws Exception {
String simID = exportSpecs.getVCDataIdentifier().getID();
final VCDataIdentifier vcdID = exportSpecs.getVCDataIdentifier();
VariableSpecs variableSpecs = exportSpecs.getVariableSpecs();
TimeSpecs timeSpecs = exportSpecs.getTimeSpecs();
ChomboFiles chomboFiles = dataServerImpl.getChomboFiles(user, vcdID);
ChomboVtkFileWriter chomboVTKFileWriter = new ChomboVtkFileWriter();
File[] vtkFiles = chomboVTKFileWriter.writeVtuExportFiles(chomboFiles, tmpDir, new ChomboVtkFileWriter.ProgressListener() {
public void progress(double percentDone) {
exportServiceImpl.fireExportProgress(jobRequest.getJobID(), vcdID, "VTKUNSTR", percentDone);
}
});
Vector<ExportOutput> exportOutV = new Vector<ExportOutput>();
for (File file : vtkFiles) {
String dataID = file.getName().replace(simID.toString(), "");
ExportOutput exportOut = new ExportOutput(true, ".vtu", simID.toString(), dataID, fileDataContainerManager);
fileDataContainerManager.manageExistingTempFile(exportOut.getFileDataContainerID(), file);
exportOutV.add(exportOut);
}
ExportOutput[] exportOutputArr = exportOutV.toArray(new ExportOutput[0]);
return exportOutputArr;
}
use of org.vcell.vis.io.ChomboFiles in project vcell by virtualcell.
the class SimulationData method getChomboFiles.
@Override
public ChomboFiles getChomboFiles() throws IOException, XmlParseException, ExpressionException {
if (chomboFileIterationIndices == null) {
throw new RuntimeException("SimulationData.chomboFileIterationIndices is null, can't process Chombo HDF5 files");
}
if (!(getVcDataId() instanceof VCSimulationDataIdentifier)) {
throw new RuntimeException("SimulationData.getVcDataId() is not a VCSimulationDataIdentifier (type is " + getVcDataId().getClass().getName() + "), can't process chombo HDF5 files");
}
VCSimulationDataIdentifier vcDataID = (VCSimulationDataIdentifier) getVcDataId();
String expectedMeshfile = vcDataID.getID() + ".mesh.hdf5";
File meshFile = amplistorHelper.getFile(expectedMeshfile);
ChomboFiles chomboFiles = new ChomboFiles(vcDataID.getSimulationKey(), vcDataID.getJobIndex(), meshFile);
String simtaskFilePath = vcDataID.getID() + "_0.simtask.xml";
File simtaskFile = amplistorHelper.getFile(simtaskFilePath);
if (!simtaskFile.exists()) {
throw new RuntimeException("Chombo dataset mission .simtask.xml file, please rerun");
}
String xmlString = FileUtils.readFileToString(simtaskFile);
SimulationTask simTask = XmlHelper.XMLToSimTask(xmlString);
if (!simTask.getSimulation().getSolverTaskDescription().getChomboSolverSpec().isSaveChomboOutput() && !simTask.getSimulation().getSolverTaskDescription().isParallel()) {
throw new RuntimeException("Export of Chombo simulations to VTK requires chombo data, select 'Chombo' data format in simulation solver options and rerun simulation.");
}
CartesianMeshChombo chomboMesh = (CartesianMeshChombo) mesh;
FeaturePhaseVol[] featurePhaseVols = chomboMesh.getFeaturePhaseVols();
for (int timeIndex : chomboFileIterationIndices) {
if (featurePhaseVols == null) {
// for old format which doesn't have featurephasevols, we need to try ivol up to 20 for each feature
Enumeration<SubDomain> subdomainEnum = simTask.getSimulation().getMathDescription().getSubDomains();
while (subdomainEnum.hasMoreElements()) {
SubDomain subDomain = subdomainEnum.nextElement();
if (subDomain instanceof CompartmentSubDomain) {
for (int ivol = 0; ivol < 20; ++ivol) {
// can be many vol, let us try 20
findChomboFeatureVolFile(chomboFiles, vcDataID, subDomain.getName(), ivol, timeIndex);
}
}
}
} else {
// note: some feature + ivol doesn't have a file if there are no variables defined in that feature
for (FeaturePhaseVol pfv : featurePhaseVols) {
findChomboFeatureVolFile(chomboFiles, vcDataID, pfv.feature, pfv.ivol, timeIndex);
}
}
}
return chomboFiles;
}
Aggregations