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;
}
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;
}
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;
}
Aggregations