Search in sources :

Example 1 with FilamentSubDomain

use of cbit.vcell.math.FilamentSubDomain in project vcell by virtualcell.

the class Xmlproducer method getXML.

/**
 * This method returns a XML representation of a SubDomain object type.
 * Creation date: (3/2/2001 1:13:30 PM)
 * @return Element
 * @param param cbit.vcell.math.SubDomain
 */
private Element getXML(SubDomain param) throws XmlParseException {
    Element e = null;
    if (param instanceof CompartmentSubDomain) {
        e = getXML((CompartmentSubDomain) param);
    } else if (param instanceof FilamentSubDomain) {
        e = getXML((FilamentSubDomain) param);
    } else if (param instanceof MembraneSubDomain) {
        e = getXML((MembraneSubDomain) param);
    } else if (param instanceof PointSubDomain) {
        e = getXML((PointSubDomain) param);
    }
    transcribeComments(param, e);
    return e;
}
Also used : MembraneSubDomain(cbit.vcell.math.MembraneSubDomain) CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain) Element(org.jdom.Element) PointSubDomain(cbit.vcell.math.PointSubDomain) FilamentSubDomain(cbit.vcell.math.FilamentSubDomain)

Example 2 with FilamentSubDomain

use of cbit.vcell.math.FilamentSubDomain in project vcell by virtualcell.

the class ITextWriter method writeSubDomainsEquationsAsText.

protected void writeSubDomainsEquationsAsText(Section mathDescSection, MathDescription mathDesc) throws DocumentException {
    Enumeration<SubDomain> subDomains = mathDesc.getSubDomains();
    Section volDomains = mathDescSection.addSection("Volume Domains", mathDescSection.depth() + 1);
    Section memDomains = mathDescSection.addSection("Membrane Domains", mathDescSection.depth() + 1);
    Section filDomains = mathDescSection.addSection("Filament Domains", mathDescSection.depth() + 1);
    while (subDomains.hasMoreElements()) {
        Section tempSection = null;
        SubDomain subDomain = subDomains.nextElement();
        if (subDomain instanceof CompartmentSubDomain) {
            tempSection = volDomains.addSection(subDomain.getName(), volDomains.depth() + 1);
        } else if (subDomain instanceof MembraneSubDomain) {
            tempSection = memDomains.addSection(subDomain.getName(), memDomains.depth() + 1);
        } else if (subDomain instanceof FilamentSubDomain) {
            tempSection = filDomains.addSection(subDomain.getName(), filDomains.depth() + 1);
        }
        Enumeration<Equation> equationsList = subDomain.getEquations();
        while (equationsList.hasMoreElements()) {
            Equation equ = equationsList.nextElement();
            writeEquation(tempSection, equ);
        }
        if (subDomain.getFastSystem() != null) {
            writeFastSystem(tempSection, subDomain.getFastSystem());
        }
        if (subDomain instanceof MembraneSubDomain) {
            Enumeration<JumpCondition> jcList = ((MembraneSubDomain) subDomain).getJumpConditions();
            while (jcList.hasMoreElements()) {
                JumpCondition jc = jcList.nextElement();
                writeJumpCondition(tempSection, jc);
            }
        }
    }
    if (volDomains.isEmpty()) {
        mathDescSection.remove(volDomains);
    }
    if (memDomains.isEmpty()) {
        mathDescSection.remove(memDomains);
    }
    if (filDomains.isEmpty()) {
        mathDescSection.remove(filDomains);
    }
}
Also used : CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain) FilamentSubDomain(cbit.vcell.math.FilamentSubDomain) SubDomain(cbit.vcell.math.SubDomain) MembraneSubDomain(cbit.vcell.math.MembraneSubDomain) JumpCondition(cbit.vcell.math.JumpCondition) MembraneSubDomain(cbit.vcell.math.MembraneSubDomain) CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain) PdeEquation(cbit.vcell.math.PdeEquation) VolumeRegionEquation(cbit.vcell.math.VolumeRegionEquation) OdeEquation(cbit.vcell.math.OdeEquation) FilamentRegionEquation(cbit.vcell.math.FilamentRegionEquation) MembraneRegionEquation(cbit.vcell.math.MembraneRegionEquation) Equation(cbit.vcell.math.Equation) Section(com.lowagie.text.Section) FilamentSubDomain(cbit.vcell.math.FilamentSubDomain)

Example 3 with FilamentSubDomain

