Search in sources :

Example 6 with VariableDomain

use of cbit.vcell.math.VariableType.VariableDomain in project vcell by virtualcell.

the class MovingBoundaryFileWriter method getSpecies.

// TODO: flatten here
private Element getSpecies(Equation eq) throws ExpressionException, MathException {
    Element e = new Element(MBTags.species);
    e.setAttribute(MBTags.name, eq.getVariable().getName());
    VariableDomain varDomain = null;
    if (eq.getVariable() instanceof VolVariable) {
        e.setAttribute(MBXmlTags.type.name(), MBXmlTags.volume.name());
        varDomain = VariableDomain.VARIABLEDOMAIN_VOLUME;
    } else if (eq.getVariable() instanceof PointVariable) {
        e.setAttribute(MBXmlTags.type.name(), MBXmlTags.point.name());
        varDomain = VariableDomain.VARIABLEDOMAIN_POINT;
    }
    Element e1 = null;
    e1 = new Element(MBTags.initial);
    Expression ex = eq.getInitialExpression();
    setExpression(e1, ex, varDomain);
    e.addContent(e1);
    e1 = new Element(MBTags.source);
    ex = eq.getRateExpression();
    setExpression(e1, ex, varDomain);
    e.addContent(e1);
    if (eq instanceof PdeEquation) {
        e1 = new Element(MBTags.diffusion);
        ex = ((PdeEquation) eq).getDiffusionExpression();
        setExpression(e1, ex, varDomain);
        e.addContent(e1);
        ex = ((PdeEquation) eq).getVelocityX();
        if (ex != null) {
            e1 = new Element(MBTags.advectVelocityFunctionX);
            setExpression(e1, ex, varDomain);
            e.addContent(e1);
        }
        ex = ((PdeEquation) eq).getVelocityY();
        if (ex != null) {
            e1 = new Element(MBTags.advectVelocityFunctionY);
            setExpression(e1, ex, varDomain);
            e.addContent(e1);
        }
    }
    return e;
}
Also used : PdeEquation(cbit.vcell.math.PdeEquation) VariableDomain(cbit.vcell.math.VariableType.VariableDomain) VolVariable(cbit.vcell.math.VolVariable) Expression(cbit.vcell.parser.Expression) Element(org.jdom.Element) PointVariable(cbit.vcell.math.PointVariable)

Example 7 with VariableDomain

use of cbit.vcell.math.VariableType.VariableDomain in project vcell by virtualcell.

the class DataSetControllerImpl method getVtuVarInfos.

public VtuVarInfo[] getVtuVarInfos(MovingBoundarySimFiles movingBoundaryFiles, OutputContext outputContext, VCDataIdentifier vcdataID) throws DataAccessException {
    try {
        DataIdentifier[] dataIdentifiers = getDataIdentifiers(outputContext, vcdataID);
        if (dataIdentifiers == null) {
            return null;
        }
        ArrayList<VtuVarInfo> vtuVarInfos = new ArrayList<VtuVarInfo>();
        for (DataIdentifier di : dataIdentifiers) {
            String name = di.getName();
            String displayName = di.getDisplayName();
            if (di.getDomain() != null) {
                System.err.println("DataSetControllerImpl.getVtuVarInfos(movingboundary): need to support proper domain names now");
            }
            String domainName = MovingBoundaryReader.getFakeInsideDomainName();
            VariableDomain variableDomain = null;
            VariableType variableType = di.getVariableType();
            if (variableType.equals(VariableType.VOLUME) || variableType.equals(VariableType.VOLUME_REGION)) {
                variableDomain = VariableDomain.VARIABLEDOMAIN_VOLUME;
            } else if (variableType.equals(VariableType.MEMBRANE) || variableType.equals(VariableType.MEMBRANE_REGION)) {
                variableDomain = VariableDomain.VARIABLEDOMAIN_MEMBRANE;
            } else if (variableType.equals(VariableType.POINT_VARIABLE)) {
                variableDomain = VariableDomain.VARIABLEDOMAIN_POINT;
            } else if (variableType.equals(VariableType.CONTOUR) || variableType.equals(VariableType.CONTOUR_REGION)) {
                variableDomain = VariableDomain.VARIABLEDOMAIN_CONTOUR;
            } else if (variableType.equals(VariableType.NONSPATIAL)) {
                variableDomain = VariableDomain.VARIABLEDOMAIN_UNKNOWN;
            } else if (variableType.equals(VariableType.POSTPROCESSING)) {
                variableDomain = VariableDomain.VARIABLEDOMAIN_POSTPROCESSING;
            } else {
                System.err.print("skipping var " + di + ", unsupported data type");
            }
            String functionExpression = null;
            boolean bMeshVariable = false;
            if (name.toUpperCase().contains("SIZE")) {
                System.err.println("Skipping Moving Boundary variable '" + name + "' because it is a size ... change later");
                continue;
            }
            vtuVarInfos.add(new VtuVarInfo(name, displayName, domainName, variableDomain, functionExpression, DataType.CellData, bMeshVariable));
        }
        return vtuVarInfos.toArray(new VtuVarInfo[0]);
    } catch (Exception e) {
        lg.error(e.getMessage(), e);
        throw new DataAccessException("failed to retrieve VTK variable list: " + e.getMessage(), e);
    }
}
Also used : VtuVarInfo(org.vcell.vis.io.VtuVarInfo) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) ExternalDataIdentifier(org.vcell.util.document.ExternalDataIdentifier) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) VariableDomain(cbit.vcell.math.VariableType.VariableDomain) VariableType(cbit.vcell.math.VariableType) ArrayList(java.util.ArrayList) 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 VariableDomain

