Search in sources :

Example 1 with MovingBoundaryVolumeIndex

use of org.vcell.vis.vismesh.thrift.MovingBoundaryVolumeIndex 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 2 with MovingBoundaryVolumeIndex

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

the class MovingBoundaryMeshMapping method fromReader.

public VisMesh fromReader(MovingBoundaryReader reader, DomainType domainType, int timeIndex) {
    MeshInfo meshInfo = reader.getMeshInfo();
    ISize size = new ISize(meshInfo.xinfo.number(), meshInfo.yinfo.number(), 1);
    Plane plane = reader.getPlane(timeIndex);
    int numX = size.getX();
    int numY = size.getY();
    int dimension = 2;
    Vect3D origin = new Vect3D(meshInfo.xinfo.start, meshInfo.yinfo.start, 0.0);
    Vect3D extent = new Vect3D(meshInfo.xinfo.end - meshInfo.xinfo.start, meshInfo.yinfo.end - meshInfo.yinfo.start, 1.0);
    // invoke VisMesh() constructor
    VisMesh visMesh = new VisMesh(dimension, origin, extent);
    int currPointIndex = 0;
    HashMap<String, Integer> pointDict = new HashMap<String, Integer>();
    PointIndex pointIndex = reader.getPointIndex();
    if (domainType == DomainType.INSIDE || domainType == DomainType.OUTSIDE) {
        int volumeIndex = 0;
        for (int j = 0; j < numY; j++) {
            for (int i = 0; i < numX; i++) {
                Element mbElement = plane.get(i, j);
                if ((domainType == DomainType.INSIDE && (mbElement.position == Position.INSIDE || mbElement.position == Position.BOUNDARY)) || (domainType == DomainType.OUTSIDE && mbElement.position == Position.OUTSIDE)) {
                    ArrayList<Integer> elementVisIndices = new ArrayList<Integer>();
                    int[] elementPointIndices = mbElement.boundary();
                    // first and last index is same
                    int numUniqueElementIndices = elementPointIndices.length - 1;
                    for (int p = 0; p < numUniqueElementIndices; p++) {
                        Vect3Didx point = pointIndex.lookup(elementPointIndices[p]);
                        VisPoint visPoint = new VisPoint(point.x, point.y, point.z);
                        String visPointKey = toStringKey(visPoint);
                        Integer visPointIndex = pointDict.get(visPointKey);
                        if (visPointIndex == null) {
                            visPointIndex = currPointIndex++;
                            pointDict.put(visPointKey, visPointIndex);
                            visMesh.addToPoints(visPoint);
                        }
                        elementVisIndices.add(visPointIndex);
                    }
                    VisPolygon polygon = new VisPolygon(elementVisIndices);
                    polygon.setMovingBoundaryVolumeIndex(new MovingBoundaryVolumeIndex(volumeIndex));
                    visMesh.addToPolygons(polygon);
                    volumeIndex++;
                }
            // end if
            }
        // end i
        }
    // end j
    } else if (domainType == DomainType.MEMBRANE) {
        throw new RuntimeException("DomainType MEMBRANE not yet implemented for moving boundary vtk processing");
    }
    return visMesh;
}
Also used : Plane(cbit.vcell.solvers.mb.MovingBoundaryTypes.Plane) HashMap(java.util.HashMap) ISize(org.vcell.util.ISize) Element(cbit.vcell.solvers.mb.MovingBoundaryTypes.Element) ArrayList(java.util.ArrayList) VisPoint(org.vcell.vis.vismesh.thrift.VisPoint) Vect3D(org.vcell.vis.vismesh.thrift.Vect3D) VisMesh(org.vcell.vis.vismesh.thrift.VisMesh) PointIndex(cbit.vcell.solvers.mb.PointIndex) VisPolygon(org.vcell.vis.vismesh.thrift.VisPolygon) MeshInfo(cbit.vcell.solvers.mb.MovingBoundaryTypes.MeshInfo) Vect3Didx(cbit.vcell.solvers.mb.Vect3Didx) MovingBoundaryVolumeIndex(org.vcell.vis.vismesh.thrift.MovingBoundaryVolumeIndex) VisPoint(org.vcell.vis.vismesh.thrift.VisPoint)

Aggregations

Element (cbit.vcell.solvers.mb.MovingBoundaryTypes.Element)2 Plane (cbit.vcell.solvers.mb.MovingBoundaryTypes.Plane)2 MovingBoundaryVolumeIndex (org.vcell.vis.vismesh.thrift.MovingBoundaryVolumeIndex)2 MovingBoundaryReader (cbit.vcell.solvers.mb.MovingBoundaryReader)1 MeshInfo (cbit.vcell.solvers.mb.MovingBoundaryTypes.MeshInfo)1 PointIndex (cbit.vcell.solvers.mb.PointIndex)1 Vect3Didx (cbit.vcell.solvers.mb.Vect3Didx)1 DoubleBuffer (java.nio.DoubleBuffer)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ISize (org.vcell.util.ISize)1 MovingBoundaryIndexData (org.vcell.vis.vismesh.thrift.MovingBoundaryIndexData)1 Vect3D (org.vcell.vis.vismesh.thrift.Vect3D)1 VisMesh (org.vcell.vis.vismesh.thrift.VisMesh)1 VisPoint (org.vcell.vis.vismesh.thrift.VisPoint)1 VisPolygon (org.vcell.vis.vismesh.thrift.VisPolygon)1