Search in sources :

Example 1 with CartesianMeshVtkFileWriter

use of org.vcell.vis.mapping.vcell.CartesianMeshVtkFileWriter in project vcell by virtualcell.

the class DataSetControllerImpl method getVtuVarInfos.

public VtuVarInfo[] getVtuVarInfos(VCellSimFiles vcellFiles, OutputContext outputContext, VCDataIdentifier vcdataID) throws DataAccessException {
    try {
        CartesianMeshVtkFileWriter cartesianMeshVTKFileWriter = new CartesianMeshVtkFileWriter();
        VtuVarInfo[] vtuVarInfos = cartesianMeshVTKFileWriter.getVtuVarInfos(vcellFiles, outputContext, getVCData(vcdataID));
        return vtuVarInfos;
    } catch (Exception e) {
        lg.error(e.getMessage(), e);
        throw new DataAccessException("failed to retrieve VTK variable list: " + e.getMessage(), e);
    }
}
Also used : VtuVarInfo(org.vcell.vis.io.VtuVarInfo) CartesianMeshVtkFileWriter(org.vcell.vis.mapping.vcell.CartesianMeshVtkFileWriter) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) XmlParseException(cbit.vcell.xml.XmlParseException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) DivideByZeroException(cbit.vcell.parser.DivideByZeroException) CacheException(org.vcell.util.CacheException) ExpressionBindingException(cbit.vcell.parser.ExpressionBindingException) FileNotFoundException(java.io.FileNotFoundException) ExpressionException(cbit.vcell.parser.ExpressionException) MathException(cbit.vcell.math.MathException) DataAccessException(org.vcell.util.DataAccessException)

Example 2 with CartesianMeshVtkFileWriter

use of org.vcell.vis.mapping.vcell.CartesianMeshVtkFileWriter in project vcell by virtualcell.

the class DataSetControllerImpl method getVtuMeshData.

public double[] getVtuMeshData(VCellSimFiles vcellFiles, OutputContext outputContext, VCDataIdentifier vcdataID, VtuVarInfo var, double time) throws DataAccessException {
    try {
        CartesianMeshVtkFileWriter cartesianMeshVTKFileWriter = new CartesianMeshVtkFileWriter();
        SimDataBlock simDataBlock = getSimDataBlock(outputContext, vcdataID, var.name, time);
        double[] vtuData = cartesianMeshVTKFileWriter.getVtuMeshData(vcellFiles, outputContext, simDataBlock, getUserDataDirectory(vcdataID), var, time);
        return vtuData;
    } catch (Exception e) {
        lg.error(e.getMessage(), e);
        throw new DataAccessException("failed to retrieve VTK files: " + e.getMessage(), e);
    }
}
Also used : CartesianMeshVtkFileWriter(org.vcell.vis.mapping.vcell.CartesianMeshVtkFileWriter) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) XmlParseException(cbit.vcell.xml.XmlParseException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) DivideByZeroException(cbit.vcell.parser.DivideByZeroException) CacheException(org.vcell.util.CacheException) ExpressionBindingException(cbit.vcell.parser.ExpressionBindingException) FileNotFoundException(java.io.FileNotFoundException) ExpressionException(cbit.vcell.parser.ExpressionException) MathException(cbit.vcell.math.MathException) DataAccessException(org.vcell.util.DataAccessException)

Example 3 with CartesianMeshVtkFileWriter

use of org.vcell.vis.mapping.vcell.CartesianMeshVtkFileWriter in project vcell by virtualcell.

the class RasterExporter method makeVTKUnstructuredData_VCell.