use of cbit.vcell.math.VariableType.VariableDomain in project vcell by virtualcell.

the class ChomboVtkFileWriter method getVtuVarInfos.

public VtuVarInfo[] getVtuVarInfos(ChomboFiles chomboFiles, OutputContext outputContext, VCData vcData) throws DataAccessException, IOException {
    // 
    // read the time=0 chombo dataset into memory to get the var names (probably a more efficient way of doing this).
    // 
    ChomboDataset chomboDataset;
    try {
        int timeIndex = 0;
        chomboDataset = ChomboFileReader.readDataset(chomboFiles, chomboFiles.getTimeIndices().get(timeIndex));
    } catch (Exception e) {
        throw new DataAccessException("failed to read chombo dataset: " + e.getMessage(), e);
    }
    DataIdentifier[] dataIdentifiers = vcData.getVarAndFunctionDataIdentifiers(outputContext);
    for (DataIdentifier di : dataIdentifiers) {
        System.out.println(((di.getDomain() != null) ? di.getDomain().getName() : "none") + "::" + di.getName() + "-" + di.getVariableType());
    }
    // 
    // for each ChomboDomain get list of built-in (mesh) variables, component (regular) volume variables, and Membrane Variables (still tied to the volume).
    // 
    ArrayList<VtuVarInfo> varInfos = new ArrayList<VtuVarInfo>();
    for (ChomboCombinedVolumeMembraneDomain chomboCombinedVolumeMembraneDomain : chomboDataset.getCombinedVolumeMembraneDomains()) {
        ChomboMeshData chomboMeshData = chomboCombinedVolumeMembraneDomain.getChomboMeshData();
        // 
        // process Volume variables for this combined domain (chombo stores membrane data with volume)
        // 
        {
            String volumeDomainName = chomboCombinedVolumeMembraneDomain.getVolumeDomainName();
            VariableDomain volVariableDomain = VariableDomain.VARIABLEDOMAIN_VOLUME;
            for (String builtinVarName : chomboMeshData.getVolumeBuiltinNames()) {
                String varName = builtinVarName;
                String displayName = "(" + volumeDomainName + ")  " + varName;
                String expressionString = null;
                boolean bMeshVariable = true;
                varInfos.add(new VtuVarInfo(varName, displayName, volumeDomainName, volVariableDomain, expressionString, DataType.CellData, bMeshVariable));
            }
            for (String componentVarName : chomboMeshData.getVisibleVolumeDataNames()) {
                String varName = componentVarName;
                String displayName = "(" + volumeDomainName + ")  " + varName;
                String expressionString = null;
                boolean bMeshVariable = false;
                varInfos.add(new VtuVarInfo(varName, displayName, volumeDomainName, volVariableDomain, expressionString, DataType.CellData, bMeshVariable));
            }
            for (DataIdentifier dataID : dataIdentifiers) {
                if (dataID.isVisible() && dataID.getVariableType().getVariableDomain() == VariableDomain.VARIABLEDOMAIN_VOLUME && (dataID.getDomain() == null || dataID.getDomain().getName().equals(volumeDomainName))) {
                    String displayName = "(" + volumeDomainName + ")  " + dataID.getDisplayName();
                    String expressionString = null;
                    AnnotatedFunction f = vcData.getFunction(outputContext, dataID.getName());
                    if (f != null) {
                        expressionString = f.getExpression().infix();
                    }
                    boolean bMeshVar = false;
                    varInfos.add(new VtuVarInfo(dataID.getName(), displayName, volumeDomainName, volVariableDomain, expressionString, DataType.CellData, bMeshVar));
                }
            }
        }
        // 
        // process membrane variables for this combined domain (chombo stores membrane data with volume)
        // 
        {
            String memDomainName = chomboCombinedVolumeMembraneDomain.getMembraneDomainName();
            VariableDomain memVariableDomain = VariableDomain.VARIABLEDOMAIN_MEMBRANE;
            for (ChomboMembraneVarData membraneVarData : chomboMeshData.getMembraneVarData()) {
                String varName = membraneVarData.getName();
                String displayName = "(" + membraneVarData.getDomainName() + ")  " + varName;
                String expressionString = null;
                boolean bMeshVariable = false;
                varInfos.add(new VtuVarInfo(varName, displayName, memDomainName, memVariableDomain, expressionString, DataType.CellData, bMeshVariable));
            }
            for (String builtinVarName : chomboMeshData.getMembraneBuiltinNames()) {
                String varName = builtinVarName;
                String displayName = "(" + memDomainName + ")  " + varName;
                String expressionString = null;
                boolean bMeshVariable = true;
                varInfos.add(new VtuVarInfo(varName, displayName, memDomainName, memVariableDomain, expressionString, DataType.CellData, bMeshVariable));
            }
            for (DataIdentifier dataID : dataIdentifiers) {
                if (dataID.isVisible() && dataID.getVariableType().getVariableDomain() == VariableDomain.VARIABLEDOMAIN_MEMBRANE && (dataID.getDomain() == null || dataID.getDomain().getName().equals(memDomainName))) {
                    String displayName = "(" + memDomainName + ")  " + dataID.getDisplayName();
                    String expressionString = null;
                    AnnotatedFunction f = vcData.getFunction(outputContext, dataID.getName());
                    if (f != null) {
                        expressionString = f.getExpression().infix();
                    }
                    boolean bMeshVar = false;
                    varInfos.add(new VtuVarInfo(dataID.getName(), displayName, memDomainName, memVariableDomain, expressionString, DataType.CellData, bMeshVar));
                }
            }
        }
    }
    return varInfos.toArray(new VtuVarInfo[0]);
}
Also used : VtuVarInfo(org.vcell.vis.io.VtuVarInfo) DataIdentifier(cbit.vcell.simdata.DataIdentifier) VariableDomain(cbit.vcell.math.VariableType.VariableDomain) ArrayList(java.util.ArrayList) ChomboMembraneVarData(org.vcell.vis.chombo.ChomboMembraneVarData) DivideByZeroException(cbit.vcell.parser.DivideByZeroException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) ExpressionException(cbit.vcell.parser.ExpressionException) ExpressionBindingException(cbit.vcell.parser.ExpressionBindingException) MathException(cbit.vcell.math.MathException) ChomboCombinedVolumeMembraneDomain(org.vcell.vis.chombo.ChomboDataset.ChomboCombinedVolumeMembraneDomain) ChomboMeshData(org.vcell.vis.chombo.ChomboMeshData) DataAccessException(org.vcell.util.DataAccessException) ChomboDataset(org.vcell.vis.chombo.ChomboDataset) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction)

