use of org.vcell.vis.chombo.ChomboMeshData 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.chombo.ChomboMeshData in project vcell by virtualcell.
the class ChomboFileReader method readDataset.
public static ChomboDataset readDataset(ChomboFiles chomboFiles, int timeIndex) throws Exception {
String meshFilename = chomboFiles.getMeshFile().getPath();
ChomboDataset chomboDataset = new ChomboDataset();
int domainOrdinal = 0;
for (ChomboFileEntry cfe : chomboFiles.getEntries(timeIndex)) {
File domainFile = cfe.getFile();
ChomboMeshData chomboMeshData = readMesh(meshFilename, domainFile.getPath());
ChomboMesh chomboMesh = chomboMeshData.getMesh();
ChomboDataset.ChomboCombinedVolumeMembraneDomain chomboCombinedVolumeMembraneDomain = new ChomboDataset.ChomboCombinedVolumeMembraneDomain(cfe, chomboMesh, chomboMeshData, domainOrdinal);
chomboDataset.addDomain(chomboCombinedVolumeMembraneDomain);
domainOrdinal++;
}
return chomboDataset;
}
use of org.vcell.vis.chombo.ChomboMeshData in project vcell by virtualcell.
the class ChomboVtkFileWriter method getVtuVarInfos.
public VtuVarInfo[] getVtuVarInfos(ChomboFiles chomboFiles, OutputContext outputContext, VCData vcData) throws DataAccessException, IOException {
//
// read the time=0 chombo dataset into memory to get the var names (probably a more efficient way of doing this).
//
ChomboDataset chomboDataset;
try {
int timeIndex = 0;
chomboDataset = ChomboFileReader.readDataset(chomboFiles, chomboFiles.getTimeIndices().get(timeIndex));
} catch (Exception e) {
throw new DataAccessException("failed to read chombo dataset: " + e.getMessage(), e);
}
DataIdentifier[] dataIdentifiers = vcData.getVarAndFunctionDataIdentifiers(outputContext);
for (DataIdentifier di : dataIdentifiers) {
System.out.println(((di.getDomain() != null) ? di.getDomain().getName() : "none") + "::" + di.getName() + "-" + di.getVariableType());
}
//
// for each ChomboDomain get list of built-in (mesh) variables, component (regular) volume variables, and Membrane Variables (still tied to the volume).
//
ArrayList<VtuVarInfo> varInfos = new ArrayList<VtuVarInfo>();
for (ChomboCombinedVolumeMembraneDomain chomboCombinedVolumeMembraneDomain : chomboDataset.getCombinedVolumeMembraneDomains()) {
ChomboMeshData chomboMeshData = chomboCombinedVolumeMembraneDomain.getChomboMeshData();
//
// process Volume variables for this combined domain (chombo stores membrane data with volume)
//
{
String volumeDomainName = chomboCombinedVolumeMembraneDomain.getVolumeDomainName();
VariableDomain volVariableDomain = VariableDomain.VARIABLEDOMAIN_VOLUME;
for (String builtinVarName : chomboMeshData.getVolumeBuiltinNames()) {
String varName = builtinVarName;
String displayName = "(" + volumeDomainName + ") " + varName;
String expressionString = null;
boolean bMeshVariable = true;
varInfos.add(new VtuVarInfo(varName, displayName, volumeDomainName, volVariableDomain, expressionString, DataType.CellData, bMeshVariable));
}
for (String componentVarName : chomboMeshData.getVisibleVolumeDataNames()) {
String varName = componentVarName;
String displayName = "(" + volumeDomainName + ") " + varName;
String expressionString = null;
boolean bMeshVariable = false;
varInfos.add(new VtuVarInfo(varName, displayName, volumeDomainName, volVariableDomain, expressionString, DataType.CellData, bMeshVariable));
}
for (DataIdentifier dataID : dataIdentifiers) {
if (dataID.isVisible() && dataID.getVariableType().getVariableDomain() == VariableDomain.VARIABLEDOMAIN_VOLUME && (dataID.getDomain() == null || dataID.getDomain().getName().equals(volumeDomainName))) {
String displayName = "(" + volumeDomainName + ") " + dataID.getDisplayName();
String expressionString = null;
AnnotatedFunction f = vcData.getFunction(outputContext, dataID.getName());
if (f != null) {
expressionString = f.getExpression().infix();
}
boolean bMeshVar = false;
varInfos.add(new VtuVarInfo(dataID.getName(), displayName, volumeDomainName, volVariableDomain, expressionString, DataType.CellData, bMeshVar));
}
}
}
//
// process membrane variables for this combined domain (chombo stores membrane data with volume)
//
{
String memDomainName = chomboCombinedVolumeMembraneDomain.getMembraneDomainName();
VariableDomain memVariableDomain = VariableDomain.VARIABLEDOMAIN_MEMBRANE;
for (ChomboMembraneVarData membraneVarData : chomboMeshData.getMembraneVarData()) {
String varName = membraneVarData.getName();
String displayName = "(" + membraneVarData.getDomainName() + ") " + varName;
String expressionString = null;
boolean bMeshVariable = false;
varInfos.add(new VtuVarInfo(varName, displayName, memDomainName, memVariableDomain, expressionString, DataType.CellData, bMeshVariable));
}
for (String builtinVarName : chomboMeshData.getMembraneBuiltinNames()) {
String varName = builtinVarName;
String displayName = "(" + memDomainName + ") " + varName;
String expressionString = null;
boolean bMeshVariable = true;
varInfos.add(new VtuVarInfo(varName, displayName, memDomainName, memVariableDomain, expressionString, DataType.CellData, bMeshVariable));
}
for (DataIdentifier dataID : dataIdentifiers) {
if (dataID.isVisible() && dataID.getVariableType().getVariableDomain() == VariableDomain.VARIABLEDOMAIN_MEMBRANE && (dataID.getDomain() == null || dataID.getDomain().getName().equals(memDomainName))) {
String displayName = "(" + memDomainName + ") " + dataID.getDisplayName();
String expressionString = null;
AnnotatedFunction f = vcData.getFunction(outputContext, dataID.getName());
if (f != null) {
expressionString = f.getExpression().infix();
}
boolean bMeshVar = false;
varInfos.add(new VtuVarInfo(dataID.getName(), displayName, memDomainName, memVariableDomain, expressionString, DataType.CellData, bMeshVar));
}
}
}
}
return varInfos.toArray(new VtuVarInfo[0]);
}
use of org.vcell.vis.chombo.ChomboMeshData in project vcell by virtualcell.
the class ChomboVtkFileWriter method writeEmptyMeshFiles.
public File[] writeEmptyMeshFiles(ChomboFiles chomboFiles, File destinationDirectory, ProgressListener progressListener) throws IOException, MathException, DataAccessException {
ArrayList<File> meshFiles = new ArrayList<File>();
int timeIndex = 0;
HashMap<String, VisMesh> domainMeshMap = new HashMap<String, VisMesh>();
ChomboDataset chomboDataset;
try {
chomboDataset = ChomboFileReader.readDataset(chomboFiles, chomboFiles.getTimeIndices().get(timeIndex));
} catch (Exception e) {
throw new DataAccessException("failed to read Chombo Dataset: " + e.getMessage(), e);
}
for (ChomboCombinedVolumeMembraneDomain chomboCombinedVolumeMembraneDomain : chomboDataset.getCombinedVolumeMembraneDomains()) {
ChomboMeshData chomboMeshData = chomboCombinedVolumeMembraneDomain.getChomboMeshData();
ChomboMeshMapping chomboMeshMapping = new ChomboMeshMapping();
VisMesh visMesh = domainMeshMap.get(chomboCombinedVolumeMembraneDomain.getVolumeDomainName());
if (visMesh == null) {
visMesh = chomboMeshMapping.fromMeshData(chomboMeshData, chomboCombinedVolumeMembraneDomain);
domainMeshMap.put(chomboCombinedVolumeMembraneDomain.getVolumeDomainName(), visMesh);
}
String volumeDomainName = chomboCombinedVolumeMembraneDomain.getVolumeDomainName();
//
// write volume mesh file
//
{
File volumeMeshFile = getVtuMeshFileName(destinationDirectory, chomboFiles, volumeDomainName);
File chomboIndexDataFile = getChomboIndexDataFileName(destinationDirectory, chomboFiles, volumeDomainName);
VtkService.getInstance().writeChomboVolumeVtkGridAndIndexData(visMesh, volumeDomainName, volumeMeshFile, chomboIndexDataFile);
meshFiles.add(volumeMeshFile);
}
if (chomboMeshData.getMembraneVarData().size() > 0) {
//
// write membrane mesh file
//
String membraneDomainName = chomboCombinedVolumeMembraneDomain.getMembraneDomainName();
File membraneMeshFile = getVtuMeshFileName(destinationDirectory, chomboFiles, membraneDomainName);
File membraneIndexDataFile = getChomboIndexDataFileName(destinationDirectory, chomboFiles, membraneDomainName);
VtkService.getInstance().writeChomboMembraneVtkGridAndIndexData(visMesh, membraneDomainName, membraneMeshFile, membraneIndexDataFile);
meshFiles.add(membraneMeshFile);
}
}
return meshFiles.toArray(new File[0]);
}
use of org.vcell.vis.chombo.ChomboMeshData in project vcell by virtualcell.
the class ChomboFileReader method main.
public static void main(String[] args) {
try {
ChomboMeshData meshdata = readMesh("C:\\Developer\\eclipse\\workspace\\pyVCell\\ChomboUtils\\SimData\\SimID_85232385_0_.mesh.hdf5", "C:\\Developer\\eclipse\\workspace\\pyVCell\\ChomboUtils\\SimData\\SimID_85232385_0_000075.feature_EC.vol0.hdf5");
System.out.println("read mesh of dimension " + meshdata.getMesh().getDimension());
} catch (Exception e) {
e.printStackTrace(System.out);
}
}
Aggregations