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