Search in sources :

Example 56 with DataAccessException

use of org.vcell.util.DataAccessException in project vcell by virtualcell.

the class ClientPDEDataContext method initialize.

/**
 * Insert the method's description here.
 * Creation date: (10/3/00 5:16:19 PM)
 */
private void initialize() {
    try {
        setVCDataIdentifier(getDataManager().getVCDataIdentifier());
        setParticleData(getDataManager().getParticleDataExists());
        setCartesianMesh(getDataManager().getMesh());
        setTimePoints(getDataManager().getDataSetTimes());
        setDataIdentifiers(getDataManager().getDataIdentifiers());
        double tp = getTimePoint();
        double[] timePoints = getTimePoints();
        if (timePoints != null && timePoints.length > 0) {
            tp = timePoints[0];
        }
        DataIdentifier variable = getDataIdentifier();
        DataIdentifier[] dataIdentifiers = getDataIdentifiers();
        if (dataIdentifiers != null && dataIdentifiers.length > 0) {
            variable = dataIdentifiers[0];
        }
        setVariableAndTime(variable, tp);
    } catch (DataAccessException exc) {
        exc.printStackTrace(System.out);
        throw new RuntimeException(exc.getMessage(), exc);
    }
}
Also used : VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) DataAccessException(org.vcell.util.DataAccessException)

Example 57 with DataAccessException

use of org.vcell.util.DataAccessException in project vcell by virtualcell.

the class DataSetControllerImpl method getSimDataBlock.

/**
 * This method was created by a SmartGuide.
 * @return double[]
 * @param varName java.lang.String
 * @param time double
 */
public SimDataBlock getSimDataBlock(OutputContext outputContext, VCDataIdentifier vcdID, String varName, double time) throws DataAccessException {
    VCMongoMessage.sendTrace("DataSetControllerImpl.getSimDataBlock(" + varName + ", " + time + ")  <<ENTER>>");
    try {
        // 
        // check if already cached for non-function variables
        // 
        VCData simData = getVCData(vcdID);
        VCMongoMessage.sendTrace("DataSetControllerImpl.getSimDataBlock(" + varName + ", " + time + ") got VCData");
        long dataBlockTimeStamp = simData.getDataBlockTimeStamp(PDE_DATA, time);
        VCMongoMessage.sendTrace("DataSetControllerImpl.getSimDataBlock(" + varName + ", " + time + ") got dataBlockTimeStamp");
        PDEDataInfo pdeDataInfo = new PDEDataInfo(vcdID.getOwner(), vcdID.getID(), varName, time, dataBlockTimeStamp);
        SimDataBlock simDataBlock = null;
        AnnotatedFunction function = getFunction(outputContext, vcdID, varName);
        VCMongoMessage.sendTrace("DataSetControllerImpl.getSimDataBlock(" + varName + ", " + time + ") got function");
        if (function == null) {
            simDataBlock = (cacheTable0 != null ? cacheTable0.get(pdeDataInfo) : null);
            if (simDataBlock == null) {
                simDataBlock = simData.getSimDataBlock(outputContext, varName, time);
                if (simDataBlock != null && dataCachingEnabled) {
                    // cacheTable.put(pdeDataInfo,simDataBlock);
                    if (cacheTable0 != null) {
                        try {
                            cacheTable0.put(pdeDataInfo, simDataBlock);
                        } catch (CacheException e) {
                            // if can't cache the data, it is ok
                            e.printStackTrace();
                        }
                    }
                }
            }
        } else {
            if (simData instanceof SimulationData) {
                function = ((SimulationData) simData).simplifyFunction(function);
            }
            VCMongoMessage.sendTrace("DataSetControllerImpl.getSimDataBlock(" + varName + ", " + time + ") evaluating function");
            simDataBlock = evaluateFunction(outputContext, vcdID, simData, function, time);
        }
        CartesianMesh mesh = getMesh(vcdID);
        if (mesh != null && mesh.isChomboMesh()) {
            for (int i = 0; i < simDataBlock.getData().length; i++) {
                if (simDataBlock.getData()[i] == 1.23456789e300) {
                    simDataBlock.getData()[i] = Double.NaN;
                }
            }
        }
        if (simDataBlock != null) {
            VCMongoMessage.sendTrace("DataSetControllerImpl.getSimDataBlock(" + varName + ", " + time + ")  <<EXIT-simDataBlock not null>>");
            return simDataBlock;
        } else {
            String msg = "failure reading " + varName + " at t=" + time + " for " + vcdID.getOwner().getName() + "'s " + vcdID.getID();
            if (lg.isWarnEnabled())
                lg.warn("DataSetControllerImpl.getDataBlockValues(): " + msg);
            VCMongoMessage.sendTrace("DataSetControllerImpl.getSimDataBlock(" + varName + ", " + time + ")  <<EXIT-Exception>>");
            throw new DataAccessException(msg);
        }
    } catch (MathException e) {
        lg.error(e.getMessage(), e);
        VCMongoMessage.sendTrace("DataSetControllerImpl.getSimDataBlock(" + varName + ", " + time + ")  <<EXIT-Exception>>");
        throw new DataAccessException(e.getMessage());
    } catch (IOException e) {
        lg.error(e.getMessage(), e);
        VCMongoMessage.sendTrace("DataSetControllerImpl.getSimDataBlock(" + varName + ", " + time + ")  <<EXIT-Exception>>");
        throw new DataAccessException(e.getMessage());
    } catch (ExpressionException e) {
        lg.error(e.getMessage(), e);
        VCMongoMessage.sendTrace("DataSetControllerImpl.getSimDataBlock(" + varName + ", " + time + ")  <<EXIT-Exception>>");
        throw new DataAccessException(e.getMessage());
    }
}
Also used : CacheException(org.vcell.util.CacheException) IOException(java.io.IOException) ExpressionException(cbit.vcell.parser.ExpressionException) CartesianMesh(cbit.vcell.solvers.CartesianMesh) MathException(cbit.vcell.math.MathException) DataAccessException(org.vcell.util.DataAccessException) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction)

