Search in sources :

Example 21 with Geometry

use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.

the class ClientDocumentManager method save.

/**
 * Insert the method's description here.
 * Creation date: (10/28/00 12:08:30 AM)
 */
public Geometry save(Geometry geometry) throws DataAccessException {
    try {
        String geometryXML = null;
        try {
            geometryXML = XmlHelper.geometryToXML(geometry);
        } catch (XmlParseException e) {
            e.printStackTrace(System.out);
            throw new DataAccessException(e.getMessage());
        }
        String savedGeometryXML = sessionManager.getUserMetaDbServer().saveGeometry(new BigString(geometryXML)).toString();
        Geometry savedGeometry = getGeometryFromDatabaseXML(savedGeometryXML);
        KeyValue savedKey = savedGeometry.getVersion().getVersionKey();
        if (xmlHash.get(savedKey) == null) {
            xmlHash.put(savedKey, savedGeometryXML);
        }
        updateGeometryRelatedHashes(savedGeometry);
        return savedGeometry;
    } catch (RemoteProxyException e) {
        e.printStackTrace(System.out);
        throw new DataAccessException(VCellErrorMessages.FAIL_SAVE_MESSAGE + "\n\n" + e.getMessage());
    }
}
Also used : Geometry(cbit.vcell.geometry.Geometry) KeyValue(org.vcell.util.document.KeyValue) BigString(org.vcell.util.BigString) XmlParseException(cbit.vcell.xml.XmlParseException) BigString(org.vcell.util.BigString) DataAccessException(org.vcell.util.DataAccessException) RemoteProxyException(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)

Example 22 with Geometry

use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.

the class RayCasterBitSet method createGeometry.

