Search in sources :

Example 1 with ChomboFiles

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;
}
Also used : ChomboVtkFileWriter(org.vcell.vis.mapping.chombo.ChomboVtkFileWriter) ChomboFiles(org.vcell.vis.io.ChomboFiles) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) File(java.io.File) Vector(java.util.Vector)

Example 2 with ChomboFiles

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;
}
Also used : SimulationTask(cbit.vcell.messaging.server.SimulationTask) FeaturePhaseVol(cbit.vcell.solvers.CartesianMeshChombo.FeaturePhaseVol) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) CartesianMeshChombo(cbit.vcell.solvers.CartesianMeshChombo) CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain) FilamentSubDomain(cbit.vcell.math.FilamentSubDomain) SubDomain(cbit.vcell.math.SubDomain) PointSubDomain(cbit.vcell.math.PointSubDomain) MembraneSubDomain(cbit.vcell.math.MembraneSubDomain) ChomboFiles(org.vcell.vis.io.ChomboFiles) CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain) ZipFile(org.apache.commons.compress.archivers.zip.ZipFile) File(java.io.File)

Aggregations

File (java.io.File)2 ChomboFiles (org.vcell.vis.io.ChomboFiles)2 CompartmentSubDomain (cbit.vcell.math.CompartmentSubDomain)1 FilamentSubDomain (cbit.vcell.math.FilamentSubDomain)1 MembraneSubDomain (cbit.vcell.math.MembraneSubDomain)1 PointSubDomain (cbit.vcell.math.PointSubDomain)1 SubDomain (cbit.vcell.math.SubDomain)1 SimulationTask (cbit.vcell.messaging.server.SimulationTask)1 VCSimulationDataIdentifier (cbit.vcell.solver.VCSimulationDataIdentifier)1 CartesianMeshChombo (cbit.vcell.solvers.CartesianMeshChombo)1 FeaturePhaseVol (cbit.vcell.solvers.CartesianMeshChombo.FeaturePhaseVol)1 Vector (java.util.Vector)1 ZipFile (org.apache.commons.compress.archivers.zip.ZipFile)1 VCDataIdentifier (org.vcell.util.document.VCDataIdentifier)1 ChomboVtkFileWriter (org.vcell.vis.mapping.chombo.ChomboVtkFileWriter)1