public ExportOutput[] makeVTKUnstructuredData_VCell(OutputContext outputContext, final JobRequest jobRequest, User user, DataServerImpl dataServerImpl, ExportSpecs exportSpecs, File tmpDir, FileDataContainerManager fileDataContainerManager) throws Exception {
    String simID = exportSpecs.getVCDataIdentifier().getID();
    final VCDataIdentifier vcdID = exportSpecs.getVCDataIdentifier();
    VariableSpecs variableSpecs = exportSpecs.getVariableSpecs();
    TimeSpecs timeSpecs = exportSpecs.getTimeSpecs();
    VCellSimFiles vcellFiles = dataServerImpl.getVCellSimFiles(user, vcdID);
    CartesianMeshVtkFileWriter cartesianMeshVtkFileWriter = new CartesianMeshVtkFileWriter();
    File[] vtkFiles = cartesianMeshVtkFileWriter.writeVtuExportFiles(vcellFiles, tmpDir, new CartesianMeshVtkFileWriter.ProgressListener() {

        public void progress(double percentDone) {
            exportServiceImpl.fireExportProgress(jobRequest.getJobID(), vcdID, "VTKUNSTR", percentDone);
        }
    });
    Vector<ExportOutput> exportOutV = new Vector<ExportOutput>();
    for (File file : vtkFiles) {
        String dataID = file.getName().replace(simID.toString(), "");
        ExportOutput exportOut = new ExportOutput(true, ".vtu", simID.toString(), dataID, fileDataContainerManager);
        fileDataContainerManager.manageExistingTempFile(exportOut.getFileDataContainerID(), file);
        exportOutV.add(exportOut);
    }
    ExportOutput[] exportOutputArr = exportOutV.toArray(new ExportOutput[0]);
    return exportOutputArr;
}
Also used : CartesianMeshVtkFileWriter(org.vcell.vis.mapping.vcell.CartesianMeshVtkFileWriter) VCellSimFiles(org.vcell.vis.io.VCellSimFiles) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) File(java.io.File) Vector(java.util.Vector)

Example 4 with CartesianMeshVtkFileWriter

use of org.vcell.vis.mapping.vcell.CartesianMeshVtkFileWriter in project vcell by virtualcell.

the class VCellDataTest method main.

/**
 * @param args
 */