public static Geometry createGeometry(GeometryThumbnailImageFactory geometryThumbnailImageFactory, SurfaceCollection surfaceCollection, Origin origin, Extent extent, ISize sampleSize) throws ImageException, PropertyVetoException, GeometryException, ExpressionException {
    int numX = sampleSize.getX();
    int numY = sampleSize.getY();
    int numZ = sampleSize.getZ();
    VolumeSamplesBitSet volumeSamples = volumeSampleSurface(surfaceCollection, sampleSize, origin, extent, false);
    // 
    // create a graph with:
    // a node for each surface face (mask)
    // an edge for each pair of surface faces share by a volume node.
    // 
    Graph connectivityGraph = new Graph();
    ArrayList<Long> masks = new ArrayList<Long>(volumeSamples.getIncidentSurfaceBitSets().keySet());
    for (int i = 0; i < masks.size(); i++) {
        cbit.util.graph.Node node = new cbit.util.graph.Node(masks.get(i).toString(), volumeSamples.getIncidentSurfaceBitSets().get(masks.get(i)));
        connectivityGraph.addNode(node);
    }
    for (int i = 0; i < masks.size(); i++) {
        long mask1 = masks.get(i);
        cbit.util.graph.Node node1 = connectivityGraph.getNode(Long.toString(mask1));
        BitSet bitSet1 = volumeSamples.getIncidentSurfaceBitSets().get(mask1);
        for (int j = i + 1; j < masks.size(); j++) {
            long mask2 = masks.get(j);
            cbit.util.graph.Node node2 = connectivityGraph.getNode(Long.toString(mask2));
            BitSet bitSet2 = volumeSamples.getIncidentSurfaceBitSets().get(mask2);
            if (bitSet1.intersects(bitSet2)) {
                BitSet bitSetIntersection = new BitSet();
                bitSetIntersection.or(bitSet1);
                bitSetIntersection.and(bitSet2);
                Edge edge = new Edge(node1, node2, bitSetIntersection);
                connectivityGraph.addEdge(edge);
            }
        }
    }
    // 
    for (int i = 0; i < surfaceCollection.getSurfaceCount(); i++) {
        Surface surface = surfaceCollection.getSurfaces(i);
        Tree[] spanningForest = connectivityGraph.getSpanningForest();
        for (Tree tree : spanningForest) {
            cbit.util.graph.Node insideNode = tree.getNode(Long.toString(surface.getInteriorMask()));
            cbit.util.graph.Node outsideNode = tree.getNode(Long.toString(surface.getExteriorMask()));
            if (insideNode != null && outsideNode != null) {
                System.out.println("++++++++++++++++++++++++++++++++ separating " + Long.toBinaryString(Long.parseLong(insideNode.getName())) + " with " + Long.toBinaryString(Long.parseLong(outsideNode.getName())));
                // 
                // remove sub-region covered by more loosely connected (insideNode or outsideNode) from this ensemble region
                // this could be improved by considering a minimal cut-set (too hard for today).
                // 
                int connectionCardinalityInsideNode = 0;
                Edge[] insideNodeEdges = connectivityGraph.getAdjacentEdges(insideNode);
                for (Edge insideEdge : insideNodeEdges) {
                    connectionCardinalityInsideNode += ((BitSet) insideEdge.getData()).cardinality();
                }
                int connectionCardinalityOutsideNode = 0;
                Edge[] outsideNodeEdges = connectivityGraph.getAdjacentEdges(outsideNode);
                for (Edge outsideEdge : outsideNodeEdges) {
                    connectionCardinalityOutsideNode += ((BitSet) outsideEdge.getData()).cardinality();
                }
                if (connectionCardinalityInsideNode < connectionCardinalityOutsideNode) {
                    // remove inside Node (clear its bits from all others in this tree)
                    for (cbit.util.graph.Node node : tree.getNodes()) {
                        if (node != insideNode) {
                            BitSet otherBitSet = (BitSet) node.getData();
                            otherBitSet.andNot((BitSet) insideNode.getData());
                        }
                    }
                    for (Edge edge : insideNodeEdges) {
                        connectivityGraph.remove(edge);
                    }
                } else {
                    // remove inside Node (clear its bits from all others in this tree)
                    for (cbit.util.graph.Node node : tree.getNodes()) {
                        if (node != outsideNode) {
                            BitSet otherBitSet = (BitSet) node.getData();
                            otherBitSet.andNot((BitSet) outsideNode.getData());
                        }
                    }
                    for (Edge edge : outsideNodeEdges) {
                        connectivityGraph.remove(edge);
                    }
                }
            }
        }
    }
    Tree[] spanningForest = connectivityGraph.getSpanningForest();
    BitSet[] regionBitSets = new BitSet[spanningForest.length];
    long[] regionMasks = new long[spanningForest.length];
    for (int i = 0; i < spanningForest.length; i++) {
        Tree tree = spanningForest[i];
        regionBitSets[i] = new BitSet();
        for (cbit.util.graph.Node node : tree.getNodes()) {
            regionBitSets[i].or((BitSet) node.getData());
            regionMasks[i] = regionMasks[i] | Long.valueOf(node.getName());
        }
        System.out.println("+++++++++++++++++++++++++++++++++++++ final region mask : " + Long.toBinaryString(regionMasks[i]) + ", region size = " + regionBitSets[i].cardinality());
    }
    byte[] pixels = new byte[numX * numY * numZ];
    byte pixelValue = 1;
    for (int r = 0; r < regionMasks.length; r++) {
        BitSet regionBitSet = regionBitSets[r];
        for (int i = 0; i < pixels.length; i++) {
            if (regionBitSet.get(i)) {
                pixels[i] = pixelValue;
            }
        }
        pixelValue++;
    }
    VCImageUncompressed vcImage = new VCImageUncompressed(null, pixels, extent, numX, numY, numZ);
    Geometry geometry = new Geometry("newGeometry", vcImage);
    geometry.getGeometrySpec().setExtent(extent);
    geometry.getGeometrySpec().setOrigin(origin);
    geometry.precomputeAll(geometryThumbnailImageFactory, true, true);
    return geometry;
}
Also used : ArrayList(java.util.ArrayList) BitSet(java.util.BitSet) VCImageUncompressed(cbit.image.VCImageUncompressed) Geometry(cbit.vcell.geometry.Geometry) Graph(cbit.util.graph.Graph) Tree(cbit.util.graph.Tree) Edge(cbit.util.graph.Edge)

Example 23 with Geometry

use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.

the class RayCasterBitSet method createGeometryFromSTL.

