Search in sources :

Example 1 with MovingBoundaryIndexData

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

the class MovingBoundaryVtkFileWriter method getMovingBoundaryIndexData.

public MovingBoundaryIndexData getMovingBoundaryIndexData(MovingBoundarySimFiles movingBoundarySimFiles, File destinationDirectory, VtuVarInfo var, int timeIndex) throws Exception {
    String domainName = var.domainName;
    File movingBoundaryIndexDataFile = getMovingBoundaryIndexDataFileName(movingBoundarySimFiles, domainName, timeIndex);
    if (!movingBoundaryIndexDataFile.exists()) {
        writeEmptyMeshFiles(movingBoundarySimFiles, timeIndex, destinationDirectory, null);
    }
    MovingBoundaryIndexData movingBoundaryIndexData = VisMeshUtils.readMovingBoundaryIndexData(movingBoundaryIndexDataFile);
    return movingBoundaryIndexData;
}
Also used : MovingBoundaryIndexData(org.vcell.vis.vismesh.thrift.MovingBoundaryIndexData) File(java.io.File)

Example 2 with MovingBoundaryIndexData

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

the class MovingBoundaryVtkFileWriter method getVtuMeshData.

public double[] getVtuMeshData(MovingBoundarySimFiles movingBoundarySimFiles, double[] fullRasterData, File destinationDirectory, VtuVarInfo var, int timeIndex) throws Exception {
    MovingBoundaryReader reader = new MovingBoundaryReader(movingBoundarySimFiles.hdf5OutputFile.getAbsolutePath());
    Plane plane = reader.getPlane(timeIndex);
    int numX = plane.getSizeX();
    int numY = plane.getSizeY();
    DoubleBuffer buffer = DoubleBuffer.wrap(new double[numX * numY]);
    for (int j = 0; j < numY; j++) {
        for (int i = 0; i < numX; i++) {
            Element element = plane.get(i, j);
            if (element != null) {
                if (var.variableDomain == VariableDomain.VARIABLEDOMAIN_VOLUME && var.domainName.equals(reader.getFakeInsideDomainName())) {
                    if (element.position == Position.BOUNDARY || element.position == Position.INSIDE) {
                        buffer.put(fullRasterData[i + numX * j]);
                    // buffer.put(species.mass);
                    // buffer.put(i+j*numX);
                    // buffer.put(i);
                    // buffer.put(j);
                    } else {
                    // skip this element, it is "outside" domain.
                    }
                }
            } else {
                System.out.println("found empty species at index(" + i + "," + j + ")");
            }
        }
    }
    double[] volumeData = buffer.array();
    double[] data = null;
    switch(var.variableDomain) {
        case VARIABLEDOMAIN_CONTOUR:
            {
                break;
            }
        case VARIABLEDOMAIN_MEMBRANE:
            {
                /*
				MovingBoundaryIndexData movingBoundaryIndexData = 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:
            {
                MovingBoundaryIndexData movingBoundaryIndexData = getMovingBoundaryIndexData(movingBoundarySimFiles, destinationDirectory, var, timeIndex);
                if (var.functionExpression != null) {
                    throw new UnsupportedOperationException();
                } else {
                    int numElements = movingBoundaryIndexData.movingBoundaryVolumeIndices.size();
                    data = new double[numElements];
                    int i = 0;
                    for (MovingBoundaryVolumeIndex mbvIndex : movingBoundaryIndexData.movingBoundaryVolumeIndices) {
                        data[i++] = volumeData[mbvIndex.index];
                    }
                }
                break;
            }
        default:
            {
                throw new RuntimeException("unsupported variable type " + var.variableDomain.name() + " for variable " + var.name);
            }
    }
    return data;
}
Also used : DoubleBuffer(java.nio.DoubleBuffer) MovingBoundaryIndexData(org.vcell.vis.vismesh.thrift.MovingBoundaryIndexData) Plane(cbit.vcell.solvers.mb.MovingBoundaryTypes.Plane) Element(cbit.vcell.solvers.mb.MovingBoundaryTypes.Element) MovingBoundaryReader(cbit.vcell.solvers.mb.MovingBoundaryReader) MovingBoundaryVolumeIndex(org.vcell.vis.vismesh.thrift.MovingBoundaryVolumeIndex)

Example 3 with MovingBoundaryIndexData

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

the class VisMeshUtils method readMovingBoundaryIndexData.

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

Aggregations

MovingBoundaryIndexData (org.vcell.vis.vismesh.thrift.MovingBoundaryIndexData)3 MovingBoundaryReader (cbit.vcell.solvers.mb.MovingBoundaryReader)1 Element (cbit.vcell.solvers.mb.MovingBoundaryTypes.Element)1 Plane (cbit.vcell.solvers.mb.MovingBoundaryTypes.Plane)1 File (java.io.File)1 IOException (java.io.IOException)1 DoubleBuffer (java.nio.DoubleBuffer)1 TDeserializer (org.apache.thrift.TDeserializer)1 TException (org.apache.thrift.TException)1 TBinaryProtocol (org.apache.thrift.protocol.TBinaryProtocol)1 MovingBoundaryVolumeIndex (org.vcell.vis.vismesh.thrift.MovingBoundaryVolumeIndex)1