Search in sources :

Example 1 with ChomboMeshData

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;
}
Also used : ChomboSurfaceIndex(org.vcell.vis.vismesh.thrift.ChomboSurfaceIndex) ChomboIndexData(org.vcell.vis.vismesh.thrift.ChomboIndexData) ChomboVolumeIndex(org.vcell.vis.vismesh.thrift.ChomboVolumeIndex) ChomboCombinedVolumeMembraneDomain(org.vcell.vis.chombo.ChomboDataset.ChomboCombinedVolumeMembraneDomain) ChomboMeshData(org.vcell.vis.chombo.ChomboMeshData) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File) ChomboDataset(org.vcell.vis.chombo.ChomboDataset)

Example 2 with ChomboMeshData

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;
}
Also used : ChomboMesh(org.vcell.vis.chombo.ChomboMesh) ChomboMeshData(org.vcell.vis.chombo.ChomboMeshData) ChomboFileEntry(org.vcell.vis.io.ChomboFiles.ChomboFileEntry) File(java.io.File) ChomboDataset(org.vcell.vis.chombo.ChomboDataset)

Example 3 with ChomboMeshData

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]);
}
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)

Example 4 with ChomboMeshData

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]);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) 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) VisMesh(org.vcell.vis.vismesh.thrift.VisMesh) ChomboCombinedVolumeMembraneDomain(org.vcell.vis.chombo.ChomboDataset.ChomboCombinedVolumeMembraneDomain) ChomboMeshData(org.vcell.vis.chombo.ChomboMeshData) File(java.io.File) DataAccessException(org.vcell.util.DataAccessException) ChomboDataset(org.vcell.vis.chombo.ChomboDataset)

Example 5 with ChomboMeshData

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);
    }
}
Also used : ChomboMeshData(org.vcell.vis.chombo.ChomboMeshData)

Aggregations

ChomboMeshData (org.vcell.vis.chombo.ChomboMeshData)6 File (java.io.File)4 ChomboDataset (org.vcell.vis.chombo.ChomboDataset)4 ArrayList (java.util.ArrayList)3 ChomboCombinedVolumeMembraneDomain (org.vcell.vis.chombo.ChomboDataset.ChomboCombinedVolumeMembraneDomain)3 MathException (cbit.vcell.math.MathException)2 DivideByZeroException (cbit.vcell.parser.DivideByZeroException)2 ExpressionBindingException (cbit.vcell.parser.ExpressionBindingException)2 ExpressionException (cbit.vcell.parser.ExpressionException)2 IOException (java.io.IOException)2 DataAccessException (org.vcell.util.DataAccessException)2 ChomboMesh (org.vcell.vis.chombo.ChomboMesh)2 VariableDomain (cbit.vcell.math.VariableType.VariableDomain)1 DataIdentifier (cbit.vcell.simdata.DataIdentifier)1 AnnotatedFunction (cbit.vcell.solver.AnnotatedFunction)1 CartesianMeshChombo (cbit.vcell.solvers.CartesianMeshChombo)1 FeaturePhaseVol (cbit.vcell.solvers.CartesianMeshChombo.FeaturePhaseVol)1 HashMap (java.util.HashMap)1 List (java.util.List)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1