Search in sources :

Example 1 with ChomboFileEntry

use of org.vcell.vis.io.ChomboFiles.ChomboFileEntry 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 2 with ChomboFileEntry

use of org.vcell.vis.io.ChomboFiles.ChomboFileEntry in project vcell by virtualcell.

the class ChomboVtkFileWriter method getEmptyVtuMeshFiles.

public VtuFileContainer getEmptyVtuMeshFiles(ChomboFiles chomboFiles, File destinationDirectory) throws IOException, MathException, DataAccessException {
    // 
    // find mesh for each file at time 0
    // 
    List<ChomboFileEntry> chomboFileEntries = chomboFiles.getEntries(0);
    ArrayList<File> meshFiles = new ArrayList<File>();
    ArrayList<String> domains = new ArrayList<String>();
    // 
    // look at domains returned from chomboFiles (volume domains only) and check for existence of corresponding volume mesh files.
    // 
    boolean bMeshFileMissing = false;
    for (ChomboFileEntry cfe : chomboFileEntries) {
        File volumeMeshFile = getVtuMeshFileName(destinationDirectory, chomboFiles, cfe.getVolumeDomainName());
        meshFiles.add(volumeMeshFile);
        domains.add(cfe.getVolumeDomainName());
        if (!volumeMeshFile.exists()) {
            bMeshFileMissing = true;
        }
    }
    // 
    if (bMeshFileMissing) {
        writeEmptyMeshFiles(chomboFiles, destinationDirectory, null);
    }
    // 
    for (ChomboFileEntry cfe : chomboFileEntries) {
        String membraneDomainName = cfe.getMembraneDomainName();
        File membraneMeshFile = getVtuMeshFileName(destinationDirectory, chomboFiles, membraneDomainName);
        if (membraneMeshFile.exists()) {
            meshFiles.add(membraneMeshFile);
            domains.add(membraneDomainName);
        }
    }
    // 
    // for all mesh files (volume and membrane) make a VtuMesh entry (with domainName and file contents).
    // 
    VtuFileContainer vtuFileContainer = new VtuFileContainer();
    for (int i = 0; i < meshFiles.size(); i++) {
        byte[] vtuMeshFileContents = FileUtils.readByteArrayFromFile(meshFiles.get(i));
        vtuFileContainer.addVtuMesh(new VtuFileContainer.VtuMesh(domains.get(i), 0.0, vtuMeshFileContents));
    }
    return vtuFileContainer;
}
Also used : ArrayList(java.util.ArrayList) ChomboFileEntry(org.vcell.vis.io.ChomboFiles.ChomboFileEntry) VtuFileContainer(org.vcell.vis.io.VtuFileContainer) File(java.io.File)

Aggregations

File (java.io.File)2 ChomboFileEntry (org.vcell.vis.io.ChomboFiles.ChomboFileEntry)2 ArrayList (java.util.ArrayList)1 ChomboDataset (org.vcell.vis.chombo.ChomboDataset)1 ChomboMesh (org.vcell.vis.chombo.ChomboMesh)1 ChomboMeshData (org.vcell.vis.chombo.ChomboMeshData)1 VtuFileContainer (org.vcell.vis.io.VtuFileContainer)1