Example 58 with DataAccessException

use of org.vcell.util.DataAccessException in project vcell by virtualcell.

the class DataSetControllerImpl method getVtuVarInfos.

public VtuVarInfo[] getVtuVarInfos(ComsolSimFiles comsolFiles, 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(comsol): need to support proper domain names now");
            }
            String domainName = "domain";
            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.PointData, 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 59 with DataAccessException

use of org.vcell.util.DataAccessException in project vcell by virtualcell.

the class DataSetControllerImpl method getVtuVarInfos.

public VtuVarInfo[] getVtuVarInfos(VCellSimFiles vcellFiles, OutputContext outputContext, VCDataIdentifier vcdataID) throws DataAccessException {
    try {
        CartesianMeshVtkFileWriter cartesianMeshVTKFileWriter = new CartesianMeshVtkFileWriter();
        VtuVarInfo[] vtuVarInfos = cartesianMeshVTKFileWriter.getVtuVarInfos(vcellFiles, outputContext, getVCData(vcdataID));
        return vtuVarInfos;
    } 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) CartesianMeshVtkFileWriter(org.vcell.vis.mapping.vcell.CartesianMeshVtkFileWriter) 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 60 with DataAccessException

use of org.vcell.util.DataAccessException in project vcell by virtualcell.

the class DataSetControllerImpl method fieldFunctionSubstitution.