use of cbit.vcell.math.FilamentSubDomain in project vcell by virtualcell.

the class SimulationData method getVarAndFunctionDataIdentifiers.

/**
 * This method was created in VisualAge.
 * @return java.lang.String[]
 */
public synchronized DataIdentifier[] getVarAndFunctionDataIdentifiers(OutputContext outputContext) throws IOException, DataAccessException {
    // Is this zip format?
    boolean bIsChombo = false;
    try {
        bIsChombo = isChombo();
    } catch (FileNotFoundException e) {
        e.printStackTrace(System.out);
    }
    File zipFile1 = getZipFile(bIsChombo, null);
    File zipFile2 = getZipFile(bIsChombo, 0);
    bZipFormat1 = false;
    bZipFormat2 = false;
    if (zipFile1.exists()) {
        bZipFormat1 = true;
    } else if (zipFile2.exists()) {
        bZipFormat2 = true;
    }
    refreshLogFile();
    if (!isComsol()) {
        try {
            refreshMeshFile();
        } catch (MathException e) {
            e.printStackTrace(System.out);
            throw new DataAccessException(e.getMessage());
        }
    }
    if (!isRulesData && !getIsODEData() && !isComsol() && dataFilenames != null) {
        // read variables only when I have never read the file since variables don't change
        if (dataSetIdentifierList.size() == 0) {
            File file = getPDEDataFile(0.0);
            DataSet dataSet = getPDEDataSet(file, 0.0);
            String[] varNames = dataSet.getDataNames();
            int[] varTypeInts = dataSet.getVariableTypeIntegers();
            if (varNames == null) {
                return null;
            }
            dataSetIdentifierList.clear();
            for (int i = 0; i < varNames.length; i++) {
                VariableType varType = null;
                try {
                    varType = VariableType.getVariableTypeFromInteger(varTypeInts[i]);
                } catch (IllegalArgumentException e) {
                    if (LG.isEnabledFor(Level.WARN)) {
                        LG.warn("Exception typing " + varNames[i] + " has unsupported type " + varTypeInts[i] + ": " + e.getMessage());
                    }
                    varType = SimulationData.getVariableTypeFromLength(mesh, dataSet.getDataLength(varNames[i]));
                }
                Domain domain = Variable.getDomainFromCombinedIdentifier(varNames[i]);
                String varName = Variable.getNameFromCombinedIdentifier(varNames[i]);
                dataSetIdentifierList.addElement(new DataSetIdentifier(varName, varType, domain));
            }
            refreshDataProcessingOutputInfo(outputContext);
            if (dataProcessingOutputInfo != null) {
                for (int i = 0; i < dataProcessingOutputInfo.getVariableNames().length; i++) {
                    if (dataProcessingOutputInfo.getPostProcessDataType(dataProcessingOutputInfo.getVariableNames()[i]).equals(DataProcessingOutputInfo.PostProcessDataType.image)) {
                        dataSetIdentifierList.addElement(new DataSetIdentifier(dataProcessingOutputInfo.getVariableNames()[i], VariableType.POSTPROCESSING, null));
                    }
                }
            }
        }
        // always read functions file since functions might change
        getFunctionDataIdentifiers(outputContext);
    }
    if ((isRulesData || getIsODEData()) && dataSetIdentifierList.size() == 0) {
        ODEDataBlock odeDataBlock = getODEDataBlock();
        if (odeDataBlock == null) {
            throw new DataAccessException("Results are not availabe yet. Please try again later.");
        }
        ODESimData odeSimData = odeDataBlock.getODESimData();
        int colCount = odeSimData.getColumnDescriptionsCount();
        // assume index=0 is time "t"
        int DATA_OFFSET = 1;
        dataSetIdentifierList.clear();
        for (int i = 0; i < (colCount - DATA_OFFSET); i++) {
            String varName = odeSimData.getColumnDescriptions(i + DATA_OFFSET).getDisplayName();
            // TODO domain
            Domain domain = null;
            dataSetIdentifierList.addElement(new DataSetIdentifier(varName, VariableType.NONSPATIAL, domain));
        }
    }
    if (isComsol() && dataSetIdentifierList.size() == 0) {
        ComsolSimFiles comsolSimFiles = getComsolSimFiles();
        if (comsolSimFiles.simTaskXMLFile != null) {
            try {
                String xmlString = FileUtils.readFileToString(comsolSimFiles.simTaskXMLFile);
                SimulationTask simTask = XmlHelper.XMLToSimTask(xmlString);
                Enumeration<Variable> variablesEnum = simTask.getSimulation().getMathDescription().getVariables();
                while (variablesEnum.hasMoreElements()) {
                    Variable var = variablesEnum.nextElement();
                    if (var instanceof VolVariable) {
                        dataSetIdentifierList.addElement(new DataSetIdentifier(var.getName(), VariableType.VOLUME, var.getDomain()));
                    } else if (var instanceof MemVariable) {
                        dataSetIdentifierList.addElement(new DataSetIdentifier(var.getName(), VariableType.MEMBRANE, var.getDomain()));
                    } else if (var instanceof Function) {
                        VariableType varType = VariableType.UNKNOWN;
                        if (var.getDomain() != null && var.getDomain().getName() != null) {
                            SubDomain subDomain = simTask.getSimulation().getMathDescription().getSubDomain(var.getDomain().getName());
                            if (subDomain instanceof CompartmentSubDomain) {
                                varType = VariableType.VOLUME;
                            } else if (subDomain instanceof MembraneSubDomain) {
                                varType = VariableType.MEMBRANE;
                            } else if (subDomain instanceof FilamentSubDomain) {
                                throw new RuntimeException("filament subdomains not supported");
                            } else if (subDomain instanceof PointSubDomain) {
                                varType = VariableType.POINT_VARIABLE;
                            }
                        }
                        dataSetIdentifierList.addElement(new DataSetIdentifier(var.getName(), varType, var.getDomain()));
                    } else if (var instanceof Constant) {
                        System.out.println("ignoring Constant " + var.getName());
                    } else if (var instanceof InsideVariable) {
                        System.out.println("ignoring InsideVariable " + var.getName());
                    } else if (var instanceof OutsideVariable) {
                        System.out.println("ignoring OutsideVariable " + var.getName());
                    } else {
                        throw new RuntimeException("unexpected variable " + var.getName() + " of type " + var.getClass().getName());
                    }
                }
            } catch (XmlParseException | ExpressionException e) {
                e.printStackTrace();
                throw new RuntimeException("failed to read sim task file, msg: " + e.getMessage(), e);
            }
        }
    }
    DataIdentifier[] dis = new DataIdentifier[dataSetIdentifierList.size()];
    for (int i = 0; i < dataSetIdentifierList.size(); i++) {
        DataSetIdentifier dsi = (DataSetIdentifier) dataSetIdentifierList.elementAt(i);
        String displayName = dsi.getName();
        if (dsi.isFunction()) {
            AnnotatedFunction f = null;
            for (int j = 0; j < annotatedFunctionList.size(); j++) {
                AnnotatedFunction function = (AnnotatedFunction) annotatedFunctionList.elementAt(j);
                if (function.getName().equals(dsi.getName())) {
                    f = function;
                    break;
                }
            }
            if (f != null) {
                displayName = f.getDisplayName();
            }
        }
        dis[i] = new DataIdentifier(dsi.getName(), dsi.getVariableType(), dsi.getDomain(), dsi.isFunction(), displayName);
    }
    return dis;
}
Also used : MembraneSubDomain(cbit.vcell.math.MembraneSubDomain) SimulationTask(cbit.vcell.messaging.server.SimulationTask) InsideVariable(cbit.vcell.math.InsideVariable) VolVariable(cbit.vcell.math.VolVariable) ReservedVariable(cbit.vcell.math.ReservedVariable) MemVariable(cbit.vcell.math.MemVariable) OutsideVariable(cbit.vcell.math.OutsideVariable) Variable(cbit.vcell.math.Variable) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) ExternalDataIdentifier(org.vcell.util.document.ExternalDataIdentifier) Constant(cbit.vcell.math.Constant) FileNotFoundException(java.io.FileNotFoundException) PointSubDomain(cbit.vcell.math.PointSubDomain) ODESimData(cbit.vcell.solver.ode.ODESimData) InsideVariable(cbit.vcell.math.InsideVariable) ExpressionException(cbit.vcell.parser.ExpressionException) CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain) FilamentSubDomain(cbit.vcell.math.FilamentSubDomain) SubDomain(cbit.vcell.math.SubDomain) PointSubDomain(cbit.vcell.math.PointSubDomain) MembraneSubDomain(cbit.vcell.math.MembraneSubDomain) Function(cbit.vcell.math.Function) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction) MemVariable(cbit.vcell.math.MemVariable) DataAccessException(org.vcell.util.DataAccessException) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction) ComsolSimFiles(org.vcell.vis.io.ComsolSimFiles) VariableType(cbit.vcell.math.VariableType) VolVariable(cbit.vcell.math.VolVariable) XmlParseException(cbit.vcell.xml.XmlParseException) FilamentSubDomain(cbit.vcell.math.FilamentSubDomain) MathException(cbit.vcell.math.MathException) CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain) OutsideVariable(cbit.vcell.math.OutsideVariable) CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain) FilamentSubDomain(cbit.vcell.math.FilamentSubDomain) SubDomain(cbit.vcell.math.SubDomain) PointSubDomain(cbit.vcell.math.PointSubDomain) Domain(cbit.vcell.math.Variable.Domain) MembraneSubDomain(cbit.vcell.math.MembraneSubDomain) ZipFile(org.apache.commons.compress.archivers.zip.ZipFile) File(java.io.File)

