Search in sources :

Example 6 with VtuFileContainer

use of org.vcell.vis.io.VtuFileContainer in project vcell by virtualcell.

the class DataSetControllerImpl method getEmptyVtuMeshFiles.

public VtuFileContainer getEmptyVtuMeshFiles(ChomboFiles chomboFiles, VCDataIdentifier vcdataID, int timeIndex) throws DataAccessException {
    try {
        if (timeIndex > 0) {
            throw new RuntimeException("only time index 0 supported for chombo vtk mesh files");
        }
        ChomboVtkFileWriter chomboVTKFileWriter = new ChomboVtkFileWriter();
        File primaryDirectory = getPrimaryUserDir(vcdataID.getOwner(), false);
        VtuFileContainer vtuFiles = chomboVTKFileWriter.getEmptyVtuMeshFiles(chomboFiles, primaryDirectory);
        return vtuFiles;
    } catch (Exception e) {
        lg.error(e.getMessage(), e);
        throw new DataAccessException("failed to retrieve VTK files: " + e.getMessage(), e);
    }
}
Also used : ChomboVtkFileWriter(org.vcell.vis.mapping.chombo.ChomboVtkFileWriter) 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)

Example 7 with VtuFileContainer

use of org.vcell.vis.io.VtuFileContainer 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)

Example 8 with VtuFileContainer

use of org.vcell.vis.io.VtuFileContainer in project vcell by virtualcell.

the class VtkMeshGenerator method generateVtkMeshes.

private void generateVtkMeshes(User owner, KeyValue simKey, int jobIndex) throws DataAccessException, IOException {
    VCSimulationIdentifier vcSimID = new VCSimulationIdentifier(simKey, owner);
    VCSimulationDataIdentifier vcdataID = new VCSimulationDataIdentifier(vcSimID, jobIndex);
    Cachetable cacheTable = new Cachetable(MessageConstants.MINUTE_IN_MS * 20);
    DataSetControllerImpl dataSetControllerImpl = new DataSetControllerImpl(cacheTable, new File(PropertyLoader.getRequiredProperty(PropertyLoader.primarySimDataDirInternalProperty)), new File(PropertyLoader.getRequiredProperty(PropertyLoader.secondarySimDataDirInternalProperty)));
    ExportServiceImpl exportServiceImpl = new ExportServiceImpl();
    DataServerImpl dataServerImpl = new DataServerImpl(dataSetControllerImpl, exportServiceImpl);
    // @SuppressWarnings("unused")
    if (!dataSetControllerImpl.getIsMovingBoundary(vcdataID)) {
        // 
        // precompute single static vtk mesh
        // 
        VtuFileContainer vtuFileContainer = dataServerImpl.getEmptyVtuMeshFiles(owner, vcdataID, 0);
    } else {
        // 
        // precompute static vtk mesh for each saved time point
        // 
        double[] times = dataServerImpl.getDataSetTimes(owner, vcdataID);
        for (int i = 0; i < times.length; i++) {
            VtuFileContainer vtuFileContainer = dataServerImpl.getEmptyVtuMeshFiles(owner, vcdataID, i);
        }
    }
}
Also used : VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) ExportServiceImpl(cbit.vcell.export.server.ExportServiceImpl) VtuFileContainer(org.vcell.vis.io.VtuFileContainer) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) File(java.io.File)

Example 9 with VtuFileContainer

use of org.vcell.vis.io.VtuFileContainer 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;
}
Also used : ArrayList(java.util.ArrayList) ChomboFileEntry(org.vcell.vis.io.ChomboFiles.ChomboFileEntry) VtuFileContainer(org.vcell.vis.io.VtuFileContainer) File(java.io.File)

Example 10 with VtuFileContainer

use of org.vcell.vis.io.VtuFileContainer in project vcell by virtualcell.

the class MovingBoundaryVtkFileWriter method getEmptyVtuMeshFiles.

public VtuFileContainer getEmptyVtuMeshFiles(MovingBoundarySimFiles movingBoundaryFiles, int timeIndex, File destinationDirectory) throws IOException, MathException, DataAccessException {
    // 
    // find mesh for each file at time 0
    // 
    File hdf5OutputFile = movingBoundaryFiles.hdf5OutputFile;
    MovingBoundaryReader reader = new MovingBoundaryReader(hdf5OutputFile.getAbsolutePath());
    // 
    // for each domain in cartesian mesh, get the mesh file
    // 
    ArrayList<String> domains = new ArrayList<String>();
    domains.add(reader.getFakeInsideDomainName());
    // domains.add(reader.getFakeOutsideDomainName());
    // domains.add(reader.getFakeMembraneDomainName());
    boolean bMeshFileMissing = false;
    for (String domainName : domains) {
        File file = getVtuMeshFileName(destinationDirectory, movingBoundaryFiles, domainName, timeIndex);
        if (!file.exists()) {
            bMeshFileMissing = true;
        }
    }
    if (bMeshFileMissing) {
        writeEmptyMeshFiles(movingBoundaryFiles, timeIndex, destinationDirectory, null);
    }
    VtuFileContainer vtuFileContainer = new VtuFileContainer();
    for (int i = 0; i < domains.size(); i++) {
        String domainName = domains.get(i);
        File vtuMeshFile = getVtuMeshFileName(destinationDirectory, movingBoundaryFiles, domainName, timeIndex);
        byte[] vtuMeshFileContents = FileUtils.readByteArrayFromFile(vtuMeshFile);
        double time = reader.getTimeInfo().generationTimes.get(timeIndex);
        vtuFileContainer.addVtuMesh(new VtuFileContainer.VtuMesh(domainName, time, vtuMeshFileContents));
    }
    return vtuFileContainer;
}
Also used : ArrayList(java.util.ArrayList) MovingBoundaryReader(cbit.vcell.solvers.mb.MovingBoundaryReader) VtuFileContainer(org.vcell.vis.io.VtuFileContainer) File(java.io.File)

Aggregations

VtuFileContainer (org.vcell.vis.io.VtuFileContainer)11 File (java.io.File)10 FileNotFoundException (java.io.FileNotFoundException)6 IOException (java.io.IOException)6 DataAccessException (org.vcell.util.DataAccessException)5 MathException (cbit.vcell.math.MathException)4 DivideByZeroException (cbit.vcell.parser.DivideByZeroException)4 ExpressionBindingException (cbit.vcell.parser.ExpressionBindingException)4 ExpressionException (cbit.vcell.parser.ExpressionException)4 XmlParseException (cbit.vcell.xml.XmlParseException)4 ZipFile (org.apache.commons.compress.archivers.zip.ZipFile)4 CacheException (org.vcell.util.CacheException)4 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)4 ArrayList (java.util.ArrayList)3 ExportServiceImpl (cbit.vcell.export.server.ExportServiceImpl)1 VtkManager (cbit.vcell.simdata.VtkManager)1 VCSimulationDataIdentifier (cbit.vcell.solver.VCSimulationDataIdentifier)1 VCSimulationIdentifier (cbit.vcell.solver.VCSimulationIdentifier)1 MovingBoundaryReader (cbit.vcell.solvers.mb.MovingBoundaryReader)1 TException (org.apache.thrift.TException)1