public static void main(String[] args) {
    try {
        ResourceUtil.setNativeLibraryDirectory();
        KeyValue simKey = new KeyValue("1661241954");
        String pathPrefix = "C:\\Users\\schaff\\.vcell\\simdata\\user\\";
        File meshFile = new File(pathPrefix + "SimID_" + simKey + "_0_.mesh");
        File meshMetricsFile = new File(pathPrefix + "SimID_" + simKey + "_0_.meshmetrics");
        File subdomainFile = new File(pathPrefix + "SimID_" + simKey + "_0_.subdomains");
        File logFile = new File(pathPrefix + "SimID_" + simKey + "_0_.log");
        File zipFile = new File(pathPrefix + "SimID_" + simKey + "_0_00.zip");
        File postprocessingFile = new File(pathPrefix + "SimID_" + simKey + "_0_.hdf5");
        VCellSimFiles vcellFiles = new VCellSimFiles(simKey, 0, meshFile, meshMetricsFile, subdomainFile, logFile, postprocessingFile);
        vcellFiles.addDataFileEntry(zipFile, new File("SimID_" + simKey + "_0_0000.sim"), 0.0);
        // vcellFiles.addDataFileEntry(zipFile,new File("SimID_"+simKey+"_0_0001.sim"),0.05);
        // vcellFiles.addDataFileEntry(zipFile,new File("SimID_"+simKey+"_0_0002.sim"),0.10);
        // vcellFiles.addDataFileEntry(zipFile,new File("SimID_"+simKey+"_0_0003.sim"),0.15);
        // vcellFiles.addDataFileEntry(zipFile,new File("SimID_"+simKey+"_0_0004.sim"),0.20);
        // vcellFiles.addDataFileEntry(zipFile,new File("SimID_"+simKey+"_0_0005.sim"),0.25);
        // vcellFiles.addDataFileEntry(zipFile,new File("SimID_"+simKey+"_0_0006.sim"),0.30);
        // vcellFiles.addDataFileEntry(zipFile,new File("SimID_"+simKey+"_0_0007.sim"),0.35);
        // vcellFiles.addDataFileEntry(zipFile,new File("SimID_"+simKey+"_0_0008.sim"),0.40);
        // vcellFiles.addDataFileEntry(zipFile,new File("SimID_"+simKey+"_0_0009.sim"),0.45);
        // vcellFiles.addDataFileEntry(zipFile,new File("SimID_"+simKey+"_0_0010.sim"),0.50);
        // vcellFiles.addDataFileEntry(zipFile,new File("SimID_"+simKey+"_0_0011.sim"),0.55);
        // vcellFiles.addDataFileEntry(zipFile,new File("SimID_"+simKey+"_0_0012.sim"),0.60);
        // vcellFiles.addDataFileEntry(zipFile,new File("SimID_"+simKey+"_0_0013.sim"),0.65);
        // vcellFiles.addDataFileEntry(zipFile,new File("SimID_"+simKey+"_0_0014.sim"),0.70);
        // vcellFiles.addDataFileEntry(zipFile,new File("SimID_"+simKey+"_0_0015.sim"),0.75);
        // vcellFiles.addDataFileEntry(zipFile,new File("SimID_"+simKey+"_0_0016.sim"),0.80);
        // vcellFiles.addDataFileEntry(zipFile,new File("SimID_"+simKey+"_0_0017.sim"),0.85);
        // vcellFiles.addDataFileEntry(zipFile,new File("SimID_"+simKey+"_0_0018.sim"),0.90);
        // vcellFiles.addDataFileEntry(zipFile,new File("SimID_"+simKey+"_0_0019.sim"),0.95);
        // vcellFiles.addDataFileEntry(zipFile,new File("SimID_"+simKey+"_0_0020.sim"),1.0);
        // process each domain separately (only have to process the mesh once for each one)
        CartesianMeshVtkFileWriter cartesianMeshVtkFileWriter = new CartesianMeshVtkFileWriter();
        File destinationDirectory = new File("C:\\Developer\\eclipse\\workspace\\VCell_5.3_visfull\\VtkData\\");
        File[] generatedFiles = cartesianMeshVtkFileWriter.writeVtuExportFiles(vcellFiles, destinationDirectory, null);
        boolean bDisplay = true;
        if (bDisplay) {
            CartesianMeshFileReader reader = new CartesianMeshFileReader();
            CartesianMesh mesh = reader.readFromFiles(vcellFiles);
            ArrayList<String> allDomainNames = new ArrayList<String>();
            allDomainNames.addAll(mesh.getVolumeDomainNames());
            allDomainNames.addAll(mesh.getMembraneDomainNames());
            for (String domain : allDomainNames) {
                for (int timeIndex = 0; timeIndex < vcellFiles.getTimes().size(); timeIndex++) {
                    // String filename = new File(destinationDirectory,vcellFiles.getCannonicalFilePrefix(domain,timeIndex)+".vtu").getAbsolutePath();
                    // vtkUnstructuredGrid vtkgrid = vtkGridUtils.read(filename);
                    // vtkgrid.BuildLinks();
                    // 
                    // String varName0 = vtkgrid.GetCellData().GetArrayName(0);
                    // String varName1 = vtkgrid.GetCellData().GetArrayName(1);
                    // SimpleVTKViewer simpleViewer = new SimpleVTKViewer();
                    // simpleViewer.showGrid(vtkgrid, varName0, varName1);
                    Thread.sleep(1000);
                }
            }
        }
        // CartesianMeshFileReader reader = new CartesianMeshFileReader();
        // CartesianMesh mesh = reader.readFromFiles(vcellFiles);
        // CartesianMeshMapping cartesianMeshMapping = new CartesianMeshMapping();
        // 
        // //String domainName = mesh.meshRegionInfo.getVolumeDomainNames().get(1);
        // String domainName = mesh.meshRegionInfo.getVolumeDomainNames().get(0);
        // 
        // System.out.println("making visMesh for domain "+domainName+" of ["+mesh.meshRegionInfo.getVolumeDomainNames()+"]");
        // VisMesh visMesh = cartesianMeshMapping.fromMeshData(mesh, domainName);
        // final int numElements = visMesh.getPolyhedra().size();
        // final double[] data1 = new double[numElements];
        // final double[] data2 = new double[numElements];
        // 
        // for (int i=0;i<numElements;i++){
        // data1[i] = Math.sin(i/10000.0);
        // data2[i] = Math.cos(i/10000.0);
        // }
        // VisMeshData visData = new VisMeshData() {
        // private String[] names = new String[] { "data1", "data2" };
        // 
        // @Override
        // public String[] getVarNames() {
        // return new String[] { "data1", "data2" };
        // }
        // 
        // @Override
        // public double getTime() {
        // return 0.0;
        // }
        // 
        // @Override
        // public double[] getData(String var) {
        // if (var.equals("data1")){
        // return data1;
        // }else if (var.equals("data2")){
        // return data2;
        // }else{
        // throw new RuntimeException("var "+var+" not found");
        // }
        // }
        // };
        // 
        // VisDomain visDomain = new VisDomain("domain1",visMesh,visData);
        // VtkGridUtils vtkGridUtils = new VtkGridUtils();
        // vtkUnstructuredGrid vtkgrid = vtkGridUtils.getVtkGrid(visDomain);
        // vtkgrid = TestVTK.testWindowedSincPolyDataFilter(vtkgrid);
        // String filenameBinary = "testBinary.vtu";
        // vtkGridUtils.writeXML(vtkgrid, filenameBinary, false);
        // vtkgrid = vtkGridUtils.read(filenameBinary);
        // //vtkgrid.s
        // vtkgrid.BuildLinks();
        // SimpleVTKViewer simpleViewer = new SimpleVTKViewer();
        // String[] varNames = visDomain.getVisMeshData().getVarNames();
        // simpleViewer.showGrid(vtkgrid, varNames[0], varNames[1]);
        System.out.println("ran");
    } catch (Exception e) {
        e.printStackTrace(System.out);
    }
}
Also used : CartesianMeshFileReader(org.vcell.vis.io.CartesianMeshFileReader) KeyValue(org.vcell.util.document.KeyValue) CartesianMeshVtkFileWriter(org.vcell.vis.mapping.vcell.CartesianMeshVtkFileWriter) ArrayList(java.util.ArrayList) VCellSimFiles(org.vcell.vis.io.VCellSimFiles) CartesianMesh(org.vcell.vis.vcell.CartesianMesh) File(java.io.File)