Example 4 with FilamentSubDomain

use of cbit.vcell.math.FilamentSubDomain in project vcell by virtualcell.

the class XmlReader method getFilamentSubDomain.

/**
 * This method returns a FilamentSubDomain object from a XMl element.
 * Creation date: (5/18/2001 4:27:22 PM)
 * @return cbit.vcell.math.FilamentSubDomain
 * @param param org.jdom.Element
 * @exception cbit.vcell.xml.XmlParseException The exception description.
 */
private FilamentSubDomain getFilamentSubDomain(Element param, MathDescription mathDesc) throws XmlParseException {
    // get name
    String name = unMangle(param.getAttributeValue(XMLTags.NameAttrTag));
    // get outside Compartment ref
    String outsideName = unMangle(param.getAttributeValue(XMLTags.OutsideCompartmentTag));
    CompartmentSubDomain outsideRef = (CompartmentSubDomain) mathDesc.getCompartmentSubDomain(outsideName);
    if (outsideRef == null) {
        throw new XmlParseException("The reference to the CompartmentSubDomain " + outsideName + ", could not be resolved!");
    }
    // *** create new filamentSubDomain object ***
    FilamentSubDomain filDomain = new FilamentSubDomain(name, outsideRef);
    // add OdeEquations
    Iterator<Element> iterator = param.getChildren(XMLTags.OdeEquationTag, vcNamespace).iterator();
    while (iterator.hasNext()) {
        Element tempElement = (Element) iterator.next();
        try {
            filDomain.addEquation(getOdeEquation(tempElement, mathDesc));
        } catch (MathException e) {
            e.printStackTrace(System.out);
            throw new XmlParseException("A MathException was fired when adding an OdeEquation to the FilamentSubDomain " + name, e);
        }
    }
    // Add the FastSytem
    filDomain.setFastSystem(getFastSystem(param.getChild(XMLTags.FastSystemTag, vcNamespace), mathDesc));
    return filDomain;
}
Also used : CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain) MathException(cbit.vcell.math.MathException) Element(org.jdom.Element) FilamentSubDomain(cbit.vcell.math.FilamentSubDomain)

