Search in sources :

Example 6 with CartesianMesh

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

Aggregations

CartesianMesh (org.vcell.vis.vcell.CartesianMesh)6 ArrayList (java.util.ArrayList)4 CartesianMeshFileReader (org.vcell.vis.io.CartesianMeshFileReader)4 File (java.io.File)3 MathFormatException (cbit.vcell.math.MathFormatException)2 IOException (java.io.IOException)2 MathException (cbit.vcell.math.MathException)1 VariableDomain (cbit.vcell.math.VariableType.VariableDomain)1 DataIdentifier (cbit.vcell.simdata.DataIdentifier)1 AnnotatedFunction (cbit.vcell.solver.AnnotatedFunction)1 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1 HashMap (java.util.HashMap)1 CommentStringTokenizer (org.vcell.util.CommentStringTokenizer)1 Coordinate (org.vcell.util.Coordinate)1 ISize (org.vcell.util.ISize)1 KeyValue (org.vcell.util.document.KeyValue)1 Vect3D (org.vcell.vis.core.Vect3D)1 VCellSimFiles (org.vcell.vis.io.VCellSimFiles)1 VtuFileContainer (org.vcell.vis.io.VtuFileContainer)1