Example 5 with CartesianMeshVtkFileWriter

use of org.vcell.vis.mapping.vcell.CartesianMeshVtkFileWriter in project vcell by virtualcell.

the class DataSetControllerImpl method getEmptyVtuMeshFiles.

public VtuFileContainer getEmptyVtuMeshFiles(VCellSimFiles vcellSimFiles, VCDataIdentifier vcdataID, int timeIndex) throws DataAccessException {
    if (timeIndex > 0) {
        throw new RuntimeException("only time index 0 supported for finitevolume vtk mesh files");
    }
    try {
        CartesianMeshVtkFileWriter cartesianMeshVTKFileWriter = new CartesianMeshVtkFileWriter();
        File primaryDirectory = PropertyLoader.getRequiredDirectory(PropertyLoader.primarySimDataDirInternalProperty);
        VtuFileContainer vtuFiles = cartesianMeshVTKFileWriter.getEmptyVtuMeshFiles(vcellSimFiles, primaryDirectory);
        return vtuFiles;
    } catch (Exception e) {
        lg.error(e.getMessage(), e);
        throw new DataAccessException("failed to retrieve VTK files: " + e.getMessage(), e);
    }
}
Also used : CartesianMeshVtkFileWriter(org.vcell.vis.mapping.vcell.CartesianMeshVtkFileWriter) VtuFileContainer(org.vcell.vis.io.VtuFileContainer) ZipFile(org.apache.commons.compress.archivers.zip.ZipFile) File(java.io.File) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) XmlParseException(cbit.vcell.xml.XmlParseException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) DivideByZeroException(cbit.vcell.parser.DivideByZeroException) CacheException(org.vcell.util.CacheException) ExpressionBindingException(cbit.vcell.parser.ExpressionBindingException) FileNotFoundException(java.io.FileNotFoundException) ExpressionException(cbit.vcell.parser.ExpressionException) MathException(cbit.vcell.math.MathException) DataAccessException(org.vcell.util.DataAccessException)

Aggregations

CartesianMeshVtkFileWriter (org.vcell.vis.mapping.vcell.CartesianMeshVtkFileWriter)5 MathException (cbit.vcell.math.MathException)3 DivideByZeroException (cbit.vcell.parser.DivideByZeroException)3 ExpressionBindingException (cbit.vcell.parser.ExpressionBindingException)3 ExpressionException (cbit.vcell.parser.ExpressionException)3 XmlParseException (cbit.vcell.xml.XmlParseException)3 File (java.io.File)3 FileNotFoundException (java.io.FileNotFoundException)3 IOException (java.io.IOException)3 CacheException (org.vcell.util.CacheException)3 DataAccessException (org.vcell.util.DataAccessException)3 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)3 VCellSimFiles (org.vcell.vis.io.VCellSimFiles)2 ArrayList (java.util.ArrayList)1 Vector (java.util.Vector)1 ZipFile (org.apache.commons.compress.archivers.zip.ZipFile)1 KeyValue (org.vcell.util.document.KeyValue)1 VCDataIdentifier (org.vcell.util.document.VCDataIdentifier)1 CartesianMeshFileReader (org.vcell.vis.io.CartesianMeshFileReader)1 VtuFileContainer (org.vcell.vis.io.VtuFileContainer)1