Example 9 with VariableDomain

use of cbit.vcell.math.VariableType.VariableDomain in project vcell by virtualcell.

the class CartesianMeshVtkFileWriter method getVtuVarInfos.

public VtuVarInfo[] getVtuVarInfos(VCellSimFiles vcellFiles, OutputContext outputContext, VCData vcData) throws IOException, DataAccessException, MathException {
    CartesianMeshFileReader reader = new CartesianMeshFileReader();
    CartesianMesh mesh = reader.readFromFiles(vcellFiles);
    List<String> volumeDomainNames = mesh.getVolumeDomainNames();
    List<String> membraneDomainNames = mesh.getMembraneDomainNames();
    ArrayList<String> allDomains = new ArrayList<String>();
    allDomains.addAll(volumeDomainNames);
    allDomains.addAll(membraneDomainNames);
    DataIdentifier[] dataIdentifiers = vcData.getVarAndFunctionDataIdentifiers(outputContext);
    AnnotatedFunction[] annotationFunctions = vcData.getFunctions(outputContext);
    ArrayList<VtuVarInfo> varInfos = new ArrayList<VtuVarInfo>();
    for (String domainName : allDomains) {
        VariableDomain varDomain = VariableDomain.VARIABLEDOMAIN_UNKNOWN;
        if (volumeDomainNames.contains(domainName)) {
            varDomain = VariableDomain.VARIABLEDOMAIN_VOLUME;
        } else if (membraneDomainNames.contains(domainName)) {
            varDomain = VariableDomain.VARIABLEDOMAIN_MEMBRANE;
        }
        for (DataIdentifier dataID : dataIdentifiers) {
            if (dataID.getDomain() == null || dataID.getDomain().getName().equals(domainName)) {
                boolean bMeshVar = isMeshVar(dataID);
                String expressionString = null;
                if (dataID.isFunction()) {
                    for (AnnotatedFunction f : annotationFunctions) {
                        if (f.getName().equals(dataID.getName())) {
                            expressionString = f.getExpression().infix();
                        }
                    }
                }
                varInfos.add(new VtuVarInfo(dataID.getName(), "(" + domainName + ")  " + dataID.getDisplayName(), domainName, varDomain, expressionString, DataType.CellData, bMeshVar));
            }
        }
        varInfos.add(new VtuVarInfo(GLOBAL_INDEX_VAR, "(" + domainName + ")  " + GLOBAL_INDEX_VAR, domainName, varDomain, null, DataType.CellData, true));
        varInfos.add(new VtuVarInfo(REGION_ID_VAR, "(" + domainName + ")  " + REGION_ID_VAR, domainName, varDomain, null, DataType.CellData, true));
    }
    return varInfos.toArray(new VtuVarInfo[0]);
}
Also used : CartesianMeshFileReader(org.vcell.vis.io.CartesianMeshFileReader) VtuVarInfo(org.vcell.vis.io.VtuVarInfo) DataIdentifier(cbit.vcell.simdata.DataIdentifier) VariableDomain(cbit.vcell.math.VariableType.VariableDomain) ArrayList(java.util.ArrayList) CartesianMesh(org.vcell.vis.vcell.CartesianMesh) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction)

Aggregations

VariableDomain (cbit.vcell.math.VariableType.VariableDomain)9 ExpressionException (cbit.vcell.parser.ExpressionException)5 VtuVarInfo (org.vcell.vis.io.VtuVarInfo)5 Expression (cbit.vcell.parser.Expression)4 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 DataAccessException (org.vcell.util.DataAccessException)4 MathException (cbit.vcell.math.MathException)3 VariableType (cbit.vcell.math.VariableType)3 DivideByZeroException (cbit.vcell.parser.DivideByZeroException)3 ExpressionBindingException (cbit.vcell.parser.ExpressionBindingException)3 FileNotFoundException (java.io.FileNotFoundException)3 ReservedVariable (cbit.vcell.math.ReservedVariable)2 Variable (cbit.vcell.math.Variable)2 VolVariable (cbit.vcell.math.VolVariable)2 VolumeRandomVariable (cbit.vcell.math.VolumeRandomVariable)2 DataIdentifier (cbit.vcell.simdata.DataIdentifier)2 AnnotatedFunction (cbit.vcell.solver.AnnotatedFunction)2 VCSimulationDataIdentifier (cbit.vcell.solver.VCSimulationDataIdentifier)2 XmlParseException (cbit.vcell.xml.XmlParseException)2