use of org.vcell.vis.vcell.CartesianMesh in project vcell by virtualcell.
the class CartesianMeshVtkFileWriter method writeEmptyMeshFiles.
public File[] writeEmptyMeshFiles(VCellSimFiles vcellFiles, File destinationDirectory, ProgressListener progressListener) throws IOException, MathException {
if (destinationDirectory == null || !destinationDirectory.isDirectory()) {
throw new RuntimeException("destinationDirectory '" + destinationDirectory + " not valid");
}
//
// read the simplified cartesian mesh
//
CartesianMeshFileReader reader = new CartesianMeshFileReader();
CartesianMesh mesh = reader.readFromFiles(vcellFiles);
//
// for each volume domain in mesh, extract the associated VisMesh
//
List<String> volumeDomainNames = mesh.getVolumeDomainNames();
HashMap<String, VisMesh> domainMeshMap = new HashMap<String, VisMesh>();
for (String volumeDomainName : volumeDomainNames) {
CartesianMeshMapping meshMapping = new CartesianMeshMapping();
VisMesh visMesh = meshMapping.fromMeshData(mesh, volumeDomainName, true);
domainMeshMap.put(volumeDomainName, visMesh);
}
//
// for each membrane domain in mesh, extract the associated VisMesh
//
List<String> membraneDomainNames = mesh.getMembraneDomainNames();
for (String membraneDomainName : membraneDomainNames) {
CartesianMeshMapping meshMapping = new CartesianMeshMapping();
VisMesh visMesh = meshMapping.fromMeshData(mesh, membraneDomainName, false);
domainMeshMap.put(membraneDomainName, visMesh);
}
ArrayList<String> allDomainNames = new ArrayList<String>();
allDomainNames.addAll(volumeDomainNames);
allDomainNames.addAll(membraneDomainNames);
int numFiles = vcellFiles.getTimes().size() * allDomainNames.size();
ArrayList<File> files = new ArrayList<File>();
int filesProcessed = 0;
for (final String domainName : allDomainNames) {
//
// find the globalIndexes for each domain element - use this to extract the domain-only data.
//
VisMesh visMesh = domainMeshMap.get(domainName);
File vtuFile = getVtuMeshFileName(vcellFiles, domainName);
File fvIndexDataFileName = getFiniteVolumeIndexDataFileName(vcellFiles, domainName);
VtkService.getInstance().writeFiniteVolumeSmoothedVtkGridAndIndexData(visMesh, domainName, vtuFile, fvIndexDataFileName);
files.add(vtuFile);
filesProcessed++;
if (progressListener != null) {
progressListener.progress(((double) filesProcessed) / numFiles);
}
}
return files.toArray(new File[0]);
}
Aggregations