use of org.vcell.vis.chombo.ChomboMembraneVarData in project vcell by virtualcell.
the class ChomboFileReader method readMembraneVarData.
//
// Membrane data are stored as a UCHC (or vcell) extension to the normal Chombo Data.
// ChomboMembraneVarData was formally called VCellSolution by Fei.
//
private static void readMembraneVarData(ChomboMeshData chomboMeshData, Group rootGroup) {
// I added solution and extrapolated_volumes group to hold all the solutions from vcell
String[] groups = new String[] { "solution" /*, "extrapolated_volumes"*/
};
for (String group : groups) {
try {
Group vcellGroup = Hdf5Reader.getChildGroup(rootGroup, group);
if (vcellGroup != null) {
List<HObject> children = vcellGroup.getMemberList();
for (HObject c : children) {
if (c instanceof Dataset) {
Dataset dataset = (Dataset) c;
String name = dataset.getName();
List<Attribute> solAttrList = dataset.getMetadata();
String domain = null;
for (Attribute attr : solAttrList) {
String attrName = attr.getName();
if (attrName.equals("domain")) {
Object obj = attr.getValue();
domain = ((String[]) obj)[0];
break;
}
}
ChomboMembraneVarData vcellSolution = new ChomboMembraneVarData(name, domain, (double[]) dataset.read());
chomboMeshData.addMembraneVarData(vcellSolution);
}
}
}
} catch (Exception ex) {
// it is ok if there is no vcell group
}
}
}
use of org.vcell.vis.chombo.ChomboMembraneVarData 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]);
}
Aggregations