public static Geometry createGeometryFromSTL(GeometryThumbnailImageFactory geometryThumbnailImageFactory, File stlFile, int numSamples) throws ImageException, PropertyVetoException, GeometryException, ExpressionException, IOException {
    SurfaceCollection surfaceCollection = StlReader.readStl(stlFile);
    Node[] nodes = surfaceCollection.getNodes();
    double minX = Double.MAX_VALUE;
    double maxX = -Double.MAX_VALUE;
    double minY = Double.MAX_VALUE;
    double maxY = -Double.MAX_VALUE;
    double minZ = Double.MAX_VALUE;
    double maxZ = -Double.MAX_VALUE;
    for (Node node : nodes) {
        double nx = node.getX();
        double ny = node.getY();
        double nz = node.getZ();
        minX = Math.min(minX, nx);
        maxX = Math.max(maxX, nx);
        minY = Math.min(minY, ny);
        maxY = Math.max(maxY, ny);
        minZ = Math.min(minZ, nz);
        maxZ = Math.max(maxZ, nz);
    }
    Extent extent = new Extent((maxX - minX) * 1.4, (maxY - minY) * 1.4, (maxZ - minZ) * 1.4);
    Origin origin = new Origin(minX - 0.2 * extent.getX(), minY - 0.2 * extent.getY(), minZ - 0.2 * extent.getZ());
    ISize sampleSize = GeometrySpec.calulateResetSamplingSize(3, extent, numSamples);
    Geometry geometry = createGeometry(geometryThumbnailImageFactory, surfaceCollection, origin, extent, sampleSize);
    return geometry;
}
Also used : Origin(org.vcell.util.Origin) Geometry(cbit.vcell.geometry.Geometry) Extent(org.vcell.util.Extent) ISize(org.vcell.util.ISize)

Example 24 with Geometry

use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.

the class FiniteVolumeFileWriter method writeChomboSpec.

