Search in sources :

Example 1 with ChomboIndexData

use of org.vcell.vis.vismesh.thrift.ChomboIndexData in project vcell by virtualcell.

the class ChomboVtkFileWriter method getVtuMeshData.

public double[] getVtuMeshData(ChomboFiles chomboFiles, OutputContext outputContext, File destinationDirectory, double time, VtuVarInfo var, int timeIndex) throws Exception {
    ChomboDataset chomboDataset = ChomboFileReader.readDataset(chomboFiles, chomboFiles.getTimeIndices().get(timeIndex));
    String domainName = var.domainName;
    ChomboCombinedVolumeMembraneDomain chomboCombinedVolumeMembraneDomain = chomboDataset.getDomainFromVolumeOrMembraneName(domainName);
    ChomboMeshData chomboMeshData = chomboCombinedVolumeMembraneDomain.getChomboMeshData();
    File chomboIndexDataFile = getChomboIndexDataFileName(destinationDirectory, chomboFiles, domainName);
    if (!chomboIndexDataFile.exists()) {
        writeEmptyMeshFiles(chomboFiles, destinationDirectory, null);
    }
    double[] data = null;
    switch(var.variableDomain) {
        case VARIABLEDOMAIN_CONTOUR:
            {
                break;
            }
        case VARIABLEDOMAIN_MEMBRANE:
            {
                ChomboIndexData chomboIndexData = VisMeshUtils.readChomboIndexData(chomboIndexDataFile);
                List<ChomboVisMembraneIndex> cellIndices = new ArrayList<ChomboVisMembraneIndex>();
                for (ChomboSurfaceIndex chomboSurfaceIndex : chomboIndexData.chomboSurfaceIndices) {
                    cellIndices.add(new SimpleChomboVisMembraneIndex(chomboSurfaceIndex.index));
                }
                data = chomboMeshData.getMembraneCellData(var.name, cellIndices);
                break;
            }
        case VARIABLEDOMAIN_NONSPATIAL:
            {
                break;
            }
        case VARIABLEDOMAIN_POSTPROCESSING:
            {
                break;
            }
        case VARIABLEDOMAIN_UNKNOWN:
            {
                break;
            }
        case VARIABLEDOMAIN_VOLUME:
            {
                ChomboIndexData chomboIndexData = VisMeshUtils.readChomboIndexData(chomboIndexDataFile);
                List<ChomboCellIndices> cellIndices = new ArrayList<ChomboCellIndices>();
                for (ChomboVolumeIndex chomboVolIndex : chomboIndexData.getChomboVolumeIndices()) {
                    cellIndices.add(new SimpleChomboCellIndices(chomboVolIndex.getLevel(), chomboVolIndex.getBoxNumber(), chomboVolIndex.getBoxIndex()));
                }
                if (var.functionExpression != null) {
                    data = evaluateFunction(var, chomboMeshData, cellIndices);
                } else {
                    data = chomboMeshData.getVolumeCellData(var.name, cellIndices);
                }
                break;
            }
        default:
            {
                throw new RuntimeException("unsupported variable type " + var.variableDomain.name() + " for variable " + var.name);
            }
    }
    return data;
}
Also used : ChomboSurfaceIndex(org.vcell.vis.vismesh.thrift.ChomboSurfaceIndex) ChomboIndexData(org.vcell.vis.vismesh.thrift.ChomboIndexData) ChomboVolumeIndex(org.vcell.vis.vismesh.thrift.ChomboVolumeIndex) ChomboCombinedVolumeMembraneDomain(org.vcell.vis.chombo.ChomboDataset.ChomboCombinedVolumeMembraneDomain) ChomboMeshData(org.vcell.vis.chombo.ChomboMeshData) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File) ChomboDataset(org.vcell.vis.chombo.ChomboDataset)

Example 2 with ChomboIndexData

use of org.vcell.vis.vismesh.thrift.ChomboIndexData in project vcell by virtualcell.

the class VisMeshUtils method readChomboIndexData.

public static ChomboIndexData readChomboIndexData(File chomboIndexDataFile) throws IOException {
    TDeserializer deserializer = new TDeserializer(new TBinaryProtocol.Factory());
    byte[] blob = FileUtils.readFileToByteArray(chomboIndexDataFile);
    ChomboIndexData chomboIndexData = new ChomboIndexData();
    try {
        deserializer.deserialize(chomboIndexData, blob);
    } catch (TException e) {
        e.printStackTrace();
        throw new IOException("error reading ChomboIndexData from file " + chomboIndexDataFile.getPath() + ": " + e.getMessage(), e);
    }
    return chomboIndexData;
}
Also used : TException(org.apache.thrift.TException) TDeserializer(org.apache.thrift.TDeserializer) TBinaryProtocol(org.apache.thrift.protocol.TBinaryProtocol) ChomboIndexData(org.vcell.vis.vismesh.thrift.ChomboIndexData) IOException(java.io.IOException)

Aggregations

ChomboIndexData (org.vcell.vis.vismesh.thrift.ChomboIndexData)2 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 TDeserializer (org.apache.thrift.TDeserializer)1 TException (org.apache.thrift.TException)1 TBinaryProtocol (org.apache.thrift.protocol.TBinaryProtocol)1 ChomboDataset (org.vcell.vis.chombo.ChomboDataset)1 ChomboCombinedVolumeMembraneDomain (org.vcell.vis.chombo.ChomboDataset.ChomboCombinedVolumeMembraneDomain)1 ChomboMeshData (org.vcell.vis.chombo.ChomboMeshData)1 ChomboSurfaceIndex (org.vcell.vis.vismesh.thrift.ChomboSurfaceIndex)1 ChomboVolumeIndex (org.vcell.vis.vismesh.thrift.ChomboVolumeIndex)1