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;
}
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;
}
Aggregations