Search in sources :

Example 1 with ChomboMembraneVarData

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
        }
    }
}
Also used : Group(ncsa.hdf.object.Group) HObject(ncsa.hdf.object.HObject) Attribute(ncsa.hdf.object.Attribute) ChomboDataset(org.vcell.vis.chombo.ChomboDataset) Dataset(ncsa.hdf.object.Dataset) HObject(ncsa.hdf.object.HObject) ChomboMembraneVarData(org.vcell.vis.chombo.ChomboMembraneVarData)

Example 2 with ChomboMembraneVarData

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]);
}
Also used : VtuVarInfo(org.vcell.vis.io.VtuVarInfo) DataIdentifier(cbit.vcell.simdata.DataIdentifier) VariableDomain(cbit.vcell.math.VariableType.VariableDomain) ArrayList(java.util.ArrayList) ChomboMembraneVarData(org.vcell.vis.chombo.ChomboMembraneVarData) DivideByZeroException(cbit.vcell.parser.DivideByZeroException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) ExpressionException(cbit.vcell.parser.ExpressionException) ExpressionBindingException(cbit.vcell.parser.ExpressionBindingException) MathException(cbit.vcell.math.MathException) ChomboCombinedVolumeMembraneDomain(org.vcell.vis.chombo.ChomboDataset.ChomboCombinedVolumeMembraneDomain) ChomboMeshData(org.vcell.vis.chombo.ChomboMeshData) DataAccessException(org.vcell.util.DataAccessException) ChomboDataset(org.vcell.vis.chombo.ChomboDataset) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction)

Aggregations

ChomboDataset (org.vcell.vis.chombo.ChomboDataset)2 ChomboMembraneVarData (org.vcell.vis.chombo.ChomboMembraneVarData)2 MathException (cbit.vcell.math.MathException)1 VariableDomain (cbit.vcell.math.VariableType.VariableDomain)1 DivideByZeroException (cbit.vcell.parser.DivideByZeroException)1 ExpressionBindingException (cbit.vcell.parser.ExpressionBindingException)1 ExpressionException (cbit.vcell.parser.ExpressionException)1 DataIdentifier (cbit.vcell.simdata.DataIdentifier)1 AnnotatedFunction (cbit.vcell.solver.AnnotatedFunction)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Attribute (ncsa.hdf.object.Attribute)1 Dataset (ncsa.hdf.object.Dataset)1 Group (ncsa.hdf.object.Group)1 HObject (ncsa.hdf.object.HObject)1 DataAccessException (org.vcell.util.DataAccessException)1 ChomboCombinedVolumeMembraneDomain (org.vcell.vis.chombo.ChomboDataset.ChomboCombinedVolumeMembraneDomain)1 ChomboMeshData (org.vcell.vis.chombo.ChomboMeshData)1 VtuVarInfo (org.vcell.vis.io.VtuVarInfo)1