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);
}
}
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);
}
}
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);
}
}
}
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;
}
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;
}
Aggregations