Aggregations

CompartmentSubDomain (cbit.vcell.math.CompartmentSubDomain)4 FilamentSubDomain (cbit.vcell.math.FilamentSubDomain)4 MembraneSubDomain (cbit.vcell.math.MembraneSubDomain)3 MathException (cbit.vcell.math.MathException)2 PointSubDomain (cbit.vcell.math.PointSubDomain)2 SubDomain (cbit.vcell.math.SubDomain)2 Element (org.jdom.Element)2 Constant (cbit.vcell.math.Constant)1 Equation (cbit.vcell.math.Equation)1 FilamentRegionEquation (cbit.vcell.math.FilamentRegionEquation)1 Function (cbit.vcell.math.Function)1 InsideVariable (cbit.vcell.math.InsideVariable)1 JumpCondition (cbit.vcell.math.JumpCondition)1 MemVariable (cbit.vcell.math.MemVariable)1 MembraneRegionEquation (cbit.vcell.math.MembraneRegionEquation)1 OdeEquation (cbit.vcell.math.OdeEquation)1 OutsideVariable (cbit.vcell.math.OutsideVariable)1 PdeEquation (cbit.vcell.math.PdeEquation)1 ReservedVariable (cbit.vcell.math.ReservedVariable)1 Variable (cbit.vcell.math.Variable)1