private Expression fieldFunctionSubstitution(OutputContext outputContext, final VCDataIdentifier vcdID, Expression functionExpression) throws ExpressionException, DataAccessException, IOException, MathException {
    SimResampleInfoProvider simResampleInfoProvider = null;
    Expression origExpression = new Expression(functionExpression);
    if (vcdID instanceof VCSimulationDataIdentifier) {
        simResampleInfoProvider = ((VCSimulationDataIdentifier) vcdID);
    } else if (vcdID instanceof VCSimulationDataIdentifierOldStyle) {
        simResampleInfoProvider = ((VCSimulationDataIdentifierOldStyle) vcdID);
    } else if (vcdID instanceof ExternalDataIdentifier) {
        simResampleInfoProvider = ((ExternalDataIdentifier) vcdID);
    } else {
        return origExpression;
    }
    FieldFunctionArguments[] fieldfuncArgumentsArr = FieldUtilities.getFieldFunctionArguments(origExpression);
    if (fieldfuncArgumentsArr == null || fieldfuncArgumentsArr.length == 0) {
        return origExpression;
    }
    String[] origSymbols = origExpression.getSymbols();
    Vector<SymbolTableEntry> originalSymbolTablEntrryV = new Vector<SymbolTableEntry>();
    for (int i = 0; origSymbols != null && i < origSymbols.length; i++) {
        if (!originalSymbolTablEntrryV.contains(origExpression.getSymbolBinding(origSymbols[i]))) {
            originalSymbolTablEntrryV.add(origExpression.getSymbolBinding(origSymbols[i]));
        }
    }
    Expression exp = new Expression(origExpression);
    // 
    // Handle Field Data Function field(...)
    // 
    double[][] resampledFieldDatas = null;
    HashMap<String, Integer> substSymbolIndexH = new HashMap<String, Integer>();
    // if(fieldfuncArgumentsArr != null && fieldfuncArgumentsArr.length > 0){
    FieldDataIdentifierSpec[] fieldDataIdentifierSpecArr = getFieldDataIdentifierSpecs(fieldfuncArgumentsArr, simResampleInfoProvider.getOwner());
    // Substitute Field Data Functions for simple symbols for lookup-------
    for (int i = 0; i < fieldfuncArgumentsArr.length; i += 1) {
        for (int j = 0; j < fieldDataIdentifierSpecArr.length; j++) {
            if (fieldfuncArgumentsArr[i].equals(fieldDataIdentifierSpecArr[j].getFieldFuncArgs())) {
                String substFieldName = fieldfuncArgumentsArr[i].getFieldName() + "_" + fieldfuncArgumentsArr[i].getVariableName() + "_" + fieldfuncArgumentsArr[i].getTime().evaluateConstant();
                substFieldName = TokenMangler.fixTokenStrict(substFieldName);
                if (exp.hasSymbol(substFieldName)) {
                    throw new DataAccessException("Substitute Field data name is not unique");
                }
                String fieldFuncString = SimulationData.createCanonicalFieldFunctionSyntax(fieldDataIdentifierSpecArr[j].getExternalDataIdentifier().getName(), fieldfuncArgumentsArr[i].getVariableName(), fieldfuncArgumentsArr[i].getTime().evaluateConstant(), fieldfuncArgumentsArr[i].getVariableType().getTypeName());
                exp.substituteInPlace(new Expression(fieldFuncString), new Expression(substFieldName));
                substSymbolIndexH.put(substFieldName, i);
                break;
            }
        }
    }
    // ----------------------------------------------------------------------
    boolean[] bResample = new boolean[fieldDataIdentifierSpecArr.length];
    Arrays.fill(bResample, true);
    writeFieldFunctionData(outputContext, fieldDataIdentifierSpecArr, bResample, getMesh(simResampleInfoProvider), simResampleInfoProvider, getMesh(simResampleInfoProvider).getNumMembraneElements(), FVSolverStandalone.HESM_KEEP_AND_CONTINUE);
    resampledFieldDatas = new double[fieldfuncArgumentsArr.length][];
    for (int i = 0; i < fieldfuncArgumentsArr.length; i += 1) {
        // File resampledFile =
        // new File(getUserDir(vcsdID.getOwner()),
        // vcsdID.getID()+
        // FieldDataIdentifierSpec.getDefaultFieldDataFileNameForSimulation(fieldfuncArgumentsArr[i])
        // );
        // File resampledFile = new File(getPrimaryUserDir(simResampleInfoProvider.getOwner(), true),
        // SimulationData.createCanonicalResampleFileName(
        // simResampleInfoProvider, fieldfuncArgumentsArr[i]));
        File resampledFile = ((SimulationData) getVCData(simResampleInfoProvider)).getFieldDataFile(simResampleInfoProvider, fieldfuncArgumentsArr[i]);
        resampledFieldDatas[i] = DataSet.fetchSimData(fieldfuncArgumentsArr[i].getVariableName(), resampledFile);
    }
    // }
    // Rebind all the symbols
    String[] dependentIDs = exp.getSymbols();
    VariableSymbolTable varSymbolTable = new VariableSymbolTable();
    for (int i = 0; dependentIDs != null && i < dependentIDs.length; i++) {
        SymbolTableEntry newSymbolTableEntry = null;
        for (int j = 0; j < originalSymbolTablEntrryV.size(); j++) {
            if (originalSymbolTablEntrryV.elementAt(j).getName().equals(dependentIDs[i])) {
                newSymbolTableEntry = originalSymbolTablEntrryV.elementAt(j);
                break;
            }
        }
        if (newSymbolTableEntry == null) {
            if (substSymbolIndexH.containsKey(dependentIDs[i])) {
                int resampledDataIndex = substSymbolIndexH.get(dependentIDs[i]).intValue();
                FieldDataParameterVariable fieldDataParameterVariable = new FieldDataParameterVariable(dependentIDs[i], resampledFieldDatas[resampledDataIndex]);
                newSymbolTableEntry = fieldDataParameterVariable;
            }
        }
        if (newSymbolTableEntry == null) {
            throw new DataAccessException("Field Data Couldn't find substituted expression while evaluating function");
        }
        varSymbolTable.addVar(newSymbolTableEntry);
    }
    exp.bindExpression(varSymbolTable);
    return exp;
}
Also used : HashMap(java.util.HashMap) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) ExternalDataIdentifier(org.vcell.util.document.ExternalDataIdentifier) VariableSymbolTable(cbit.vcell.parser.VariableSymbolTable) Vector(java.util.Vector) DataAccessException(org.vcell.util.DataAccessException) FieldDataParameterVariable(cbit.vcell.field.FieldDataParameterVariable) FieldFunctionArguments(cbit.vcell.field.FieldFunctionArguments) SimResampleInfoProvider(org.vcell.util.document.SimResampleInfoProvider) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) Expression(cbit.vcell.parser.Expression) FieldDataIdentifierSpec(cbit.vcell.field.FieldDataIdentifierSpec) VCSimulationDataIdentifierOldStyle(cbit.vcell.solver.VCSimulationDataIdentifierOldStyle) ZipFile(org.apache.commons.compress.archivers.zip.ZipFile) File(java.io.File)

Aggregations

DataAccessException (org.vcell.util.DataAccessException)345 KeyValue (org.vcell.util.document.KeyValue)82 XmlParseException (cbit.vcell.xml.XmlParseException)80 ExpressionException (cbit.vcell.parser.ExpressionException)78 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)71 SQLException (java.sql.SQLException)67 IOException (java.io.IOException)60 MathException (cbit.vcell.math.MathException)59 RemoteProxyException (cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)46 BigString (org.vcell.util.BigString)45 User (org.vcell.util.document.User)42 FileNotFoundException (java.io.FileNotFoundException)38 ResultSet (java.sql.ResultSet)38 PropertyVetoException (java.beans.PropertyVetoException)37 File (java.io.File)34 PermissionException (org.vcell.util.PermissionException)34 Statement (java.sql.Statement)33 ExpressionBindingException (cbit.vcell.parser.ExpressionBindingException)32 BioModelInfo (org.vcell.util.document.BioModelInfo)29 Vector (java.util.Vector)26