Search in sources :

Example 1 with VtuFileContainer

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

the class CartesianMeshVtkFileWriter method getEmptyVtuMeshFiles.

public VtuFileContainer getEmptyVtuMeshFiles(VCellSimFiles vcellFiles, File destinationDirectory) throws IOException, MathException, DataAccessException {
    // 
    // read the simplified cartesian mesh
    // 
    CartesianMeshFileReader reader = new CartesianMeshFileReader();
    CartesianMesh mesh = reader.readFromFiles(vcellFiles);
    // 
    // for each domain in cartesian mesh, get the mesh file
    // 
    ArrayList<String> domains = new ArrayList<String>();
    domains.addAll(mesh.getVolumeDomainNames());
    domains.addAll(mesh.getMembraneDomainNames());
    boolean bMeshFileMissing = false;
    ArrayList<File> meshFiles = new ArrayList<File>();
    for (String domainName : domains) {
        File file = getVtuMeshFileName(vcellFiles, domainName);
        meshFiles.add(file);
        if (!file.exists()) {
            bMeshFileMissing = true;
        }
    }
    if (bMeshFileMissing) {
        writeEmptyMeshFiles(vcellFiles, destinationDirectory, null);
    }
    VtuFileContainer vtuFileContainer = new VtuFileContainer();
    for (int i = 0; i < domains.size(); i++) {
        byte[] vtuMeshFileContents = FileUtils.readByteArrayFromFile(meshFiles.get(i));
        vtuFileContainer.addVtuMesh(new VtuFileContainer.VtuMesh(domains.get(i), 0.0, vtuMeshFileContents));
    }
    return vtuFileContainer;
}
Also used : CartesianMeshFileReader(org.vcell.vis.io.CartesianMeshFileReader) CartesianMesh(org.vcell.vis.vcell.CartesianMesh) ArrayList(java.util.ArrayList) VtuFileContainer(org.vcell.vis.io.VtuFileContainer) File(java.io.File)

Example 2 with VtuFileContainer

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

the class VCellProxyHandler method downloadEmptyVtuFileContainer.

private VtuFileContainer downloadEmptyVtuFileContainer(SimulationDataSetRef simulationDataSetRef, int timeIndex) throws ThriftDataAccessException {
    try {
        VtkManager vtkManager = vcellClientDataService.getVtkManager(simulationDataSetRef);
        VtuFileContainer vtuFileContainer = vtkManager.getEmptyVtuMeshFiles(timeIndex);
        return vtuFileContainer;
    } catch (Exception e) {
        e.printStackTrace();
        throw new ThriftDataAccessException("failed to get data for simulation " + simulationDataSetRef + ": " + e.getMessage());
    }
}
Also used : VtuFileContainer(org.vcell.vis.io.VtuFileContainer) VtkManager(cbit.vcell.simdata.VtkManager) TException(org.apache.thrift.TException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) FileNotFoundException(java.io.FileNotFoundException)

Example 3 with VtuFileContainer

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

the class DataSetControllerImpl method getEmptyVtuMeshFiles.

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

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

the class VCellProxyHandler method getEmptyMeshFile.

private File getEmptyMeshFile(SimulationDataSetRef simulationDataSetRef, String domainName, int timeIndex) throws ThriftDataAccessException {
    if (!simulationDataSetRef.isTimeVaryingMesh) {
        timeIndex = 0;
    }
    File vtuEmptyMeshFile;
    try {
        vtuEmptyMeshFile = getEmptyMeshFileLocation(simulationDataSetRef, domainName, timeIndex);
    } catch (FileNotFoundException e1) {
        e1.printStackTrace();
        throw new ThriftDataAccessException("failed to find data location: " + e1.getMessage());
    }
    System.out.println("looking for file: " + vtuEmptyMeshFile);
    // 
    if (!vtuEmptyMeshFile.exists()) {
        try {
            VtuFileContainer vtuFileContainer = downloadEmptyVtuFileContainer(simulationDataSetRef, timeIndex);
            for (VtuFileContainer.VtuMesh mesh : vtuFileContainer.getVtuMeshes()) {
                FileUtils.writeByteArrayToFile(mesh.vtuMeshContents, getEmptyMeshFileLocation(simulationDataSetRef, mesh.domainName, timeIndex));
            }
            if (!vtuEmptyMeshFile.exists()) {
                System.out.println("after export, couldn't find requested empty mesh file " + vtuEmptyMeshFile);
                throw new ThriftDataAccessException("after export, couldn't find empty requested mesh file " + vtuEmptyMeshFile);
            }
            System.out.println("vtuData file exists, " + vtuEmptyMeshFile);
        } catch (IOException e) {
            e.printStackTrace();
            System.out.println("failed to export entire dataset: " + e.getMessage());
            throw new ThriftDataAccessException("failed to export entire dataset: " + e.getMessage());
        }
    }
    return vtuEmptyMeshFile;
}
Also used : FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) VtuFileContainer(org.vcell.vis.io.VtuFileContainer) File(java.io.File)

Example 5 with VtuFileContainer

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

the class DataSetControllerImpl method getEmptyVtuMeshFiles.

public VtuFileContainer getEmptyVtuMeshFiles(MovingBoundarySimFiles movingBoundarySimFiles, VCDataIdentifier vcdataID, int timeIndex) throws DataAccessException {
    try {
        MovingBoundaryVtkFileWriter movingBoundaryVtkFileWriter = new MovingBoundaryVtkFileWriter();
        File primaryDirectory = PropertyLoader.getRequiredDirectory(PropertyLoader.primarySimDataDirInternalProperty);
        VtuFileContainer vtuFiles = movingBoundaryVtkFileWriter.getEmptyVtuMeshFiles(movingBoundarySimFiles, timeIndex, primaryDirectory);
        return vtuFiles;
    } catch (Exception e) {
        lg.error(e.getMessage(), e);
        throw new DataAccessException("failed to retrieve VTK files: " + e.getMessage(), e);
    }
}
Also used : MovingBoundaryVtkFileWriter(org.vcell.vis.mapping.movingboundary.MovingBoundaryVtkFileWriter) 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

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