Search in sources :

Example 11 with VisMesh

use of org.vcell.vis.vismesh.thrift.VisMesh 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)

Example 12 with VisMesh

use of org.vcell.vis.vismesh.thrift.VisMesh in project vcell by virtualcell.

the class DebugWriteProblem method main.

/**
 * @param args
 */
public static void main(String[] args) {
    try {
        VisMesh visMesh = new VisMesh(3, new Vect3D(0, 0, 0), new Vect3D(3, 1, 1));
        VisPoint[] points0 = new VisPoint[] { new VisPoint(0, 0, 0), new VisPoint(1, 0, 0), new VisPoint(0, 1, 0), new VisPoint(0, 0, 1) };
        visMesh.addToPoints(points0[0]);
        visMesh.addToPoints(points0[1]);
        visMesh.addToPoints(points0[2]);
        visMesh.addToPoints(points0[3]);
        List<PolyhedronFace> faces0 = Arrays.asList(new PolyhedronFace(Arrays.asList(0, 1, 3)), new PolyhedronFace(Arrays.asList(0, 3, 2)), new PolyhedronFace(Arrays.asList(0, 2, 1)), new PolyhedronFace(Arrays.asList(1, 3, 2)));
        int level = 0;
        int boxNumber = 0;
        int boxIndex = 0;
        int fraction = 0;
        VisIrregularPolyhedron genPolyhedra0 = new VisIrregularPolyhedron(faces0);
        genPolyhedra0.setChomboVolumeIndex(new ChomboVolumeIndex(level, boxNumber, boxIndex, fraction));
        visMesh.addToIrregularPolyhedra(genPolyhedra0);
    // VisPoint[] points1 = new VisPoint[] {
    // new VisPoint(2+0, 0, 0),
    // new VisPoint(2+1, 0, 0),
    // new VisPoint(2+0, 1, 0),
    // new VisPoint(2+0, 0, 1)
    // };
    // 
    // visMesh.addPoint(points1[0]);
    // visMesh.addPoint(points1[1]);
    // visMesh.addPoint(points1[2]);
    // visMesh.addPoint(points1[3]);
    // 
    // vtkUnstructuredGrid vtkgrid = VtkGridUtils.getVolumeVtkGrid(visMesh);
    // String filenameASCII = "testASCII.vtk";
    // String filenameBinary = "testBinary.vtk";
    // VtkGridUtils.writeXML(vtkgrid, filenameASCII, true);
    // VtkGridUtils.writeXML(vtkgrid, filenameBinary, false);
    // vtkgrid = VtkGridUtils.read(filenameBinary);
    // vtkgrid.BuildLinks();
    // SimpleVTKViewer simpleViewer = new SimpleVTKViewer();
    // String[] varNames = visDomain.getVisMeshData().getVarNames();
    // simpleViewer.showGrid(vtkgrid, varNames[0], varNames[1]);
    } catch (Exception e) {
        e.printStackTrace(System.out);
    }
}
Also used : VisMesh(org.vcell.vis.vismesh.thrift.VisMesh) PolyhedronFace(org.vcell.vis.vismesh.thrift.PolyhedronFace) VisPoint(org.vcell.vis.vismesh.thrift.VisPoint) VisIrregularPolyhedron(org.vcell.vis.vismesh.thrift.VisIrregularPolyhedron) ChomboVolumeIndex(org.vcell.vis.vismesh.thrift.ChomboVolumeIndex) VisPoint(org.vcell.vis.vismesh.thrift.VisPoint) Vect3D(org.vcell.vis.vismesh.thrift.Vect3D)

Aggregations

VisMesh (org.vcell.vis.vismesh.thrift.VisMesh)12 HashMap (java.util.HashMap)9 VisPoint (org.vcell.vis.vismesh.thrift.VisPoint)7 ISize (org.vcell.util.ISize)6 Vect3D (org.vcell.vis.vismesh.thrift.Vect3D)6 File (java.io.File)5 ArrayList (java.util.ArrayList)4 VisPolygon (org.vcell.vis.vismesh.thrift.VisPolygon)4 IOException (java.io.IOException)3 Box3D (org.vcell.vis.core.Box3D)3 ChomboVolumeIndex (org.vcell.vis.vismesh.thrift.ChomboVolumeIndex)3 FiniteVolumeIndex (org.vcell.vis.vismesh.thrift.FiniteVolumeIndex)3 ExpressionException (cbit.vcell.parser.ExpressionException)2 ChomboBoundaries (org.vcell.vis.chombo.ChomboBoundaries)2 ChomboBox (org.vcell.vis.chombo.ChomboBox)2 ChomboLevel (org.vcell.vis.chombo.ChomboLevel)2 Covering (org.vcell.vis.chombo.ChomboLevel.Covering)2 ChomboLevelData (org.vcell.vis.chombo.ChomboLevelData)2 ChomboMesh (org.vcell.vis.chombo.ChomboMesh)2 ChomboSurfaceIndex (org.vcell.vis.vismesh.thrift.ChomboSurfaceIndex)2