private void writeChomboSpec() throws ExpressionException, SolverException, PropertyVetoException, ClassNotFoundException, IOException, GeometryException, ImageException {
    if (!bChomboSolver) {
        return;
    }
    GeometrySpec geometrySpec = resampledGeometry.getGeometrySpec();
    int dimension = geometrySpec.getDimension();
    if (dimension == 1) {
        throw new SolverException(simTask.getSimulation().getSolverTaskDescription().getSolverDescription().getDisplayLabel() + " is only supported for simulations with 2D or 3D geometry.");
    }
    Simulation simulation = getSimulationTask().getSimulation();
    SolverTaskDescription solverTaskDescription = simulation.getSolverTaskDescription();
    ChomboSolverSpec chomboSolverSpec = solverTaskDescription.getChomboSolverSpec();
    printWriter.println(FVInputFileKeyword.CHOMBO_SPEC_BEGIN);
    printWriter.println(FVInputFileKeyword.DIMENSION + " " + geometrySpec.getDimension());
    Extent extent = geometrySpec.getExtent();
    Origin origin = geometrySpec.getOrigin();
    ISize isize = simulation.getMeshSpecification().getSamplingSize();
    switch(geometrySpec.getDimension()) {
        case 2:
            printWriter.println(FVInputFileKeyword.MESH_SIZE + " " + isize.getX() + " " + isize.getY());
            printWriter.println(FVInputFileKeyword.DOMAIN_SIZE + " " + extent.getX() + " " + extent.getY());
            printWriter.println(FVInputFileKeyword.DOMAIN_ORIGIN + " " + origin.getX() + " " + origin.getY());
            break;
        case 3:
            printWriter.println(FVInputFileKeyword.MESH_SIZE + " " + isize.getX() + " " + isize.getY() + " " + isize.getZ());
            printWriter.println(FVInputFileKeyword.DOMAIN_SIZE + " " + extent.getX() + " " + extent.getY() + " " + extent.getZ());
            printWriter.println(FVInputFileKeyword.DOMAIN_ORIGIN + " " + origin.getX() + " " + origin.getY() + " " + origin.getZ());
            break;
    }
    List<CompartmentSubDomain> featureList = new ArrayList<CompartmentSubDomain>();
    Enumeration<SubDomain> enum1 = simulation.getMathDescription().getSubDomains();
    while (enum1.hasMoreElements()) {
        SubDomain sd = enum1.nextElement();
        if (sd instanceof CompartmentSubDomain) {
            featureList.add((CompartmentSubDomain) sd);
        }
    }
    int numFeatures = featureList.size();
    CompartmentSubDomain[] features = featureList.toArray(new CompartmentSubDomain[0]);
    int[] phases = new int[numFeatures];
    Arrays.fill(phases, -1);
    phases[numFeatures - 1] = 0;
    int[] numAssigned = new int[] { 1 };
    assignPhases(features, numFeatures - 1, phases, numAssigned);
    Map<String, Integer> subDomainPhaseMap = new HashMap<String, Integer>();
    for (int i = 0; i < phases.length; ++i) {
        if (phases[i] == -1) {
            throw new SolverException("Failed to assign a phase to CompartmentSubdomain '" + features[i].getName() + "'. It might be caused by too coarsh a mesh.");
        }
        subDomainPhaseMap.put(features[i].getName(), phases[i]);
    }
    SubVolume[] subVolumes = geometrySpec.getSubVolumes();
    if (geometrySpec.hasImage()) {
        Geometry geometry = (Geometry) BeanUtils.cloneSerializable(simulation.getMathDescription().getGeometry());
        Geometry simGeometry = geometry;
        VCImage img = geometry.getGeometrySpec().getImage();
        int factor = Math.max(Math.max(img.getNumX(), img.getNumY()), img.getNumZ()) < 512 ? 2 : 1;
        ISize distanceMapMeshSize = new ISize(img.getNumX() * factor, img.getNumY() * factor, img.getNumZ() * factor);
        Vect3d deltaX = null;
        boolean bCellCentered = false;
        double dx = 0.5;
        double dy = 0.5;
        double dz = 0.5;
        int Nx = distanceMapMeshSize.getX();
        int Ny = distanceMapMeshSize.getY();
        int Nz = distanceMapMeshSize.getZ();
        if (dimension == 2) {
            // pad the 2D image with itself in order to obtain a 3D image used to compute the distance map
            // because the distance map algorithm is 3D only (using distance to triangles)
            byte[] oldPixels = img.getPixels();
            byte[] newPixels = new byte[oldPixels.length * 3];
            System.arraycopy(oldPixels, 0, newPixels, 0, oldPixels.length);
            System.arraycopy(oldPixels, 0, newPixels, oldPixels.length, oldPixels.length);
            System.arraycopy(oldPixels, 0, newPixels, oldPixels.length * 2, oldPixels.length);
            double distX = geometry.getExtent().getX() / img.getNumX();
            double distY = geometry.getExtent().getY() / img.getNumY();
            // we set the distance on the z axis to something that makes sense
            double distZ = Math.max(distX, distY);
            Extent newExtent = new Extent(geometry.getExtent().getX(), geometry.getExtent().getY(), distZ * 3);
            VCImage newImage = new VCImageUncompressed(null, newPixels, newExtent, img.getNumX(), img.getNumY(), 3);
            // copy the pixel classes too
            ArrayList<VCPixelClass> newPixelClasses = new ArrayList<VCPixelClass>();
            for (VCPixelClass origPixelClass : geometry.getGeometrySpec().getImage().getPixelClasses()) {
                SubVolume origSubvolume = geometry.getGeometrySpec().getImageSubVolumeFromPixelValue(origPixelClass.getPixel());
                newPixelClasses.add(new VCPixelClass(null, origSubvolume.getName(), origPixelClass.getPixel()));
            }
            newImage.setPixelClasses(newPixelClasses.toArray(new VCPixelClass[newPixelClasses.size()]));
            simGeometry = new Geometry(geometry, newImage);
            Nz = 3;
        }
        GeometrySpec simGeometrySpec = simGeometry.getGeometrySpec();
        Extent simExtent = simGeometrySpec.getExtent();
        dx = simExtent.getX() / (Nx - 1);
        dy = simExtent.getY() / (Ny - 1);
        dz = simExtent.getZ() / (Nz - 1);
        if (Math.abs(dx - dy) > 0.1 * Math.max(dx, dy)) {
            dx = Math.min(dx, dy);
            dy = dx;
            Nx = (int) (simExtent.getX() / dx + 1);
            Ny = (int) (simExtent.getY() / dx + 1);
            if (dimension == 3) {
                dz = dx;
                Nz = (int) (simExtent.getZ() / dx + 1);
            }
        }
        deltaX = new Vect3d(dx, dy, dz);
        // one more point in each direction
        distanceMapMeshSize = new ISize(Nx + 1, Ny + 1, Nz + 1);
        Extent distanceMapExtent = new Extent(simExtent.getX() + dx, simExtent.getY() + dy, simExtent.getZ() + dz);
        simGeometrySpec.setExtent(distanceMapExtent);
        GeometrySurfaceDescription geoSurfaceDesc = simGeometry.getGeometrySurfaceDescription();
        geoSurfaceDesc.setVolumeSampleSize(distanceMapMeshSize);
        geoSurfaceDesc.updateAll();
        VCImage vcImage = RayCaster.sampleGeometry(simGeometry, distanceMapMeshSize, bCellCentered);
        SubvolumeSignedDistanceMap[] distanceMaps = DistanceMapGenerator.computeDistanceMaps(simGeometry, vcImage, bCellCentered);
        if (dimension == 2) {
            distanceMaps = DistanceMapGenerator.extractMiddleSlice(distanceMaps);
        }
        printWriter.println(FVInputFileKeyword.SUBDOMAINS + " " + simGeometrySpec.getNumSubVolumes() + " " + FVInputFileKeyword.DISTANCE_MAP);
        for (int i = 0; i < subVolumes.length; i++) {
            File distanceMapFile = new File(workingDirectory, getSimulationTask().getSimulationJobID() + "_" + subVolumes[i].getName() + DISTANCE_MAP_FILE_EXTENSION);
            writeDistanceMapFile(deltaX, distanceMaps[i], distanceMapFile);
            int phase = subDomainPhaseMap.get(subVolumes[i].getName());
            printWriter.println(subVolumes[i].getName() + " " + phase + " " + distanceMapFile.getAbsolutePath());
        }
    } else {
        printWriter.println(FVInputFileKeyword.SUBDOMAINS + " " + geometrySpec.getNumSubVolumes());
        Expression[] rvachevExps = convertAnalyticGeometryToRvachevFunction(geometrySpec);
        for (int i = 0; i < subVolumes.length; i++) {
            if (subVolumes[i] instanceof AnalyticSubVolume) {
                String name = subVolumes[i].getName();
                int phase = subDomainPhaseMap.get(name);
                printWriter.println(name + " " + phase + " ");
                printWriter.println(FVInputFileKeyword.IF + " " + rvachevExps[i].infix() + ";");
                printWriter.println(FVInputFileKeyword.USER + " " + ((AnalyticSubVolume) subVolumes[i]).getExpression().infix() + ";");
            }
        }
    }
    printWriter.println(FVInputFileKeyword.MAX_BOX_SIZE + " " + chomboSolverSpec.getMaxBoxSize());
    printWriter.println(FVInputFileKeyword.FILL_RATIO + " " + chomboSolverSpec.getFillRatio());
    printWriter.println(FVInputFileKeyword.RELATIVE_TOLERANCE + " " + simulation.getSolverTaskDescription().getErrorTolerance().getRelativeErrorTolerance());
    printWriter.println(FVInputFileKeyword.SAVE_VCELL_OUTPUT + " " + chomboSolverSpec.isSaveVCellOutput());
    printWriter.println(FVInputFileKeyword.SAVE_CHOMBO_OUTPUT + " " + chomboSolverSpec.isSaveChomboOutput());
    printWriter.println(FVInputFileKeyword.ACTIVATE_FEATURE_UNDER_DEVELOPMENT + " " + chomboSolverSpec.isActivateFeatureUnderDevelopment());
    printWriter.println(FVInputFileKeyword.SMALL_VOLFRAC_THRESHOLD + " " + chomboSolverSpec.getSmallVolfracThreshold());
    printWriter.println(FVInputFileKeyword.BLOCK_FACTOR + " " + chomboSolverSpec.getBlockFactor());
    printWriter.println(FVInputFileKeyword.TAGS_GROW + " " + chomboSolverSpec.getTagsGrow());
    // Refinement
    int numLevels = chomboSolverSpec.getNumRefinementLevels();
    // Refinements #Levels ratio 1, ratio 2, etc
    printWriter.print(FVInputFileKeyword.REFINEMENTS + " " + (numLevels + 1));
    List<Integer> ratios = chomboSolverSpec.getRefineRatioList();
    for (int i : ratios) {
        printWriter.print(" " + i);
    }
    // write last refinement ratio, fake
    printWriter.println(" 2");
    // membrane rois
    List<RefinementRoi> memRios = chomboSolverSpec.getMembraneRefinementRois();
    printWriter.println(FVInputFileKeyword.REFINEMENT_ROIS + " " + RoiType.Membrane + " " + memRios.size());
    for (RefinementRoi roi : memRios) {
        if (roi.getRoiExpression() == null) {
            throw new SolverException("ROI expression cannot be null");
        }
        // level tagsGrow ROIexpression
        printWriter.println(roi.getLevel() + " " + roi.getRoiExpression().infix() + ";");
    }
    List<RefinementRoi> volRios = chomboSolverSpec.getVolumeRefinementRois();
    printWriter.println(FVInputFileKeyword.REFINEMENT_ROIS + " " + RoiType.Volume + " " + volRios.size());
    for (RefinementRoi roi : volRios) {
        if (roi.getRoiExpression() == null) {
            throw new SolverException("ROI expression cannot be null");
        }
        printWriter.println(roi.getLevel() + " " + roi.getRoiExpression().infix() + ";");
    }
    printWriter.println(FVInputFileKeyword.VIEW_LEVEL + " " + chomboSolverSpec.getViewLevel());
    printWriter.println(FVInputFileKeyword.CHOMBO_SPEC_END);
    printWriter.println();
}
Also used : Origin(org.vcell.util.Origin) VCPixelClass(cbit.image.VCPixelClass) GeometrySurfaceDescription(cbit.vcell.geometry.surface.GeometrySurfaceDescription) Extent(org.vcell.util.Extent) HashMap(java.util.HashMap) ISize(org.vcell.util.ISize) ArrayList(java.util.ArrayList) VCImage(cbit.image.VCImage) SubvolumeSignedDistanceMap(cbit.vcell.geometry.surface.SubvolumeSignedDistanceMap) GeometrySpec(cbit.vcell.geometry.GeometrySpec) CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain) SubDomain(cbit.vcell.math.SubDomain) MembraneSubDomain(cbit.vcell.math.MembraneSubDomain) RefinementRoi(org.vcell.chombo.RefinementRoi) SubVolume(cbit.vcell.geometry.SubVolume) AnalyticSubVolume(cbit.vcell.geometry.AnalyticSubVolume) SolverTaskDescription(cbit.vcell.solver.SolverTaskDescription) VCImageUncompressed(cbit.image.VCImageUncompressed) ChomboSolverSpec(org.vcell.chombo.ChomboSolverSpec) Vect3d(cbit.vcell.render.Vect3d) Geometry(cbit.vcell.geometry.Geometry) Simulation(cbit.vcell.solver.Simulation) Expression(cbit.vcell.parser.Expression) CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain) SolverException(cbit.vcell.solver.SolverException) File(java.io.File) AnalyticSubVolume(cbit.vcell.geometry.AnalyticSubVolume)

Example 25 with Geometry

use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.

the class ITextWriter method writeSimulation.

// container can be a chapter or a section of a chapter.
protected void writeSimulation(Section container, Simulation sim) throws DocumentException {
    if (sim == null) {
        return;
    }
    Section simSection = container.addSection(sim.getName(), container.numberDepth() + 1);
    writeMetadata(simSection, sim.getName(), sim.getDescription(), null, "Simulation ");
    // add overriden params
    Table overParamTable = null;
    MathOverrides mo = sim.getMathOverrides();
    if (mo != null) {
        String[] constants = mo.getOverridenConstantNames();
        for (int i = 0; i < constants.length; i++) {
            String actualStr = "", defStr = "";
            Expression tempExp = mo.getDefaultExpression(constants[i]);
            if (tempExp != null) {
                defStr = tempExp.infix();
            }
            if (mo.isScan(constants[i])) {
                actualStr = mo.getConstantArraySpec(constants[i]).toString();
            } else {
                tempExp = mo.getActualExpression(constants[i], 0);
                if (tempExp != null) {
                    actualStr = tempExp.infix();
                }
            }
            if (overParamTable == null) {
                overParamTable = getTable(3, 75, 1, 3, 3);
                overParamTable.setAlignment(Table.ALIGN_LEFT);
                overParamTable.addCell(createCell("Overriden Parameters", getBold(DEF_HEADER_FONT_SIZE), 3, 1, Element.ALIGN_CENTER, true));
                overParamTable.addCell(createHeaderCell("Name", getBold(), 1));
                overParamTable.addCell(createHeaderCell("Actual Value", getBold(), 1));
                overParamTable.addCell(createHeaderCell("Default Value", getBold(), 1));
            }
            overParamTable.addCell(createCell(constants[i], getFont()));
            overParamTable.addCell(createCell(actualStr, getFont()));
            overParamTable.addCell(createCell(defStr, getFont()));
        }
    }
    if (overParamTable != null) {
        simSection.add(overParamTable);
    }
    // add spatial details
    // sim.isSpatial();
    Table meshTable = null;
    MeshSpecification mesh = sim.getMeshSpecification();
    if (mesh != null) {
        Geometry geom = mesh.getGeometry();
        Extent extent = geom.getExtent();
        String extentStr = "(" + extent.getX() + ", " + extent.getY() + ", " + extent.getZ() + ")";
        ISize meshSize = mesh.getSamplingSize();
        String meshSizeStr = "(" + meshSize.getX() + ", " + meshSize.getY() + ", " + meshSize.getZ() + ")";
        meshTable = getTable(2, 75, 1, 3, 3);
        meshTable.setAlignment(Table.ALIGN_LEFT);
        meshTable.addCell(createCell("Geometry Setting", getBold(DEF_HEADER_FONT_SIZE), 2, 1, Element.ALIGN_CENTER, true));
        meshTable.addCell(createCell("Geometry Size (um)", getFont()));
        meshTable.addCell(createCell(extentStr, getFont()));
        meshTable.addCell(createCell("Mesh Size (elements)", getFont()));
        meshTable.addCell(createCell(meshSizeStr, getFont()));
    }
    if (meshTable != null) {
        simSection.add(meshTable);
    }
    // write advanced sim settings
    Table simAdvTable = null;
    SolverTaskDescription solverDesc = sim.getSolverTaskDescription();
    if (solverDesc != null) {
        String solverName = solverDesc.getSolverDescription().getDisplayLabel();
        simAdvTable = getTable(2, 75, 1, 3, 3);
        simAdvTable.setAlignment(Table.ALIGN_LEFT);
        simAdvTable.addCell(createCell("Advanced Settings", getBold(DEF_HEADER_FONT_SIZE), 2, 1, Element.ALIGN_CENTER, true));
        simAdvTable.addCell(createCell("Solver Name", getFont()));
        simAdvTable.addCell(createCell(solverName, getFont()));
        simAdvTable.addCell(createCell("Time Bounds - Starting", getFont()));
        simAdvTable.addCell(createCell("" + solverDesc.getTimeBounds().getStartingTime(), getFont()));
        simAdvTable.addCell(createCell("Time Bounds - Ending", getFont()));
        simAdvTable.addCell(createCell("" + solverDesc.getTimeBounds().getEndingTime(), getFont()));
        simAdvTable.addCell(createCell("Time Step - Min", getFont()));
        simAdvTable.addCell(createCell("" + solverDesc.getTimeStep().getMinimumTimeStep(), getFont()));
        simAdvTable.addCell(createCell("Time Step - Default", getFont()));
        simAdvTable.addCell(createCell("" + solverDesc.getTimeStep().getDefaultTimeStep(), getFont()));
        simAdvTable.addCell(createCell("Time Step - Max", getFont()));
        simAdvTable.addCell(createCell("" + solverDesc.getTimeStep().getMaximumTimeStep(), getFont()));
        ErrorTolerance et = solverDesc.getErrorTolerance();
        if (et != null) {
            simAdvTable.addCell(createCell("Error Tolerance - Absolute", getFont()));
            simAdvTable.addCell(createCell("" + et.getAbsoluteErrorTolerance(), getFont()));
            simAdvTable.addCell(createCell("Error Tolerance - Relative", getFont()));
            simAdvTable.addCell(createCell("" + et.getRelativeErrorTolerance(), getFont()));
        }
        OutputTimeSpec ots = solverDesc.getOutputTimeSpec();
        if (ots.isDefault()) {
            simAdvTable.addCell(createCell("Keep Every", getFont()));
            simAdvTable.addCell(createCell("" + ((DefaultOutputTimeSpec) ots).getKeepEvery(), getFont()));
            simAdvTable.addCell(createCell("Keep At Most", getFont()));
            simAdvTable.addCell(createCell("" + ((DefaultOutputTimeSpec) ots).getKeepAtMost(), getFont()));
        } else if (ots.isUniform()) {
            simAdvTable.addCell(createCell("Output Time Step", getFont()));
            simAdvTable.addCell(createCell("" + ((UniformOutputTimeSpec) ots).getOutputTimeStep(), getFont()));
        } else if (ots.isExplicit()) {
            simAdvTable.addCell(createCell("Output Time Points", getFont()));
            simAdvTable.addCell(createCell("" + ((ExplicitOutputTimeSpec) ots).toCommaSeperatedOneLineOfString(), getFont()));
        }
        simAdvTable.addCell(createCell("Use Symbolic Jacobian (T/F)", getFont()));
        simAdvTable.addCell(createCell((solverDesc.getUseSymbolicJacobian() ? " T " : " F "), getFont()));
        Constant sp = solverDesc.getSensitivityParameter();
        if (sp != null) {
            simAdvTable.addCell(createCell("Sensitivity Analysis Param", getFont()));
            simAdvTable.addCell(createCell(sp.getName(), getFont()));
        }
    }
    if (simAdvTable != null) {
        simSection.add(simAdvTable);
    }
}
Also used : Table(com.lowagie.text.Table) UniformOutputTimeSpec(cbit.vcell.solver.UniformOutputTimeSpec) Extent(org.vcell.util.Extent) ISize(org.vcell.util.ISize) Constant(cbit.vcell.math.Constant) Section(com.lowagie.text.Section) MeshSpecification(cbit.vcell.solver.MeshSpecification) Geometry(cbit.vcell.geometry.Geometry) MathOverrides(cbit.vcell.solver.MathOverrides) DefaultOutputTimeSpec(cbit.vcell.solver.DefaultOutputTimeSpec) ExplicitOutputTimeSpec(cbit.vcell.solver.ExplicitOutputTimeSpec) OutputTimeSpec(cbit.vcell.solver.OutputTimeSpec) UniformOutputTimeSpec(cbit.vcell.solver.UniformOutputTimeSpec) Expression(cbit.vcell.parser.Expression) ErrorTolerance(cbit.vcell.solver.ErrorTolerance) SolverTaskDescription(cbit.vcell.solver.SolverTaskDescription)

Aggregations

Geometry (cbit.vcell.geometry.Geometry)121 MathDescription (cbit.vcell.math.MathDescription)32 SimulationContext (cbit.vcell.mapping.SimulationContext)31 Simulation (cbit.vcell.solver.Simulation)29 PropertyVetoException (java.beans.PropertyVetoException)24 BioModel (cbit.vcell.biomodel.BioModel)23 DataAccessException (org.vcell.util.DataAccessException)23 VCImage (cbit.image.VCImage)22 SubVolume (cbit.vcell.geometry.SubVolume)21 MathModel (cbit.vcell.mathmodel.MathModel)21 Expression (cbit.vcell.parser.Expression)19 ISize (org.vcell.util.ISize)19 Hashtable (java.util.Hashtable)18 GeometryThumbnailImageFactoryAWT (cbit.vcell.geometry.GeometryThumbnailImageFactoryAWT)17 UserCancelException (org.vcell.util.UserCancelException)17 KeyValue (org.vcell.util.document.KeyValue)17 ImageException (cbit.image.ImageException)16 Extent (org.vcell.util.Extent)16 SurfaceClass (cbit.vcell.geometry.SurfaceClass)15 ExpressionException (cbit.vcell.parser.ExpressionException)15